aboutsummaryrefslogtreecommitdiffstats
path: root/entityx/Entity.cc
diff options
context:
space:
mode:
authorAndy <drumsetmonkey@gmail.com>2017-01-19 09:21:12 -0500
committerAndy <drumsetmonkey@gmail.com>2017-01-19 09:21:12 -0500
commit213d9ccfbb4752d4c62d6b7e6b3f9172cdf1bccc (patch)
tree7872c6f30c8adf048a7863a33d837299c7fb0771 /entityx/Entity.cc
parent19a32074595a4a2797eaeb978f8bd302f736f6a6 (diff)
parent8452b199d28bea53bf2c5e3b3d604064000fc73d (diff)
Limb animation actually works
Diffstat (limited to 'entityx/Entity.cc')
-rw-r--r--entityx/Entity.cc61
1 files changed, 61 insertions, 0 deletions
diff --git a/entityx/Entity.cc b/entityx/Entity.cc
new file mode 100644
index 0000000..ddb8df7
--- /dev/null
+++ b/entityx/Entity.cc
@@ -0,0 +1,61 @@
+/*
+ * Copyright (C) 2012 Alec Thomas <alec@swapoff.org>
+ * All rights reserved.
+ *
+ * This software is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution.
+ *
+ * Author: Alec Thomas <alec@swapoff.org>
+ */
+
+#include <algorithm>
+#include "entityx/Entity.h"
+
+namespace entityx {
+
+const Entity::Id Entity::INVALID;
+BaseComponent::Family BaseComponent::family_counter_ = 0;
+
+void Entity::invalidate() {
+ id_ = INVALID;
+ manager_ = nullptr;
+}
+
+void Entity::destroy() {
+ assert(valid());
+ manager_->destroy(id_);
+ invalidate();
+}
+
+std::bitset<entityx::MAX_COMPONENTS> Entity::component_mask() const {
+ return manager_->component_mask(id_);
+}
+
+EntityManager::EntityManager(EventManager &event_manager) : event_manager_(event_manager) {
+}
+
+EntityManager::~EntityManager() {
+ reset();
+}
+
+void EntityManager::reset() {
+ for (Entity entity : entities_for_debugging()) entity.destroy();
+ for (BasePool *pool : component_pools_) {
+ if (pool) delete pool;
+ }
+ for (BaseComponentHelper *helper : component_helpers_) {
+ if (helper) delete helper;
+ }
+ component_pools_.clear();
+ component_helpers_.clear();
+ entity_component_mask_.clear();
+ entity_version_.clear();
+ free_list_.clear();
+ index_counter_ = 0;
+}
+
+EntityCreatedEvent::~EntityCreatedEvent() {}
+EntityDestroyedEvent::~EntityDestroyedEvent() {}
+
+
+} // namespace entityx