Add Scene with systems

- Add Scene class which populates the engine with Systems which handles
  all logic in the game
- Add Systems to ecs
This commit is contained in:
Thraix
2023-05-20 19:45:15 +02:00
parent 05d2c2940b
commit 84b24457a0
20 changed files with 626 additions and 42 deletions
@@ -0,0 +1,58 @@
#include "copium/asset/AssetRef.h"
#include "copium/asset/AssetManager.h"
namespace Copium
{
AssetRef::AssetRef(AssetHandle handle)
: handle{handle}, refCounter{new int{1}}
{}
AssetRef::~AssetRef()
{
if (refCounter == nullptr)
return;
(*refCounter)--;
if (*refCounter == 0)
{
AssetManager::UnloadAsset(handle);
delete refCounter;
}
}
AssetRef::AssetRef(const AssetRef& other)
: handle{other.handle}, refCounter{other.refCounter}
{
(*refCounter)++;
}
AssetRef::AssetRef(AssetRef&& other)
: handle{other.handle}, refCounter{other.refCounter}
{
other.refCounter = nullptr;
}
AssetRef& AssetRef::operator=(const AssetRef& rhs)
{
handle = rhs.handle;
refCounter = rhs.refCounter;
(*refCounter)++;
return *this;
}
AssetRef& AssetRef::operator=(AssetRef&& rhs)
{
handle = rhs.handle;
refCounter = rhs.refCounter;
rhs.refCounter = nullptr;
return *this;
}
AssetRef::operator AssetHandle() const
{
return handle;
}
}