Pyrogenesis  trunk
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Private Attributes | Static Private Attributes | List of all members
CCmpSelectable Class Referencefinal
Inheritance diagram for CCmpSelectable:
Inheritance graph
[legend]
Collaboration diagram for CCmpSelectable:
Collaboration graph
[legend]

Public Types

enum  EShape { FOOTPRINT, CIRCLE, SQUARE }
 
- 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
 
 CCmpSelectable ()
 
 ~CCmpSelectable ()
 
void Init (const CParamNode &paramNode) override
 
void Deinit () override
 
void Serialize (ISerializer &serialize) override
 
void Deserialize (const CParamNode &paramNode, IDeserializer &deserialize) override
 
void HandleMessage (const CMessage &msg, bool global) override
 
void SetSelectionHighlight (const CColor &color, bool selected) override
 Sets the selection highlight state. More...
 
void SetSelectionHighlightAlpha (float alpha) override
 Sets the alpha of the selection highlight. More...
 
void SetVisibility (bool visible) override
 Enables or disables rendering of an entity's selectable. More...
 
bool IsEditorOnly () const override
 Returns true if the entity is only selectable in Atlas editor, e.g. More...
 
void RenderSubmit (SceneCollector &collector, const CFrustum &frustum, bool culling)
 
void UpdateTexturedLineOverlay (const SOverlayDescriptor *overlayDescriptor, SOverlayTexturedLine &overlay, float frameOffset)
 Draw a textured line overlay. More...
 
