Pyrogenesis  trunk
Classes | Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | List of all members
CCmpObstruction Class Referencefinal

Obstruction implementation. More...

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

Classes

struct  Shape
 

Public Types

typedef ICmpObstructionManager::tag_t tag_t
 
typedef ICmpObstructionManager::flags_t flags_t
 
- Public Types inherited from ICmpObstruction
enum  EFoundationCheck {
  FOUNDATION_CHECK_SUCCESS, FOUNDATION_CHECK_FAIL_ERROR, FOUNDATION_CHECK_FAIL_NO_OBSTRUCTION, FOUNDATION_CHECK_FAIL_OBSTRUCTS_FOUNDATION,
  FOUNDATION_CHECK_FAIL_TERRAIN_CLASS
}
 
enum  EObstructionType { STATIC, UNIT, CLUSTER }
 
- 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
 
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 SetActive (bool active) override
 
void SetDisableBlockMovementPathfinding (bool movementDisabled, bool pathfindingDisabled, int32_t shape) override
 
bool GetBlockMovementFlag (bool templateOnly) const override
 
EObstructionType GetObstructionType () const override
 
ICmpObstructionManager::tag_t GetObstruction () const override
 
bool GetPreviousObstructionSquare (ICmpObstructionManager::ObstructionSquare &out) const override
 Same as the method above, but returns an obstruction shape for the previous turn. More...
 
bool GetObstructionSquare (ICmpObstructionManager::ObstructionSquare &out) const override
 Gets the square corresponding to this obstruction shape. More...
 
virtual bool GetObstructionSquare (ICmpObstructionManager::ObstructionSquare &out, bool previousPosition) const
 
entity_pos_t GetSize () const override
 
CFixedVector2D GetStaticSize () const override
 
void SetUnitClearance (const entity_pos_t &clearance) override
 
bool IsControlPersistent () const override
 
bool CheckShorePlacement () const override
 Test whether the front of the obstruction square is in the water and the back is on the shore. More...
 
EFoundationCheck CheckFoundation (const std::string &className) const override
 Test whether this entity is colliding with any obstruction that are set to block the creation of foundations. More...
 
EFoundationCheck CheckFoundation (const std::string &className, bool onlyCenterPoint) const override
 
bool CheckDuplicateFoundation () const override
 Test whether this entity is colliding with any obstructions that share its control groups and block the creation of foundations. More...
 
std::vector< entity_id_tGetEntitiesByFlags (flags_t flags) const override
 Returns a list of entities that have an obstruction matching the given flag and intersect the current obstruction. More...
 
std::vector< entity_id_tGetEntitiesBlockingMovement () const override
 Returns a list of entities that are blocking movement. More...
 
std::vector< entity_id_tGetEntitiesBlockingConstruction () const override
 Returns a list of entities that are blocking construction of a foundation. More...
 
std::vector< entity_id_tGetEntitiesDeletedUponConstruction () const override
 Returns a list of entities that shall be deleted when a construction on this obstruction starts, for example sheep carcasses. More...
 
void SetMovingFlag (bool enabled) override
 
void SetControlGroup (entity_id_t group) override
 Change the control group that the entity belongs to. More...
 
void SetControlGroup2 (entity_id_t group2) override
 
entity_id_t GetControlGroup () const override
 See SetControlGroup. More...
 
entity_id_t GetControlGroup2 () const override
 
void UpdateControlGroups ()
 
void ResolveFoundationCollisions () const override
 Detects collisions between foundation-blocking entities and tries to fix them by setting control groups, if appropriate. More...
 
- Public Member Functions inherited from ICmpObstruction
virtual std::string CheckFoundation_wrapper (const std::string &className, bool onlyCenterPoint) const
 CheckFoundation wrapper for script calls, to return friendly strings instead of an EFoundationCheck. More...
 
- 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

EObstructionType m_Type
 
entity_pos_t m_Size0
 
entity_pos_t m_Size1
 
flags_t m_TemplateFlags
 
entity_pos_t m_Clearance
 
std::vector< Shapem_Shapes
 
bool m_Active
 Whether the obstruction is actively obstructing or just an inactive placeholder. More...
 
bool m_Moving
 Whether the entity associated with this obstruction is currently moving. More...
 
bool m_ControlPersist
 Whether an obstruction's control group should be kept consistent and used to set control groups for entities that collide with it. More...
 
bool m_IsDestroyed = false
 
entity_id_t m_ControlGroup
 Primary control group identifier. More...
 
entity_id_t m_ControlGroup2
 Optional secondary control group identifier. More...
 
tag_t m_Tag
 Identifier of this entity's obstruction shape, as registered in the obstruction manager. More...
 
std::vector< tag_tm_ClusterTags
 
flags_t m_Flags
 Set of flags affecting the behaviour of this entity's obstruction shape. More...
 

Protected Member Functions

void AddClusterShapes (entity_pos_t x, entity_pos_t z, entity_angle_t a)
 
void RemoveClusterShapes ()
 

Detailed Description

Obstruction implementation.

