Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/simulation/components/ResourceGatherer.js
Show First 20 Lines • Show All 457 Lines • ▼ Show 20 Lines | ResourceGatherer.prototype.RemoveFromPlayerCounter = function(playerid) | ||||
let cmpPlayer = playerid != undefined ? | let cmpPlayer = playerid != undefined ? | ||||
QueryPlayerIDInterface(playerid) : | QueryPlayerIDInterface(playerid) : | ||||
QueryOwnerInterface(this.entity, IID_Player); | QueryOwnerInterface(this.entity, IID_Player); | ||||
if (cmpPlayer) | if (cmpPlayer) | ||||
cmpPlayer.RemoveResourceGatherer(this.lastGathered); | cmpPlayer.RemoveResourceGatherer(this.lastGathered); | ||||
delete this.lastGathered; | delete this.lastGathered; | ||||
wraitii: (Seems a bit unexpected to delete this here) | |||||
FreagarachAuthorUnsubmitted Not Done Inline ActionsWhere would you expect it to be deleted? Freagarach: Where would you expect it to be deleted? | |||||
wraitiiUnsubmitted Not Done Inline Actionswell I wouldn't necessarily expect it to be deleted given the name :p Edit: TBH it's also confusing why this isn't just 'lastCarriedType' from a cursory reading? I didn't follow the diffs adding that code, but this variable feels misnamed. wraitii: well I wouldn't necessarily expect it to be deleted given the name :p
Edit: TBH it's also… | |||||
FreagarachAuthorUnsubmitted Not Done Inline ActionsAgreed though. ;) Freagarach: Agreed though. ;) | |||||
}; | }; | ||||
/** | /** | ||||
* @param {number} - The entity ID of the target to check. | * @param {number} - The entity ID of the target to check. | ||||
* @return {boolean} - Whether this entity is in range of its target. | * @return {boolean} - Whether this entity is in range of its target. | ||||
*/ | */ | ||||
ResourceGatherer.prototype.IsTargetInRange = function(target) | ResourceGatherer.prototype.IsTargetInRange = function(target) | ||||
{ | { | ||||
Show All 26 Lines | |||||
ResourceGatherer.prototype.OnOwnershipChanged = function(msg) | ResourceGatherer.prototype.OnOwnershipChanged = function(msg) | ||||
{ | { | ||||
if (msg.to == INVALID_PLAYER) | if (msg.to == INVALID_PLAYER) | ||||
{ | { | ||||
this.RemoveFromPlayerCounter(msg.from); | this.RemoveFromPlayerCounter(msg.from); | ||||
return; | return; | ||||
} | } | ||||
const resource = this.lastGathered; | |||||
this.RemoveFromPlayerCounter(msg.from); | |||||
StanUnsubmitted Done Inline ActionsSince you have to do it anyway you could move it to line 503 and remove line 505 Stan: Since you have to do it anyway you could move it to line 503 and remove line 505 | |||||
FreagarachAuthorUnsubmitted Done Inline ActionsNow I save the const resource = this.lastGathered. Freagarach: Now I save the `const resource = this.lastGathered`. | |||||
this.AddToPlayerCounter(resource); | |||||
this.RecalculateGatherRates(); | this.RecalculateGatherRates(); | ||||
this.RecalculateCapacities(); | this.RecalculateCapacities(); | ||||
}; | }; | ||||
ResourceGatherer.prototype.OnGlobalInitGame = function(msg) | ResourceGatherer.prototype.OnGlobalInitGame = function(msg) | ||||
{ | { | ||||
this.RecalculateGatherRates(); | this.RecalculateGatherRates(); | ||||
this.RecalculateCapacities(); | this.RecalculateCapacities(); | ||||
Show All 10 Lines |
Wildfire Games · Phabricator
(Seems a bit unexpected to delete this here)