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

Public Member Functions

virtual int GetComponentTypeId () const
 
 CCmpSelectable ()
 
 ~CCmpSelectable ()
 
virtual void Init (const CParamNode &paramNode)
 
virtual void Deinit ()
 
virtual void Serialize (ISerializer &serialize)
 
virtual void Deserialize (const CParamNode &paramNode, IDeserializer &deserialize)
 
virtual void HandleMessage (const CMessage &msg, bool global)
 
virtual void SetSelectionHighlight (const CColor &color, bool selected)
 Set the selection highlight state. More...
 
virtual void SetSelectionHighlightAlpha (float alpha)
 Set the alpha of the selection highlight. More...
 
virtual void SetVisibility (bool visible)
 Enables or disables rendering of an entity's selectable. More...
 
virtual bool IsEditorOnly () const
 Returns true if the entity is only selectable in Atlas editor, e.g. More...
 
void RenderSubmit (SceneCollector &collector)
 
void UpdateStaticOverlay ()
 Called from RenderSubmit if using a static outline; responsible for ensuring that the static overlay is up-to-date before it is rendered. 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...
 
- 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 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 u8 GetSerializationVersion ()
 

Private Attributes

SOverlayDescriptor m_OverlayDescriptor
 
SOverlayTexturedLinem_BuildingOverlay
 
SOverlayQuadm_UnitOverlay
 
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 double FADE_DURATION = 0.3
 Total duration of a single fade, in seconds. More...
 

Additional Inherited Members

- Public Types inherited from ICmpSelectable
enum  EOverlayType { DYNAMIC_QUAD, STATIC_OUTLINE }
 
- Static Public Attributes inherited from ICmpSelectable
static bool ms_EnableDebugOverlays = false
 
- Static Protected Attributes inherited from ICmpSelectable
static bool m_OverrideVisible = true
 

Constructor & Destructor Documentation

CCmpSelectable::CCmpSelectable ( )
inline
CCmpSelectable::~CCmpSelectable ( )
inline

Member Function Documentation

static IComponent* CCmpSelectable::Allocate ( ScriptInterface ,
JS::HandleValue   
)
inlinestatic
static void CCmpSelectable::ClassInit ( CComponentManager componentManager)
inlinestatic
static void CCmpSelectable::Deallocate ( IComponent cmp)
inlinestatic
virtual void CCmpSelectable::Deinit ( )
inlinevirtual

Implements IComponent.

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

Implements IComponent.

virtual int CCmpSelectable::GetComponentTypeId ( ) const
inlinevirtual

Implements IComponent.

static std::string CCmpSelectable::GetSchema ( )
inlinestatic
void CCmpSelectable::HandleMessage ( const CMessage msg,
bool  global 
)
virtual

Reimplemented from IComponent.

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

Implements IComponent.

void CCmpSelectable::InvalidateStaticOverlay ( )

Explicitly invalidates the static overlay.

virtual bool CCmpSelectable::IsEditorOnly ( ) const
inlinevirtual

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

a decorative visual actor.

Implements ICmpSelectable.

void CCmpSelectable::RenderSubmit ( SceneCollector collector)
virtual void CCmpSelectable::Serialize ( ISerializer serialize)
inlinevirtual

Implements IComponent.

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

Set 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.

virtual void CCmpSelectable::SetSelectionHighlightAlpha ( float  alpha)
inlinevirtual

Set the alpha of the selection highlight.

Set to 0 to hide the highlight.

Implements ICmpSelectable.

virtual void CCmpSelectable::SetVisibility ( bool  visible)
inlinevirtual

Enables or disables rendering of an entity's selectable.

Parameters
visibleWhether the selectable should be visible.

Implements ICmpSelectable.

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.

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

void CCmpSelectable::UpdateStaticOverlay ( )

Called from RenderSubmit if using a static outline; responsible for ensuring that the static overlay is up-to-date before it is rendered.

Has no effect unless the static overlay is explicitly marked as invalid first (see InvalidateStaticOverlay).

Member Data Documentation

const double CCmpSelectable::FADE_DURATION = 0.3
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.

float CCmpSelectable::m_AlphaMin
private

Minimum value for current selection overlay alpha.

bool CCmpSelectable::m_AlwaysVisible
private
SOverlayTexturedLine* CCmpSelectable::m_BuildingOverlay
private
bool CCmpSelectable::m_Cached
private

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

CColor CCmpSelectable::m_Color
private

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

SOverlayLine* CCmpSelectable::m_DebugBoundingBoxOverlay
private
SOverlayLine* CCmpSelectable::m_DebugSelectionBoxOverlay
private
bool CCmpSelectable::m_EditorOnly
private
bool CCmpSelectable::m_EnabledInterpolate
private
bool CCmpSelectable::m_EnabledRenderSubmit
private
float CCmpSelectable::m_FadeBaselineAlpha
private

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

float CCmpSelectable::m_FadeDeltaAlpha
private

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

float CCmpSelectable::m_FadeProgress
private

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

SOverlayDescriptor CCmpSelectable::m_OverlayDescriptor
private
bool CCmpSelectable::m_Selected
private

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

SOverlayQuad* CCmpSelectable::m_UnitOverlay
private
bool CCmpSelectable::m_Visible
private

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