aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYann Herklotz <ymherklotz@gmail.com>2018-06-15 20:00:26 +0100
committerYann Herklotz <ymherklotz@gmail.com>2018-06-15 20:00:26 +0100
commit2acf4bfcbb5c4b457590e0ce6336645bc3900d83 (patch)
tree7b668e425cf9c89082f145cf929c644b0e8f9473
parentc3a7658120c9bb396bde01bed2bcec938fef1f10 (diff)
downloadYAGE-2acf4bfcbb5c4b457590e0ce6336645bc3900d83.tar.gz
YAGE-2acf4bfcbb5c4b457590e0ce6336645bc3900d83.zip
Deleting entity system so that it can be rewritten
-rw-r--r--yage/entity/engine.cpp65
-rw-r--r--yage/entity/engine.h58
-rw-r--r--yage/entity/entity.cpp42
-rw-r--r--yage/entity/space.cpp29
-rw-r--r--yage/entity/space.h76
5 files changed, 0 insertions, 270 deletions
diff --git a/yage/entity/engine.cpp b/yage/entity/engine.cpp
deleted file mode 100644
index 73774093..00000000
--- a/yage/entity/engine.cpp
+++ /dev/null
@@ -1,65 +0,0 @@
-/** ---------------------------------------------------------------------------
- * -*- c++ -*-
- * @file: engine.cpp
- *
- * Copyright (c) 2017 Yann Herklotz Grave <ymherklotz@gmail.com>
- * MIT License, see LICENSE file for more details.
- * ----------------------------------------------------------------------------
- */
-
-#include "engine.h"
-
-#include "../core/core.h"
-
-#include "space.h"
-
-namespace yage
-{
-
-Engine::~Engine()
-{
- quit();
-}
-
-Engine &Engine::init()
-{
- yage::init();
- window_.create("Game Engine", 800, 640);
- return *this;
-}
-
-Engine &Engine::mainLoop()
-{
- while (!window_.shouldClose()) {
- window_.pollEvents();
- window_.clearBuffer();
-
- update();
-
- window_.swapBuffer();
- }
-
- return *this;
-}
-
-void Engine::update()
-{
- for (auto &space : spaces_) {
- space->update();
- }
-}
-
-Engine &Engine::addSpace(std::unique_ptr<Space> space)
-{
- spaces_.push_back(std::move(space));
- return *this;
-}
-
-Engine &Engine::instance()
-{
- static Engine engine_instance;
-
- return engine_instance;
-}
-
-} // namespace yage
diff --git a/yage/entity/engine.h b/yage/entity/engine.h
deleted file mode 100644
index 6719eeaf..00000000
--- a/yage/entity/engine.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/** ---------------------------------------------------------------------------
- * -*- c++ -*-
- * @file: engine.h
- *
- * Copyright (c) 2017 Yann Herklotz Grave <ymherklotz@gmail.com>
- * MIT License, see LICENSE file for more details.
- * ----------------------------------------------------------------------------
- */
-
-#pragma once
-
-#include "system.h"
-
-#include "../core/window.h"
-#include "../util/noncopyable.h"
-
-#include <memory>
-#include <vector>
-
-namespace yage
-{
-
-class Space;
-
-/**
- * Main engine class that contains a systems, the main loop and the update
- * function that updates all the systems.
- */
-class Engine : public NonCopyable
-{
-public:
- ~Engine();
-
- /// Initialize window and other aspects of the engine.
- Engine &init();
-
- /// Main game loop of the engine.
- Engine &mainLoop();
-
- /// Updates the systems.
- void update();
-
- /// Add spaces to the engine
- Engine &addSpace(std::unique_ptr<Space> space);
-
- /// Returns the instance of the engine, as there is only one instance of the
- /// engine.
- static Engine &instance();
-
-private:
- /// Window
- Window window_;
-
- /// A vector of all the spaces
- std::vector<std::unique_ptr<Space>> spaces_;
-};
-
-} // namespace yage
diff --git a/yage/entity/entity.cpp b/yage/entity/entity.cpp
deleted file mode 100644
index 1a2b16ad..00000000
--- a/yage/entity/entity.cpp
+++ /dev/null
@@ -1,42 +0,0 @@
-/** ---------------------------------------------------------------------------
- * -*- c++ -*-
- * @file: entity.cpp
- *
- * Copyright (c) 2017 Yann Herklotz Grave <ymherklotz@gmail.com>
- * MIT License, see LICENSE file for more details.
- * ----------------------------------------------------------------------------
- */
-
-#include "entity.h"
-
-#include <algorithm>
-
-namespace yage
-{
-
-BaseComponent::Group BaseComponent::group_id_counter_ = 0;
-
-EntityManager::EntityManager(Space *space) : space_(space) {}
-
-EntityManager::EntityManager(Space *space, std::size_t n) : space_(space)
-{
- entities_.reserve(n);
-}
-
-Entity EntityManager::createEntity()
-{
- Entity entity = next_entity_++;
- entities_.push_back(entity);
- return entity;
-}
-
-void EntityManager::deleteEntity(Entity entity)
-{
- auto index = std::find_if(entities_.begin(), entities_.end(),
- [&](Entity &value) { return value == entity; });
- if (index != entities_.end()) {
- entities_.erase(index);
- }
-}
-
-} // namespace yage
diff --git a/yage/entity/space.cpp b/yage/entity/space.cpp
deleted file mode 100644
index 530f5b49..00000000
--- a/yage/entity/space.cpp
+++ /dev/null
@@ -1,29 +0,0 @@
-/** ---------------------------------------------------------------------------
- * -*- c++ -*-
- * @file: space.cpp
- *
- * Copyright (c) 2017 Yann Herklotz Grave <ymherklotz@gmail.com>
- * MIT License, see LICENSE file for more details.
- * ----------------------------------------------------------------------------
- */
-
-#include "space.h"
-
-namespace yage
-{
-
-Space::Space() : em_(this) {}
-
-unsigned Space::createEntity()
-{
- return em_.createEntity();
-}
-
-void Space::update()
-{
- for (auto &system : systems_) {
- system->update();
- }
-}
-
-} // namespace yage
diff --git a/yage/entity/space.h b/yage/entity/space.h
deleted file mode 100644
index 0763b189..00000000
--- a/yage/entity/space.h
+++ /dev/null
@@ -1,76 +0,0 @@
-/** ---------------------------------------------------------------------------
- * -*- c++ -*-
- * @file: space.h
- *
- * Copyright (c) 2017 Yann Herklotz Grave <ymherklotz@gmail.com>
- * MIT License, see LICENSE file for more details.
- * ----------------------------------------------------------------------------
- */
-
-#pragma once
-
-#include <memory>
-#include <vector>
-
-#include "entity.h"
-#include "system.h"
-
-struct Movement {
-};
-
-namespace yage
-{
-
-class System;
-
-/**
- * Space that keeps track of all the entities, componenets and runs
- * the systems on the data to update them. There can be multiple
- * instances of a space, which can be used, for example, for different
- * levels in the game that can be loaded separately, or a game menu
- * that can be loaded above the other spaces when the user presses on
- * pause.
- */
-class Space
-{
-public:
- /**
- * Default instance for a space.
- */
- Space();
-
- /**
- * Create an entity that will belong to this space, and return the
- * handle to the user. The Entity class itself should not be
- * visible to the user, as the user only needs to worry about the
- * handle when referring to the Entity and changing it.
- */
- Entity createEntity();
-
- /**
- * Update all the systems.
- */
- void update();
-
-private:
- /**
- * The systems of the Space that act on the data and on their
- * respective component. These are specific to the Space, as other
- * spaces might have different Systems and not act on the same
- * entities.
- */
- std::vector<std::unique_ptr<System>> systems_;
-
- /**
- * Manages all the entities in the system, can create them for the
- * current space.
- */
- EntityManager em_;
-
- /**
- * Manages all the components
- */
- // ComponentManager cm_;
-};
-
-} // namespace yage