void UpdateDynamicOverlay (float frameOffset)
 Called from the interpolation handler; responsible for ensuring the dynamic overlay (provided we're using one) is up-to-date and ready to be submitted to the next rendering run. More...
 
void InvalidateStaticOverlay ()
 Explicitly invalidates the static overlay. More...
 
void UpdateMessageSubscriptions ()
 Subscribe/unsubscribe to MT_Interpolate, MT_RenderSubmit, depending on whether we will do any actual work when receiving them. More...
 
void UpdateColor () override
 Set the color of the current owner. 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 ICmpSelectable
static void SetOverrideVisibility (bool visible)
 Enables or disables rendering of all entities selectable. More...
 
- 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

EShape m_Shape
 
entity_pos_t m_Width
 
entity_pos_t m_Height
 

Private Attributes

SOverlayDescriptor m_OverlayDescriptor
 
SOverlayTexturedLinem_BuildingOverlay
 
SOverlayQuadm_UnitOverlay
 
CBoundingBoxAligned m_UnitOverlayBoundingBox
 
SOverlayLinem_DebugBoundingBoxOverlay
 
SOverlayLinem_DebugSelectionBoxOverlay
 
bool m_EnabledInterpolate
 
bool m_EnabledRenderSubmit
 
bool m_Visible
 
bool m_EditorOnly
 
bool m_AlwaysVisible
 
bool m_Selected
 Whether the parent entity is selected (caches GUI's selection state). More...
 
CColor m_Color
 Current selection overlay color. Alpha component is subject to fading. More...
 
bool m_Cached
 Whether the selectable's player color has been cached for rendering. More...
 
float m_AlphaMin
 Minimum value for current selection overlay alpha. More...
 
float m_FadeBaselineAlpha
 Baseline alpha value to start fading from. Constant during a single fade. More...
 
float m_FadeDeltaAlpha
 Delta between target and baseline alpha. Constant during a single fade. Can be positive or negative. More...
 
float m_FadeProgress
 Linear time progress of the fade, between 0 and m_FadeDuration. More...
 

Static Private Attributes

static const float FADE_DURATION = 0.3f
 Total duration of a single fade, in seconds. More...
 
static const char * TEXTUREBASEPATH = "art/textures/selection/"
 

Additional Inherited Members

- Static Public Attributes inherited from ICmpSelectable
static bool ms_EnableDebugOverlays = false
 
- Static Protected Attributes inherited from ICmpSelectable
static bool m_OverrideVisible = true
 

Member Enumeration Documentation

◆ EShape

Enumerator
FOOTPRINT 
CIRCLE 
SQUARE 

Constructor & Destructor Documentation

◆ CCmpSelectable()

CCmpSelectable::CCmpSelectable ( )
inline

◆ ~CCmpSelectable()

CCmpSelectable::~CCmpSelectable ( )
inline

Member Function Documentation

◆ Allocate()

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

◆ ClassInit()

static void CCmpSelectable::ClassInit ( CComponentManager componentManager)
inlinestatic

◆ Deallocate()

static void CCmpSelectable::Deallocate ( IComponent cmp)
inlinestatic

◆ Deinit()

void CCmpSelectable::Deinit ( )
inlineoverridevirtual

Implements IComponent.

◆ Deserialize()

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

Implements IComponent.

◆ GetComponentTypeId()

int CCmpSelectable::GetComponentTypeId ( ) const
inlineoverridevirtual

Implements IComponent.

◆ GetSchema()

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

◆ HandleMessage()

void CCmpSelectable::HandleMessage ( const CMessage msg,
bool  global 
)
overridevirtual

Reimplemented from IComponent.

◆ Init()

void CCmpSelectable::Init ( const CParamNode paramNode)
inlineoverridevirtual

Implements IComponent.

◆ InvalidateStaticOverlay()

void CCmpSelectable::InvalidateStaticOverlay ( )

Explicitly invalidates the static overlay.

◆ IsEditorOnly()

bool CCmpSelectable::IsEditorOnly ( ) const
inlineoverridevirtual

Returns true if the entity is only selectable in Atlas editor, e.g.

a decorative visual actor.

Implements ICmpSelectable.

◆ RenderSubmit()

void CCmpSelectable::RenderSubmit ( SceneCollector collector,
const CFrustum frustum,
bool  culling 
)

◆ Serialize()

void CCmpSelectable::Serialize ( ISerializer serialize)
inlineoverridevirtual

Implements IComponent.

◆ SetSelectionHighlight()

void CCmpSelectable::SetSelectionHighlight ( const CColor color,
bool  selected 
)
inlineoverridevirtual

Sets the selection highlight state.

The highlight is typically a circle/square overlay around the unit.

Parameters
colorcolor and alpha of the selection highlight. Set color.a = 0 to hide the highlight.
selectedwhether the entity is selected; affects desaturation for always visible highlights.

Implements ICmpSelectable.

◆ SetSelectionHighlightAlpha()

void CCmpSelectable::SetSelectionHighlightAlpha ( float  alpha)
inlineoverridevirtual

Sets the alpha of the selection highlight.

Set to 0 to hide the highlight.

Implements ICmpSelectable.

◆ SetVisibility()

void CCmpSelectable::SetVisibility ( bool  visible)
inlineoverridevirtual

Enables or disables rendering of an entity's selectable.

Parameters
visibleWhether the selectable should be visible.

Implements ICmpSelectable.

◆ UpdateColor()

void CCmpSelectable::UpdateColor ( )
overridevirtual

Set the color of the current owner.

Implements ICmpSelectable.

◆ UpdateDynamicOverlay()

void CCmpSelectable::UpdateDynamicOverlay ( float  frameOffset)

Called from the interpolation handler; responsible for ensuring the dynamic overlay (provided we're using one) is up-to-date and ready to be submitted to the next rendering run.

◆ UpdateMessageSubscriptions()

void CCmpSelectable::UpdateMessageSubscriptions ( )

Subscribe/unsubscribe to MT_Interpolate, MT_RenderSubmit, depending on whether we will do any actual work when receiving them.

(This is to avoid the performance cost of receiving messages in the typical case when the entity is not selected.)

Must be called after changing m_Visible, m_FadeDeltaAlpha, m_Color.a

◆ UpdateTexturedLineOverlay()

void CCmpSelectable::UpdateTexturedLineOverlay ( const SOverlayDescriptor overlayDescriptor,
SOverlayTexturedLine overlay,
float  frameOffset 
)

Draw a textured line overlay.

Member Data Documentation

◆ FADE_DURATION

const float CCmpSelectable::FADE_DURATION = 0.3f
staticprivate

Total duration of a single fade, in seconds.

Assumed constant for now; feel free to change this into a member variable if you need to adjust it per component.

◆ m_AlphaMin

float CCmpSelectable::m_AlphaMin
private

Minimum value for current selection overlay alpha.

◆ m_AlwaysVisible

bool CCmpSelectable::m_AlwaysVisible
private

◆ m_BuildingOverlay

SOverlayTexturedLine* CCmpSelectable::m_BuildingOverlay
private

◆ m_Cached

bool CCmpSelectable::m_Cached
private

Whether the selectable's player color has been cached for rendering.

◆ m_Color

CColor CCmpSelectable::m_Color
private

Current selection overlay color. Alpha component is subject to fading.

◆ m_DebugBoundingBoxOverlay

SOverlayLine* CCmpSelectable::m_DebugBoundingBoxOverlay
private

◆ m_DebugSelectionBoxOverlay

SOverlayLine* CCmpSelectable::m_DebugSelectionBoxOverlay
private

◆ m_EditorOnly

bool CCmpSelectable::m_EditorOnly
private

◆ m_EnabledInterpolate

bool CCmpSelectable::m_EnabledInterpolate
private

◆ m_EnabledRenderSubmit

bool CCmpSelectable::m_EnabledRenderSubmit
private

◆ m_FadeBaselineAlpha

float CCmpSelectable::m_FadeBaselineAlpha
private

Baseline alpha value to start fading from. Constant during a single fade.

◆ m_FadeDeltaAlpha

float CCmpSelectable::m_FadeDeltaAlpha
private

Delta between target and baseline alpha. Constant during a single fade. Can be positive or negative.

◆ m_FadeProgress

float CCmpSelectable::m_FadeProgress
private

Linear time progress of the fade, between 0 and m_FadeDuration.

◆ m_Height

entity_pos_t CCmpSelectable::m_Height

◆ m_OverlayDescriptor

SOverlayDescriptor CCmpSelectable::m_OverlayDescriptor
private

◆ m_Selected

bool CCmpSelectable::m_Selected
private

Whether the parent entity is selected (caches GUI's selection state).

◆ m_Shape

EShape CCmpSelectable::m_Shape

◆ m_UnitOverlay

SOverlayQuad* CCmpSelectable::m_UnitOverlay
private

◆ m_UnitOverlayBoundingBox

CBoundingBoxAligned CCmpSelectable::m_UnitOverlayBoundingBox
private

◆ m_Visible

bool CCmpSelectable::m_Visible
private

◆ m_Width

entity_pos_t CCmpSelectable::m_Width

◆ TEXTUREBASEPATH

const char * CCmpSelectable::TEXTUREBASEPATH = "art/textures/selection/"
staticprivate

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