2
3
4
5
11#include "World/WorldFunctions/WorldFunctions.h"
13#include "World/Components/CameraComponent.h"
14#include "World/Components/TransformComponent.h"
15#include "World/Components/MeshComponent.h"
16#include "World/Components/TagComponent.h"
17#include "World/Components/UUIDComponent.h"
18#include "World/Components/DirectionalLightComponent.h"
19#include "World/Components/NativeScriptComponent.h"
20#include "World/Components/PointLightComponent.h"
21#include "World/Components/SkyBoxComponent.h"
22#include "World/Components/SpriteComponent.h"
23#include "World/Components/EntityComponent.h"
24#include "World/Components/LandscapeComponent.h"
25#include "World/Components/ParticleComponent.h"
26#include "World/Components/WidgetComponent.h"
31
32
36
37
38
39
58
59
63
64
68
69
73
74
75
79
80
84
85
86
90
91
92
93
97
98
99
103
104
105
109
110
111
112
116
117
118
122
123
124
128
129
133
134
135
139
140
141
142
143 template<
typename T,
typename F>
147
148
149
150
151
152 template<
typename T,
typename F>
153 void ViewComponent(
const std::vector<uint32_t>& ranges, F&& fn);
156
157
158
159
160
161
162
163 template<
typename T,
typename F>
164 void ViewComponent(
const std::vector<uint32_t>& ranges, uint32_t floor, uint32_t ceil, F&& fn);
167
168
169
174
175
176
177
178
179
180
181 template<
typename T,
typename... Args>
185
186
187
188
189
194
195
196
197
202
203
204
205
206
211
212
213
217
218
219
223
224
225
233
234
235
236
243
244
248
249
253
254
255
256
260
261
265
266
270
271
275 template <
typename T,
typename F>
280 std::shared_lock<std::shared_mutex> lock(m_Mutex);
282 auto view = m_Registry.view<T>();
286 auto& comp = m_Registry.get<T>(e);
288 if(fn(e, comp))
break;
292 template <
typename T,
typename F>
297 std::shared_lock<std::shared_mutex> lock(m_Mutex);
299 for(
auto range : ranges)
301 auto e =
static_cast<entt::entity>(range);
302 auto& comp = m_Registry.get<T>(e);
308 template<
typename T,
typename F>
309 inline void World::
ViewComponent(
const std::vector<uint32_t>& ranges, uint32_t floor, uint32_t ceil, F&& fn)
313 std::shared_lock<std::shared_mutex> lock(m_Mutex);
316 assert(ceil >= floor);
317 assert(ceil <= ranges.size() - 1);
319 for(int32_t i = floor; i < ceil; i++)
321 auto e =
static_cast<entt::entity>(ranges[i]);
322 auto& comp = m_Registry.get<T>(e);
333 std::shared_lock<std::shared_mutex> lock(m_Mutex);
335 for (
auto entity : m_RootEntityMap)
337 Entity e(entity.second,
this);
342 template <
typename T,
typename ... Args>
347 std::unique_lock<std::shared_mutex> lock(m_Mutex);
349 return m_Registry.emplace<T>(e, std::forward<Args>(args)...);
352 template <
typename T>
358
359
362 return m_Registry.get<T>(e);
365 template <
typename T>
370 std::unique_lock<std::shared_mutex> lock(m_Mutex);
372 m_Registry.remove<T>(e);
375 template <
typename T>
380 std::shared_lock<std::shared_mutex> lock(m_Mutex);
382 return m_Registry.all_of<T>(e);
390 component.OnComponentAdded(*entity);
#define PROCESS_INSTANCE_ENTRY
Macros of modify Process instance state.
#define PROCESS_INSTANCE_EXIT
#define SPICES_PROFILE_ZONE
Application(const Application &)=delete
Copy Constructor Function.
virtual ~Application()
Destructor Function.
Application & operator=(const Application &)=delete
Copy Assignment Operation.
Application()
Constructor Function.
static void Run()
Run Our World.
Application Class. Our Engine Start here.
Entity Class. This class defines the specific behaves of Entity.
static std::shared_ptr< spdlog::logger > s_ClientLogger
Game Stage Logger.
static bool m_IsInitialized
static std::shared_ptr< spdlog::logger > s_CoreLogger
Engine Stage Logger.
static void Init()
Init Log.
static std::shared_ptr< spdlog::logger > & GetCoreLogger()
Get Engine Stage Logger.
static std::shared_ptr< spdlog::logger > & GetClientLogger()
Get Game Stage Logger.
static void PostHandle(format_string_t< Args... > fmt, Args &&...args)
Post handle with log message.
static void ShutDown()
Shutdown Log.
float m_FrameTime
time step(s) during frames.
std::chrono::steady_clock::time_point m_StartTime
Engine Start time.
void Flush()
Refresh time in each engine loop.
const float & ft() const
Get time step during frames.
TimeStep(const TimeStep &)=delete
Copy Constructor Function.
const uint64_t & fs() const
Get frames count.
TimeStep()
Constructor Function.
virtual ~TimeStep()=default
Destructor Function.
std::chrono::steady_clock::time_point m_LastTime
Last frame time.
float m_GameTime
time step(s) since Engine Start.
uint64_t m_Frames
Frames since Engine Start.
TimeStep & operator=(const TimeStep &)=delete
Copy Assignment Operation.
const float & gt() const
Get time step since Engine Start.
This Class handles our engine time step during frames. Global Unique.
static TracyGPUContext & Get()
Get this Single Instance.
static std::shared_ptr< TracyGPUContext > m_TracyGPUContext
This Single Instance.
virtual ~TracyGPUContext()=default
Destructor Function.
tracy::VkCtx * m_Context
Tracy Vulkan Context.
TracyGPUContext(VulkanState &state)
Constructor Function.
VulkanState & m_VulkanState
VulkanState.
tracy::VkCtx *& GetContext()
Get Context.
static void CreateInstance(VulkanState &state)
Create this Single Instance.
Wapper of Tracy GPU collect features.
This class helps to generate a uuid for one resource.
WorldMarkFlags GetMarker() const
Get WorldMarkFlags this frame.
void ViewComponent(const std::vector< uint32_t > &ranges, uint32_t floor, uint32_t ceil, F &&fn)
View all component in this world in ranges.
void Mark(WorldMarkFlags flags)
Mark WorldMarkFlags with flags.
Entity CreateEntity(const std::string &name="None")
Create a new empty entity in this world.
void OnComponentAdded(Entity *entity, T &component)
Called On any Component Added to this world.
void ReserMark()
Reset WorldMarkFlags to Clean.
void ViewRoot(F &&fn)
View all root in this world.
Entity CreateEmptyEntity(UUID uuid)
Entity CreateEntityWithUUID(UUID uuid, const std::string &name="None")
Create a new empty entity with a uuid in this world.
void ViewComponent(F &&fn)
View all component in this world.
void ViewComponent(const std::vector< uint32_t > &ranges, F &&fn)
View all component in this world in ranges.
virtual void OnDeactivate()=0
This interface defines the specific world behaves after on activated.
virtual ~World()=default
Destructor Function.
Entity QueryEntitybyID(uint32_t id)
Get World Entity by id(entt::entity).
virtual void OnPreActivate()=0
This interface define the specific world behaves before on activated.
entt::registry m_Registry
This variable handles all entity.
std::shared_mutex m_Mutex
Mutex for world.
void DestroyEntity(Entity &entity)
Destroy a entity from this world.
T & GetComponent(entt::entity e)
Get Component owned by this entity.
void RemoveComponent(entt::entity e)
Remove Component owned from this entity.
WorldMarkFlags m_Marker
World State this frame.
entt::registry & GetRegistry()
Get Registry variable.
void RemoveFromRoot(Entity &entity)
Remove a entity from this world root.
virtual void OnActivate(TimeStep &ts)=0
This interface define the specific world behaves on activated.
void AddToRoot(Entity &entity)
Add a entity to this world root.
World()=default
Constructor Function.
std::unordered_map< UUID, entt::entity > m_RootEntityMap
This variable is a cache. @noto Not in use now.
bool IsRootEntity(Entity &entity)
Determine if a entity is in root.
void ClearMarkerWithBits(WorldMarkFlags flags)
Clear WorldMarkFlags with flags.
bool HasComponent(entt::entity e)
If Component is owned by this entity or not.
T & AddComponent(entt::entity e, Args &&... args)
Template Function. Used for add specific component to entity.
World Class. This class defines the basic behaves of World. When we create an new world,...
static const char * memoryPoolNames[3]
MemoryPool's name.
std::shared_ptr< World > CreateWorld()
extern WorldCreation definition in Game.
static constexpr char const * name
static constexpr uint32_t id
Define a named category tag type.
static constexpr char const * name
Define a custom domain tag type.
static constexpr char const * message
Define a registered string tag type.
This struct contains all Vulkan object in used global.