diff --git a/binaries/data/mods/public/simulation/components/ResourceGatherer.js b/binaries/data/mods/public/simulation/components/ResourceGatherer.js index 9f93538c9b..71fded63ee 100644 --- a/binaries/data/mods/public/simulation/components/ResourceGatherer.js +++ b/binaries/data/mods/public/simulation/components/ResourceGatherer.js @@ -427,9 +427,9 @@ ResourceGatherer.prototype.DropResources = function() /** * @return {string} - A generic resource type if we were tasked to gather. */ -ResourceGatherer.prototype.LastGatheredType = function() +ResourceGatherer.prototype.GetTaskedResourceType = function() { - return this.lastGathered; + return this.taskedResourceType; }; /** @@ -438,14 +438,14 @@ ResourceGatherer.prototype.LastGatheredType = function() ResourceGatherer.prototype.AddToPlayerCounter = function(type) { // We need to be removed from the player counter first. - if (this.lastGathered) + if (this.taskedResourceType) return; let cmpPlayer = QueryOwnerInterface(this.entity, IID_Player); if (cmpPlayer) cmpPlayer.AddResourceGatherer(type); - this.lastGathered = type; + this.taskedResourceType = type; }; /** @@ -453,7 +453,7 @@ ResourceGatherer.prototype.AddToPlayerCounter = function(type) */ ResourceGatherer.prototype.RemoveFromPlayerCounter = function(playerid) { - if (!this.lastGathered) + if (!this.taskedResourceType) return; let cmpPlayer = playerid != undefined ? @@ -461,9 +461,9 @@ ResourceGatherer.prototype.RemoveFromPlayerCounter = function(playerid) QueryOwnerInterface(this.entity, IID_Player); if (cmpPlayer) - cmpPlayer.RemoveResourceGatherer(this.lastGathered); + cmpPlayer.RemoveResourceGatherer(this.taskedResourceType); - delete this.lastGathered; + delete this.taskedResourceType; }; /** @@ -507,7 +507,7 @@ ResourceGatherer.prototype.OnOwnershipChanged = function(msg) } if (this.lastGathered && msg.from !== INVALID_PLAYER) { - const resource = this.lastGathered; + const resource = this.taskedResourceType; this.RemoveFromPlayerCounter(msg.from); this.AddToPlayerCounter(resource); } diff --git a/binaries/data/mods/public/simulation/components/UnitAI.js b/binaries/data/mods/public/simulation/components/UnitAI.js index f0fe40a0f6..079a710edf 100644 --- a/binaries/data/mods/public/simulation/components/UnitAI.js +++ b/binaries/data/mods/public/simulation/components/UnitAI.js @@ -484,8 +484,8 @@ UnitAI.prototype.UnitFsmSpec = { // We were given the order to gather while we were still gathering. // This is needed because we don't re-enter the GATHER-state. - let lastGatheredType = cmpResourceGatherer.LastGatheredType(); - if (lastGatheredType && msg.data.type.generic != lastGatheredType) + const taskedResourceType = cmpResourceGatherer.GetTaskedResourceType(); + if (taskedResourceType && msg.data.type.generic != taskedResourceType) this.UnitFsm.SwitchToNextState(this, "INDIVIDUAL.GATHER"); if (!this.CanGather(msg.data.target))