entity system!

This commit is contained in:
Asuro
2025-02-09 19:30:18 +01:00
parent d1270c47a9
commit 90bc5753a9
19 changed files with 306 additions and 67 deletions

View File

@@ -1,7 +1,9 @@
#include "Setup.h"
#include "Log.h"
#include "bx/timer.h"
#include "rendering/Rendering.h"
#include "Global.h"
#include "Instance.h"
namespace Game
{
@@ -20,7 +22,22 @@ namespace Game
{
Log("Game Setup Start!");
GameInstance& instance = *reinterpret_cast<GameInstance*>(&shared.Game.PermanentStorage);
if (shared.Game.PermanentStorage == nullptr)
{
Log("Game memory not initialized!!");
return;
}
if (shared.Game.EntityStorage == nullptr)
{
Log("Entity memory not initialized!");
return;
}
if (shared.Game.PermanentStorageSize < sizeof(GameInstance))
{
Log("Game memory too small! %u < %u", shared.Game.PermanentStorageSize, sizeof(GameInstance));
return;
}
GameInstance& instance = *reinterpret_cast<GameInstance*>(shared.Game.PermanentStorage);
if (sizeof(GameInstance) != instance.Size)
{
Log("Game instance size changed, resetting!");
@@ -29,11 +46,14 @@ namespace Game
SetShared(shared);
SetInstance(instance);
SetupInstance.Rendering.Setup();
instance.GameLevel.Setup(shared.Game);
instance.IsInitialized = true;
}
void Update()
{
++GetInstance().FrameCounter;
GetInstance().Now = (bx::getHPCounter() - GetInstance().StartTime) / (double)(bx::getHPFrequency());
SetupInstance.Rendering.Update();
}