Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/simulation/ai/common-api/entity.js
Show All 10 Lines | "_init": function(sharedAI, templateName, template) | ||||
// save a reference to the template tech modifications | // save a reference to the template tech modifications | ||||
if (!sharedAI._templatesModifications[this._templateName]) | if (!sharedAI._templatesModifications[this._templateName]) | ||||
sharedAI._templatesModifications[this._templateName] = {}; | sharedAI._templatesModifications[this._templateName] = {}; | ||||
this._templateModif = sharedAI._templatesModifications[this._templateName]; | this._templateModif = sharedAI._templatesModifications[this._templateName]; | ||||
this._tpCache = new Map(); | this._tpCache = new Map(); | ||||
}, | }, | ||||
// Helper function to return a template value, adjusting for tech. | // Helper function to return a template value, adjusting for tech. | ||||
"get": function(string) | "get": function(string) | ||||
marder: Indeed this is the problem. get will not get an empty component/ template value. It works if I… | |||||
{ | { | ||||
if (this._entityModif && this._entityModif.has(string)) | if (this._entityModif && this._entityModif.has(string)) | ||||
return this._entityModif.get(string); | return this._entityModif.get(string); | ||||
else if (this._templateModif) | else if (this._templateModif) | ||||
{ | { | ||||
let owner = this._entity ? this._entity.owner : PlayerID; | let owner = this._entity ? this._entity.owner : PlayerID; | ||||
if (this._templateModif[owner] && this._templateModif[owner].has(string)) | if (this._templateModif[owner] && this._templateModif[owner].has(string)) | ||||
return this._templateModif[owner].get(string); | return this._templateModif[owner].get(string); | ||||
▲ Show 20 Lines • Show All 153 Lines • ▼ Show 20 Lines | m.Template = m.Class({ | ||||
"isHealable": function() | "isHealable": function() | ||||
{ | { | ||||
if (this.get("Health") !== undefined) | if (this.get("Health") !== undefined) | ||||
return this.get("Health/Unhealable") !== "true"; | return this.get("Health/Unhealable") !== "true"; | ||||
return false; | return false; | ||||
}, | }, | ||||
"isCamouflaged": function() { return "Camouflaged" in this._template; }, | |||||
Done Inline Actionsthis.get("Camouflaged") always return undefined. marder: this.get("Camouflaged") always return undefined.
Can't figure out why, cause the component is… | |||||
Done Inline ActionsUse something like this: Silier: Use something like this:
`"canOccupyTurret": function() { return "Turretable" in this._template… | |||||
"isRepairable": function() { return this.get("Repairable") !== undefined; }, | "isRepairable": function() { return this.get("Repairable") !== undefined; }, | ||||
"getPopulationBonus": function() { | "getPopulationBonus": function() { | ||||
if (!this.get("Population")) | if (!this.get("Population")) | ||||
return 0; | return 0; | ||||
return +this.get("Population/Bonus"); | return +this.get("Population/Bonus"); | ||||
}, | }, | ||||
▲ Show 20 Lines • Show All 822 Lines • ▼ Show 20 Lines | m.Entity = m.Class({ | ||||
"removeGuard": function() { | "removeGuard": function() { | ||||
Engine.PostCommand(PlayerID, { "type": "remove-guard", "entities": [this.id()] }); | Engine.PostCommand(PlayerID, { "type": "remove-guard", "entities": [this.id()] }); | ||||
return this; | return this; | ||||
} | } | ||||
}); | }); | ||||
return m; | return m; | ||||
}(API3); | }(API3); | ||||
Lint: no-use-before-define 'API3' was used before it was defined. Lint: no-use-before-define: 'API3' was used before it was defined. |
Wildfire Games · Phabricator
Indeed this is the problem. get will not get an empty component/ template value. It works if I add anything in the componet, even without calling the subelement.
(still don't understand why tho)