Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/simulation/components/UnitAI.js
Show All 14 Lines | |||||
"</choice>" + | "</choice>" + | ||||
"</element>" + | "</element>" + | ||||
"<element name='FormationController'>" + | "<element name='FormationController'>" + | ||||
"<data type='boolean'/>" + | "<data type='boolean'/>" + | ||||
"</element>" + | "</element>" + | ||||
"<element name='FleeDistance'>" + | "<element name='FleeDistance'>" + | ||||
"<ref name='positiveDecimal'/>" + | "<ref name='positiveDecimal'/>" + | ||||
"</element>" + | "</element>" + | ||||
"<optional>" + | |||||
"<element name='Formations' a:help='Optional list of space-separated formations this unit is allowed to use. Choices include: Scatter, Box, ColumnClosed, LineClosed, ColumnOpen, LineOpen, Flank, Skirmish, Wedge, Testudo, Phalanx, Syntagma, BattleLine.'>" + | |||||
"<attribute name='datatype'>" + | |||||
"<value>tokens</value>" + | |||||
"</attribute>" + | |||||
"<text/>" + | |||||
"</element>" + | |||||
"</optional>" + | |||||
"<element name='CanGuard'>" + | "<element name='CanGuard'>" + | ||||
"<data type='boolean'/>" + | "<data type='boolean'/>" + | ||||
"</element>" + | "</element>" + | ||||
"<element name='CanPatrol'>" + | "<element name='CanPatrol'>" + | ||||
"<data type='boolean'/>" + | "<data type='boolean'/>" + | ||||
"</element>" + | "</element>" + | ||||
"<element name='PatrolWaitTime' a:help='Number of seconds to wait in between patrol waypoints.'>" + | "<element name='PatrolWaitTime' a:help='Number of seconds to wait in between patrol waypoints.'>" + | ||||
"<data type='nonNegativeInteger'/>" + | "<data type='nonNegativeInteger'/>" + | ||||
▲ Show 20 Lines • Show All 1,982 Lines • ▼ Show 20 Lines | |||||
return (this.template.FormationController == "true"); | return (this.template.FormationController == "true"); | ||||
}; | }; | ||||
UnitAI.prototype.IsFormationMember = function() | UnitAI.prototype.IsFormationMember = function() | ||||
{ | { | ||||
return (this.formationController != INVALID_ENTITY); | return (this.formationController != INVALID_ENTITY); | ||||
}; | }; | ||||
UnitAI.prototype.GetFormationsList = function() | |||||
{ | |||||
return this.template.Formations?._string?.split(/\s+/) || []; | |||||
Stan: Need to profile if we actually need the regex someday (it tests for all whitespace types)… | |||||
Done Inline ActionsI don't think we need it. But I don't want to change anyhing else than moving in this patch. Freagarach: I don't think we need it. But I don't want to change anyhing else than moving in this patch. | |||||
}; | |||||
UnitAI.prototype.CanUseFormation = function(formation) | |||||
{ | |||||
return this.GetFormationsList().includes(formation); | |||||
}; | |||||
/** | /** | ||||
* For now, entities with a RoamDistance are animals. | * For now, entities with a RoamDistance are animals. | ||||
*/ | */ | ||||
UnitAI.prototype.IsAnimal = function() | UnitAI.prototype.IsAnimal = function() | ||||
{ | { | ||||
return !!this.template.RoamDistance; | return !!this.template.RoamDistance; | ||||
}; | }; | ||||
▲ Show 20 Lines • Show All 991 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator
Need to profile if we actually need the regex someday (it tests for all whitespace types) (since the c++ does the sanitization)