Class ComponentBase
Defined in File ComponentBase.h
Inheritance Relationships
Derived Types
public csp::multiplayer::AnimatedModelSpaceComponent
(Class AnimatedModelSpaceComponent)public csp::multiplayer::AudioSpaceComponent
(Class AudioSpaceComponent)public csp::multiplayer::AvatarSpaceComponent
(Class AvatarSpaceComponent)public csp::multiplayer::ButtonSpaceComponent
(Class ButtonSpaceComponent)public csp::multiplayer::CinematicCameraSpaceComponent
(Class CinematicCameraSpaceComponent)public csp::multiplayer::CollisionSpaceComponent
(Class CollisionSpaceComponent)public csp::multiplayer::ConversationSpaceComponent
(Class ConversationSpaceComponent)public csp::multiplayer::CustomSpaceComponent
(Class CustomSpaceComponent)public csp::multiplayer::ECommerceSpaceComponent
(Class ECommerceSpaceComponent)public csp::multiplayer::ExternalLinkSpaceComponent
(Class ExternalLinkSpaceComponent)public csp::multiplayer::FiducialMarkerSpaceComponent
(Class FiducialMarkerSpaceComponent)public csp::multiplayer::FogSpaceComponent
(Class FogSpaceComponent)public csp::multiplayer::GaussianSplatSpaceComponent
(Class GaussianSplatSpaceComponent)public csp::multiplayer::HotspotSpaceComponent
(Class HotspotSpaceComponent)public csp::multiplayer::ImageSpaceComponent
(Class ImageSpaceComponent)public csp::multiplayer::LightSpaceComponent
(Class LightSpaceComponent)public csp::multiplayer::PortalSpaceComponent
(Class PortalSpaceComponent)public csp::multiplayer::ReflectionSpaceComponent
(Class ReflectionSpaceComponent)public csp::multiplayer::ScriptSpaceComponent
(Class ScriptSpaceComponent)public csp::multiplayer::SplineSpaceComponent
(Class SplineSpaceComponent)public csp::multiplayer::StaticModelSpaceComponent
(Class StaticModelSpaceComponent)public csp::multiplayer::TextSpaceComponent
(Class TextSpaceComponent)public csp::multiplayer::VideoPlayerSpaceComponent
(Class VideoPlayerSpaceComponent)
Class Documentation
-
class ComponentBase
The base class for all components, provides mechanisms for dirtying properties and subscribing to events on property changes.
Subclassed by csp::multiplayer::AnimatedModelSpaceComponent, csp::multiplayer::AudioSpaceComponent, csp::multiplayer::AvatarSpaceComponent, csp::multiplayer::ButtonSpaceComponent, csp::multiplayer::CinematicCameraSpaceComponent, csp::multiplayer::CollisionSpaceComponent, csp::multiplayer::ConversationSpaceComponent, csp::multiplayer::CustomSpaceComponent, csp::multiplayer::ECommerceSpaceComponent, csp::multiplayer::ExternalLinkSpaceComponent, csp::multiplayer::FiducialMarkerSpaceComponent, csp::multiplayer::FogSpaceComponent, csp::multiplayer::GaussianSplatSpaceComponent, csp::multiplayer::HotspotSpaceComponent, csp::multiplayer::ImageSpaceComponent, csp::multiplayer::LightSpaceComponent, csp::multiplayer::PortalSpaceComponent, csp::multiplayer::ReflectionSpaceComponent, csp::multiplayer::ScriptSpaceComponent, csp::multiplayer::SplineSpaceComponent, csp::multiplayer::StaticModelSpaceComponent, csp::multiplayer::TextSpaceComponent, csp::multiplayer::VideoPlayerSpaceComponent
Public Types
-
typedef std::function<void(ComponentBase*, const csp::common::String&, const csp::common::String&)> EntityActionHandler
A callback that can be registered to be called when an action of a given name is invoked.
Contains a pointer to the component, the action name as a string and parameters as a string.
Public Functions
-
virtual ~ComponentBase()
Virtual destructor for the component.
-
uint16_t GetId()
Get the ID for this component.
This is set when calling SpaceEntity::AddComponent and is autogenerated with the intention of being unique within the context of the entity it is attached to.
- Returns
The ID.
-
ComponentType GetComponentType()
Get the ComponentType of the component.
- Returns
The type of the component as an enum.
-
const csp::common::Map<uint32_t, ReplicatedValue> *GetProperties()
Get a map of the replicated values defined for this component.
The index of the map represents a unique index for the property, intended to be defined in the inherited component as an enum of available properties keys.
- Returns
A map of the replicated values, keyed by their unique key.
-
SpaceEntity *GetParent()
Get the parent SpaceEntity for this component.
Components can only attach to one parent.
- Returns
A pointer to the parent SpaceEntity.
-
void SubscribeToPropertyChange(uint32_t PropertyKey, csp::common::String Message)
Part of the scripting interface, allows you to subscribe to a property change and assign a script message to execute when activated.
- Parameters
PropertyKey – uint32_t : The key of the property to subscribe to.
Message – csp::common::String : The message to be sent to the script.
-
void RegisterActionHandler(const csp::common::String &InAction, EntityActionHandler ActionHandler)
Register an action handler callback to be called when the given action is invoked.
- Parameters
InAction – csp::common::String : The identifying name of the action.
ActionHandler – EntityActionHandler : Callback to be called when the action is invoked, contains a pointer to this component, the name of the action and a string of parameters for the action.
-
void UnregisterActionHandler(const csp::common::String &InAction)
Removes the action handler callback for the given action.
- Parameters
InAction – csp::common::String : The identifying name of the action.
-
void InvokeAction(const csp::common::String &InAction, const csp::common::String &InActionParams)
Calls the registered action handler callback for the given action and passes the given parameters.
- Parameters
InAction – csp::common::String : The identifying name of the action.
InActionParams – csp::common::String : Parameters for the action that will be passed to the action handler callback.
Protected Functions
-
ComponentBase()
-
ComponentBase(ComponentType Type, SpaceEntity *Parent)
-
const ReplicatedValue &GetProperty(uint32_t Key) const
-
const bool GetBooleanProperty(uint32_t Key) const
-
const int64_t GetIntegerProperty(uint32_t Key) const
-
const float GetFloatProperty(uint32_t Key) const
-
const csp::common::Map<csp::common::String, ReplicatedValue> &GetStringMapProperty(uint32_t Key) const
-
void SetProperty(uint32_t Key, const ReplicatedValue &Value)
-
void RemoveProperty(uint32_t Key)
-
void SetProperties(const csp::common::Map<uint32_t, ReplicatedValue> &Value)
-
virtual void SetPropertyFromPatch(uint32_t Key, const ReplicatedValue &Value)
-
virtual void OnRemove()
-
virtual void OnLocalDelete()
-
void SetScriptInterface(ComponentScriptInterface *ScriptInterface)
-
ComponentScriptInterface *GetScriptInterface()
Protected Attributes
-
SpaceEntity *Parent
-
uint16_t Id
-
ComponentType Type
-
csp::common::Map<uint32_t, ReplicatedValue> Properties
-
csp::common::Map<uint32_t, ReplicatedValue> DirtyProperties
-
ComponentScriptInterface *ScriptInterface
-
csp::common::Map<csp::common::String, EntityActionHandler> ActionMap
-
typedef std::function<void(ComponentBase*, const csp::common::String&, const csp::common::String&)> EntityActionHandler