Rename misnamed lastGatheredType in ResourceGatherer.
Since it stores not the last gathered, but the last tasked type. As discussed on IRC (http://irclogs.wildfiregames.com/%230ad-dev/2021-09-16-QuakeNet-%230ad-dev.log). Differential revision: https://code.wildfiregames.com/D4277 Reviewed by: @bb Comments by: @Angen, @Stan, @wraitii This was SVN commit r25942.
This commit is contained in:
parent
be8a2258ed
commit
4597cecd50
@ -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);
|
||||
}
|
||||
|
@ -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))
|
||||
|
Loading…
Reference in New Issue
Block a user