Pyrogenesis HEAD
Pyrogenesis, a RTS Engine
CCmpDecay Class Referencefinal

Fairly basic decay implementation, for units and buildings etc. More...

Inheritance diagram for CCmpDecay:
Collaboration diagram for CCmpDecay:

Public Member Functions

int GetComponentTypeId () const override
 
void Init (const CParamNode &paramNode) override
 
void Deinit () override
 
void Serialize (ISerializer &) override
 
void Deserialize (const CParamNode &paramNode, IDeserializer &) override
 
void HandleMessage (const CMessage &msg, bool) override
 
- 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 CSimContext & GetSimContext () const
 
void SetSimContext (const CSimContext &context)
 
virtual void Serialize (ISerializer &serialize)=0
 
virtual void Deserialize (const CParamNode &paramNode, IDeserializer &deserialize)=0
 
virtual JS::HandleValue GetJSInstance () const =0
 @Returns JS::NullHandleValue if a scripted wrapper of this IComponent is not supported, the wrapper otherwise. More...
 
virtual int GetComponentTypeId () const =0
 

Static Public Member Functions

static void ClassInit (CComponentManager &)
 
static IComponent * Allocate (const Script::Interface &, 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, ClassInitFunc classInit)
 
static std::uint8_t GetSerializationVersion ()
 

Public Attributes

bool m_Active
 
bool m_ShipSink
 
bool m_Stochastic
 
std::optional< std::minstd_rand > m_Generator
 
std::negative_binomial_distribution m_Distribution { 6, 0.032 }
 
std::geometric_distribution ::result_type m_NextSink
 
float m_SinkProb
 
float m_DelayTime
 
float m_SinkRate
 
float m_SinkAccel
 
entity_pos_t m_InitialXRotation
 
entity_pos_t m_InitialZRotation
 
float m_SinkingAngleX
 
float m_SinkingAngleZ
 
float m_CurrentTime
 
float m_TotalSinkDepth
 

Additional Inherited Members

- Public Types inherited from IComponent
using AllocFunc = IComponent *(*)(const Script::Interface &scriptInterface, JS::HandleValue ctor)
 
using DeallocFunc = void(*)(IComponent *)
 
using ClassInitFunc = void(*)(CComponentManager &componentManager)
 

Detailed Description

Fairly basic decay implementation, for units and buildings etc.

The decaying entity remains stationary for some time period, then falls downwards with some initial speed and some acceleration, until it has fully sunk. The sinking depth is determined from the actor's bounding box and the terrain.

This currently doesn't work with entities whose ICmpPosition has an initial Y offset.

This isn't very efficient (we'll store data and iterate every frame for every entity, not just for corpse entities) - it could be designed more optimally if that's a real problem.

Eventually we might want to adjust the decay rate based on user configuration (low-spec machines could have fewer corpses), number of corpses, etc.

Must not be used on network-synchronised entities, unless <Inactive> is present.

Member Function Documentation

◆ Allocate()

static IComponent * CCmpDecay::Allocate ( const Script::Interface &  ,
JS::HandleValue   
)
inlinestatic

◆ ClassInit()

static void CCmpDecay::ClassInit ( CComponentManager &  )
inlinestatic

◆ Deallocate()

static void CCmpDecay::Deallocate ( IComponent *  cmp)
inlinestatic

◆ Deinit()

void CCmpDecay::Deinit ( )
inlineoverridevirtual

Implements IComponent.

◆ Deserialize()

void CCmpDecay::Deserialize ( const CParamNode &  paramNode,
IDeserializer &   
)
inlineoverridevirtual

Implements IComponent.

◆ GetComponentTypeId()

int CCmpDecay::GetComponentTypeId ( ) const
inlineoverridevirtual

Implements IComponent.

◆ GetSchema()

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

◆ HandleMessage()

void CCmpDecay::HandleMessage ( const CMessage &  msg,
bool   
)
inlineoverridevirtual

Reimplemented from IComponent.

◆ Init()

void CCmpDecay::Init ( const CParamNode &  paramNode)
inlineoverridevirtual

Implements IComponent.

◆ Serialize()

void CCmpDecay::Serialize ( ISerializer &  )
inlineoverridevirtual

Implements IComponent.

Member Data Documentation

◆ m_Active

bool CCmpDecay::m_Active

◆ m_CurrentTime

float CCmpDecay::m_CurrentTime

◆ m_DelayTime

float CCmpDecay::m_DelayTime

◆ m_Distribution

std::negative_binomial_distribution CCmpDecay::m_Distribution { 6, 0.032 }

◆ m_Generator

std::optional<std::minstd_rand> CCmpDecay::m_Generator

◆ m_InitialXRotation

entity_pos_t CCmpDecay::m_InitialXRotation

◆ m_InitialZRotation

entity_pos_t CCmpDecay::m_InitialZRotation

◆ m_NextSink

std::geometric_distribution ::result_type CCmpDecay::m_NextSink

◆ m_ShipSink

bool CCmpDecay::m_ShipSink

◆ m_SinkAccel

float CCmpDecay::m_SinkAccel

◆ m_SinkingAngleX

float CCmpDecay::m_SinkingAngleX

◆ m_SinkingAngleZ

float CCmpDecay::m_SinkingAngleZ

◆ m_SinkProb

float CCmpDecay::m_SinkProb

◆ m_SinkRate

float CCmpDecay::m_SinkRate

◆ m_Stochastic

bool CCmpDecay::m_Stochastic

◆ m_TotalSinkDepth

float CCmpDecay::m_TotalSinkDepth

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