Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/simulation/components/TreasureCollecter.js
Show First 20 Lines • Show All 59 Lines • ▼ Show 20 Lines | TreasureCollecter.prototype.StartCollecting = function(target, callerIID) | ||||
return true; | return true; | ||||
}; | }; | ||||
/** | /** | ||||
* @param {string} reason - The reason why we stopped collecting, used to notify the caller. | * @param {string} reason - The reason why we stopped collecting, used to notify the caller. | ||||
*/ | */ | ||||
TreasureCollecter.prototype.StopCollecting = function(reason) | TreasureCollecter.prototype.StopCollecting = 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; | ||||
} | |||||
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 collecting 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 All 38 Lines |
Wildfire Games · Phabricator