Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/simulation/components/ResourceGatherer.js
Show All 15 Lines | "<Capacities>" + | ||||
"<metal>10</metal>" + | "<metal>10</metal>" + | ||||
"<stone>10</stone>" + | "<stone>10</stone>" + | ||||
"<wood>10</wood>" + | "<wood>10</wood>" + | ||||
"</Capacities>" + | "</Capacities>" + | ||||
"</a:example>" + | "</a:example>" + | ||||
"<element name='MaxDistance' a:help='Max resource-gathering distance'>" + | "<element name='MaxDistance' a:help='Max resource-gathering distance'>" + | ||||
"<ref name='positiveDecimal'/>" + | "<ref name='positiveDecimal'/>" + | ||||
"</element>" + | "</element>" + | ||||
"<element name='AutoGatherRange' a:help='Max distance to search for a new resource to gather.'>" + | |||||
elexis: Could also mention where the center is (its not obvious whether it searches at the current unit… | |||||
StanUnsubmitted Done Inline ActionsIndeed would be nice to specify. Search for → look for? Maybe // When switching from a depleted resource, defines the max range around the current resource at which an entity will look for another resource to gather. Stan: Indeed would be nice to specify. Search for → look for? Maybe
```
// When switching from a… | |||||
Done Inline Actionsnot only on depletion, also when the resource has already the max amount of gatherers. Max range to search for a new resource to gather. bb: not only on depletion, also when the resource has already the max amount of gatherers. `Max… | |||||
"<ref name='positiveDecimal'/>" + | |||||
"</element>" + | |||||
"<element name='BaseSpeed' a:help='Base resource-gathering rate (in resource units per second)'>" + | "<element name='BaseSpeed' a:help='Base resource-gathering rate (in resource units per second)'>" + | ||||
"<ref name='positiveDecimal'/>" + | "<ref name='positiveDecimal'/>" + | ||||
"</element>" + | "</element>" + | ||||
"<element name='Rates' a:help='Per-resource-type gather rate multipliers. If a resource type is not specified then it cannot be gathered by this unit'>" + | "<element name='Rates' a:help='Per-resource-type gather rate multipliers. If a resource type is not specified then it cannot be gathered by this unit'>" + | ||||
Resources.BuildSchema("positiveDecimal", ["treasure"], true) + | Resources.BuildSchema("positiveDecimal", ["treasure"], true) + | ||||
"</element>" + | "</element>" + | ||||
"<element name='Capacities' a:help='Per-resource-type maximum carrying capacity'>" + | "<element name='Capacities' a:help='Per-resource-type maximum carrying capacity'>" + | ||||
Resources.BuildSchema("positiveDecimal") + | Resources.BuildSchema("positiveDecimal") + | ||||
▲ Show 20 Lines • Show All 62 Lines • ▼ Show 20 Lines | |||||
{ | { | ||||
if (this.lastCarriedType && this.lastCarriedType.generic in this.carrying) | if (this.lastCarriedType && this.lastCarriedType.generic in this.carrying) | ||||
return this.lastCarriedType; | return this.lastCarriedType; | ||||
return undefined; | return undefined; | ||||
}; | }; | ||||
// Since this code is very performancecritical and applying technologies quite slow, cache it. | // Since this code is very performancecritical and applying technologies quite slow, cache it. | ||||
ResourceGatherer.prototype.RecalculateGatherRatesAndCapacities = function() | ResourceGatherer.prototype.RecalculateGatherRatesAndCapacities = function() | ||||
Not Done Inline Actionsperformance-critical bb: performance-critical | |||||
{ | { | ||||
this.baseSpeed = ApplyValueModificationsToEntity("ResourceGatherer/BaseSpeed", +this.template.BaseSpeed, this.entity); | this.baseSpeed = ApplyValueModificationsToEntity("ResourceGatherer/BaseSpeed", +this.template.BaseSpeed, this.entity); | ||||
this.rates = {}; | this.rates = {}; | ||||
for (let r in this.template.Rates) | for (let r in this.template.Rates) | ||||
{ | { | ||||
let type = r.split("."); | let type = r.split("."); | ||||
Show All 33 Lines | |||||
}; | }; | ||||
ResourceGatherer.prototype.GetRange = function() | ResourceGatherer.prototype.GetRange = function() | ||||
{ | { | ||||
return { "max": +this.template.MaxDistance, "min": 0 }; | return { "max": +this.template.MaxDistance, "min": 0 }; | ||||
// maybe this should depend on the unit or target or something? | // maybe this should depend on the unit or target or something? | ||||
}; | }; | ||||
ResourceGatherer.prototype.GetAutoGatherRange = function() | |||||
{ | |||||
StanUnsubmitted Done Inline ActionsI assume that the cost of having a cached variable and a message subscription is less than calling that function all the time? Stan: I assume that the cost of having a cached variable and a message subscription is less than… | |||||
return ApplyValueModificationsToEntity("ResourceGatherer/AutoGatherRange", +this.template.AutoGatherRange, this.entity); | |||||
}; | |||||
/** | /** | ||||
* Try to gather treasure | * Try to gather treasure | ||||
* @return 'true' if treasure is successfully gathered, otherwise 'false' | * @return 'true' if treasure is successfully gathered, otherwise 'false' | ||||
*/ | */ | ||||
ResourceGatherer.prototype.TryInstantGather = function(target) | ResourceGatherer.prototype.TryInstantGather = function(target) | ||||
{ | { | ||||
let cmpResourceSupply = Engine.QueryInterface(target, IID_ResourceSupply); | let cmpResourceSupply = Engine.QueryInterface(target, IID_ResourceSupply); | ||||
let type = cmpResourceSupply.GetType(); | let type = cmpResourceSupply.GetType(); | ||||
▲ Show 20 Lines • Show All 191 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator
Could also mention where the center is (its not obvious whether it searches at the current unit position or at the last position gathered)