CRM64Pro GDK v0.20.0
A free cross-platform game development kit built on top of SDL 3.0
Loading...
Searching...
No Matches
CRM64Pro::SceneObject

Base class for all Scene game objects. More...

Public Types

using TriggerEventCallback = function<void(const SceneTriggerEvent& rEvent)>
 Scene object trigger event callback type.

Public Member Functions

 SceneObject ()
 Default constructor.
virtual ~SceneObject ()
 Virtual destructor for proper cleanup of derived classes.
virtual void initialize ()
 Called after Scene configuration populates all fields.
virtual void update (Scene *pScene, SceneLayerContext &rContext)
 Called each frame when layer has UPDATE enabled.
virtual void render (Scene *pScene, SceneLayerContext &rContext)
 Called each frame when layer has RENDER enabled and object is visible.
void setPosition (float fNewX, float fNewY, bool bTeleport=false)
 Set object position and update spatial grid.
bool setSize (float fNewWidth, float fNewHeight)
 Set object size and update cached bounds.
bool setRotationDeg (float fNewRotationDeg)
 Set object rotation and update cached bounds.
bool setShape (const SceneShapeData &rNewShape)
 Set object shape and update the spatial grid and particle-collision geometry.
bool setType (const string &sNewType)
 Set the object type identifier.
bool setName (const string &sNewName)
 Set the object name.
bool setProperty (const string &sKey, const string &sValue)
 Set a custom property.
bool removeProperty (const string &sKey)
 Remove a custom property.
void setVisible (bool bNewVisible)
 Set object visibility.
bool setPortalClosed (bool bClosed)
 Set whether a portal is closed.
void recalculateBounds ()
 Recalculate the cached AABB from the current object geometry.
bool containsPoint (float fX, float fY) const
 Test if a point is inside this object's shape.
bool overlapsObject (const SceneObject *pOther, SDL_FRect *pOverlap=nullptr) const
 Test if this object's AABB overlaps another object's AABB.
float getX () const
 Get the object X position.
float getY () const
 Get the object Y position.
float getWidth () const
 Get the object width.
float getHeight () const
 Get the object height.
float getRotationDeg () const
 Get the object rotation.
bool isVisible () const
 Check if the object is visible.
bool isPortalClosed () const
 Check whether this portal is closed.
Sint32 getID () const
 Get the object ID.
const string & getType () const
 Get the type identifier.
const string & getName () const
 Get the object name.
ParticleEmittergetParticleEmitter ()
 Get this scene object's particle emitter.
bool hasProperty (const string &sKey) const
 Check if a custom property exists.
string getPropertyString (const string &sKey, const string &sDefault="") const
 Get a string custom property.
Sint32 getPropertyInt (const string &sKey, Sint32 iDefault=0) const
 Get an integer custom property.
bool getPropertyBool (const string &sKey, bool bDefault=false) const
 Get a boolean custom property.
float getPropertyFloat (const string &sKey, float fDefault=0.0f) const
 Get a floating-point custom property.
const SceneShapeDatagetShape () const
 Get the object shape data.
bool isPendingDestruction () const
 Check if the object is pending destruction.
bool addTrigger (const SceneObjectTrigger &rTrigger)
 Add a trigger zone to this object.
bool updateTrigger (const SceneObjectTrigger &rTrigger)
 Update an existing trigger by name.
bool removeTrigger (const string &sName)
 Remove a trigger by name.
void clearTriggers ()
 Remove all triggers.
bool setTriggerEnabled (const string &sName, bool bEnabled)
 Enable or disable a trigger.
bool getTrigger (const string &sName, SceneObjectTrigger *pOut) const
 Get a trigger definition by name.
Sint32 getTriggerCount () const
 Get number of triggers assigned to this object.
void setOnTriggerEvent (TriggerEventCallback fnCallback)
 Set trigger event callback.

Detailed Description

Base class for all Scene game objects.

Member Typedef Documentation

◆ TriggerEventCallback

using CRM64Pro::SceneObject::TriggerEventCallback = function<void(const SceneTriggerEvent& rEvent)>

Scene object trigger event callback type.

Parameters
rEventRead-only trigger event payload valid for the duration of the callback.