Changeset View
Standalone View
binaries/data/mods/public/simulation/components/Builder.js
Show First 20 Lines • Show All 67 Lines • ▼ Show 20 Lines | |||||
}; | }; | ||||
/** | /** | ||||
* @param {number} target - The target to check. | * @param {number} target - The target to check. | ||||
* @return {boolean} - Whether we can build/repair the given target. | * @return {boolean} - Whether we can build/repair the given target. | ||||
*/ | */ | ||||
Builder.prototype.CanRepair = function(target) | Builder.prototype.CanRepair = function(target) | ||||
{ | { | ||||
let cmpFoundation = QueryMiragedInterface(target, IID_Foundation); | let cmpFoundation = QueryMiragedInterface(target, IID_Foundation); | ||||
Stan: Only query after l79, no need to get it if you don't need it . | |||||
Done Inline ActionsMoved down after the first condition. Mister: Moved down after the first condition. | |||||
let cmpRepairable = QueryMiragedInterface(target, IID_Repairable); | let cmpRepairable = QueryMiragedInterface(target, IID_Repairable); | ||||
if (!cmpFoundation && (!cmpRepairable || !cmpRepairable.IsRepairable())) | if (!cmpFoundation && (!cmpRepairable || !cmpRepairable.IsRepairable())) | ||||
return false; | return false; | ||||
let buildList = this.GetEntitiesList(); | |||||
Done Inline ActionsAs @Freagarach said, you'd need to double check what type of info variables are. Is it an array or an object? Same goes for the target parameter. Grapjas: As @Freagarach said, you'd need to double check what type of info variables are. Is it an array… | |||||
let cmpTemplateManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_TemplateManager); | |||||
Done Inline ActionsYou can do warn(uneval("BuildList is:" + buildList)) instead of doing a warn twice. Grapjas: You can do `warn(uneval("BuildList is:" + buildList))` instead of doing a warn twice.
| |||||
Done Inline ActionsMore likely warn("BuildList is:" + uneval(buildList)) Stan: More likely
```lang=js
warn("BuildList is:" + uneval(buildList))
``` | |||||
Not Done Inline ActionsNeed to update the name. lyv: Need to update the name. | |||||
Done Inline Actionsupdated. Mister: updated. | |||||
let targetTemplate = cmpTemplateManager.GetCurrentTemplateName(target); | |||||
Not Done Inline ActionsAs you've noticed, this will return the template with a filter. Also, this is not the truth about what structure this entity will become. I guess we want to define "building structure x" as "working on a foundation that becomes structure x" and as such we have to check another component what structure we are building/repairing. It is in the JS component specific to a foundation. Check the foundation filter template to see what I am pointing towards. :) Freagarach: As you've noticed, this will return the template with a filter. Also, this is not the truth… | |||||
Not Done Inline ActionsThis returns a template with format: 'foundation|template_name'. I think i wasn't able to figure out what do you want me to check with this. Could you please give me a little more of context/explanation? Mister: This returns a template with format: 'foundation|template_name'. I think i wasn't able to… | |||||
Not Done Inline ActionsHave you checked the foundation filter template and the Foundation.js component it points toward? Freagarach: Have you checked the `foundation` filter template and the `Foundation.js` component it points… | |||||
Not Done Inline ActionsI have checked that, also I have a question about this. For example if i tried to do stuff like searching references, autocomplete and declarations of things is there any plugin that Im I missing to install, has been hard to search for things. Also, I know makes sense that foundation.xml and foundation.js are tied but since im coming from a web development path, is there any structure/architecture are we following with the code? I would like to have a better idea about know how could i search for stuff in the future. Mister: I have checked that, also I have a question about this.
For example if i tried to do stuff… | |||||
Not Done Inline ActionsGenerally, hardcoding stuff like this is best avoided. It would break if we ever updated the directory structure or a building from elsewhere (a unit perhaps) is built. !buildList.some(buildable => targetTemplate.includes(buildable)) is an alternative check that checks whether any buildable template is a substring of the target template. lyv: Generally, hardcoding stuff like this is best avoided. It would break if we ever updated the… | |||||
Done Inline ActionsThat looks better! Updated. Mister: That looks better! Updated.
| |||||
if (!buildList.some(buildable => targetTemplate.includes(buildable))) | |||||
return false; | |||||
let cmpOwnership = Engine.QueryInterface(this.entity, IID_Ownership); | let cmpOwnership = Engine.QueryInterface(this.entity, IID_Ownership); | ||||
Done Inline Actionstarget is an entity ID while buildList would be having template names. I believe you could get the template for an entity using cmpIdentity. lyv: `target` is an entity ID while buildList would be having template names. I believe you could… | |||||
Done Inline ActionsCorrection on the last point.
lyv: Correction on the last point.
> <lyv> ah you're right. it appears its actually… | |||||
return cmpOwnership && IsOwnedByAllyOfPlayer(cmpOwnership.GetOwner(), target); | return cmpOwnership && IsOwnedByAllyOfPlayer(cmpOwnership.GetOwner(), target); | ||||
}; | }; | ||||
/** | /** | ||||
* @param {number} target - The target to repair. | * @param {number} target - The target to repair. | ||||
* @param {number} callerIID - The IID to notify on specific events. | * @param {number} callerIID - The IID to notify on specific events. | ||||
* @return {boolean} - Whether we started repairing. | * @return {boolean} - Whether we started repairing. | ||||
*/ | */ | ||||
▲ Show 20 Lines • Show All 119 Lines • Show Last 20 Lines |
Only query after l79, no need to get it if you don't need it .