Class: Formation

Formation()

new Formation()

Source:

Methods

ComputeMotionParameters()

Set formation controller's speed based on its current members.
Source:

Disband()

Remove all members and destroy the formation.
Source:

GetEstimatedOrientation()

Calculate the estimated rotation of the formation based on the current rotation. Return the sine and cosine of the angle.
Source:

GetFormationAnimationVariant(entity)

Get the formation animation variant for a certain member of this formation.
Parameters:
Name Type Description
entity The entity ID to get the animation for.
Source:
Returns:
The name of the animation variant as defined in the template, e.g. "testudo_front" or undefined if does not exist.

GetPrimaryMember()

Returns the 'primary' member of this formation (typically the most important unit type), for e.g. playing a representative sound. Returns undefined if no members. TODO: Actually implement something like that. Currently this just returns the arbitrary first one.
Source:

GetRealOffsetPositions()

Get the world positions for a list of offsets in this formation.
Source:

MoveMembersIntoFormation(moveCenter, force, variant)

Set all members to form up into the formation shape.
Parameters:
Name Type Description
moveCenter boolean The formation center will be reinitialized to the center of the units.
force boolean All individual orders of the formation units are replaced, otherwise the order to walk into formation is just pushed to the front.
variant string | undefined Variant to be passed as order parameter.
Source:

RemoveMembers(rename)

Remove the given list of entities. The entities must already be members of this formation.
Parameters:
Name Type Description
rename boolean Whether the removal was part of an entity rename (prevents disbanding of the formation when under the member limit).
Source:

SetFormationSeparation()

Set the value from which two twin formations will become one.
Source:

SetMembers()

Initialize the members of this formation. Must only be called once. All members must implement UnitAI.
Source:

SetRearrange()

Set whether we are allowed to rearrange formation members.
Source:

SetupPositionAndHandleRotation()

Set formation position. If formation is not in world at time this is called, set new rotation and flag for range manager.
Source:

TakeClosestOffset(entPos, realPositions, offsets)

Search the closest position in the realPositions list to the given entity.
Parameters:
Name Type Description
entPos Object with entity position and entity ID.
realPositions The world coordinates of the available offsets.
offsets
Source:
Returns:
The index of the closest offset position.