29#include <condition_variable>
31#include <nlohmann/json.hpp>
39 using JSON = nlohmann::json;
53 inline static std::unordered_map<std::string, std::function<std::shared_ptr<Node>(
JSON)>>
nodeMap;
58 std::list<std::shared_ptr<Node>>
nodes;
120 void render(
float deltaTime)
const;
127 void update(
size_t threadNum,
float deltaTime);
168 template <
typename T>
void addNode(std::shared_ptr<T>& node) {
169 std::shared_ptr<Kale::Node> nodePtr = std::dynamic_pointer_cast<Kale::Node>(node);
184 template <
typename T>
void removeNode(std::shared_ptr<T>& node) {
185 std::shared_ptr<Kale::Node> nodePtr = std::dynamic_pointer_cast<Kale::Node>(node);
207 virtual void onUpdate(
size_t threadNum,
float deltaTime);
216 virtual void onPreUpdate(
size_t threadNum,
float deltaTime);
236 Scene(
const std::string& filename);
242 const std::list<std::shared_ptr<Node>>&
getNodes()
const;
void update(size_t threadNum, float deltaTime)
std::mutex nodePreUpdateMutex
void updateNodeStructures()
std::list< std::shared_ptr< Node > > nodes
virtual void onSceneChange()
std::condition_variable nodePreUpdateCondVar
std::queue< std::shared_ptr< Node > > nodesToRemove
void removeNode(std::shared_ptr< Node > &node)
const std::list< std::shared_ptr< Node > > & getNodes() const
void removeNode(std::shared_ptr< T > &node)
void addNode(std::shared_ptr< T > &node)
void render(float deltaTime) const
Rect getSceneBounds() const
std::mutex nodeQueueUpdateMutex
static void addNodeSaveStateConstructor(const std::string &key, std::function< std::shared_ptr< Node >(JSON)> constructor)
std::queue< std::shared_ptr< Node > > nodesToAdd
void onWindowResize(Vector2ui oldSize, Vector2ui newSize) override
virtual void onPreUpdate(size_t threadNum, float deltaTime)
static std::unordered_map< std::string, std::function< std::shared_ptr< Node >(JSON)> > nodeMap
virtual void onUpdate(size_t threadNum, float deltaTime)
std::vector< std::list< std::shared_ptr< Node > > > updateNodes
std::vector< std::pair< float, float > > threadedNodePerformanceTimes
Vector2f getViewport() const
std::vector< std::list< std::shared_ptr< Node > > > preUpdateNodes
const Camera & getCamera() const