Pyrogenesis  trunk
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Private Member Functions | List of all members
CCmpPosition Class Referencefinal

Basic ICmpPosition implementation. More...

Inheritance diagram for CCmpPosition:
Inheritance graph
[legend]
Collaboration diagram for CCmpPosition:
Collaboration graph
[legend]

Public Types

enum  { UPRIGHT = 0, PITCH = 1, PITCH_ROLL = 2, ROLL = 3 }
 
- Public Types inherited from IComponent
using AllocFunc = IComponent *(*)(const ScriptInterface &scriptInterface, JS::HandleValue ctor)
 
using DeallocFunc = void(*)(IComponent *)
 

Public Member Functions

int GetComponentTypeId () const override
 
void Init (const CParamNode &paramNode) override
 
void Deinit () override
 
void Serialize (ISerializer &serialize) override
 
void Deserialize (const CParamNode &paramNode, IDeserializer &deserialize) override
 
void Deserialized ()
 
void UpdateTurretPosition () override
 Has to be called to update the simulation position of the turret. More...
 
std::set< entity_id_t > * GetTurrets () override
 Get the list of turrets to read or edit. More...
 
void SetTurretParent (entity_id_t id, const CFixedVector3D &offset) override
 Set this as a turret of an other entity. More...
 
entity_id_t GetTurretParent () const override
 Get the turret parent of this entity. More...
 
bool IsInWorld () const override
 Returns true if the entity currently exists at a defined position in the world. More...
 
void MoveOutOfWorld () override
 Causes IsInWorld to return false. More...
 
void MoveTo (entity_pos_t x, entity_pos_t z) override
 Move smoothly to the given location. More...
 
void MoveAndTurnTo (entity_pos_t x, entity_pos_t z, entity_angle_t ry) override
 Combines MoveTo and TurnTo to avoid an uncessary "AdvertisePositionChange". More...
 
void JumpTo (entity_pos_t x, entity_pos_t z) override
 Move immediately to the given location, with no interpolation. More...
 
void SetHeightOffset (entity_pos_t dy) override
 Set the vertical offset above the terrain/water surface. More...
 
entity_pos_t GetHeightOffset () const override
 Returns the current vertical offset above the terrain/water surface. More...
 
void SetHeightFixed (entity_pos_t y) override
 Set the vertical position above the map zero point. More...
 
entity_pos_t GetHeightFixed () const override
 Returns the current vertical offset above above the map zero point. More...
 
entity_pos_t GetHeightAtFixed (entity_pos_t x, entity_pos_t z) const override
 Returns the vertical offset above above the map zero point the unit would have at the given position. More...
 
bool IsHeightRelative () const override
 Returns true iff the entity will follow the terrain height (possibly with an offset) More...
 
void SetHeightRelative (bool relative) override
 When set to true, the entity will follow the terrain height (possibly with an offset) When set to false, it's height won't change automatically. More...
 
bool CanFloat () const override
 Returns whether the entity can float on water. More...
 
void SetFloating (bool flag) override
 Set the entity to float on water. More...
 
void SetActorFloating (bool flag) override
 Set the entity to float on water, in a non-network-synchronised visual-only way. More...
 
void SetConstructionProgress (fixed progress) override
 Set construction progress of the model, this affects the rendered position of the model. More...
 
CFixedVector3D GetPosition () const override
 Returns the current x,y,z position (no interpolation). More...
 
CFixedVector2D GetPosition2D () const override
 Returns the current x,z position (no interpolation). More...
 
CFixedVector3D GetPreviousPosition () const override
 Returns the previous turn's x,y,z position (no interpolation). More...
 
CFixedVector2D GetPreviousPosition2D () const override
 Returns the previous turn's x,z position (no interpolation). More...
 
fixed GetTurnRate () const override
 Returns the turn rate in radians per second. More...
 
void TurnTo (entity_angle_t y) override
 Rotate smoothly to the given angle around the upwards axis. More...
 