This keeps the ICmpPathfinder's model of the world updated when the entities move and die, with shapes derived from ICmpFootprint.

Member Typedef Documentation

◆ flags_t

◆ tag_t

Member Function Documentation

◆ AddClusterShapes()

void CCmpObstruction::AddClusterShapes ( entity_pos_t  x,
entity_pos_t  z,
entity_angle_t  a 
)
inlineprotected

◆ Allocate()

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

◆ CheckDuplicateFoundation()

bool CCmpObstruction::CheckDuplicateFoundation ( ) const
inlineoverridevirtual

Test whether this entity is colliding with any obstructions that share its control groups and block the creation of foundations.

Returns
true if foundation is valid (not obstructed)

Implements ICmpObstruction.

◆ CheckFoundation() [1/2]

EFoundationCheck CCmpObstruction::CheckFoundation ( const std::string &  className) const
inlineoverridevirtual

Test whether this entity is colliding with any obstruction that are set to block the creation of foundations.

Parameters
ignoredEntitiesList of entities to ignore during the test.
Returns
FOUNDATION_CHECK_SUCCESS if check passes, else an EFoundationCheck value describing the type of failure.

Implements ICmpObstruction.

◆ CheckFoundation() [2/2]

EFoundationCheck CCmpObstruction::CheckFoundation ( const std::string &  className,
bool  onlyCenterPoint 
) const
inlineoverridevirtual

Implements ICmpObstruction.

◆ CheckShorePlacement()

bool CCmpObstruction::CheckShorePlacement ( ) const
inlineoverridevirtual

Test whether the front of the obstruction square is in the water and the back is on the shore.

Implements ICmpObstruction.

◆ ClassInit()

static void CCmpObstruction::ClassInit ( CComponentManager componentManager)
inlinestatic

◆ Deallocate()

static void CCmpObstruction::Deallocate ( IComponent cmp)
inlinestatic

◆ Deinit()

void CCmpObstruction::Deinit ( )
inlineoverridevirtual

Implements IComponent.

◆ Deserialize()

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

Implements IComponent.

◆ GetBlockMovementFlag()

bool CCmpObstruction::GetBlockMovementFlag ( bool  templateOnly) const
inlineoverridevirtual
Parameters
templateOnly- whether to return the raw template value or the current value.

Implements ICmpObstruction.

◆ GetComponentTypeId()

int CCmpObstruction::GetComponentTypeId ( ) const
inlineoverridevirtual

Implements IComponent.

◆ GetControlGroup()

entity_id_t CCmpObstruction::GetControlGroup ( ) const
inlineoverridevirtual

See SetControlGroup.

Implements ICmpObstruction.

◆ GetControlGroup2()

entity_id_t CCmpObstruction::GetControlGroup2 ( ) const
inlineoverridevirtual

Implements ICmpObstruction.

◆ GetEntitiesBlockingConstruction()

std::vector<entity_id_t> CCmpObstruction::GetEntitiesBlockingConstruction ( ) const
inlineoverridevirtual

Returns a list of entities that are blocking construction of a foundation.

Returns
vector of blocking entities

Implements ICmpObstruction.

◆ GetEntitiesBlockingMovement()

std::vector<entity_id_t> CCmpObstruction::GetEntitiesBlockingMovement ( ) const
inlineoverridevirtual

Returns a list of entities that are blocking movement.

Returns
vector of blocking entities

Implements ICmpObstruction.

◆ GetEntitiesByFlags()

std::vector<entity_id_t> CCmpObstruction::GetEntitiesByFlags ( flags_t  flags) const
inlineoverridevirtual

Returns a list of entities that have an obstruction matching the given flag and intersect the current obstruction.

Returns
vector of blocking entities

Implements ICmpObstruction.

◆ GetEntitiesDeletedUponConstruction()

std::vector<entity_id_t> CCmpObstruction::GetEntitiesDeletedUponConstruction ( ) const
inlineoverridevirtual

Returns a list of entities that shall be deleted when a construction on this obstruction starts, for example sheep carcasses.

Implements ICmpObstruction.

◆ GetObstruction()

ICmpObstructionManager::tag_t CCmpObstruction::GetObstruction ( ) const
inlineoverridevirtual

Implements ICmpObstruction.

◆ GetObstructionSquare() [1/2]

bool CCmpObstruction::GetObstructionSquare ( ICmpObstructionManager::ObstructionSquare out) const
inlineoverridevirtual

Gets the square corresponding to this obstruction shape.

Returns
true and updates out on success; false on failure (e.g. object not in the world).

Implements ICmpObstruction.

◆ GetObstructionSquare() [2/2]

virtual bool CCmpObstruction::GetObstructionSquare ( ICmpObstructionManager::ObstructionSquare out,
bool  previousPosition 
) const
inlinevirtual

◆ GetObstructionType()

EObstructionType CCmpObstruction::GetObstructionType ( ) const
inlineoverridevirtual

Implements ICmpObstruction.

◆ GetPreviousObstructionSquare()

bool CCmpObstruction::GetPreviousObstructionSquare ( ICmpObstructionManager::ObstructionSquare out) const
inlineoverridevirtual

