Pyrogenesis HEAD
Pyrogenesis, a RTS Engine
CCmpUnitMotion Class Referencefinal

#include <CCmpUnitMotion.h>

Inheritance diagram for CCmpUnitMotion:
Collaboration diagram for CCmpUnitMotion:

Classes

struct  MoveRequest
 
struct  Ticket
 

Public Member Functions

int GetComponentTypeId () const override
 
void Init (const CParamNode &paramNode) override
 
void Deinit () override
 
template<typename S >
void SerializeCommon (S &serialize)
 
void Serialize (ISerializer &serialize) override
 
void Deserialize (const CParamNode &paramNode, IDeserializer &deserialize) override
 
void HandleMessage (const CMessage &msg, bool global) override
 
void UpdateMessageSubscriptions ()
 
bool IsMoveRequested () const override
 
fixed GetSpeedMultiplier () const override
 Returns the ratio of GetSpeed() / GetWalkSpeed(). More...
 
void SetSpeedMultiplier (fixed multiplier) override
 Set the current movement speed. More...
 
fixed GetSpeed () const override
 Get the speed at which the unit intends to move. More...
 
fixed GetWalkSpeed () const override
 Get the unit template walk speed after modifications. More...
 
fixed GetRunMultiplier () const override
 Get the unit template running (i.e. More...
 
CFixedVector2D EstimateFuturePosition (const fixed dt) const override
 
fixed GetAcceleration () const override
 Get the current acceleration. More...
 
void SetAcceleration (fixed acceleration) override
 Set the current acceleration. More...
 
virtual entity_pos_t GetWeight () const
 
pass_class_t GetPassabilityClass () const override
 Get the unit's passability class. More...
 
std::string GetPassabilityClassName () const override
 Get the passability class name (as defined in pathfinder.xml) More...
 
void SetPassabilityClassName (const std::string &passClassName) override
 Sets the passability class name (as defined in pathfinder.xml) More...
 
fixed GetCurrentSpeed () const override
 Get the speed at the end of the current turn. More...
 
void SetFacePointAfterMove (bool facePointAfterMove) override
 Set whether the unit will turn to face the target point after finishing moving. More...
 
bool GetFacePointAfterMove () const override
 
void SetDebugOverlay (bool enabled) override
 Toggle the rendering of debug info. More...
 
bool MoveToPointRange (entity_pos_t x, entity_pos_t z, entity_pos_t minRange, entity_pos_t maxRange) override
 Attempt to walk into range of a to a given point, or as close as possible. More...
 
bool MoveToTargetRange (entity_id_t target, entity_pos_t minRange, entity_pos_t maxRange) override
 Attempt to walk into range of a given target entity, or as close as possible. More...
 
void MoveToFormationOffset (entity_id_t controller, entity_pos_t x, entity_pos_t z) override
 Join a formation, and move towards a given offset relative to the formation controller entity. More...
 
void SetMemberOfFormation (entity_id_t controller) override
 Set/unset the unit as a formation member. More...
 
bool IsTargetRangeReachable (entity_id_t target, entity_pos_t minRange, entity_pos_t maxRange) override
 Check if the target is reachable. More...
 
void FaceTowardsPoint (entity_pos_t x, entity_pos_t z) override
 Turn to look towards the given point. More...
 
void StopMoving () override
 Clears the current MoveRequest - the unit will stop and no longer try and move. More...
 
entity_pos_t GetUnitClearance () const override
 Get the unit clearance (used by the Obstruction component) More...
 
virtual bool MoveToPointRange (entity_pos_t x, entity_pos_t z, entity_pos_t minRange, entity_pos_t maxRange)=0
 Attempt to walk into range of a to a given point, or as close as possible. More...
 
virtual bool MoveToTargetRange (entity_id_t target, entity_pos_t minRange, entity_pos_t maxRange)=0
 Attempt to walk into range of a given target entity, or as close as possible. More...
 
virtual void MoveToFormationOffset (entity_id_t controller, entity_pos_t x, entity_pos_t z)=0
 Join a formation, and move towards a given offset relative to the formation controller entity. More...
 
virtual void SetMemberOfFormation (entity_id_t controller)=0
 Set/unset the unit as a formation member. More...
 
virtual bool IsTargetRangeReachable (entity_id_t target, entity_pos_t minRange, entity_pos_t maxRange)=0
 Check if the target is reachable. More...
 
virtual void FaceTowardsPoint (entity_pos_t x, entity_pos_t z)=0
 Turn to look towards the given point. More...
 
virtual void StopMoving ()=0
 Stop moving immediately. More...
 
virtual fixed GetCurrentSpeed () const =0
 Get the speed at the end of the current turn. More...
 
virtual bool IsMoveRequested () const =0
 
virtual fixed GetWalkSpeed () const =0
 Get the unit template walk speed after modifications. More...
 
virtual fixed GetRunMultiplier () const =0
 Get the unit template running (i.e. More...
 
virtual fixed GetSpeedMultiplier () const =0
 Returns the ratio of GetSpeed() / GetWalkSpeed(). More...
 
virtual void SetSpeedMultiplier (fixed multiplier)=0
 Set the current movement speed. More...
 
virtual fixed GetSpeed () const =0
 Get the speed at which the unit intends to move. More...
 
virtual CFixedVector2D EstimateFuturePosition (const fixed dt) const =0
 
virtual fixed GetAcceleration () const =0
 Get the current acceleration. More...
 
virtual void SetAcceleration (fixed acceleration)=0
 Set the current acceleration. More...
 
virtual void SetFacePointAfterMove (bool facePointAfterMove)=0
 Set whether the unit will turn to face the target point after finishing moving. More...
 
virtual bool GetFacePointAfterMove () const =0
 
virtual pass_class_t GetPassabilityClass () const =0
 Get the unit's passability class. More...
 
virtual std::string GetPassabilityClassName () const =0
 Get the passability class name (as defined in pathfinder.xml) More...
 
virtual void SetPassabilityClassName (const std::string &passClassName)=0
 Sets the passability class name (as defined in pathfinder.xml) More...
 
virtual entity_pos_t GetUnitClearance () const =0
 Get the unit clearance (used by the Obstruction component) More...
 
virtual void SetDebugOverlay (bool enabled)=0
 Toggle the rendering of debug info. More...
 
- Public Member Functions inherited from IComponent
virtual ~IComponent ()
 
virtual void Init (const CParamNode &paramNode)=0
 
virtual void Deinit ()=0
 
virtual void HandleMessage (const CMessage &msg, bool global)
 
CEntityHandle GetEntityHandle () const
 
void SetEntityHandle (CEntityHandle ent)
 
entity_id_t GetEntityId () const
 
CEntityHandle GetSystemEntity () const
 
const CSimContextGetSimContext () const
 
void SetSimContext (const CSimContext &context)
 
virtual void Serialize (ISerializer &serialize)=0
 
virtual void Deserialize (const CParamNode &paramNode, IDeserializer &deserialize)=0
 
virtual bool NewJSObject (const ScriptInterface &scriptInterface, JS::MutableHandleObject out) const
 Returns false by default, indicating that a scripted wrapper of this IComponent is not supported. More...
 
virtual JS::Value GetJSInstance () const
 
virtual int GetComponentTypeId () const =0
 

Static Public Member Functions

static void ClassInit (CComponentManager &componentManager)
 
static IComponentAllocate (const ScriptInterface &, JS::HandleValue)
 
static void Deallocate (IComponent *cmp)
 
static std::string GetSchema ()
 
- Static Public Member Functions inherited from IComponent
static std::string GetSchema ()
 
static void RegisterComponentType (CComponentManager &mgr, EInterfaceId iid, EComponentTypeId cid, AllocFunc alloc, DeallocFunc dealloc, const char *name, const std::string &schema)
 
static void RegisterComponentTypeScriptWrapper (CComponentManager &mgr, EInterfaceId iid, EComponentTypeId cid, AllocFunc alloc, DeallocFunc dealloc, const char *name, const std::string &schema)
 
static u8 GetSerializationVersion ()
 

Public Attributes

bool m_DebugOverlayEnabled
 
std::vector< SOverlayLinem_DebugOverlayLongPathLines
 
std::vector< SOverlayLinem_DebugOverlayShortPathLines
 
bool m_IsFormationController
 
fixed m_TemplateWalkSpeed
 
fixed m_TemplateRunMultiplier
 
fixed m_TemplateAcceleration
 
fixed m_TemplateWeight
 
pass_class_t m_PassClass
 
std::string m_PassClassName
 
entity_pos_t m_Clearance
 
fixed m_WalkSpeed
 
fixed m_RunMultiplier
 
bool m_FacePointAfterMove
 
bool m_Pushing = false
 
bool m_BlockMovement = false
 
u8 m_FailedMovements = 0
 
u8 m_FollowKnownImperfectPathCountdown = 0
 
struct CCmpUnitMotion::Ticket m_ExpectedPathTicket
 
struct CCmpUnitMotion::MoveRequest m_MoveRequest
 
entity_id_t m_FormationController = INVALID_ENTITY
 
fixed m_SpeedMultiplier
 
fixed m_Speed
 
fixed m_LastTurnSpeed
 
fixed m_CurrentSpeed
 
fixed m_InstantTurnAngle
 
fixed m_Acceleration
 
WaypointPath m_LongPath
 
WaypointPath m_ShortPath
 

Private Member Functions

bool IsFormationMember () const
 
bool IsMovingAsFormation () const
 
bool IsFormationControllerMoving () const
 
entity_id_t GetGroup () const
 
void SetParticipateInPushing (bool pushing)
 
void SetPassabilityData (const std::string &passClassName)
 
void MoveFailed ()
 Warns other components that our current movement will likely fail (e.g. More...
 
void MoveSucceeded ()
 Warns other components that our current movement is likely over (i.e. More...
 
void MoveObstructed ()
 Warns other components that our current movement was obstructed (i.e. More...
 
bool IncrementFailedMovementsAndMaybeNotify ()
 Increment the number of failed movements and notify other components if required. More...
 
bool RejectFartherPaths (const PathGoal &goal, const WaypointPath &path, const CFixedVector2D &pos) const
 If path would take us farther away from the goal than pos currently is, return false, else return true. More...
 
bool ShouldAlternatePathfinder () const
 
bool InShortPathRange (const PathGoal &goal, const CFixedVector2D &pos) const
 
entity_pos_t ShortPathSearchRange () const
 
void PathResult (u32 ticket, const WaypointPath &path)
 Handle the result of an asynchronous path query. More...
 
void OnValueModification ()
 
void OnTurnStart ()
 Check if we are at destination early in the turn, this both lets units react faster and ensure that distance comparisons are done while units are not being moved (otherwise they won't be commutative). More...
 
void PreMove (CCmpUnitMotionManager::MotionState &state)
 
void Move (CCmpUnitMotionManager::MotionState &state, fixed dt)
 
void PostMove (CCmpUnitMotionManager::MotionState &state, fixed dt)
 
bool PossiblyAtDestination () const
 Returns true if we are possibly at our destination. More...
 
bool PerformMove (fixed dt, const fixed &turnRate, WaypointPath &shortPath, WaypointPath &longPath, CFixedVector2D &pos, fixed &speed, entity_angle_t &angle, uint8_t pushingPressure) const
 Process the move the unit will do this turn. More...
 
void UpdateMovementState (entity_pos_t speed, entity_pos_t meanSpeed)
 Update other components on our speed. More...
 
bool HandleObstructedMove (bool moved)
 React if our move was obstructed. More...
 
bool TargetHasValidPosition (const MoveRequest &moveRequest) const
 Returns true if the target position is valid. More...
 
bool TargetHasValidPosition () const
 
bool ComputeTargetPosition (CFixedVector2D &out, const MoveRequest &moveRequest) const
 Computes the current location of our target entity (plus offset). More...
 
bool ComputeTargetPosition (CFixedVector2D &out) const
 
bool TryGoingStraightToTarget (const CFixedVector2D &from, bool updatePaths)
 Attempts to replace the current path with a straight line to the target, if it's close enough and the route is not obstructed. More...
 
bool PathingUpdateNeeded (const CFixedVector2D &from) const
 Returns whether our we need to recompute a path to reach our target. More...
 
void FaceTowardsPointFromPos (const CFixedVector2D &pos, entity_pos_t x, entity_pos_t z)
 Rotate to face towards the target point, given the current pos. More...
 
bool ShouldCollideWithMovingUnits () const
 Units in 'pushing' mode are marked as 'moving' in the obstruction manager. More...
 
ControlGroupMovementObstructionFilter GetObstructionFilter () const
 Returns an appropriate obstruction filter for use with path requests. More...
 
SkipTagAndControlGroupObstructionFilter GetObstructionFilter (const ICmpObstructionManager::tag_t &tag) const
 Filter a specific tag on top of the existing control groups. More...
 
bool ShouldTreatTargetAsCircle (entity_pos_t range, entity_pos_t circleRadius) const
 Decide whether to approximate the given range from a square target as a circle, rather than as a square. More...
 
bool ComputeGoal (PathGoal &out, const MoveRequest &moveRequest) const
 Create a PathGoal from a move request. More...
 
void ComputePathToGoal (const CFixedVector2D &from, const PathGoal &goal)
 Compute a path to the given goal from the given position. More...
 
void RequestLongPath (const CFixedVector2D &from, const PathGoal &goal)
 Start an asynchronous long path query. More...
 
void RequestShortPath (const CFixedVector2D &from, const PathGoal &goal, bool extendRange)
 Start an asynchronous short path query. More...
 
bool MoveTo (MoveRequest request)
 General handler for MoveTo interface functions. More...
 
void RenderPath (const WaypointPath &path, std::vector< SOverlayLine > &lines, CColor color)
 Convert a path into a renderable list of lines. More...
 
void RenderSubmit (SceneCollector &collector)
 

Friends

class CCmpUnitMotionManager
 

Additional Inherited Members

- Public Types inherited from IComponent
using AllocFunc = IComponent *(*)(const ScriptInterface &scriptInterface, JS::HandleValue ctor)
 
using DeallocFunc = void(*)(IComponent *)
 

Member Function Documentation

◆ Allocate()

static IComponent * CCmpUnitMotion::Allocate ( const ScriptInterface ,
JS::HandleValue   
)
inlinestatic

◆ ClassInit()

static void CCmpUnitMotion::ClassInit ( CComponentManager componentManager)
inlinestatic

◆ ComputeGoal()

bool CCmpUnitMotion::ComputeGoal ( PathGoal out,
const MoveRequest moveRequest 
) const
private

Create a PathGoal from a move request.

Returns
true if the goal was successfully created.

◆ ComputePathToGoal()

void CCmpUnitMotion::ComputePathToGoal ( const CFixedVector2D from,
const PathGoal goal 
)
private

Compute a path to the given goal from the given position.

Might go in a straight line immediately, or might start an asynchronous path request.

◆ ComputeTargetPosition() [1/2]

bool CCmpUnitMotion::ComputeTargetPosition ( CFixedVector2D out) const
inlineprivate

◆ ComputeTargetPosition() [2/2]

bool CCmpUnitMotion::ComputeTargetPosition ( CFixedVector2D out,
const MoveRequest moveRequest 
) const
private

Computes the current location of our target entity (plus offset).

Returns false if no target entity or no valid position.

◆ Deallocate()

static void CCmpUnitMotion::Deallocate ( IComponent cmp)
inlinestatic

◆ Deinit()

void CCmpUnitMotion::Deinit ( )
inlineoverridevirtual

Implements IComponent.

◆ Deserialize()

void CCmpUnitMotion::Deserialize ( const CParamNode paramNode,
IDeserializer deserialize 
)
inlineoverridevirtual

Implements IComponent.

◆ EstimateFuturePosition()

CFixedVector2D CCmpUnitMotion::EstimateFuturePosition ( const fixed  dt) const
inlineoverridevirtual
Returns
the estimated position of the unit in
Parameters
dtseconds, following current paths. This is allowed to 'look into the future'.

Implements ICmpUnitMotion.

◆ FaceTowardsPoint()

void CCmpUnitMotion::FaceTowardsPoint ( entity_pos_t  x,
entity_pos_t  z 
)
overridevirtual

Turn to look towards the given point.

Implements ICmpUnitMotion.

◆ FaceTowardsPointFromPos()

void CCmpUnitMotion::FaceTowardsPointFromPos ( const CFixedVector2D pos,
entity_pos_t  x,
entity_pos_t  z 
)
private

Rotate to face towards the target point, given the current pos.

◆ GetAcceleration()

fixed CCmpUnitMotion::GetAcceleration ( ) const
inlineoverridevirtual

Get the current acceleration.

Implements ICmpUnitMotion.

◆ GetComponentTypeId()

int CCmpUnitMotion::GetComponentTypeId ( ) const
inlineoverridevirtual

Implements IComponent.

◆ GetCurrentSpeed()

fixed CCmpUnitMotion::GetCurrentSpeed ( ) const
inlineoverridevirtual

Get the speed at the end of the current turn.

Implements ICmpUnitMotion.

◆ GetFacePointAfterMove()

bool CCmpUnitMotion::GetFacePointAfterMove ( ) const
inlineoverridevirtual

Implements ICmpUnitMotion.

◆ GetGroup()

entity_id_t CCmpUnitMotion::GetGroup ( ) const
inlineprivate

◆ GetObstructionFilter() [1/2]

ControlGroupMovementObstructionFilter CCmpUnitMotion::GetObstructionFilter ( ) const
inlineprivate

Returns an appropriate obstruction filter for use with path requests.

◆ GetObstructionFilter() [2/2]

SkipTagAndControlGroupObstructionFilter CCmpUnitMotion::GetObstructionFilter ( const ICmpObstructionManager::tag_t tag) const
inlineprivate

Filter a specific tag on top of the existing control groups.

◆ GetPassabilityClass()

pass_class_t CCmpUnitMotion::GetPassabilityClass ( ) const
inlineoverridevirtual

Get the unit's passability class.

Implements ICmpUnitMotion.

◆ GetPassabilityClassName()

std::string CCmpUnitMotion::GetPassabilityClassName ( ) const
inlineoverridevirtual

Get the passability class name (as defined in pathfinder.xml)

Implements ICmpUnitMotion.

◆ GetRunMultiplier()

fixed CCmpUnitMotion::GetRunMultiplier ( ) const
inlineoverridevirtual

Get the unit template running (i.e.

max) speed after modifications.

Implements ICmpUnitMotion.

◆ GetSchema()

static std::string CCmpUnitMotion::GetSchema ( )
inlinestatic

◆ GetSpeed()

fixed CCmpUnitMotion::GetSpeed ( ) const
inlineoverridevirtual

Get the speed at which the unit intends to move.

(regardless of whether the unit is moving or not right now).

Implements ICmpUnitMotion.

◆ GetSpeedMultiplier()

fixed CCmpUnitMotion::GetSpeedMultiplier ( ) const
inlineoverridevirtual

Returns the ratio of GetSpeed() / GetWalkSpeed().

Implements ICmpUnitMotion.

◆ GetUnitClearance()

entity_pos_t CCmpUnitMotion::GetUnitClearance ( ) const
inlineoverridevirtual

Get the unit clearance (used by the Obstruction component)

Implements ICmpUnitMotion.

◆ GetWalkSpeed()

fixed CCmpUnitMotion::GetWalkSpeed ( ) const
inlineoverridevirtual

Get the unit template walk speed after modifications.

Implements ICmpUnitMotion.

◆ GetWeight()

virtual entity_pos_t CCmpUnitMotion::GetWeight ( ) const
inlinevirtual

◆ HandleMessage()

void CCmpUnitMotion::HandleMessage ( const CMessage msg,
bool  global 
)
inlineoverridevirtual

Reimplemented from IComponent.

◆ HandleObstructedMove()

bool CCmpUnitMotion::HandleObstructedMove ( bool  moved)
private

React if our move was obstructed.

Parameters
moved- true if the unit still managed to move.
Returns
true if the obstruction required handling, false otherwise.

◆ IncrementFailedMovementsAndMaybeNotify()

bool CCmpUnitMotion::IncrementFailedMovementsAndMaybeNotify ( )
inlineprivate

Increment the number of failed movements and notify other components if required.

Returns
true if the failure was notified, false otherwise.

◆ Init()

void CCmpUnitMotion::Init ( const CParamNode paramNode)
inlineoverridevirtual

Implements IComponent.

◆ InShortPathRange()

bool CCmpUnitMotion::InShortPathRange ( const PathGoal goal,
const CFixedVector2D pos 
) const
inlineprivate

◆ IsFormationControllerMoving()

bool CCmpUnitMotion::IsFormationControllerMoving ( ) const
inlineprivate

◆ IsFormationMember()

bool CCmpUnitMotion::IsFormationMember ( ) const
inlineprivate

◆ IsMoveRequested()

bool CCmpUnitMotion::IsMoveRequested ( ) const
inlineoverridevirtual
Returns
true if the unit has a destination.

Implements ICmpUnitMotion.

◆ IsMovingAsFormation()

bool CCmpUnitMotion::IsMovingAsFormation ( ) const
inlineprivate

◆ IsTargetRangeReachable()

bool CCmpUnitMotion::IsTargetRangeReachable ( entity_id_t  target,
entity_pos_t  minRange,
entity_pos_t  maxRange 
)
overridevirtual

Check if the target is reachable.

Don't take this as absolute gospel since there are things that the pathfinder may not detect, such as entity obstructions in the way, but in general it should return satisfactory results. The interface is similar to MoveToTargetRange but the move is not attempted.

Returns
true if the target is assumed reachable, false otherwise.

Implements ICmpUnitMotion.

◆ Move()

void CCmpUnitMotion::Move ( CCmpUnitMotionManager::MotionState state,
fixed  dt 
)
private

◆ MoveFailed()

void CCmpUnitMotion::MoveFailed ( )
inlineprivate

Warns other components that our current movement will likely fail (e.g.

we won't be able to reach our target) This should only be called before the actual movement in a given turn, or units might both move and try to do things on the same turn, leading to gliding units.

◆ MoveObstructed()

void CCmpUnitMotion::MoveObstructed ( )
inlineprivate

Warns other components that our current movement was obstructed (i.e.

we failed to move this turn). This should only be called before the actual movement in a given turn, or units might both move and try to do things on the same turn, leading to gliding units.

◆ MoveSucceeded()

void CCmpUnitMotion::MoveSucceeded ( )
inlineprivate

Warns other components that our current movement is likely over (i.e.

we probably reached our destination) This should only be called before the actual movement in a given turn, or units might both move and try to do things on the same turn, leading to gliding units.

◆ MoveTo()

bool CCmpUnitMotion::MoveTo ( MoveRequest  request)
private

General handler for MoveTo interface functions.

◆ MoveToFormationOffset()

void CCmpUnitMotion::MoveToFormationOffset ( entity_id_t  controller,
entity_pos_t  x,
entity_pos_t  z 
)
inlineoverridevirtual

Join a formation, and move towards a given offset relative to the formation controller entity.

The unit will remain 'in formation' fromthe perspective of UnitMotion until SetMemberOfFormation(INVALID_ENTITY) is passed.

Implements ICmpUnitMotion.

◆ MoveToPointRange()

bool CCmpUnitMotion::MoveToPointRange ( entity_pos_t  x,
entity_pos_t  z,
entity_pos_t  minRange,
entity_pos_t  maxRange 
)
inlineoverridevirtual

Attempt to walk into range of a to a given point, or as close as possible.

The range is measured from the center of the unit. If cannot move anywhere at all, or if there is some other error, then returns false. Otherwise, returns true. If maxRange is negative, then the maximum range is treated as infinity.

Implements ICmpUnitMotion.

◆ MoveToTargetRange()

bool CCmpUnitMotion::MoveToTargetRange ( entity_id_t  target,
entity_pos_t  minRange,
entity_pos_t  maxRange 
)
inlineoverridevirtual

Attempt to walk into range of a given target entity, or as close as possible.

The range is measured between approximately the edges of the unit and the target, so that maxRange=0 is not unreachably close to the target. If the unit cannot move anywhere at all, or if there is some other error, then returns false. Otherwise, returns true. If maxRange is negative, then the maximum range is treated as infinity.

Implements ICmpUnitMotion.

◆ OnTurnStart()

void CCmpUnitMotion::OnTurnStart ( )
private

Check if we are at destination early in the turn, this both lets units react faster and ensure that distance comparisons are done while units are not being moved (otherwise they won't be commutative).

◆ OnValueModification()

void CCmpUnitMotion::OnValueModification ( )
inlineprivate

◆ PathingUpdateNeeded()

bool CCmpUnitMotion::PathingUpdateNeeded ( const CFixedVector2D from) const
private

Returns whether our we need to recompute a path to reach our target.

◆ PathResult()

void CCmpUnitMotion::PathResult ( u32  ticket,
const WaypointPath path 
)
private

Handle the result of an asynchronous path query.

◆ PerformMove()

bool CCmpUnitMotion::PerformMove ( fixed  dt,
const fixed turnRate,
WaypointPath shortPath,
WaypointPath longPath,
CFixedVector2D pos,
fixed speed,
entity_angle_t angle,
uint8_t  pushingPressure 
) const
private

Process the move the unit will do this turn.

This does not send actually change the position.

Returns
true if the move was obstructed.

◆ PossiblyAtDestination()

bool CCmpUnitMotion::PossiblyAtDestination ( ) const
private

Returns true if we are possibly at our destination.

Since the concept of being at destination is dependent on why the move was requested, UnitMotion can only ever hint about this, hence the conditional tone.

◆ PostMove()

void CCmpUnitMotion::PostMove ( CCmpUnitMotionManager::MotionState state,
fixed  dt 
)
private

◆ PreMove()

void CCmpUnitMotion::PreMove ( CCmpUnitMotionManager::MotionState state)
private

◆ RejectFartherPaths()

bool CCmpUnitMotion::RejectFartherPaths ( const PathGoal goal,
const WaypointPath path,
const CFixedVector2D pos 
) const
private

If path would take us farther away from the goal than pos currently is, return false, else return true.

◆ RenderPath()

void CCmpUnitMotion::RenderPath ( const WaypointPath path,
std::vector< SOverlayLine > &  lines,
CColor  color 
)
private

Convert a path into a renderable list of lines.

◆ RenderSubmit()

void CCmpUnitMotion::RenderSubmit ( SceneCollector collector)
private

◆ RequestLongPath()

void CCmpUnitMotion::RequestLongPath ( const CFixedVector2D from,
const PathGoal goal 
)
private

Start an asynchronous long path query.

◆ RequestShortPath()

void CCmpUnitMotion::RequestShortPath ( const CFixedVector2D from,
const PathGoal goal,
bool  extendRange 
)
private

Start an asynchronous short path query.

Parameters
extendRange- if true, extend the search range to at least the distance to the goal.

◆ Serialize()

void CCmpUnitMotion::Serialize ( ISerializer serialize)
inlineoverridevirtual

Implements IComponent.

◆ SerializeCommon()

template<typename S >
void CCmpUnitMotion::SerializeCommon ( S &  serialize)
inline

◆ SetAcceleration()

void CCmpUnitMotion::SetAcceleration ( fixed  acceleration)
inlineoverridevirtual

Set the current acceleration.

Parameters
accelerationThe acceleration.

Implements ICmpUnitMotion.

◆ SetDebugOverlay()

void CCmpUnitMotion::SetDebugOverlay ( bool  enabled)
inlineoverridevirtual

Toggle the rendering of debug info.

Implements ICmpUnitMotion.

◆ SetFacePointAfterMove()

void CCmpUnitMotion::SetFacePointAfterMove ( bool  facePointAfterMove)
inlineoverridevirtual

Set whether the unit will turn to face the target point after finishing moving.

Implements ICmpUnitMotion.

◆ SetMemberOfFormation()

void CCmpUnitMotion::SetMemberOfFormation ( entity_id_t  controller)
inlineoverridevirtual

Set/unset the unit as a formation member.

Parameters
controller- if INVALID_ENTITY, the unit is no longer a formation member. Otherwise it is and this is the controller.

Implements ICmpUnitMotion.

◆ SetParticipateInPushing()

void CCmpUnitMotion::SetParticipateInPushing ( bool  pushing)
inlineprivate

◆ SetPassabilityClassName()

void CCmpUnitMotion::SetPassabilityClassName ( const std::string &  passClassName)
inlineoverridevirtual

Sets the passability class name (as defined in pathfinder.xml)

Implements ICmpUnitMotion.

◆ SetPassabilityData()

void CCmpUnitMotion::SetPassabilityData ( const std::string &  passClassName)
inlineprivate

◆ SetSpeedMultiplier()

void CCmpUnitMotion::SetSpeedMultiplier ( fixed  multiplier)
inlineoverridevirtual

Set the current movement speed.

Parameters
speedA multiplier of GetWalkSpeed().

Implements ICmpUnitMotion.

◆ ShortPathSearchRange()

entity_pos_t CCmpUnitMotion::ShortPathSearchRange ( ) const
inlineprivate

◆ ShouldAlternatePathfinder()

bool CCmpUnitMotion::ShouldAlternatePathfinder ( ) const
inlineprivate

◆ ShouldCollideWithMovingUnits()

bool CCmpUnitMotion::ShouldCollideWithMovingUnits ( ) const
inlineprivate

Units in 'pushing' mode are marked as 'moving' in the obstruction manager.

Units in 'pushing' mode should skip them in checkMovement (to enable pushing). However, units for which pushing is deactivated should collide against everyone. Units that don't block movement never participate in pushing, but they also shouldn't collide with pushing units.

◆ ShouldTreatTargetAsCircle()

bool CCmpUnitMotion::ShouldTreatTargetAsCircle ( entity_pos_t  range,
entity_pos_t  circleRadius 
) const
private

Decide whether to approximate the given range from a square target as a circle, rather than as a square.

◆ StopMoving()

void CCmpUnitMotion::StopMoving ( )
inlineoverridevirtual

Clears the current MoveRequest - the unit will stop and no longer try and move.

This should never be called from UnitMotion, since MoveToX orders are given by other components - these components should also decide when to stop.

Implements ICmpUnitMotion.

◆ TargetHasValidPosition() [1/2]

bool CCmpUnitMotion::TargetHasValidPosition ( ) const
inlineprivate

◆ TargetHasValidPosition() [2/2]

bool CCmpUnitMotion::TargetHasValidPosition ( const MoveRequest moveRequest) const
private

Returns true if the target position is valid.

False otherwise. (this may indicate that the target is e.g. out of the world/dead). NB: for code-writing convenience, if we have no target, this returns true.

◆ TryGoingStraightToTarget()

bool CCmpUnitMotion::TryGoingStraightToTarget ( const CFixedVector2D from,
bool  updatePaths 
)
private

Attempts to replace the current path with a straight line to the target, if it's close enough and the route is not obstructed.

◆ UpdateMessageSubscriptions()

void CCmpUnitMotion::UpdateMessageSubscriptions ( )
inline

◆ UpdateMovementState()

void CCmpUnitMotion::UpdateMovementState ( entity_pos_t  speed,
entity_pos_t  meanSpeed 
)
private

Update other components on our speed.

(For performance, this should try to avoid sending messages).

Friends And Related Function Documentation

◆ CCmpUnitMotionManager

friend class CCmpUnitMotionManager
friend

Member Data Documentation

◆ m_Acceleration

fixed CCmpUnitMotion::m_Acceleration

◆ m_BlockMovement

bool CCmpUnitMotion::m_BlockMovement = false

◆ m_Clearance

entity_pos_t CCmpUnitMotion::m_Clearance

◆ m_CurrentSpeed

fixed CCmpUnitMotion::m_CurrentSpeed

◆ m_DebugOverlayEnabled

bool CCmpUnitMotion::m_DebugOverlayEnabled

◆ m_DebugOverlayLongPathLines

std::vector<SOverlayLine> CCmpUnitMotion::m_DebugOverlayLongPathLines

◆ m_DebugOverlayShortPathLines

std::vector<SOverlayLine> CCmpUnitMotion::m_DebugOverlayShortPathLines

◆ m_ExpectedPathTicket

struct CCmpUnitMotion::Ticket CCmpUnitMotion::m_ExpectedPathTicket

◆ m_FacePointAfterMove

bool CCmpUnitMotion::m_FacePointAfterMove

◆ m_FailedMovements

u8 CCmpUnitMotion::m_FailedMovements = 0

◆ m_FollowKnownImperfectPathCountdown

u8 CCmpUnitMotion::m_FollowKnownImperfectPathCountdown = 0

◆ m_FormationController

entity_id_t CCmpUnitMotion::m_FormationController = INVALID_ENTITY

◆ m_InstantTurnAngle

fixed CCmpUnitMotion::m_InstantTurnAngle

◆ m_IsFormationController

bool CCmpUnitMotion::m_IsFormationController

◆ m_LastTurnSpeed

fixed CCmpUnitMotion::m_LastTurnSpeed

◆ m_LongPath

WaypointPath CCmpUnitMotion::m_LongPath

◆ m_MoveRequest

struct CCmpUnitMotion::MoveRequest CCmpUnitMotion::m_MoveRequest

◆ m_PassClass

pass_class_t CCmpUnitMotion::m_PassClass

◆ m_PassClassName

std::string CCmpUnitMotion::m_PassClassName

◆ m_Pushing

bool CCmpUnitMotion::m_Pushing = false

◆ m_RunMultiplier

fixed CCmpUnitMotion::m_RunMultiplier

◆ m_ShortPath

WaypointPath CCmpUnitMotion::m_ShortPath

◆ m_Speed

fixed CCmpUnitMotion::m_Speed

◆ m_SpeedMultiplier

fixed CCmpUnitMotion::m_SpeedMultiplier

◆ m_TemplateAcceleration

fixed CCmpUnitMotion::m_TemplateAcceleration

◆ m_TemplateRunMultiplier

fixed CCmpUnitMotion::m_TemplateRunMultiplier

◆ m_TemplateWalkSpeed

fixed CCmpUnitMotion::m_TemplateWalkSpeed

◆ m_TemplateWeight

fixed CCmpUnitMotion::m_TemplateWeight

◆ m_WalkSpeed

fixed CCmpUnitMotion::m_WalkSpeed

The documentation for this class was generated from the following file: