Index: binaries/data/mods/public/simulation/components/ResourceGatherer.js =================================================================== --- binaries/data/mods/public/simulation/components/ResourceGatherer.js +++ binaries/data/mods/public/simulation/components/ResourceGatherer.js @@ -330,15 +330,6 @@ }; /** - * @param {number} target - The entity ID of the target to check. - * @return {boolean} - Whether we can gather from the target. - */ -ResourceGatherer.prototype.CanGather = function(target) -{ - return this.GetTargetGatherRate(target) > 0; -}; - -/** * Returns whether this unit can carry more of the given type of resource. * (This ignores whether the unit is actually able to gather that * resource type or not.) Index: binaries/data/mods/public/simulation/components/UnitAI.js =================================================================== --- binaries/data/mods/public/simulation/components/UnitAI.js +++ binaries/data/mods/public/simulation/components/UnitAI.js @@ -558,19 +558,10 @@ }, "Order.ReturnResource": function(msg) { - let cmpResourceGatherer = Engine.QueryInterface(this.entity, IID_ResourceGatherer); - if (this.CheckTargetRange(msg.data.target, IID_ResourceGatherer) && - this.CanReturnResource(msg.data.target, true, cmpResourceGatherer)) - { - cmpResourceGatherer.CommitResources(msg.data.target); - this.SetDefaultAnimationVariant(); - - // Our next order should always be a Gather, - // so just switch back to that order. - this.FinishOrder(); - } + if (this.CheckTargetRange(msg.data.target, IID_ResourceGatherer)) + this.SetNextState("RETURNRESOURCE.DROPPINGRESOURCES"); else if (this.AbleToMove()) - this.SetNextState("INDIVIDUAL.RETURNRESOURCE.APPROACHING"); + this.SetNextState("RETURNRESOURCE.APPROACHING"); else return this.FinishOrder(); return ACCEPT_ORDER; @@ -2440,7 +2431,7 @@ // If we failed, the GATHERING timer will handle finding a valid resource. if (msg.likelyFailure || msg.obstructed && this.RelaxedMaxRangeCheck(this.order.data, this.DefaultRelaxedMaxRange) || this.CheckRange(this.order.data)) - this.SetNextState("GATHERING"); + this.SetNextState("FINDINGNEWTARGET"); }, }, @@ -2557,7 +2548,7 @@ if (!initPos) initPos = { 'x': pos.X, 'z': pos.Z }; else if (!nearbyResource) - nearbyResource = this.FindNearbyResource(new Vector2D(initPos.X, initPos.Z), filter); + nearbyResource = this.FindNearbyResource(new Vector2D(initPos.x, initPos.z), filter); if (nearbyResource) { @@ -2727,8 +2718,6 @@ // Stop showing the carried resource animation. this.SetDefaultAnimationVariant(); - // Our next order should always be a Gather, - // so just switch back to that order. this.FinishOrder(); return true; } @@ -4318,15 +4307,14 @@ return nearby.find(ent => { if (!this.CanGather(ent) || !this.CheckTargetVisible(ent)) return false; - let cmpResourceSupply = Engine.QueryInterface(ent, IID_ResourceSupply); - let type = cmpResourceSupply.GetType(); - let amount = cmpResourceSupply.GetCurrentAmount(); let template = cmpTemplateManager.GetCurrentTemplateName(ent); if (template.indexOf("resource|") != -1) template = template.slice(9); - return amount > 0 && cmpResourceSupply.IsAvailableTo(this.entity) && filter(ent, type, template); + let cmpResourceSupply = Engine.QueryInterface(ent, IID_ResourceSupply); + let type = cmpResourceSupply.GetType(); + return cmpResourceSupply.IsAvailableTo(this.entity) && filter(ent, type, template); }); };