6 #include <unordered_map>
Core class representing an entity in the game world.
Singleton class that manages scenes and their transitions.
Represents a node in the scene graph, encapsulating a game object and its hierarchy.
bool m_isBackground
Flag to indicate whether this node is part of the background.
void addChild(GameObject *child, bool isBackground=false)
Adds a child game object to this node.
void setIsBackground(bool isBackground)
Sets whether this node is part of the background.
~SceneNode()
Destructor, ensures proper cleanup of node resources. This destructor is private to ensure that Scene...
bool isBackground()
Checks if this node is part of the background.
GameObject * m_gameObject
Pointer to the GameObject this node represents.
SceneNode * m_parent
Pointer to the parent node in the scene graph.
void setDestroy(bool destroy)
Sets the destruction state of this node.
bool m_destroy
Flag to indicate whether this node is scheduled for destruction.
bool readyToDestroy()
Checks if this node is marked for destruction.
std::vector< SceneNode * > m_children
List of child nodes.
SceneNode(GameObject *gameObject)
Constructor that assigns a game object to this node.
const std::vector< SceneNode * > getChildren()
Returns the children of this node.
SceneNode * getParent()
Gets the parent of this node.
GameObject * getGameObject()
Gets the GameObject associated with this node.
Manages a tree structure of SceneNodes, facilitating scene graph operations.
std::unordered_map< std::string, std::vector< GameObject * > > m_cachedGameObjectsInFrame
Cache for faster lookup of GameObjects by tag within a frame.
std::unordered_map< std::string, GameObject * > m_cachedGameObjects
Cache for faster lookup of GameObjects by ID.
GameObject * findGameObjectById(std::string id)
Finds a GameObject by its ID.
SceneNode * m_root
Root node of the scene tree.
SceneTree()
Constructor for creating a root node of the scene tree.
void addChild(GameObject *child, bool isBackground=false)
Adds a child GameObject to the scene tree.
void resetCachedGameObjectsInFrame()
Resets the cached game objects for a new frame, clearing the current frame's cache.
~SceneTree()
Destructor, cleans up the tree resources.
void traverseTree(std::function< void(SceneNode *)> callback)
Traverses the entire tree, executing a callback on each node.
std::vector< GameObject * > & findCachedGameObjectsInFrame(std::string tag)
Retrieves the game objects cached by tag.
int gameStatus()
Retrieves the current game status.
std::vector< GameObject * > findGameObjectsByTag(std::string tag)
Finds GameObjects by a tag.