Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/simulation/components/ResourceGatherer.js
Show First 20 Lines • Show All 288 Lines • ▼ Show 20 Lines | for (let type in this.carrying) | ||||
if (type != exceptedType) | if (type != exceptedType) | ||||
return true; | return true; | ||||
return false; | return false; | ||||
}; | }; | ||||
/** | /** | ||||
* Transfer our carried resources to our owner immediately. | * Transfer our carried resources to our owner immediately. | ||||
* Only resources of the given types will be transferred. | * Only resources of the appropriate types will be transferred. | ||||
* (This should typically be called after reaching a dropsite). | * (This should typically be called after reaching a dropsite.) | ||||
* @param {number} target - The target to drop resources at. | |||||
*/ | */ | ||||
ResourceGatherer.prototype.CommitResources = function(types) | ResourceGatherer.prototype.CommitResources = function(target) | ||||
{ | { | ||||
let cmpPlayer = QueryOwnerInterface(this.entity); | let cmpResourceDropsite = Engine.QueryInterface(target, IID_ResourceDropsite); | ||||
if (!cmpResourceDropsite) | |||||
return; | |||||
let cmpPlayer = QueryOwnerInterface(this.entity); | |||||
if (cmpPlayer) | if (cmpPlayer) | ||||
for (let type of types) | { | ||||
if (type in this.carrying) | let changed = false; | ||||
for (let type in this.carrying) | |||||
if (cmpResourceDropsite.AcceptsType(type)) | |||||
{ | { | ||||
cmpPlayer.AddResource(type, this.carrying[type]); | cmpPlayer.AddResource(type, this.carrying[type]); | ||||
delete this.carrying[type]; | delete this.carrying[type]; | ||||
changed = true; | |||||
} | } | ||||
if (changed) | |||||
Engine.PostMessage(this.entity, MT_ResourceCarryingChanged, { "to": this.GetCarryingStatus() }); | Engine.PostMessage(this.entity, MT_ResourceCarryingChanged, { "to": this.GetCarryingStatus() }); | ||||
} | |||||
}; | }; | ||||
/** | /** | ||||
* Drop all currently-carried resources. | * Drop all currently-carried resources. | ||||
* (Currently they just vanish after being dropped - we don't bother depositing | * (Currently they just vanish after being dropped - we don't bother depositing | ||||
* them onto the ground.) | * them onto the ground.) | ||||
*/ | */ | ||||
ResourceGatherer.prototype.DropResources = function() | ResourceGatherer.prototype.DropResources = function() | ||||
Show All 35 Lines |
Wildfire Games · Phabricator