Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/simulation/components/Garrisonable.js
function Garrisonable() {} | class Garrisonable | ||||
{ | |||||
get Schema() | |||||
{ | |||||
return "<empty/>"; | |||||
} | |||||
elexis: (I suggest Garrisonable.prototype.Schema = "..."; to avoid precedents for the getter syntax… | |||||
Done Inline ActionsWill do. Freagarach: Will do. | |||||
Init() | |||||
{ | |||||
this.garrisonHolder = INVALID_ENTITY; | |||||
} | |||||
Garrisonable.prototype.Schema = "<empty/>"; | /** | ||||
* Which garrisonholder this entity is garrisoned in. | |||||
* | |||||
* @return {number} - The entity ID of the entity this entity is garrisoned in. | |||||
*/ | |||||
GetGarrisonHolder() | |||||
{ | |||||
return this.garrisonHolder; | |||||
} | |||||
Garrisonable.prototype.Init = function() | /** | ||||
* Sets the garrisonholder, where this entity is garrisoned in. | |||||
* | |||||
* @param {number} entity - The entity ID of the entity this entity is garrisoned in. | |||||
*/ | |||||
Garrison(entity) | |||||
{ | { | ||||
}; | this.garrisonHolder = entity; | ||||
} | |||||
Garrisonable.prototype.Serialize = null; | /** | ||||
Done Inline ActionsI wonder if we shouldn't start to explicitely serialize or objects. Not related to this patch. Stan: I wonder if we shouldn't start to explicitely serialize or objects. Not related to this patch. | |||||
Done Inline ActionsAgreed. I threw the ball earlier, but it got thrown back ;) Freagarach: Agreed. I threw the ball earlier, but it got thrown back ;) | |||||
* Resets the garrisonholder. | |||||
*/ | |||||
UnGarrison() | |||||
Done Inline ActionsWonder if it shouldn't be GetGarrisonHolderEntity, because one does not return the component. Stan: Wonder if it shouldn't be GetGarrisonHolderEntity, because one does not return the component. | |||||
{ | |||||
this.garrisonHolder = INVALID_ENTITY; | |||||
} | |||||
} | |||||
Engine.RegisterComponentType(IID_Garrisonable, "Garrisonable", Garrisonable); | Engine.RegisterComponentType(IID_Garrisonable, "Garrisonable", Garrisonable); | ||||
Done Inline ActionsI wonder if we shouldn't let users do stupid things and then complain ? Stan: I wonder if we shouldn't let users do stupid things and then complain ? | |||||
Done Inline ActionsShould we check here whether we are already garrisoned and return? Freagarach: Should we check here whether we are already garrisoned and return? | |||||
Done Inline ActionsDo we need to serialize if INVALID_ENTITY? Stan: Do we need to serialize if INVALID_ENTITY? | |||||
Done Inline ActionsThat is a fair point, which is valid for more patches I guess ;) Freagarach: That is a fair point, which is valid for more patches I guess ;) |
Wildfire Games · Phabricator
(I suggest Garrisonable.prototype.Schema = "..."; to avoid precedents for the getter syntax, reducing function calls and incentivizing to move component constants to the prototype by adding precedents for that syntax)