Fling Engine  0.00.1
Fling Engine is a game engine written in Vulkan
World.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "NonCopyable.hpp"
4 #include "Level.h"
5 #include "Game.h"
6 #include "FlingConfig.h"
7 
8 #include <string>
9 #include <fstream>
10 
11 #include <entt/entity/registry.hpp>
12 #include "Serilization.h"
13 
14 namespace Fling
15 {
21  class World : public NonCopyable
22  {
23  public:
24 
25  explicit World(entt::registry& t_Reg, Fling::Game* t_Game);
26 
31  void Init();
32 
36  void Shutdown();
37 
43  void Update(float t_DeltaTime);
44 
51  FORCEINLINE bool ShouldQuit() const { assert(m_Game); return m_ShouldQuit || m_Game->WantsToQuit(); }
52 
62  template<class ...ARGS>
63  bool OutputLevelFile(const std::string& t_LevelToLoad);
64 
74  template<class ...ARGS>
75  bool LoadLevelFile(const std::string& t_LevelToLoad);
76 
77  FORCEINLINE entt::registry& GetRegistry() const { return m_Registry; }
78 
79  private:
80 
82  entt::registry& m_Registry;
83 
85  Fling::Game* m_Game = nullptr;
86 
89  };
90 
91 } // namespace Fling
92 
93 #include "World.inl"
FORCEINLINE entt::registry & GetRegistry() const
Definition: World.h:77
The game class is mean to be overridden on a per-game instance.
Definition: Game.h:16
bool LoadLevelFile(const std::string &t_LevelToLoad)
Reset the current registry and load in new entities/components from a JSON file This will read in som...
Definition: World.inl:41
FORCEINLINE bool WantsToQuit() const
If true then this game wants to texit the application entirely.
Definition: Game.h:49
void Update(float t_DeltaTime)
Tick all active levels in the world.
Definition: World.cpp:30
UINT8 m_ShouldQuit
Flag if the world should quit or not!
Definition: World.h:88
The world holds all active levels in the game.
Definition: World.h:21
FORCEINLINE bool ShouldQuit() const
Check if the world wants to exit the program.
Definition: World.h:51
void Init()
Initializes the world.
Definition: World.cpp:11
World(entt::registry &t_Reg, Fling::Game *t_Game)
Definition: World.cpp:6
uint8_t UINT8
Definition: FlingTypes.h:11
Class that removes the copy operator and constructor.
Definition: NonCopyable.hpp:10
Fling::Game * m_Game
The game will allow users to specify their own update/read/write functions.
Definition: World.h:85
void Shutdown()
Called just before destruction.
Definition: World.cpp:22
Definition: Engine.h:29
entt::registry & m_Registry
The registry and represents all active entities in this world.
Definition: World.h:82
bool OutputLevelFile(const std::string &t_LevelToLoad)
Based on all current entities in the registry serialize that data to a JSON file This will write out ...
Definition: World.inl:17