Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/simulation/components/Builder.js
function Builder() {} | function Builder() {} | ||||
Builder.prototype.Schema = | Builder.prototype.Schema = | ||||
"<a:help>Allows the unit to construct and repair buildings.</a:help>" + | "<a:help>Allows the unit to construct and repair buildings.</a:help>" + | ||||
"<a:example>" + | "<a:example>" + | ||||
"<Rate>1.0</Rate>" + | "<Rate>1.0</Rate>" + | ||||
"<Entities datatype='tokens'>" + | "<Entities datatype='tokens'>" + | ||||
"\n structures/{civ}_barracks\n structures/{native}_civil_centre\n structures/pers_apadana\n " + | "\n structures/{civ}_barracks\n structures/{native}_civil_centre\n structures/pers_apadana\n " + | ||||
"</Entities>" + | "</Entities>" + | ||||
"</a:example>" + | "</a:example>" + | ||||
"<element name='Rate' a:help='Construction speed multiplier (1.0 is normal speed, higher values are faster).'>" + | "<element name='Rate' a:help='Construction speed multiplier (1.0 is normal speed, higher values are faster).'>" + | ||||
"<ref name='positiveDecimal'/>" + | "<ref name='positiveDecimal'/>" + | ||||
"</element>" + | "</element>" + | ||||
"<element name='SearchRange' a:help='Max distance to search for a new foundation to construct.'>" + | |||||
"<ref name='nonNegativeDecimal'/>" + | |||||
bb: I guess we should do nonNegativeDecimal (allowing 0 to disable searching further) | |||||
"</element>" + | |||||
"<element name='Entities' a:help='Space-separated list of entity template names that this unit can build. The special string \"{civ}\" will be automatically replaced by the civ code of the unit's owner, while the string \"{native}\" will be automatically replaced by the unit's civ code. This element can also be empty, in which case no new foundations may be placed by the unit, but they can still repair existing buildings.'>" + | "<element name='Entities' a:help='Space-separated list of entity template names that this unit can build. The special string \"{civ}\" will be automatically replaced by the civ code of the unit's owner, while the string \"{native}\" will be automatically replaced by the unit's civ code. This element can also be empty, in which case no new foundations may be placed by the unit, but they can still repair existing buildings.'>" + | ||||
"<attribute name='datatype'>" + | "<attribute name='datatype'>" + | ||||
"<value>tokens</value>" + | "<value>tokens</value>" + | ||||
"</attribute>" + | "</attribute>" + | ||||
"<text/>" + | "<text/>" + | ||||
"</element>"; | "</element>"; | ||||
Builder.prototype.Init = function() | Builder.prototype.Init = function() | ||||
Show All 30 Lines | Builder.prototype.GetRange = function() | ||||
let max = 2; | let max = 2; | ||||
let cmpObstruction = Engine.QueryInterface(this.entity, IID_Obstruction); | let cmpObstruction = Engine.QueryInterface(this.entity, IID_Obstruction); | ||||
if (cmpObstruction) | if (cmpObstruction) | ||||
max += cmpObstruction.GetUnitRadius(); | max += cmpObstruction.GetUnitRadius(); | ||||
return { "max": max, "min": 0 }; | return { "max": max, "min": 0 }; | ||||
}; | }; | ||||
Builder.prototype.GetSearchRange = function() | |||||
{ | |||||
return ApplyValueModificationsToEntity("Builder/SearchRange", +this.template.SearchRange, this.entity); | |||||
}; | |||||
Builder.prototype.GetRate = function() | Builder.prototype.GetRate = function() | ||||
{ | { | ||||
return ApplyValueModificationsToEntity("Builder/Rate", +this.template.Rate, this.entity); | return ApplyValueModificationsToEntity("Builder/Rate", +this.template.Rate, this.entity); | ||||
}; | }; | ||||
/** | /** | ||||
* Build/repair the target entity. This should only be called after a successful range check. | * Build/repair the target entity. This should only be called after a successful range check. | ||||
* It should be called at a rate of once per second. | * It should be called at a rate of once per second. | ||||
Show All 21 Lines |
Wildfire Games · Phabricator
I guess we should do nonNegativeDecimal (allowing 0 to disable searching further)