void SetYRotation (entity_angle_t y) override
 Rotate immediately to the given angle around the upwards axis. More...
 
void SetXZRotation (entity_angle_t x, entity_angle_t z) override
 Rotate immediately to the given angles around the X (pitch) and Z (roll) axes. More...
 
CFixedVector3D GetRotation () const override
 Returns the current rotation (relative to the upwards axis), as Euler angles with X=pitch, Y=yaw, Z=roll. More...
 
fixed GetDistanceTravelled () const override
 Returns the distance that the unit will be interpolated over, i.e. More...
 
float GetConstructionProgressOffset (const CVector3D &pos) const
 
void GetInterpolatedPosition2D (float frameOffset, float &x, float &z, float &rotY) const override
 Get the current interpolated 2D position and orientation, for rendering. More...
 
CMatrix3D GetInterpolatedTransform (float frameOffset) const override
 Get the current interpolated transform matrix, for rendering. More...
 
void GetInterpolatedPositions (CVector3D &pos0, CVector3D &pos1) const
 
void HandleMessage (const CMessage &msg, bool global) override
 
- Public Member Functions inherited from IComponent
virtual ~IComponent ()
 
CEntityHandle GetEntityHandle () const
 
void SetEntityHandle (CEntityHandle ent)
 
entity_id_t GetEntityId () const
 
CEntityHandle GetSystemEntity () const
 
const CSimContextGetSimContext () const
 
void SetSimContext (const CSimContext &context)
 
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
 

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

enum CCmpPosition:: { ... }  m_AnchorType
 
bool m_Floating
 
entity_pos_t m_FloatDepth
 
fixed m_RotYSpeed
 
bool m_InWorld
 
entity_pos_t m_X
 
entity_pos_t m_Z
 
entity_pos_t m_LastX
 
entity_pos_t m_LastZ
 
entity_pos_t m_PrevX
 
entity_pos_t m_PrevZ
 
entity_pos_t m_Y
 
entity_pos_t m_LastYDifference
 
bool m_RelativeToGround
 
fixed m_ConstructionProgress
 
entity_angle_t m_RotX
 
entity_angle_t m_RotY
 
entity_angle_t m_RotZ
 
player_id_t m_Territory
 
entity_id_t m_TurretParent
 
CFixedVector3D m_TurretPosition
 
std::set< entity_id_tm_Turrets
 
float m_InterpolatedRotX
 
float m_InterpolatedRotY
 
float m_InterpolatedRotZ
 
float m_LastInterpolatedRotX
 
float m_LastInterpolatedRotZ
 
bool m_ActorFloating
 
bool m_EnabledMessageInterpolate
 

Private Member Functions

void UpdateMessageSubscriptions ()
 
void AdvertisePositionChanges () const
 This must be called after changing anything that will affect the return value of GetPosition2D() or GetRotation().Y: More...
 
void AdvertiseInterpolatedPositionChanges () const
 This must be called after changing anything that will affect the return value of GetInterpolatedPositions(): More...
 
void UpdateXZRotation ()
 

Detailed Description

Basic ICmpPosition implementation.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
UPRIGHT 
PITCH 
PITCH_ROLL 
ROLL 

Member Function Documentation

◆ AdvertiseInterpolatedPositionChanges()

void CCmpPosition::AdvertiseInterpolatedPositionChanges ( ) const
inlineprivate

This must be called after changing anything that will affect the return value of GetInterpolatedPositions():

  • m_InWorld
  • m_X, m_Z
  • m_LastX, m_LastZ
  • m_Y, m_LastYDifference, m_RelativeToGround
  • If m_RelativeToGround, then the ground under this unit
  • If m_RelativeToGround && m_Float, then the water level

◆ AdvertisePositionChanges()

void CCmpPosition::AdvertisePositionChanges ( ) const
inlineprivate

This must be called after changing anything that will affect the return value of GetPosition2D() or GetRotation().Y:

  • m_InWorld
  • m_X, m_Z
  • m_RotY

◆ Allocate()

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

◆ CanFloat()

