Shkyera Engine
Easy to use, game engine for Python
UIComponent.hpp
Go to the documentation of this file.
1 
7 #pragma once
8 
9 #include <unordered_map>
10 
11 #include "game/GameObject.hpp"
12 
13 namespace shkyera {
14 
21 class UIComponent {
22  public:
29  UIComponent(std::string name, std::shared_ptr<GameObject> object);
30 
36  virtual void draw() = 0;
37 
44  static void addComponentToObject(std::shared_ptr<GameObject> object, std::shared_ptr<UIComponent> component);
45 
52  static std::vector<std::shared_ptr<UIComponent>> getComponentsOfObject(std::shared_ptr<GameObject> object);
53 
54  protected:
55  uint64_t _uuid;
56  std::string _name;
57  std::shared_ptr<GameObject> _object;
58 
59  private:
60  // Mapping of game objects to their associated UI components.
61  static std::unordered_map<std::shared_ptr<GameObject>, std::vector<std::shared_ptr<UIComponent>>> _objectComponents;
62 };
63 
64 } // namespace shkyera
Contains the declaration of the GameObject class, representing a game object in the system.
A base class representing a user interface (UI) for a game object's component.
Definition: UIComponent.hpp:21
static std::unordered_map< std::shared_ptr< GameObject >, std::vector< std::shared_ptr< UIComponent > > > _objectComponents
Definition: UIComponent.hpp:61
static std::vector< std::shared_ptr< UIComponent > > getComponentsOfObject(std::shared_ptr< GameObject > object)
Static method to retrieve a list of UI components associated with a game object.
Definition: UIComponent.cpp:17
virtual void draw()=0
Abstract method to draw the UI component.
static void addComponentToObject(std::shared_ptr< GameObject > object, std::shared_ptr< UIComponent > component)
Static method to add a UI component to a game object.
Definition: UIComponent.cpp:10
uint64_t _uuid
A unique identifier for the UI component.
Definition: UIComponent.hpp:55
std::shared_ptr< GameObject > _object
The game object associated with the UI component.
Definition: UIComponent.hpp:57
std::string _name
The name of the UI component.
Definition: UIComponent.hpp:56
UIComponent(std::string name, std::shared_ptr< GameObject > object)
Constructor to create a UI component with a specified name and associated game object.
Definition: UIComponent.cpp:6
Definition: Entity.cpp:3