#pragma once
/*
GameEngine and Editor
by John Ryland
Copyright (c) 2023
*/
////////////////////////////////////////////////////////////////////////////////////
// ECS System
#include "IEntityComponentSystem.h"
#include "GameState.h"
#include "XmlParser.h"
namespace GameEngine {
class EcsSystem : public IEntityComponentSystem
{
public:
EcsSystem();
~EcsSystem() override;
void Initialize() override;
void Shutdown() override;
void Prepare() override;
void Update() override;
void Render() override;
void Present() override;
void SetSchema(GameRuntime::Schema* schema);
void LoadScene(const char* sceneFilename);
void RegisterComponentType();
StringList AllComponentTypeNames() const;
ComponentTypeId FindComponentTypeByName(String componentName) const;
Array<EntityId> AllEntities() const;
Array<EntityId> FindEntitiesWithComponentType(ComponentTypeId componentType) const;
StringList EntityComponents(EntityId entity) const;
const EntityRef& GetEntity(EntityId entity) const;
const ComponentType& GetComponentType(ComponentTypeId componentType) const;
GameRuntime::Schema* GetSchema() const { return schema; }
void NewEntity();
void NewComponent();
void RemoveStaleComponentReferences();
void LoadEntitiesFromXml(XmlTag* tag);
private:
EntityId lastUsedEntityId = 0;
ComponentTypeId lastUsedComponentTypeId = 0;
GameRuntime::Schema* schema;
Entities entities;
ComponentTypes components;
};
} // GameEngine namespace