bool CCmpPosition::CanFloat ( ) const
inlineoverridevirtual

Returns whether the entity can float on water.

Implements ICmpPosition.

◆ ClassInit()

static void CCmpPosition::ClassInit ( CComponentManager componentManager)
inlinestatic

◆ Deallocate()

static void CCmpPosition::Deallocate ( IComponent cmp)
inlinestatic

◆ Deinit()

void CCmpPosition::Deinit ( )
inlineoverridevirtual

Implements IComponent.

◆ Deserialize()

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

Implements IComponent.

◆ Deserialized()

void CCmpPosition::Deserialized ( )
inline

◆ GetComponentTypeId()

int CCmpPosition::GetComponentTypeId ( ) const
inlineoverridevirtual

Implements IComponent.

◆ GetConstructionProgressOffset()

float CCmpPosition::GetConstructionProgressOffset ( const CVector3D pos) const
inline

◆ GetDistanceTravelled()

fixed CCmpPosition::GetDistanceTravelled ( ) const
inlineoverridevirtual

Returns the distance that the unit will be interpolated over, i.e.

the distance travelled since the start of the turn.

Implements ICmpPosition.

◆ GetHeightAtFixed()

entity_pos_t CCmpPosition::GetHeightAtFixed ( entity_pos_t  x,
entity_pos_t  z 
) const
inlineoverridevirtual

Returns the vertical offset above above the map zero point the unit would have at the given position.

Implements ICmpPosition.

◆ GetHeightFixed()

entity_pos_t CCmpPosition::GetHeightFixed ( ) const
inlineoverridevirtual

Returns the current vertical offset above above the map zero point.

Implements ICmpPosition.

◆ GetHeightOffset()

entity_pos_t CCmpPosition::GetHeightOffset ( ) const
inlineoverridevirtual

Returns the current vertical offset above the terrain/water surface.

Implements ICmpPosition.

◆ GetInterpolatedPosition2D()

void CCmpPosition::GetInterpolatedPosition2D ( float  frameOffset,
float &  x,
float &  z,
float &  rotY 
) const
inlineoverridevirtual

Get the current interpolated 2D position and orientation, for rendering.

Must not be called unless IsInWorld is true.

Implements ICmpPosition.

◆ GetInterpolatedPositions()

void CCmpPosition::GetInterpolatedPositions ( CVector3D pos0,
CVector3D pos1 
) const
inline

◆ GetInterpolatedTransform()

CMatrix3D CCmpPosition::GetInterpolatedTransform ( float  frameOffset) const
inlineoverridevirtual

Get the current interpolated transform matrix, for rendering.

Must not be called unless IsInWorld is true.

Implements ICmpPosition.

◆ GetPosition()

CFixedVector3D CCmpPosition::GetPosition ( ) const
inlineoverridevirtual

Returns the current x,y,z position (no interpolation).

Depends on the current terrain heightmap. Must not be called unless IsInWorld is true.

Implements ICmpPosition.

◆ GetPosition2D()

CFixedVector2D CCmpPosition::GetPosition2D ( ) const
inlineoverridevirtual

Returns the current x,z position (no interpolation).

Must not be called unless IsInWorld is true.

Implements ICmpPosition.

◆ GetPreviousPosition()

CFixedVector3D CCmpPosition::GetPreviousPosition ( ) const
inlineoverridevirtual

Returns the previous turn's x,y,z position (no interpolation).

Depends on the current terrain heightmap. Must not be called unless IsInWorld is true.

Implements ICmpPosition.

◆ GetPreviousPosition2D()

CFixedVector2D CCmpPosition::GetPreviousPosition2D ( ) const
inlineoverridevirtual

Returns the previous turn's x,z position (no interpolation).

Must not be called unless IsInWorld is true.

Implements ICmpPosition.

◆ GetRotation()

CFixedVector3D CCmpPosition::GetRotation ( ) const
inlineoverridevirtual

Returns the current rotation (relative to the upwards axis), as Euler angles with X=pitch, Y=yaw, Z=roll.

