Helper base class for user-defined game logic components that hooks up to update events and forwards them to virtual functions similar to ScriptInstance class. More...

#include <Urho3D/Scene/LogicComponent.h>

Inheritance diagram for Urho3D::LogicComponent:
Collaboration diagram for Urho3D::LogicComponent:

Protected Member Functions

virtual void OnNodeSet (Node *node)
 Handle scene node being assigned at creation.
virtual void OnSceneSet (Scene *scene)
 Handle scene being assigned.
- Protected Member Functions inherited from Urho3D::Component
virtual void OnAttributeAnimationAdded ()
 Handle attribute animation added.
virtual void OnAttributeAnimationRemoved ()
 Handle attribute animation removed.
virtual void OnMarkedDirty (Node *node)
 Handle scene node transform dirtied.
virtual void OnNodeSetEnabled (Node *node)
 Handle scene node enabled status changing.
void SetID (unsigned id)
 Set ID. Called by Scene.
void SetNode (Node *node)
 Set scene node. Called by Node when creating the component.
void HandleAttributeAnimationUpdate (StringHash eventType, VariantMap &eventData)
 Handle scene attribute animation update event.
ComponentGetFixedUpdateSource ()
 Return a component from the scene root that sends out fixed update events (either PhysicsWorld or PhysicsWorld2D). Return null if neither exists.
- Protected Member Functions inherited from Urho3D::Animatable
virtual AnimatableFindAttributeAnimationTarget (const String &name, String &outName)
 Find target of an attribute animation from object hierarchy by name.
void SetObjectAttributeAnimation (const String &name, ValueAnimation *attributeAnimation, WrapMode wrapMode, float speed)
 Set object attribute animation internal.
void OnObjectAnimationAdded (ObjectAnimation *objectAnimation)
 Handle object animation added.
void OnObjectAnimationRemoved (ObjectAnimation *objectAnimation)
 Handle object animation removed.
void UpdateAttributeAnimations (float timeStep)
 Update attribute animations.
bool IsAnimatedNetworkAttribute (const AttributeInfo &attrInfo) const
 Is animated network attribute.
AttributeAnimationInfoGetAttributeAnimationInfo (const String &name) const
 Return attribute animation info.
void HandleAttributeAnimationAdded (StringHash eventType, VariantMap &eventData)
 Handle attribute animation added.
void HandleAttributeAnimationRemoved (StringHash eventType, VariantMap &eventData)
 Handle attribute animation removed.

Private Member Functions

 URHO3D_OBJECT (LogicComponent, Component)
 LogicComponent (Context *context)
virtual ~LogicComponent ()
virtual void OnSetEnabled ()
 Handle enabled/disabled state change. Changes update event subscription.
virtual void Start ()
 Called when the component is added to a scene node. Other components may not yet exist.
virtual void DelayedStart ()
 Called before the first update. At this point all other components of the node should exist. Will also be called if update events are not wanted; in that case the event is immediately unsubscribed afterward.
virtual void Stop ()
 Called when the component is detached from a scene node, usually on destruction. Note that you will no longer have access to the node and scene at that point.
virtual void Update (float timeStep)
 Called on scene update, variable timestep.
virtual void PostUpdate (float timeStep)
 Called on scene post-update, variable timestep.
virtual void FixedUpdate (float timeStep)
 Called on physics update, fixed timestep.
virtual void FixedPostUpdate (float timeStep)
 Called on physics post-update, fixed timestep.
void SetUpdateEventMask (unsigned char mask)
 Set what update events should be subscribed to. Use this for optimization: by default all are in use. Note that this is not an attribute and is not saved or network-serialized, therefore it should always be called eg. in the subclass constructor.
unsigned char GetUpdateEventMask () const
 Return what update events are subscribed to.
bool IsDelayedStartCalled () const
 Return whether the DelayedStart() function has been called.
void UpdateEventSubscription ()
 Subscribe/unsubscribe to update events based on current enabled state and update event mask.
void HandleSceneUpdate (StringHash eventType, VariantMap &eventData)
 Handle scene update event.
void HandleScenePostUpdate (StringHash eventType, VariantMap &eventData)
 Handle scene post-update event.

Private Attributes

unsigned char updateEventMask_
 Requested event subscription mask.
unsigned char currentEventMask_
 Current event subscription mask.
bool delayedStartCalled_
 Flag for delayed start.

Additional Inherited Members

- Public Member Functions inherited from Urho3D::Component
 Component (Context *context)
virtual ~Component ()
virtual bool Save (Serializer &dest) const
 Save as binary data. Return true if successful.
virtual bool SaveXML (XMLElement &dest) const
 Save as XML data. Return true if successful.
virtual bool SaveJSON (JSONValue &dest) const
 Save as JSON data. Return true if successful.
virtual void MarkNetworkUpdate ()
 Mark for attribute check on the next network update.
virtual void GetDependencyNodes (PODVector< Node * > &dest)
 Return the depended on nodes to order network updates.
virtual void DrawDebugGeometry (DebugRenderer *debug, bool depthTest)
 Visualize the component as debug geometry.
void SetEnabled (bool enable)
 Set enabled/disabled state.
void Remove ()
 Remove from the scene node. If no other shared pointer references exist, causes immediate deletion.
unsigned GetID () const
 Return ID.
NodeGetNode () const
 Return scene node.
SceneGetScene () const
 Return the scene the node belongs to.
bool IsEnabled () const
 Return whether is enabled.
bool IsEnabledEffective () const
 Return whether is effectively enabled (node is also enabled.)
ComponentGetComponent (StringHash type) const
 Return component in the same scene node by type. If there are several, returns the first.
void GetComponents (PODVector< Component * > &dest, StringHash type) const
 Return components in the same scene node by type.
template<class T >
T * GetComponent () const
 Template version of returning a component in the same scene node by type.
template<class T >
void GetComponents (PODVector< T * > &dest) const
 Template version of returning components in the same scene node by type.
void AddReplicationState (ComponentReplicationState *state)
 Add a replication state that is tracking this component.
void PrepareNetworkUpdate ()
 Prepare network update by comparing attributes and marking replication states dirty as necessary.
void CleanupConnection (Connection *connection)
 Clean up all references to a network connection that is about to be removed.
- Static Public Member Functions inherited from Urho3D::Animatable
static void RegisterObject (Context *context)
 Register object factory.
- Protected Attributes inherited from Urho3D::Component
 Scene node.
unsigned id_
 Unique ID within the scene.
bool networkUpdate_
 Network update queued flag.
bool enabled_
 Enabled flag.

Detailed Description

Helper base class for user-defined game logic components that hooks up to update events and forwards them to virtual functions similar to ScriptInstance class.

The documentation for this class was generated from the following files:
  • Source/Urho3D/Scene/LogicComponent.h
  • Source/Urho3D/Scene/LogicComponent.cpp