Same as the method above, but returns an obstruction shape for the previous turn.

Implements ICmpObstruction.

◆ GetSchema()

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

◆ GetSize()

entity_pos_t CCmpObstruction::GetSize ( ) const
inlineoverridevirtual
Returns
the size of the obstruction (either the clearance or a circumscribed circle).

Implements ICmpObstruction.

◆ GetStaticSize()

CFixedVector2D CCmpObstruction::GetStaticSize ( ) const
inlineoverridevirtual
Returns
the size of the static obstruction or (0,0) for a unit shape.

Implements ICmpObstruction.

◆ HandleMessage()

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

Reimplemented from IComponent.

◆ Init()

void CCmpObstruction::Init ( const CParamNode paramNode)
inlineoverridevirtual

Implements IComponent.

◆ IsControlPersistent()

bool CCmpObstruction::IsControlPersistent ( ) const
inlineoverridevirtual

Implements ICmpObstruction.

◆ RemoveClusterShapes()

void CCmpObstruction::RemoveClusterShapes ( )
inlineprotected

◆ ResolveFoundationCollisions()

void CCmpObstruction::ResolveFoundationCollisions ( ) const
inlineoverridevirtual

Detects collisions between foundation-blocking entities and tries to fix them by setting control groups, if appropriate.

Implements ICmpObstruction.

◆ Serialize()

void CCmpObstruction::Serialize ( ISerializer serialize)
inlineoverridevirtual

Implements IComponent.

◆ SerializeCommon()

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

◆ SetActive()

void CCmpObstruction::SetActive ( bool  active)
inlineoverridevirtual

Implements ICmpObstruction.

◆ SetControlGroup()

void CCmpObstruction::SetControlGroup ( entity_id_t  group)
inlineoverridevirtual

Change the control group that the entity belongs to.

Control groups are used to let units ignore collisions with other units from the same group. Default is the entity's own ID.

Implements ICmpObstruction.

◆ SetControlGroup2()

void CCmpObstruction::SetControlGroup2 ( entity_id_t  group2)
inlineoverridevirtual

Implements ICmpObstruction.

◆ SetDisableBlockMovementPathfinding()

void CCmpObstruction::SetDisableBlockMovementPathfinding ( bool  movementDisabled,
bool  pathfindingDisabled,
int32_t  shape 
)
inlineoverridevirtual

Implements ICmpObstruction.

◆ SetMovingFlag()

void CCmpObstruction::SetMovingFlag ( bool  enabled)
inlineoverridevirtual

Implements ICmpObstruction.

◆ SetUnitClearance()

void CCmpObstruction::SetUnitClearance ( const entity_pos_t clearance)
inlineoverridevirtual

Implements ICmpObstruction.

◆ UpdateControlGroups()

void CCmpObstruction::UpdateControlGroups ( )
inline

Member Data Documentation

◆ m_Active

bool CCmpObstruction::m_Active

Whether the obstruction is actively obstructing or just an inactive placeholder.

◆ m_Clearance

entity_pos_t CCmpObstruction::m_Clearance

◆ m_ClusterTags

std::vector<tag_t> CCmpObstruction::m_ClusterTags

◆ m_ControlGroup

entity_id_t CCmpObstruction::m_ControlGroup

Primary control group identifier.

Indicates to which control group this entity's shape belongs. Typically used in combination with obstruction test filters to have member shapes ignore each other during obstruction tests. Defaults to the entity's ID. Must never be set to INVALID_ENTITY.

◆ m_ControlGroup2

entity_id_t CCmpObstruction::m_ControlGroup2

Optional secondary control group identifier.

Similar to m_ControlGroup; if set to a valid value, then this field identifies an additional, secondary control group to which this entity's shape belongs. Set to INVALID_ENTITY to not assign any secondary group. Defaults to INVALID_ENTITY.

These are only necessary in case it is not sufficient for an entity to belong to only one control group. Otherwise, they can be ignored.

◆ m_ControlPersist

bool CCmpObstruction::m_ControlPersist

Whether an obstruction's control group should be kept consistent and used to set control groups for entities that collide with it.

◆ m_Flags

flags_t CCmpObstruction::m_Flags

Set of flags affecting the behaviour of this entity's obstruction shape.

◆ m_IsDestroyed

bool CCmpObstruction::m_IsDestroyed = false

◆ m_Moving

bool CCmpObstruction::m_Moving

Whether the entity associated with this obstruction is currently moving.

Only applicable for UNIT-type obstructions.

◆ m_Shapes

std::vector<Shape> CCmpObstruction::m_Shapes

◆ m_Size0

entity_pos_t CCmpObstruction::m_Size0

◆ m_Size1

entity_pos_t CCmpObstruction::m_Size1

◆ m_Tag

tag_t CCmpObstruction::m_Tag

Identifier of this entity's obstruction shape, as registered in the obstruction manager.

Contains structure, but should be treated as opaque here.

◆ m_TemplateFlags

flags_t CCmpObstruction::m_TemplateFlags

◆ m_Type

EObstructionType CCmpObstruction::m_Type

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