(TODO: is that the right way round?)

Implements ICmpPosition.

◆ GetSchema()

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

◆ GetTurnRate()

fixed CCmpPosition::GetTurnRate ( ) const
inlineoverridevirtual

Returns the turn rate in radians per second.

Implements ICmpPosition.

◆ GetTurretParent()

entity_id_t CCmpPosition::GetTurretParent ( ) const
inlineoverridevirtual

Get the turret parent of this entity.

Implements ICmpPosition.

◆ GetTurrets()

std::set<entity_id_t>* CCmpPosition::GetTurrets ( )
inlineoverridevirtual

Get the list of turrets to read or edit.

Implements ICmpPosition.

◆ HandleMessage()

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

Reimplemented from IComponent.

◆ Init()

void CCmpPosition::Init ( const CParamNode paramNode)
inlineoverridevirtual

Implements IComponent.

◆ IsHeightRelative()

bool CCmpPosition::IsHeightRelative ( ) const
inlineoverridevirtual

Returns true iff the entity will follow the terrain height (possibly with an offset)

Implements ICmpPosition.

◆ IsInWorld()

bool CCmpPosition::IsInWorld ( ) const
inlineoverridevirtual

Returns true if the entity currently exists at a defined position in the world.

Implements ICmpPosition.

◆ JumpTo()

void CCmpPosition::JumpTo ( entity_pos_t  x,
entity_pos_t  z 
)
inlineoverridevirtual

Move immediately to the given location, with no interpolation.

Implements ICmpPosition.

◆ MoveAndTurnTo()

void CCmpPosition::MoveAndTurnTo ( entity_pos_t  x,
entity_pos_t  z,
entity_angle_t  ry 
)
inlineoverridevirtual

Combines MoveTo and TurnTo to avoid an uncessary "AdvertisePositionChange".

Implements ICmpPosition.

◆ MoveOutOfWorld()

void CCmpPosition::MoveOutOfWorld ( )
inlineoverridevirtual

Causes IsInWorld to return false.

(Use MoveTo() or JumpTo() to move back into the world.)

Implements ICmpPosition.

◆ MoveTo()

void CCmpPosition::MoveTo ( entity_pos_t  x,
entity_pos_t  z 
)
inlineoverridevirtual

Move smoothly to the given location.

Implements ICmpPosition.

◆ Serialize()

void CCmpPosition::Serialize ( ISerializer serialize)
inlineoverridevirtual

Implements IComponent.

◆ SetActorFloating()

void CCmpPosition::SetActorFloating ( bool  flag)
inlineoverridevirtual

Set the entity to float on water, in a non-network-synchronised visual-only way.

(This is to support the 'floating' flag in actor XMLs.)

Implements ICmpPosition.

◆ SetConstructionProgress()

void CCmpPosition::SetConstructionProgress ( fixed  progress)
inlineoverridevirtual

Set construction progress of the model, this affects the rendered position of the model.

0.0 will be fully underground, 1.0 will be fully visible, 0.5 will be half underground.

Implements ICmpPosition.

◆ SetFloating()

void CCmpPosition::SetFloating ( bool  flag)
inlineoverridevirtual

Set the entity to float on water.

Implements ICmpPosition.

◆ SetHeightFixed()

void CCmpPosition::SetHeightFixed ( entity_pos_t  y)
inlineoverridevirtual

Set the vertical position above the map zero point.

Implements ICmpPosition.

◆ SetHeightOffset()

void CCmpPosition::SetHeightOffset ( entity_pos_t  dy)
inlineoverridevirtual

Set the vertical offset above the terrain/water surface.

Implements ICmpPosition.

◆ SetHeightRelative()

void CCmpPosition::SetHeightRelative ( bool  flag)
inlineoverridevirtual

When set to true, the entity will follow the terrain height (possibly with an offset) When set to false, it's height won't change automatically.

Implements ICmpPosition.

◆ SetTurretParent()

