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

Obstruction implementation. More...

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

Classes

struct  SerializeTag
 
struct  Shape
 

Public Types

enum  { STATIC, UNIT, CLUSTER }
 
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
}
 

Public Member Functions

virtual int GetComponentTypeId () const
 
virtual void Init (const CParamNode &paramNode)
 
virtual void Deinit ()
 
template<typename S >
void SerializeCommon (S &serialize)
 
virtual void Serialize (ISerializer &serialize)
 
virtual void Deserialize (const CParamNode &paramNode, IDeserializer &deserialize)
 
virtual void HandleMessage (const CMessage &msg, bool global)
 
virtual void SetActive (bool active)
 
virtual void SetDisableBlockMovementPathfinding (bool movementDisabled, bool pathfindingDisabled, int32_t shape)
 
virtual bool GetBlockMovementFlag () const
 
virtual ICmpObstructionManager::tag_t GetObstruction () const
 
virtual bool GetPreviousObstructionSquare (ICmpObstructionManager::ObstructionSquare &out) const
 Same as the method above, but returns an obstruction shape for the previous turn. More...
 
virtual bool GetObstructionSquare (ICmpObstructionManager::ObstructionSquare &out) const
 Gets the square corresponding to this obstruction shape. More...
 
virtual bool GetObstructionSquare (ICmpObstructionManager::ObstructionSquare &out, bool previousPosition) const
 
virtual entity_pos_t GetUnitRadius () const
 
virtual entity_pos_t GetSize () const
 
virtual void SetUnitClearance (const entity_pos_t &clearance)
 
virtual bool IsControlPersistent () const
 
virtual EFoundationCheck CheckFoundation (const std::string &className) const
 Test whether this entity is colliding with any obstruction that are set to block the creation of foundations. More...
 
virtual EFoundationCheck CheckFoundation (const std::string &className, bool onlyCenterPoint) const
 
virtual bool CheckDuplicateFoundation () const
 Test whether this entity is colliding with any obstructions that share its control groups and block the creation of foundations. More...
 
virtual std::vector< entity_id_tGetUnitCollisions () const
 Returns a list of units that are colliding with this entity,. More...
 
virtual void SetMovingFlag (bool enabled)
 
virtual void SetControlGroup (entity_id_t group)
 Change the control group that the entity belongs to. More...
 
virtual void SetControlGroup2 (entity_id_t group2)
 
virtual entity_id_t GetControlGroup () const
 See SetControlGroup. More...
 
virtual entity_id_t GetControlGroup2 () const
 
void UpdateControlGroups ()
 
void ResolveFoundationCollisions () const
 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 (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 (ScriptInterface &, JS::HandleValue)
 
static void Deallocate (IComponent *cmp)
 
static std::string GetSchema ()
 
- Static Public Member Functions inherited from IComponent
static std::string GetSchema ()
 
static u8 GetSerializationVersion ()
 

Public Attributes

enum CCmpObstruction:: { ... }  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...
 
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

Member Enumeration Documentation

anonymous enum
Enumerator
STATIC 
UNIT 
CLUSTER 

Member Function Documentation

void CCmpObstruction::AddClusterShapes ( entity_pos_t  x,
entity_pos_t  z,
entity_angle_t  a 
)
inlineprotected
static IComponent* CCmpObstruction::Allocate ( ScriptInterface ,
JS::HandleValue   
)
inlinestatic
virtual bool CCmpObstruction::CheckDuplicateFoundation ( ) const
inlinevirtual

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.

virtual EFoundationCheck CCmpObstruction::CheckFoundation ( const std::string &  className) const
inlinevirtual

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.

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

Implements ICmpObstruction.

static void CCmpObstruction::ClassInit ( CComponentManager componentManager)
inlinestatic
static void CCmpObstruction::Deallocate ( IComponent cmp)
inlinestatic
virtual void CCmpObstruction::Deinit ( )
inlinevirtual

Implements IComponent.

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

Implements IComponent.

virtual bool CCmpObstruction::GetBlockMovementFlag ( ) const
inlinevirtual

Implements ICmpObstruction.

virtual int CCmpObstruction::GetComponentTypeId ( ) const
inlinevirtual

Implements IComponent.

virtual entity_id_t CCmpObstruction::GetControlGroup ( ) const
inlinevirtual

See SetControlGroup.

Implements ICmpObstruction.

virtual entity_id_t CCmpObstruction::GetControlGroup2 ( ) const
inlinevirtual

Implements ICmpObstruction.

virtual ICmpObstructionManager::tag_t CCmpObstruction::GetObstruction ( ) const
inlinevirtual

Implements ICmpObstruction.

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

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.

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

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

Implements ICmpObstruction.

static std::string CCmpObstruction::GetSchema ( )
inlinestatic
virtual entity_pos_t CCmpObstruction::GetSize ( ) const
inlinevirtual

Implements ICmpObstruction.

virtual std::vector<entity_id_t> CCmpObstruction::GetUnitCollisions ( ) const
inlinevirtual

Returns a list of units that are colliding with this entity,.

Returns
vector of blocking units

Implements ICmpObstruction.

virtual entity_pos_t CCmpObstruction::GetUnitRadius ( ) const
inlinevirtual

Implements ICmpObstruction.

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

Reimplemented from IComponent.

virtual void CCmpObstruction::Init ( const CParamNode paramNode)
inlinevirtual

Implements IComponent.

virtual bool CCmpObstruction::IsControlPersistent ( ) const
inlinevirtual

Implements ICmpObstruction.

void CCmpObstruction::RemoveClusterShapes ( )
inlineprotected
void CCmpObstruction::ResolveFoundationCollisions ( ) const
inlinevirtual

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

Implements ICmpObstruction.

virtual void CCmpObstruction::Serialize ( ISerializer serialize)
inlinevirtual

Implements IComponent.

template<typename S >
void CCmpObstruction::SerializeCommon ( S &  serialize)
inline
virtual void CCmpObstruction::SetActive ( bool  active)
inlinevirtual

Implements ICmpObstruction.

virtual void CCmpObstruction::SetControlGroup ( entity_id_t  group)
inlinevirtual

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.

virtual void CCmpObstruction::SetControlGroup2 ( entity_id_t  group2)
inlinevirtual

Implements ICmpObstruction.

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

Implements ICmpObstruction.

virtual void CCmpObstruction::SetMovingFlag ( bool  enabled)
inlinevirtual

Implements ICmpObstruction.

virtual void CCmpObstruction::SetUnitClearance ( const entity_pos_t clearance)
inlinevirtual

Implements ICmpObstruction.

void CCmpObstruction::UpdateControlGroups ( )
inline

Member Data Documentation

bool CCmpObstruction::m_Active

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

entity_pos_t CCmpObstruction::m_Clearance
std::vector<tag_t> CCmpObstruction::m_ClusterTags
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.

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.

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.

flags_t CCmpObstruction::m_Flags

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

bool CCmpObstruction::m_Moving

Whether the entity associated with this obstruction is currently moving.

Only applicable for UNIT-type obstructions.

std::vector<Shape> CCmpObstruction::m_Shapes
entity_pos_t CCmpObstruction::m_Size0
entity_pos_t CCmpObstruction::m_Size1
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.

flags_t CCmpObstruction::m_TemplateFlags
enum { ... } CCmpObstruction::m_Type

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