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 @@ -332,15 +332,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 @@ -2489,7 +2489,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"); }, }, @@ -2606,7 +2606,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) { @@ -4370,15 +4370,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); }); };