Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/simulation/components/Builder.js
Show First 20 Lines • Show All 111 Lines • ▼ Show 20 Lines | Builder.prototype.StartRepairing = function(target, callerIID) | ||||
return true; | return true; | ||||
}; | }; | ||||
/** | /** | ||||
* @param {string} reason - The reason why we stopped repairing. | * @param {string} reason - The reason why we stopped repairing. | ||||
*/ | */ | ||||
Builder.prototype.StopRepairing = function(reason) | Builder.prototype.StopRepairing = function(reason) | ||||
{ | { | ||||
if (this.timer) | if (!this.target) | ||||
{ | return; | ||||
let cmpTimer = Engine.QueryInterface(SYSTEM_ENTITY, IID_Timer); | let cmpTimer = Engine.QueryInterface(SYSTEM_ENTITY, IID_Timer); | ||||
cmpTimer.CancelTimer(this.timer); | cmpTimer.CancelTimer(this.timer); | ||||
delete this.timer; | delete this.timer; | ||||
} | |||||
if (this.target) | |||||
{ | |||||
let cmpBuilderList = QueryBuilderListInterface(this.target); | let cmpBuilderList = QueryBuilderListInterface(this.target); | ||||
if (cmpBuilderList) | if (cmpBuilderList) | ||||
cmpBuilderList.RemoveBuilder(this.entity); | cmpBuilderList.RemoveBuilder(this.entity); | ||||
delete this.target; | delete this.target; | ||||
} | |||||
let cmpVisual = Engine.QueryInterface(this.entity, IID_Visual); | let cmpVisual = Engine.QueryInterface(this.entity, IID_Visual); | ||||
if (cmpVisual) | if (cmpVisual) | ||||
cmpVisual.SelectAnimation("idle", false, 1.0); | cmpVisual.SelectAnimation("idle", false, 1.0); | ||||
// The callerIID component may start repairing again, | // The callerIID component may start again, | ||||
// replacing the callerIID, hence save that. | // replacing the callerIID, hence save that. | ||||
let callerIID = this.callerIID; | let callerIID = this.callerIID; | ||||
delete this.callerIID; | delete this.callerIID; | ||||
if (reason && callerIID) | if (reason && callerIID) | ||||
{ | { | ||||
let component = Engine.QueryInterface(this.entity, callerIID); | let component = Engine.QueryInterface(this.entity, callerIID); | ||||
if (component) | if (component) | ||||
▲ Show 20 Lines • Show All 63 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator