mirror of
https://gitea.wildfiregames.com/0ad/0ad.git
synced 2026-09-21 20:06:40 +00:00
drop resources before switching to next queued order, fixes #1670
This was SVN commit r17521.
This commit is contained in:
@@ -305,7 +305,14 @@ ResourceGatherer.prototype.GetTargetGatherRate = function(target)
|
||||
ResourceGatherer.prototype.CanCarryMore = function(type)
|
||||
{
|
||||
let amount = (this.carrying[type] || 0);
|
||||
return (amount < this.GetCapacity(type));
|
||||
return amount < this.GetCapacity(type);
|
||||
};
|
||||
|
||||
|
||||
ResourceGatherer.prototype.IsCarrying = function(type)
|
||||
{
|
||||
let amount = (this.carrying[type] || 0);
|
||||
return amount > 0;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -2350,6 +2350,16 @@ UnitAI.prototype.UnitFsmSpec = {
|
||||
var herdPos = this.order.data.initPos;
|
||||
|
||||
// Give up on this order and try our next queued order
|
||||
// but first check what is our next order and, if needed, insert a returnResource order
|
||||
let cmpResourceGatherer = Engine.QueryInterface(this.entity, IID_ResourceGatherer);
|
||||
if (cmpResourceGatherer.IsCarrying(resourceType.generic) &&
|
||||
this.orderQueue.length > 1 && this.orderQueue[1] !== "ReturnResource" &&
|
||||
(this.orderQueue[1].type !== "Gather" || this.orderQueue[1].data.type.generic !== resourceType.generic))
|
||||
{
|
||||
let nearby = this.FindNearestDropsite(resourceType.generic);
|
||||
if (nearby)
|
||||
this.orderQueue.splice(1, 0, { "type": "ReturnResource", "data": { "target": nearby, "force": false } });
|
||||
}
|
||||
if (this.FinishOrder())
|
||||
return;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user