Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/simulation/components/Garrisonable.js
function Garrisonable() {} | function Garrisonable() {} | ||||
Garrisonable.prototype.Schema = "<empty/>"; | Garrisonable.prototype.Schema = "<empty/>"; | ||||
Garrisonable.prototype.Init = function() | Garrisonable.prototype.Init = function() | ||||
{ | { | ||||
elexis: (I suggest Garrisonable.prototype.Schema = "..."; to avoid precedents for the getter syntax… | |||||
Done Inline ActionsWill do. Freagarach: Will do. | |||||
this.garrisonHolder = INVALID_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 ;) | |||||
* @return {number} - The entity ID of the entity this entity is garrisoned in. | |||||
*/ | |||||
Garrisonable.prototype.GetGarrisonHolder = function() | |||||
StanUnsubmitted 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. | |||||
{ | |||||
return this.garrisonHolder; | |||||
}; | |||||
/** | |||||
* @param {number} entity - The entity ID of the entity this entity is being garrisoned in. | |||||
* @return {boolean} - Whether garrisoning succeeded. | |||||
*/ | |||||
Garrisonable.prototype.Garrison = function(entity) | |||||
{ | |||||
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? | |||||
if (this.garrisonHolder != INVALID_ENTITY) | |||||
return false; | |||||
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 ? | |||||
this.garrisonHolder = entity; | |||||
return true; | |||||
}; | |||||
/** | |||||
* Resets the garrisonHolder. | |||||
*/ | |||||
Garrisonable.prototype.UnGarrison = function() | |||||
{ | |||||
this.garrisonHolder = INVALID_ENTITY; | |||||
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 ;) | |||||
}; | |||||
Engine.RegisterComponentType(IID_Garrisonable, "Garrisonable", Garrisonable); | Engine.RegisterComponentType(IID_Garrisonable, "Garrisonable", Garrisonable); |
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)