void CCmpPosition::SetTurretParent ( entity_id_t  parent,
const CFixedVector3D offset 
)
inlineoverridevirtual

Set this as a turret of an other entity.

Implements ICmpPosition.

◆ SetXZRotation()

void CCmpPosition::SetXZRotation ( entity_angle_t  x,
entity_angle_t  z 
)
inlineoverridevirtual

Rotate immediately to the given angles around the X (pitch) and Z (roll) axes.

Parameters
xradians around the X axis. (TODO: in which direction?)
zradians around the Z axis.
Note
if either x or z is non-zero, it will override terrain conformance mode

Implements ICmpPosition.

◆ SetYRotation()

void CCmpPosition::SetYRotation ( entity_angle_t  y)
inlineoverridevirtual

Rotate immediately to the given angle around the upwards axis.

Parameters
yclockwise radians from the +Z axis.

Implements ICmpPosition.

◆ TurnTo()

void CCmpPosition::TurnTo ( entity_angle_t  y)
inlineoverridevirtual

Rotate smoothly to the given angle around the upwards axis.

Parameters
yclockwise radians from the +Z axis.

Implements ICmpPosition.

◆ UpdateMessageSubscriptions()

void CCmpPosition::UpdateMessageSubscriptions ( )
inlineprivate

◆ UpdateTurretPosition()

void CCmpPosition::UpdateTurretPosition ( )
inlineoverridevirtual

Has to be called to update the simulation position of the turret.

Implements ICmpPosition.

◆ UpdateXZRotation()

void CCmpPosition::UpdateXZRotation ( )
inlineprivate

Member Data Documentation

◆ m_ActorFloating

bool CCmpPosition::m_ActorFloating

◆ m_AnchorType

enum { ... } CCmpPosition::m_AnchorType

◆ m_ConstructionProgress

fixed CCmpPosition::m_ConstructionProgress

◆ m_EnabledMessageInterpolate

bool CCmpPosition::m_EnabledMessageInterpolate

◆ m_FloatDepth

entity_pos_t CCmpPosition::m_FloatDepth

◆ m_Floating

bool CCmpPosition::m_Floating

◆ m_InterpolatedRotX

float CCmpPosition::m_InterpolatedRotX

◆ m_InterpolatedRotY

float CCmpPosition::m_InterpolatedRotY

◆ m_InterpolatedRotZ

float CCmpPosition::m_InterpolatedRotZ

◆ m_InWorld

bool CCmpPosition::m_InWorld

◆ m_LastInterpolatedRotX

float CCmpPosition::m_LastInterpolatedRotX

◆ m_LastInterpolatedRotZ

float CCmpPosition::m_LastInterpolatedRotZ

◆ m_LastX

entity_pos_t CCmpPosition::m_LastX

◆ m_LastYDifference

entity_pos_t CCmpPosition::m_LastYDifference

◆ m_LastZ

entity_pos_t CCmpPosition::m_LastZ

◆ m_PrevX

entity_pos_t CCmpPosition::m_PrevX

◆ m_PrevZ

entity_pos_t CCmpPosition::m_PrevZ

◆ m_RelativeToGround

bool CCmpPosition::m_RelativeToGround

◆ m_RotX

entity_angle_t CCmpPosition::m_RotX

◆ m_RotY

entity_angle_t CCmpPosition::m_RotY

◆ m_RotYSpeed

fixed CCmpPosition::m_RotYSpeed

◆ m_RotZ

entity_angle_t CCmpPosition::m_RotZ

◆ m_Territory

player_id_t CCmpPosition::m_Territory

◆ m_TurretParent

entity_id_t CCmpPosition::m_TurretParent

◆ m_TurretPosition

CFixedVector3D CCmpPosition::m_TurretPosition

◆ m_Turrets

std::set<entity_id_t> CCmpPosition::m_Turrets

◆ m_X

entity_pos_t CCmpPosition::m_X

◆ m_Y

entity_pos_t CCmpPosition::m_Y

◆ m_Z

entity_pos_t CCmpPosition::m_Z

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