Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/simulation/components/Auras.js
function Auras() {} | function Auras() {} | ||||
Auras.prototype.Schema = | Auras.prototype.Schema = | ||||
"<attribute name='datatype'>" + | "<attribute name='datatype'>" + | ||||
"<value>tokens</value>" + | "<value>tokens</value>" + | ||||
"</attribute>" + | "</attribute>" + | ||||
"<text a:help='A whitespace-separated list of aura files, placed under simulation/data/auras/'/>"; | "<text a:help='A whitespace-separated list of aura files, placed under simulation/data/auras/'/>"; | ||||
Auras.prototype.Init = function() | Auras.prototype.Init = function() | ||||
{ | { | ||||
this.affectedPlayers = {}; | this.affectedPlayers = {}; | ||||
for (let name of this.GetAuraNames()) | for (let name of this.GetAuraNames()) { | ||||
Stan: Useless braces. | |||||
this.affectedPlayers[name] = []; | this.affectedPlayers[name] = []; | ||||
} | |||||
// In case of autogarrisoning, this component can be called before ownership is set. | // In case of autogarrisoning, this component can be called before ownership is set. | ||||
// So it needs to be completely initialised from the start. | // So it needs to be completely initialised from the start. | ||||
this.Clean(); | this.Clean(); | ||||
}; | }; | ||||
// We can modify identifier if we want stackable auras in some case. | // We can modify identifier if we want stackable auras in some case. | ||||
Auras.prototype.GetModifierIdentifier = function(name) | Auras.prototype.GetModifierIdentifier = function(name) | ||||
Show All 15 Lines | ret[auraID] = { | ||||
"radius": this.GetRange(auraID) || null | "radius": this.GetRange(auraID) || null | ||||
}; | }; | ||||
} | } | ||||
return ret; | return ret; | ||||
}; | }; | ||||
Auras.prototype.GetAuraNames = function() | Auras.prototype.GetAuraNames = function() | ||||
{ | { | ||||
return this.template._string.split(/\s+/); | let cmpIdentity = Engine.QueryInterface(this.entity, IID_Identity); | ||||
let cmpPlayer = QueryOwnerInterface(this.entity); | |||||
let auraNames = this.template._string.split(/\s+/); | |||||
let names = []; | |||||
for (let auraName of auraNames) | |||||
{ | |||||
// replace {native} | |||||
if (auraName.search(/\{native\}/g) != -1) | |||||
{ | |||||
if (!cmpIdentity || !cmpIdentity.GetCiv()) | |||||
continue; | |||||
auraName = auraName.replace(/\{native\}/g, cmpIdentity.GetCiv()); | |||||
} | |||||
// replace {civ} | |||||
else if (auraName.search(/\{civ\}/g) != -1) | |||||
{ | |||||
if (!cmpPlayer || !cmpPlayer.GetCiv()) | |||||
continue; | |||||
auraName = auraName.replace(/\{civ\}/g, cmpPlayer.GetCiv()); | |||||
} | |||||
Not Done Inline Actions(Last thing I remember about the RegEx replacement is that we wanted to unify the copies, is it the third?) elexis: (Last thing I remember about the RegEx replacement is that we wanted to unify the copies, is it… | |||||
Not Done Inline ActionsUsing ack --type=js "replace.*(civ|native).*}" on the contents of the public mod returns ten files (across maps, gui, AI, and simulation) that use RegEx to replace "{civ}", "{native}", or both. Amongst simulation components, the current count is five. In each instance, the presence of "{native}" and "{civ}" within the string is not checked before the replace() is attempted. Whilst unifying is best left for another revision, the presence checks could be removed in this one. s0600204: Using `ack --type=js "replace.*(civ|native).*}"` on the contents of the `public` mod returns… | |||||
names.push(auraName); | |||||
} | |||||
return names; | |||||
}; | }; | ||||
Auras.prototype.GetOverlayIcon = function(name) | Auras.prototype.GetOverlayIcon = function(name) | ||||
{ | { | ||||
return AuraTemplates.Get(name).overlayIcon || ""; | return AuraTemplates.Get(name).overlayIcon || ""; | ||||
}; | }; | ||||
Auras.prototype.GetAffectedEntities = function(name) | Auras.prototype.GetAffectedEntities = function(name) | ||||
▲ Show 20 Lines • Show All 437 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator
Useless braces.