diff --git a/src/ecs/commands.cpp b/src/ecs/commands.cpp
deleted file mode 100644
index 17cae12..0000000
--- a/src/ecs/commands.cpp
+++ /dev/null
@@ -1,143 +0,0 @@
-/*
- * Copyright (C) 2021 Christopher J. Howard
- *
- * This file is part of Antkeeper source code.
- *
- * Antkeeper source code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Antkeeper source code is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Antkeeper source code. If not, see .
- */
-
-#include "ecs/commands.hpp"
-#include "ecs/components/model-component.hpp"
-#include "ecs/components/transform-component.hpp"
-#include "ecs/components/copy-transform-component.hpp"
-#include "ecs/components/snap-component.hpp"
-#include "ecs/components/parent-component.hpp"
-#include
-
-namespace ecs {
-namespace command {
-
-void translate(ecs::registry& registry, ecs::entity entity, const float3& translation)
-{
- if (registry.has(entity))
- {
- transform_component& transform = registry.get(entity);
- transform.local.translation += translation;
- }
-}
-
-void move_to(ecs::registry& registry, ecs::entity entity, const float3& position)
-{
- if (registry.has(entity))
- {
- transform_component& transform = registry.get(entity);
- transform.local.translation = position;
- }
-}
-
-void warp_to(ecs::registry& registry, ecs::entity entity, const float3& position)
-{
- if (registry.has(entity))
- {
- transform_component& transform = registry.get(entity);
- transform.local.translation = position;
- transform.warp = true;
- }
-}
-
-void set_scale(ecs::registry& registry, ecs::entity entity, const float3& scale)
-{
- if (registry.has(entity))
- {
- transform_component& transform = registry.get(entity);
- transform.local.scale = scale;
- }
-}
-
-void set_transform(ecs::registry& registry, ecs::entity entity, const math::transform& transform, bool warp)
-{
- if (registry.has(entity))
- {
- transform_component& component = registry.get(entity);
- component.local = transform;
- component.warp = warp;
- }
-}
-
-void place(ecs::registry& registry, ecs::entity entity, const float2& translation)
-{
- snap_component component;
- component.warp = true;
- component.relative = false;
- component.autoremove = true;
- component.ray.origin = {translation[0], 10000.0f, translation[1]};
- component.ray.direction = {0.0f, -1.0f, 0.0f};
- registry.assign_or_replace(entity, component);
-}
-
-void assign_render_layers(ecs::registry& registry, ecs::entity entity, unsigned int layers)
-{
- if (registry.has(entity))
- {
- model_component model = registry.get(entity);
- model.layers = layers;
- registry.replace(entity, model);
-
- // Apply to child layers
- registry.view().each(
- [&](ecs::entity entity, auto& component)
- {
- if (component.parent == entity)
- assign_render_layers(registry, entity, layers);
- });
- }
-}
-
-void bind_transform(ecs::registry& registry, entity source, entity target)
-{
- copy_transform_component copy_transform = {target};
- registry.assign_or_replace(source, copy_transform);
-}
-
-math::transform get_local_transform(ecs::registry& registry, ecs::entity entity)
-{
- if (registry.has(entity))
- {
- const transform_component& component = registry.get(entity);
- return component.local;
- }
-
- return math::identity_transform;
-}
-
-math::transform get_world_transform(ecs::registry& registry, ecs::entity entity)
-{
- if (registry.has(entity))
- {
- const transform_component& component = registry.get(entity);
- return component.world;
- }
-
- return math::identity_transform;
-}
-
-void parent(ecs::registry& registry, entity child, entity parent)
-{
- parent_component component;
- component.parent = parent;
- registry.assign_or_replace(child, component);
-}
-
-} // namespace command
-} // namespace ecs
diff --git a/src/ecs/commands.hpp b/src/ecs/commands.hpp
deleted file mode 100644
index d559212..0000000
--- a/src/ecs/commands.hpp
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright (C) 2021 Christopher J. Howard
- *
- * This file is part of Antkeeper source code.
- *
- * Antkeeper source code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Antkeeper source code is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Antkeeper source code. If not, see .
- */
-
-#ifndef ANTKEEPER_ECS_COMMANDS_HPP
-#define ANTKEEPER_ECS_COMMANDS_HPP
-
-#include "ecs/entity.hpp"
-#include "ecs/registry.hpp"
-#include "utility/fundamental-types.hpp"
-#include "math/transform-type.hpp"
-
-namespace ecs {
-
-/// Commands which operate on entity components
-namespace command {
-
-void translate(ecs::registry& registry, ecs::entity entity, const float3& translation);
-void move_to(ecs::registry& registry, ecs::entity entity, const float3& position);
-void warp_to(ecs::registry& registry, ecs::entity entity, const float3& position);
-void set_scale(ecs::registry& registry, ecs::entity entity, const float3& scale);
-void set_transform(ecs::registry& registry, ecs::entity entity, const math::transform& transform, bool warp = false);
-void place(ecs::registry& registry, ecs::entity entity, const float2& translation);
-void assign_render_layers(ecs::registry& registry, ecs::entity entity, unsigned int layers);
-void bind_transform(ecs::registry& registry, entity source_eid, entity target_eid);
-math::transform get_local_transform(ecs::registry& registry, ecs::entity entity);
-math::transform get_world_transform(ecs::registry& registry, ecs::entity entity);
-void parent(ecs::registry& registry, entity child, entity parent);
-
-} // namespace command
-} // namespace ecs
-
-#endif // ANTKEEPER_ECS_COMMANDS_HPP
-
diff --git a/src/ecs/components/copy-transform-component.hpp b/src/ecs/components/copy-transform-component.hpp
deleted file mode 100644
index 61e4818..0000000
--- a/src/ecs/components/copy-transform-component.hpp
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright (C) 2021 Christopher J. Howard
- *
- * This file is part of Antkeeper source code.
- *
- * Antkeeper source code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Antkeeper source code is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Antkeeper source code. If not, see .
- */
-
-#ifndef ANTKEEPER_ECS_COPY_TRANSFORM_COMPONENT_HPP
-#define ANTKEEPER_ECS_COPY_TRANSFORM_COMPONENT_HPP
-
-#include "ecs/entity.hpp"
-
-namespace ecs {
-
-struct copy_transform_component
-{
- entity target;
-};
-
-} // namespace ecs
-
-#endif // ANTKEEPER_ECS_COPY_TRANSFORM_COMPONENT_HPP
diff --git a/src/ecs/components/ephemeris-component.hpp b/src/ecs/components/ephemeris-component.hpp
deleted file mode 100644
index f4577f3..0000000
--- a/src/ecs/components/ephemeris-component.hpp
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright (C) 2021 Christopher J. Howard
- *
- * This file is part of Antkeeper source code.
- *
- * Antkeeper source code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Antkeeper source code is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Antkeeper source code. If not, see .
- */
-
-#ifndef ANTKEEPER_ECS_EPHEMERIS_COMPONENT_HPP
-#define ANTKEEPER_ECS_EPHEMERIS_COMPONENT_HPP
-
-#include "astro/orbit.hpp"
-
-namespace ecs {
-
-struct ephemeris_component
-{
- ecs::entity body;
-};
-
-} // namespace ecs
-
-#endif // ANTKEEPER_ECS_EPHEMERIS_COMPONENT_HPP
diff --git a/src/ecs/components/parent-component.hpp b/src/ecs/components/parent-component.hpp
deleted file mode 100644
index 9413c62..0000000
--- a/src/ecs/components/parent-component.hpp
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright (C) 2021 Christopher J. Howard
- *
- * This file is part of Antkeeper source code.
- *
- * Antkeeper source code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Antkeeper source code is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Antkeeper source code. If not, see .
- */
-
-#ifndef ANTKEEPER_ECS_PARENT_COMPONENT_HPP
-#define ANTKEEPER_ECS_PARENT_COMPONENT_HPP
-
-#include "ecs/entity.hpp"
-
-namespace ecs {
-
-struct parent_component
-{
- entity parent;
-};
-
-} // namespace ecs
-
-#endif // ANTKEEPER_ECS_PARENT_COMPONENT_HPP
diff --git a/src/ecs/systems/collision-system.cpp b/src/ecs/systems/collision-system.cpp
deleted file mode 100644
index 9084c62..0000000
--- a/src/ecs/systems/collision-system.cpp
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright (C) 2021 Christopher J. Howard
- *
- * This file is part of Antkeeper source code.
- *
- * Antkeeper source code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Antkeeper source code is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Antkeeper source code. If not, see .
- */
-
-#include "collision-system.hpp"
-#include "ecs/components/transform-component.hpp"
-
-namespace ecs {
-
-collision_system::collision_system(ecs::registry& registry):
- entity_system(registry)
-{
- registry.on_construct().connect<&collision_system::on_collision_construct>(this);
- registry.on_replace().connect<&collision_system::on_collision_replace>(this);
- registry.on_destroy().connect<&collision_system::on_collision_destroy>(this);
-}
-
-void collision_system::update(double t, double dt)
-{}
-
-void collision_system::on_collision_construct(ecs::registry& registry, ecs::entity entity, collision_component& collision)
-{}
-
-void collision_system::on_collision_replace(ecs::registry& registry, ecs::entity entity, collision_component& collision)
-{}
-
-void collision_system::on_collision_destroy(ecs::registry& registry, ecs::entity entity)
-{}
-
-} // namespace ecs
diff --git a/src/ecs/systems/entity-system.hpp b/src/ecs/systems/entity-system.hpp
deleted file mode 100644
index 1ae0192..0000000
--- a/src/ecs/systems/entity-system.hpp
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright (C) 2021 Christopher J. Howard
- *
- * This file is part of Antkeeper source code.
- *
- * Antkeeper source code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Antkeeper source code is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Antkeeper source code. If not, see .
- */
-
-#ifndef ANTKEEPER_ECS_ENTITY_SYSTEM_HPP
-#define ANTKEEPER_ECS_ENTITY_SYSTEM_HPP
-
-#include "updatable-system.hpp"
-#include "ecs/registry.hpp"
-
-namespace ecs {
-
-/**
- * Abstract base class for updatable systems which operate on entities and entity components.
- */
-class entity_system: public updatable_system
-{
-public:
- entity_system(ecs::registry& registry);
-
-protected:
- ecs::registry& registry;
-};
-
-} // namespace ecs
-
-#endif // ANTKEEPER_ECS_ENTITY_SYSTEM_HPP
-
diff --git a/src/ecs/systems/render-system.hpp b/src/ecs/systems/render-system.hpp
deleted file mode 100644
index f65c731..0000000
--- a/src/ecs/systems/render-system.hpp
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Copyright (C) 2021 Christopher J. Howard
- *
- * This file is part of Antkeeper source code.
- *
- * Antkeeper source code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Antkeeper source code is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Antkeeper source code. If not, see .
- */
-
-#ifndef ANTKEEPER_ECS_RENDER_SYSTEM_HPP
-#define ANTKEEPER_ECS_RENDER_SYSTEM_HPP
-
-#include "entity-system.hpp"
-#include "scene/collection.hpp"
-#include "scene/model-instance.hpp"
-#include "scene/light.hpp"
-#include "ecs/components/model-component.hpp"
-#include "ecs/components/light-component.hpp"
-#include "ecs/entity.hpp"
-#include
-#include
-
-class renderer;
-
-namespace ecs {
-
-class render_system: public entity_system
-{
-public:
- render_system(ecs::registry& registry);
- virtual void update(double t, double dt);
-
- void render(double alpha);
-
-
- void add_layer(scene::collection* layer);
- void remove_layers();
-
- void set_renderer(::renderer* renderer);
-
- scene::model_instance* get_model_instance(ecs::entity entity);
- scene::light* get_light(ecs::entity entity);
-
-private:
- void update_model_and_materials(ecs::entity entity, ecs::model_component& model);
- void update_light(ecs::entity entity, ecs::light_component& component);
-
- void on_model_construct(ecs::registry& registry, ecs::entity entity, ecs::model_component& model);
- void on_model_replace(ecs::registry& registry, ecs::entity entity, ecs::model_component& model);
- void on_model_destroy(ecs::registry& registry, ecs::entity entity);
-
- void on_light_construct(ecs::registry& registry, ecs::entity entity, ecs::light_component& light);
- void on_light_replace(ecs::registry& registry, ecs::entity entity, ecs::light_component& light);
- void on_light_destroy(ecs::registry& registry, ecs::entity entity);
-
- renderer* renderer;
- std::vector layers;
- std::unordered_map model_instances;
- std::unordered_map lights;
-};
-
-} // namespace ecs
-
-#endif // ANTKEEPER_ECS_RENDER_SYSTEM_HPP
-
diff --git a/src/ecs/systems/spatial-system.hpp b/src/ecs/systems/spatial-system.hpp
deleted file mode 100644
index b9a4f79..0000000
--- a/src/ecs/systems/spatial-system.hpp
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright (C) 2021 Christopher J. Howard
- *
- * This file is part of Antkeeper source code.
- *
- * Antkeeper source code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Antkeeper source code is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Antkeeper source code. If not, see .
- */
-
-#ifndef ANTKEEPER_ECS_SPATIAL_SYSTEM_HPP
-#define ANTKEEPER_ECS_SPATIAL_SYSTEM_HPP
-
-#include "entity-system.hpp"
-
-namespace ecs {
-
-class spatial_system:
- public entity_system
-{
-public:
- spatial_system(ecs::registry& registry);
- virtual void update(double t, double dt);
-};
-
-} // namespace ecs
-
-#endif // ANTKEEPER_ECS_SPATIAL_SYSTEM_HPP
diff --git a/src/ecs/systems/updatable-system.cpp b/src/ecs/systems/updatable-system.cpp
deleted file mode 100644
index 53f869b..0000000
--- a/src/ecs/systems/updatable-system.cpp
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Copyright (C) 2021 Christopher J. Howard
- *
- * This file is part of Antkeeper source code.
- *
- * Antkeeper source code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Antkeeper source code is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Antkeeper source code. If not, see .
- */
-
-#include "updatable-system.hpp"
-
-
diff --git a/src/ecs/archetype.hpp b/src/entity/archetype.hpp
similarity index 84%
rename from src/ecs/archetype.hpp
rename to src/entity/archetype.hpp
index ff336dd..b0ceb1e 100644
--- a/src/ecs/archetype.hpp
+++ b/src/entity/archetype.hpp
@@ -17,16 +17,16 @@
* along with Antkeeper source code. If not, see .
*/
-#ifndef ANTKEEPER_ECS_ARCHETYPE_HPP
-#define ANTKEEPER_ECS_ARCHETYPE_HPP
+#ifndef ANTKEEPER_ENTITY_ARCHETYPE_HPP
+#define ANTKEEPER_ENTITY_ARCHETYPE_HPP
#include
-namespace ecs {
+namespace entity {
typedef entt::prototype archetype;
-} // namespace ecs
+} // namespace entity
-#endif // ANTKEEPER_ECS_ARCHETYPE_HPP
+#endif // ANTKEEPER_ENTITY_ARCHETYPE_HPP
diff --git a/src/entity/commands.cpp b/src/entity/commands.cpp
new file mode 100644
index 0000000..6eb10aa
--- /dev/null
+++ b/src/entity/commands.cpp
@@ -0,0 +1,143 @@
+/*
+ * Copyright (C) 2021 Christopher J. Howard
+ *
+ * This file is part of Antkeeper source code.
+ *
+ * Antkeeper source code is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Antkeeper source code is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Antkeeper source code. If not, see .
+ */
+
+#include "entity/commands.hpp"
+#include "entity/components/model.hpp"
+#include "entity/components/transform.hpp"
+#include "entity/components/copy-transform.hpp"
+#include "entity/components/snap.hpp"
+#include "entity/components/parent.hpp"
+#include
+
+namespace entity {
+namespace command {
+
+void translate(entity::registry& registry, entity::id entity_id, const float3& translation)
+{
+ if (registry.has(entity_id))
+ {
+ component::transform& transform = registry.get(entity_id);
+ transform.local.translation += translation;
+ }
+}
+
+void move_to(entity::registry& registry, entity::id entity_id, const float3& position)
+{
+ if (registry.has(entity_id))
+ {
+ component::transform& transform = registry.get(entity_id);
+ transform.local.translation = position;
+ }
+}
+
+void warp_to(entity::registry& registry, entity::id entity_id, const float3& position)
+{
+ if (registry.has(entity_id))
+ {
+ component::transform& transform = registry.get(entity_id);
+ transform.local.translation = position;
+ transform.warp = true;
+ }
+}
+
+void set_scale(entity::registry& registry, entity::id entity_id, const float3& scale)
+{
+ if (registry.has(entity_id))
+ {
+ component::transform& transform = registry.get(entity_id);
+ transform.local.scale = scale;
+ }
+}
+
+void set_transform(entity::registry& registry, entity::id entity_id, const math::transform& transform, bool warp)
+{
+ if (registry.has(entity_id))
+ {
+ component::transform& component = registry.get(entity_id);
+ component.local = transform;
+ component.warp = warp;
+ }
+}
+
+void place(entity::registry& registry, entity::id entity_id, const float2& translation)
+{
+ component::snap component;
+ component.warp = true;
+ component.relative = false;
+ component.autoremove = true;
+ component.ray.origin = {translation[0], 10000.0f, translation[1]};
+ component.ray.direction = {0.0f, -1.0f, 0.0f};
+ registry.assign_or_replace(entity_id, component);
+}
+
+void assign_render_layers(entity::registry& registry, entity::id entity_id, unsigned int layers)
+{
+ if (registry.has(entity_id))
+ {
+ component::model model = registry.get(entity_id);
+ model.layers = layers;
+ registry.replace(entity_id, model);
+
+ // Apply to child layers
+ registry.view().each(
+ [&](entity::id entity_id, auto& component)
+ {
+ if (component.parent == entity_id)
+ assign_render_layers(registry, entity_id, layers);
+ });
+ }
+}
+
+void bind_transform(entity::registry& registry, entity::id source, entity::id target)
+{
+ component::copy_transform copy_transform = {target};
+ registry.assign_or_replace(source, copy_transform);
+}
+
+math::transform get_local_transform(entity::registry& registry, entity::id entity_id)
+{
+ if (registry.has(entity_id))
+ {
+ const component::transform& component = registry.get(entity_id);
+ return component.local;
+ }
+
+ return math::identity_transform;
+}
+
+math::transform get_world_transform(entity::registry& registry, entity::id entity_id)
+{
+ if (registry.has(entity_id))
+ {
+ const component::transform& component = registry.get(entity_id);
+ return component.world;
+ }
+
+ return math::identity_transform;
+}
+
+void parent(entity::registry& registry, entity::id child, entity::id parent)
+{
+ component::parent component;
+ component.parent = parent;
+ registry.assign_or_replace(child, component);
+}
+
+} // namespace command
+} // namespace entity
diff --git a/src/entity/commands.hpp b/src/entity/commands.hpp
new file mode 100644
index 0000000..ac33c5c
--- /dev/null
+++ b/src/entity/commands.hpp
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2021 Christopher J. Howard
+ *
+ * This file is part of Antkeeper source code.
+ *
+ * Antkeeper source code is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Antkeeper source code is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Antkeeper source code. If not, see .
+ */
+
+#ifndef ANTKEEPER_ENTITY_COMMANDS_HPP
+#define ANTKEEPER_ENTITY_COMMANDS_HPP
+
+#include "entity/id.hpp"
+#include "entity/registry.hpp"
+#include "utility/fundamental-types.hpp"
+#include "math/transform-type.hpp"
+
+namespace entity {
+
+/// Commands which operate on entity::id components
+namespace command {
+
+void translate(entity::registry& registry, entity::id entity_id, const float3& translation);
+void move_to(entity::registry& registry, entity::id entity_id, const float3& position);
+void warp_to(entity::registry& registry, entity::id entity_id, const float3& position);
+void set_scale(entity::registry& registry, entity::id entity_id, const float3& scale);
+void set_transform(entity::registry& registry, entity::id entity_id, const math::transform& transform, bool warp = false);
+void place(entity::registry& registry, entity::id entity_id, const float2& translation);
+void assign_render_layers(entity::registry& registry, entity::id entity_id, unsigned int layers);
+void bind_transform(entity::registry& registry, entity::id source_eid, entity::id target_eid);
+math::transform get_local_transform(entity::registry& registry, entity::id entity_id);
+math::transform get_world_transform(entity::registry& registry, entity::id entity_id);
+void parent(entity::registry& registry, entity::id child, entity::id parent);
+
+} // namespace command
+} // namespace entity
+
+#endif // ANTKEEPER_ENTITY_COMMANDS_HPP
+
diff --git a/src/ecs/components/atmosphere-component.hpp b/src/entity/components/atmosphere.hpp
similarity index 85%
rename from src/ecs/components/atmosphere-component.hpp
rename to src/entity/components/atmosphere.hpp
index ede39c5..47994a8 100644
--- a/src/ecs/components/atmosphere-component.hpp
+++ b/src/entity/components/atmosphere.hpp
@@ -17,15 +17,16 @@
* along with Antkeeper source code. If not, see .
*/
-#ifndef ANTKEEPER_ECS_ATMOSPHERE_COMPONENT_HPP
-#define ANTKEEPER_ECS_ATMOSPHERE_COMPONENT_HPP
+#ifndef ANTKEEPER_ENTITY_COMPONENT_ATMOSPHERE_HPP
+#define ANTKEEPER_ENTITY_COMPONENT_ATMOSPHERE_HPP
#include "utility/fundamental-types.hpp"
-namespace ecs {
+namespace entity {
+namespace component {
/// Atmosphere
-struct atmosphere_component
+struct atmosphere
{
/// Altitude of the outer atmosphere, in meters.
double exosphere_altitude;
@@ -55,6 +56,7 @@ struct atmosphere_component
double3 mie_scattering;
};
-} // namespace ecs
+} // namespace component
+} // namespace entity
-#endif // ANTKEEPER_ECS_ATMOSPHERE_COMPONENT_HPP
+#endif // ANTKEEPER_ENTITY_COMPONENT_ATMOSPHERE_HPP
diff --git a/src/ecs/components/behavior-component.hpp b/src/entity/components/behavior.hpp
similarity index 74%
rename from src/ecs/components/behavior-component.hpp
rename to src/entity/components/behavior.hpp
index cb33d0a..0badb6a 100644
--- a/src/ecs/components/behavior-component.hpp
+++ b/src/entity/components/behavior.hpp
@@ -17,19 +17,21 @@
* along with Antkeeper source code. If not, see .
*/
-#ifndef ANTKEEPER_ECS_BEHAVIOR_COMPONENT_HPP
-#define ANTKEEPER_ECS_BEHAVIOR_COMPONENT_HPP
+#ifndef ANTKEEPER_ENTITY_COMPONENT_BEHAVIOR_HPP
+#define ANTKEEPER_ENTITY_COMPONENT_BEHAVIOR_HPP
-#include "ecs/ebt.hpp"
+#include "entity/ebt.hpp"
-namespace ecs {
+namespace entity {
+namespace component {
-struct behavior_component
+struct behavior
{
const ebt::node* behavior_tree;
};
-} // namespace ecs
+} // namespace component
+} // namespace entity
-#endif // ANTKEEPER_ECS_BEHAVIOR_COMPONENT_HPP
+#endif // ANTKEEPER_ENTITY_COMPONENT_BEHAVIOR_HPP
diff --git a/src/ecs/components/blackbody-component.hpp b/src/entity/components/blackbody.hpp
similarity index 78%
rename from src/ecs/components/blackbody-component.hpp
rename to src/entity/components/blackbody.hpp
index 18cfbbd..98ffcfc 100644
--- a/src/ecs/components/blackbody-component.hpp
+++ b/src/entity/components/blackbody.hpp
@@ -17,13 +17,14 @@
* along with Antkeeper source code. If not, see .
*/
-#ifndef ANTKEEPER_ECS_BLACKBODY_COMPONENT_HPP
-#define ANTKEEPER_ECS_BLACKBODY_COMPONENT_HPP
+#ifndef ANTKEEPER_ENTITY_COMPONENT_BLACKBODY_HPP
+#define ANTKEEPER_ENTITY_COMPONENT_BLACKBODY_HPP
-namespace ecs {
+namespace entity {
+namespace component {
/// Blackbody radiator
-struct blackbody_component
+struct blackbody
{
/// Effective temperature, in Kelvin.
double temperature;
@@ -32,6 +33,7 @@ struct blackbody_component
double3 luminous_intensity;
};
-} // namespace ecs
+} // namespace component
+} // namespace entity
-#endif // ANTKEEPER_ECS_BLACKBODY_COMPONENT_HPP
+#endif // ANTKEEPER_ENTITY_COMPONENT_BLACKBODY_HPP
diff --git a/src/ecs/components/brush-component.hpp b/src/entity/components/brush.hpp
similarity index 77%
rename from src/ecs/components/brush-component.hpp
rename to src/entity/components/brush.hpp
index 0f5a196..f12c55a 100644
--- a/src/ecs/components/brush-component.hpp
+++ b/src/entity/components/brush.hpp
@@ -17,16 +17,18 @@
* along with Antkeeper source code. If not, see .
*/
-#ifndef ANTKEEPER_ECS_BRUSH_COMPONENT_HPP
-#define ANTKEEPER_ECS_BRUSH_COMPONENT_HPP
+#ifndef ANTKEEPER_ENTITY_COMPONENT_BRUSH_HPP
+#define ANTKEEPER_ENTITY_COMPONENT_BRUSH_HPP
-namespace ecs {
+namespace entity {
+namespace component {
-struct brush_component
+struct brush
{
float radius;
};
-} // namespace ecs
+} // namespace component
+} // namespace entity
-#endif // ANTKEEPER_ECS_BRUSH_COMPONENT_HPP
+#endif // ANTKEEPER_ENTITY_COMPONENT_BRUSH_HPP
diff --git a/src/ecs/components/camera-follow-component.hpp b/src/entity/components/camera-follow.hpp
similarity index 74%
rename from src/ecs/components/camera-follow-component.hpp
rename to src/entity/components/camera-follow.hpp
index 6883140..472a696 100644
--- a/src/ecs/components/camera-follow-component.hpp
+++ b/src/entity/components/camera-follow.hpp
@@ -17,17 +17,19 @@
* along with Antkeeper source code. If not, see .
*/
-#ifndef ANTKEEPER_ECS_CAMERA_FOLLOW_COMPONENT_HPP
-#define ANTKEEPER_ECS_CAMERA_FOLLOW_COMPONENT_HPP
+#ifndef ANTKEEPER_ENTITY_COMPONENT_CAMERA_FOLLOW_HPP
+#define ANTKEEPER_ENTITY_COMPONENT_CAMERA_FOLLOW_HPP
-namespace ecs {
+namespace entity {
+namespace component {
-struct camera_follow_component
+struct camera_follow
{
};
-} // namespace ecs
+} // namespace component
+} // namespace entity
-#endif // ANTKEEPER_ECS_CAMERA_FOLLOW_COMPONENT_HPP
+#endif // ANTKEEPER_ENTITY_COMPONENT_CAMERA_FOLLOW_HPP
diff --git a/src/ecs/components/cavity-component.hpp b/src/entity/components/cavity.hpp
similarity index 77%
rename from src/ecs/components/cavity-component.hpp
rename to src/entity/components/cavity.hpp
index 241e9ab..98e6071 100644
--- a/src/ecs/components/cavity-component.hpp
+++ b/src/entity/components/cavity.hpp
@@ -17,20 +17,22 @@
* along with Antkeeper source code. If not, see .
*/
-#ifndef ANTKEEPER_ECS_CAVITY_COMPONENT_HPP
-#define ANTKEEPER_ECS_CAVITY_COMPONENT_HPP
+#ifndef ANTKEEPER_ENTITY_COMPONENT_CAVITY_HPP
+#define ANTKEEPER_ENTITY_COMPONENT_CAVITY_HPP
#include "math/math.hpp"
-namespace ecs {
+namespace entity {
+namespace component {
-struct cavity_component
+struct cavity
{
float3 position;
float radius;
};
-} // namespace ecs
+} // namespace component
+} // namespace entity
-#endif // ANTKEEPER_ECS_CAVITY_COMPONENT_HPP
+#endif // ANTKEEPER_ENTITY_COMPONENT_CAVITY_HPP
diff --git a/src/ecs/components/celestial-body-component.hpp b/src/entity/components/celestial-body.hpp
similarity index 80%
rename from src/ecs/components/celestial-body-component.hpp
rename to src/entity/components/celestial-body.hpp
index 5ae1613..691d9d6 100644
--- a/src/ecs/components/celestial-body-component.hpp
+++ b/src/entity/components/celestial-body.hpp
@@ -17,13 +17,14 @@
* along with Antkeeper source code. If not, see .
*/
-#ifndef ANTKEEPER_ECS_CELESTIAL_BODY_COMPONENT_HPP
-#define ANTKEEPER_ECS_CELESTIAL_BODY_COMPONENT_HPP
+#ifndef ANTKEEPER_ENTITY_COMPONENT_CELESTIAL_BODY_HPP
+#define ANTKEEPER_ENTITY_COMPONENT_CELESTIAL_BODY_HPP
-namespace ecs {
+namespace entity {
+namespace component {
/// A simple celestial body.
-struct celestial_body_component
+struct celestial_body
{
/// Body radius, in meters.
double radius;
@@ -38,6 +39,7 @@ struct celestial_body_component
double angular_frequency;
};
-} // namespace ecs
+} // namespace component
+} // namespace entity
-#endif // ANTKEEPER_ECS_CELESTIAL_BODY_COMPONENT_HPP
+#endif // ANTKEEPER_ENTITY_COMPONENT_CELESTIAL_BODY_HPP
diff --git a/src/ecs/components/chamber-component.hpp b/src/entity/components/chamber.hpp
similarity index 78%
rename from src/ecs/components/chamber-component.hpp
rename to src/entity/components/chamber.hpp
index f4df393..72b61a1 100644
--- a/src/ecs/components/chamber-component.hpp
+++ b/src/entity/components/chamber.hpp
@@ -17,16 +17,17 @@
* along with Antkeeper source code. If not, see .
*/
-#ifndef ANTKEEPER_ECS_CHAMBER_COMPONENT_HPP
-#define ANTKEEPER_ECS_CHAMBER_COMPONENT_HPP
+#ifndef ANTKEEPER_ENTITY_COMPONENT_CHAMBER_HPP
+#define ANTKEEPER_ENTITY_COMPONENT_CHAMBER_HPP
#include
#include
-#include "ecs/entity.hpp"
+#include "entity/id.hpp"
-namespace ecs {
+namespace entity {
+namespace component {
-struct chamber_component
+struct chamber
{
entity nest;
float depth;
@@ -37,6 +38,7 @@ struct chamber_component
std::unordered_set> tiles;
}
-} // namespace ecs
+} // namespace component
+} // namespace entity
-#endif // ANTKEEPER_ECS_CHAMBER_COMPONENT_HPP
+#endif // ANTKEEPER_ENTITY_COMPONENT_CHAMBER_HPP
diff --git a/src/ecs/components/collision-component.hpp b/src/entity/components/collision.hpp
similarity index 79%
rename from src/ecs/components/collision-component.hpp
rename to src/entity/components/collision.hpp
index ea68575..a635498 100644
--- a/src/ecs/components/collision-component.hpp
+++ b/src/entity/components/collision.hpp
@@ -17,23 +17,25 @@
* along with Antkeeper source code. If not, see .
*/
-#ifndef ANTKEEPER_ECS_COLLISION_COMPONENT_HPP
-#define ANTKEEPER_ECS_COLLISION_COMPONENT_HPP
+#ifndef ANTKEEPER_ENTITY_COMPONENT_COLLISION_HPP
+#define ANTKEEPER_ENTITY_COMPONENT_COLLISION_HPP
#include "geom/aabb.hpp"
#include "geom/mesh.hpp"
#include "geom/mesh-accelerator.hpp"
-namespace ecs {
+namespace entity {
+namespace component {
-struct collision_component
+struct collision
{
geom::mesh* mesh;
geom::aabb bounds;
geom::mesh_accelerator mesh_accelerator;
};
-} // namespace ecs
+} // namespace component
+} // namespace entity
-#endif // ANTKEEPER_ECS_COLLISION_COMPONENT_HPP
+#endif // ANTKEEPER_ENTITY_COMPONENT_COLLISION_HPP
diff --git a/src/entity/components/copy-rotation.hpp b/src/entity/components/copy-rotation.hpp
new file mode 100644
index 0000000..24df146
--- /dev/null
+++ b/src/entity/components/copy-rotation.hpp
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2021 Christopher J. Howard
+ *
+ * This file is part of Antkeeper source code.
+ *
+ * Antkeeper source code is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Antkeeper source code is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Antkeeper source code. If not, see .
+ */
+
+#ifndef ANTKEEPER_ENTITY_COMPONENT_COPY_ROTATION_HPP
+#define ANTKEEPER_ENTITY_COMPONENT_COPY_ROTATION_HPP
+
+#include "entity/id.hpp"
+
+namespace entity {
+namespace component {
+
+struct copy_rotation
+{
+ entity::id target;
+};
+
+} // namespace component
+} // namespace entity
+
+#endif // ANTKEEPER_ENTITY_COMPONENT_COPY_ROTATION_HPP
diff --git a/src/ecs/components/copy-scale-component.hpp b/src/entity/components/copy-scale.hpp
similarity index 73%
rename from src/ecs/components/copy-scale-component.hpp
rename to src/entity/components/copy-scale.hpp
index a4f6f4f..438739e 100644
--- a/src/ecs/components/copy-scale-component.hpp
+++ b/src/entity/components/copy-scale.hpp
@@ -17,21 +17,23 @@
* along with Antkeeper source code. If not, see .
*/
-#ifndef ANTKEEPER_ECS_COPY_SCALE_COMPONENT_HPP
-#define ANTKEEPER_ECS_COPY_SCALE_COMPONENT_HPP
+#ifndef ANTKEEPER_ENTITY_COMPONENT_COPY_SCALE_HPP
+#define ANTKEEPER_ENTITY_COMPONENT_COPY_SCALE_HPP
-#include "ecs/entity.hpp"
+#include "entity/id.hpp"
-namespace ecs {
+namespace entity {
+namespace component {
-struct copy_scale_component
+struct copy_scale
{
- entity target;
+ entity::id target;
bool use_x;
bool use_y;
bool use_z;
};
-} // namespace ecs
+} // namespace component
+} // namespace entity
-#endif // ANTKEEPER_ECS_COPY_SCALE_COMPONENT_HPP
+#endif // ANTKEEPER_ENTITY_COMPONENT_COPY_SCALE_HPP
diff --git a/src/entity/components/copy-transform.hpp b/src/entity/components/copy-transform.hpp
new file mode 100644
index 0000000..0fc753f
--- /dev/null
+++ b/src/entity/components/copy-transform.hpp
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2021 Christopher J. Howard
+ *
+ * This file is part of Antkeeper source code.
+ *
+ * Antkeeper source code is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Antkeeper source code is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Antkeeper source code. If not, see .
+ */
+
+#ifndef ANTKEEPER_ENTITY_COMPONENT_COPY_TRANSFORM_HPP
+#define ANTKEEPER_ENTITY_COMPONENT_COPY_TRANSFORM_HPP
+
+#include "entity/id.hpp"
+
+namespace entity {
+namespace component {
+
+struct copy_transform
+{
+ entity::id target;
+};
+
+} // namespace component
+} // namespace entity
+
+#endif // ANTKEEPER_ENTITY_COMPONENT_COPY_TRANSFORM_HPP
diff --git a/src/ecs/components/copy-translation-component.hpp b/src/entity/components/copy-translation.hpp
similarity index 72%
rename from src/ecs/components/copy-translation-component.hpp
rename to src/entity/components/copy-translation.hpp
index f75ddb6..fd00d8d 100644
--- a/src/ecs/components/copy-translation-component.hpp
+++ b/src/entity/components/copy-translation.hpp
@@ -17,16 +17,17 @@
* along with Antkeeper source code. If not, see .
*/
-#ifndef ANTKEEPER_ECS_COPY_TRANSLATION_COMPONENT_HPP
-#define ANTKEEPER_ECS_COPY_TRANSLATION_COMPONENT_HPP
+#ifndef ANTKEEPER_ENTITY_COMPONENT_COPY_TRANSLATION_HPP
+#define ANTKEEPER_ENTITY_COMPONENT_COPY_TRANSLATION_HPP
-#include "ecs/entity.hpp"
+#include "entity/id.hpp"
-namespace ecs {
+namespace entity {
+namespace component {
-struct copy_translation_component
+struct copy_translation
{
- entity target;
+ entity::id target;
bool use_x;
bool use_y;
bool use_z;
@@ -35,6 +36,7 @@ struct copy_translation_component
bool invert_z;
};
-} // namespace ecs
+} // namespace component
+} // namespace entity
-#endif // ANTKEEPER_ECS_COPY_TRANSLATION_COMPONENT_HPP
+#endif // ANTKEEPER_ENTITY_COMPONENT_COPY_TRANSLATION_HPP
diff --git a/src/ecs/components/diffuse-reflector-component.hpp b/src/entity/components/diffuse-reflector.hpp
similarity index 73%
rename from src/ecs/components/diffuse-reflector-component.hpp
rename to src/entity/components/diffuse-reflector.hpp
index 6b00845..74cde3a 100644
--- a/src/ecs/components/diffuse-reflector-component.hpp
+++ b/src/entity/components/diffuse-reflector.hpp
@@ -17,16 +17,18 @@
* along with Antkeeper source code. If not, see .
*/
-#ifndef ANTKEEPER_ECS_DIFFUSE_REFLECTOR_COMPONENT_HPP
-#define ANTKEEPER_ECS_DIFFUSE_REFLECTOR_COMPONENT_HPP
+#ifndef ANTKEEPER_ENTITY_COMPONENT_DIFFUSE_REFLECTOR_HPP
+#define ANTKEEPER_ENTITY_COMPONENT_DIFFUSE_REFLECTOR_HPP
-namespace ecs {
+namespace entity {
+namespace component {
-struct diffuse_reflector_component
+struct diffuse_reflector
{
double albedo;
};
-} // namespace ecs
+} // namespace component
+} // namespace entity
-#endif // ANTKEEPER_ECS_DIFFUSE_REFLECTOR_COMPONENT_HPP
+#endif // ANTKEEPER_ENTITY_COMPONENT_DIFFUSE_REFLECTOR_HPP
diff --git a/src/ecs/components/light-component.hpp b/src/entity/components/light.hpp
similarity index 80%
rename from src/ecs/components/light-component.hpp
rename to src/entity/components/light.hpp
index 043cc5a..4bfe5a1 100644
--- a/src/ecs/components/light-component.hpp
+++ b/src/entity/components/light.hpp
@@ -17,15 +17,16 @@
* along with Antkeeper source code. If not, see .
*/
-#ifndef ANTKEEPER_ECS_LIGHT_COMPONENT_HPP
-#define ANTKEEPER_ECS_LIGHT_COMPONENT_HPP
+#ifndef ANTKEEPER_ENTITY_COMPONENT_LIGHT_HPP
+#define ANTKEEPER_ENTITY_COMPONENT_LIGHT_HPP
#include "utility/fundamental-types.hpp"
#include "scene/light.hpp"
-namespace ecs {
+namespace entity {
+namespace component {
-struct light_component
+struct light
{
scene::light_type type;
float3 color;
@@ -34,7 +35,8 @@ struct light_component
float2 cutoff;
};
-} // namespace ecs
+} // namespace component
+} // namespace entity
-#endif // ANTKEEPER_ECS_LIGHT_COMPONENT_HPP
+#endif // ANTKEEPER_ENTITY_COMPONENT_LIGHT_HPP
diff --git a/src/ecs/components/locomotion-component.hpp b/src/entity/components/locomotion.hpp
similarity index 78%
rename from src/ecs/components/locomotion-component.hpp
rename to src/entity/components/locomotion.hpp
index 2a09869..8f49130 100644
--- a/src/ecs/components/locomotion-component.hpp
+++ b/src/entity/components/locomotion.hpp
@@ -17,21 +17,23 @@
* along with Antkeeper source code. If not, see .
*/
-#ifndef ANTKEEPER_ECS_PLACEMENT_COMPONENT_HPP
-#define ANTKEEPER_ECS_PLACEMENT_COMPONENT_HPP
+#ifndef ANTKEEPER_ENTITY_COMPONENT_PLACEMENT_HPP
+#define ANTKEEPER_ENTITY_COMPONENT_PLACEMENT_HPP
#include "geom/mesh.hpp"
#include "utility/fundamental-types.hpp"
-namespace ecs {
+namespace entity {
+namespace component {
-struct locomotion_component
+struct locomotion
{
const geom::mesh::face* triangle;
float3 barycentric_position;
};
-} // namespace ecs
+} // namespace component
+} // namespace entity
-#endif // ANTKEEPER_ECS_PLACEMENT_COMPONENT_HPP
+#endif // ANTKEEPER_ENTITY_COMPONENT_PLACEMENT_HPP
diff --git a/src/ecs/components/marker-component.hpp b/src/entity/components/marker.hpp
similarity index 76%
rename from src/ecs/components/marker-component.hpp
rename to src/entity/components/marker.hpp
index b28c292..bcf8a00 100644
--- a/src/ecs/components/marker-component.hpp
+++ b/src/entity/components/marker.hpp
@@ -17,16 +17,18 @@
* along with Antkeeper source code. If not, see .
*/
-#ifndef ANTKEEPER_ECS_MARKER_COMPONENT_HPP
-#define ANTKEEPER_ECS_MARKER_COMPONENT_HPP
+#ifndef ANTKEEPER_ENTITY_COMPONENT_MARKER_HPP
+#define ANTKEEPER_ENTITY_COMPONENT_MARKER_HPP
-namespace ecs {
+namespace entity {
+namespace component {
-struct marker_component
+struct marker
{
int color;
};
-} // namespace ecs
+} // namespace component
+} // namespace entity
-#endif // ANTKEEPER_ECS_MARKER_COMPONENT_HPP
+#endif // ANTKEEPER_ENTITY_COMPONENT_MARKER_HPP
diff --git a/src/ecs/components/model-component.hpp b/src/entity/components/model.hpp
similarity index 78%
rename from src/ecs/components/model-component.hpp
rename to src/entity/components/model.hpp
index 36f436a..eb40f02 100644
--- a/src/ecs/components/model-component.hpp
+++ b/src/entity/components/model.hpp
@@ -17,23 +17,25 @@
* along with Antkeeper source code. If not, see .
*/
-#ifndef ANTKEEPER_ECS_MODEL_COMPONENT_HPP
-#define ANTKEEPER_ECS_MODEL_COMPONENT_HPP
+#ifndef ANTKEEPER_ENTITY_COMPONENT_MODEL_HPP
+#define ANTKEEPER_ENTITY_COMPONENT_MODEL_HPP
#include "renderer/model.hpp"
#include
-namespace ecs {
+namespace entity {
+namespace component {
-struct model_component
+struct model
{
- model* model;
+ ::model* render_model;
std::unordered_map materials;
int instance_count;
unsigned int layers;
};
-} // namespace ecs
+} // namespace component
+} // namespace entity
-#endif // ANTKEEPER_ECS_MODEL_COMPONENT_HPP
+#endif // ANTKEEPER_ENTITY_COMPONENT_MODEL_HPP
diff --git a/src/ecs/components/nest-component.hpp b/src/entity/components/nest.hpp
similarity index 75%
rename from src/ecs/components/nest-component.hpp
rename to src/entity/components/nest.hpp
index a672ba8..9346e90 100644
--- a/src/ecs/components/nest-component.hpp
+++ b/src/entity/components/nest.hpp
@@ -17,23 +17,25 @@
* along with Antkeeper source code. If not, see .
*/
-#ifndef ANTKEEPER_ECS_NEST_COMPONENT_HPP
-#define ANTKEEPER_ECS_NEST_COMPONENT_HPP
+#ifndef ANTKEEPER_ENTITY_COMPONENT_NEST_HPP
+#define ANTKEEPER_ENTITY_COMPONENT_NEST_HPP
#include
-#include "ecs/entity.hpp"
+#include "entity/id.hpp"
-namespace ecs {
+namespace entity {
+namespace component {
-struct nest_component
+struct nest
{
- std::vector chambers;
+ std::vector chambers;
float helix_radius;
float helix_pitch;
float helix_chirality;
float helix_turns;
};
-} // namespace ecs
+} // namespace component
+} // namespace entity
-#endif // ANTKEEPER_ECS_NEST_COMPONENT_HPP
+#endif // ANTKEEPER_ENTITY_COMPONENT_NEST_HPP
diff --git a/src/ecs/components/orbit-component.hpp b/src/entity/components/orbit.hpp
similarity index 79%
rename from src/ecs/components/orbit-component.hpp
rename to src/entity/components/orbit.hpp
index efb1c9e..1d8992d 100644
--- a/src/ecs/components/orbit-component.hpp
+++ b/src/entity/components/orbit.hpp
@@ -17,20 +17,22 @@
* along with Antkeeper source code. If not, see .
*/
-#ifndef ANTKEEPER_ECS_ORBIT_COMPONENT_HPP
-#define ANTKEEPER_ECS_ORBIT_COMPONENT_HPP
+#ifndef ANTKEEPER_ENTITY_COMPONENT_ORBIT_HPP
+#define ANTKEEPER_ENTITY_COMPONENT_ORBIT_HPP
#include "physics/orbit/elements.hpp"
#include "physics/orbit/state.hpp"
-namespace ecs {
+namespace entity {
+namespace component {
-struct orbit_component
+struct orbit
{
physics::orbit::elements elements;
physics::orbit::state state;
};
-} // namespace ecs
+} // namespace component
+} // namespace entity
-#endif // ANTKEEPER_ECS_ORBIT_COMPONENT_HPP
+#endif // ANTKEEPER_ENTITY_COMPONENT_ORBIT_HPP
diff --git a/src/ecs/components/copy-rotation-component.hpp b/src/entity/components/parent.hpp
similarity index 73%
rename from src/ecs/components/copy-rotation-component.hpp
rename to src/entity/components/parent.hpp
index 746eae6..0635e70 100644
--- a/src/ecs/components/copy-rotation-component.hpp
+++ b/src/entity/components/parent.hpp
@@ -17,18 +17,20 @@
* along with Antkeeper source code. If not, see .
*/
-#ifndef ANTKEEPER_ECS_COPY_ROTATION_COMPONENT_HPP
-#define ANTKEEPER_ECS_COPY_ROTATION_COMPONENT_HPP
+#ifndef ANTKEEPER_ENTITY_COMPONENT_PARENT_HPP
+#define ANTKEEPER_ENTITY_COMPONENT_PARENT_HPP
-#include "ecs/entity.hpp"
+#include "entity/id.hpp"
-namespace ecs {
+namespace entity {
+namespace component {
-struct copy_rotation_component
+struct parent
{
- entity target;
+ entity::id parent;
};
-} // namespace ecs
+} // namespace component
+} // namespace entity
-#endif // ANTKEEPER_ECS_COPY_ROTATION_COMPONENT_HPP
+#endif // ANTKEEPER_ENTITY_COMPONENT_PARENT_HPP
diff --git a/src/ecs/components/samara-component.hpp b/src/entity/components/samara.hpp
similarity index 78%
rename from src/ecs/components/samara-component.hpp
rename to src/entity/components/samara.hpp
index 691d45b..75cca63 100644
--- a/src/ecs/components/samara-component.hpp
+++ b/src/entity/components/samara.hpp
@@ -17,21 +17,23 @@
* along with Antkeeper source code. If not, see .
*/
-#ifndef ANTKEEPER_ECS_SAMARA_COMPONENT_HPP
-#define ANTKEEPER_ECS_SAMARA_COMPONENT_HPP
+#ifndef ANTKEEPER_ENTITY_COMPONENT_SAMARA_HPP
+#define ANTKEEPER_ENTITY_COMPONENT_SAMARA_HPP
#include "utility/fundamental-types.hpp"
-namespace ecs {
+namespace entity {
+namespace component {
-struct samara_component
+struct samara
{
float3 direction;
float angle;
float chirality;
};
-} // namespace ecs
+} // namespace component
+} // namespace entity
-#endif // ANTKEEPER_ECS_SAMARA_COMPONENT_HPP
+#endif // ANTKEEPER_ENTITY_COMPONENT_SAMARA_HPP
diff --git a/src/ecs/components/snap-component.hpp b/src/entity/components/snap.hpp
similarity index 79%
rename from src/ecs/components/snap-component.hpp
rename to src/entity/components/snap.hpp
index 491c996..45b1ee1 100644
--- a/src/ecs/components/snap-component.hpp
+++ b/src/entity/components/snap.hpp
@@ -17,14 +17,15 @@
* along with Antkeeper source code. If not, see .
*/
-#ifndef ANTKEEPER_ECS_SNAP_COMPONENT_HPP
-#define ANTKEEPER_ECS_SNAP_COMPONENT_HPP
+#ifndef ANTKEEPER_ENTITY_COMPONENT_SNAP_HPP
+#define ANTKEEPER_ENTITY_COMPONENT_SNAP_HPP
#include "geom/ray.hpp"
-namespace ecs {
+namespace entity {
+namespace component {
-struct snap_component
+struct snap
{
geom::ray ray;
bool relative;
@@ -32,7 +33,8 @@ struct snap_component
bool autoremove;
};
-} // namespace ecs
+} // namespace component
+} // namespace entity
-#endif // ANTKEEPER_ECS_SNAP_COMPONENT_HPP
+#endif // ANTKEEPER_ENTITY_COMPONENT_SNAP_HPP
diff --git a/src/ecs/components/terrain-component.hpp b/src/entity/components/terrain.hpp
similarity index 77%
rename from src/ecs/components/terrain-component.hpp
rename to src/entity/components/terrain.hpp
index 31ac207..be2d00c 100644
--- a/src/ecs/components/terrain-component.hpp
+++ b/src/entity/components/terrain.hpp
@@ -17,19 +17,21 @@
* along with Antkeeper source code. If not, see .
*/
-#ifndef ANTKEEPER_ECS_TERRAIN_COMPONENT_HPP
-#define ANTKEEPER_ECS_TERRAIN_COMPONENT_HPP
+#ifndef ANTKEEPER_ENTITY_COMPONENT_TERRAIN_HPP
+#define ANTKEEPER_ENTITY_COMPONENT_TERRAIN_HPP
-namespace ecs {
+namespace entity {
+namespace component {
-struct terrain_component
+struct terrain
{
int subdivisions;
int x;
int z;
};
-} // namespace ecs
+} // namespace component
+} // namespace entity
-#endif // ANTKEEPER_ECS_TERRAIN_COMPONENT_HPP
+#endif // ANTKEEPER_ENTITY_COMPONENT_TERRAIN_HPP
diff --git a/src/ecs/components/tool-component.hpp b/src/entity/components/tool.hpp
similarity index 79%
rename from src/ecs/components/tool-component.hpp
rename to src/entity/components/tool.hpp
index 29c6343..0bccf6c 100644
--- a/src/ecs/components/tool-component.hpp
+++ b/src/entity/components/tool.hpp
@@ -17,12 +17,13 @@
* along with Antkeeper source code. If not, see .
*/
-#ifndef ANTKEEPER_ECS_TOOL_COMPONENT_HPP
-#define ANTKEEPER_ECS_TOOL_COMPONENT_HPP
+#ifndef ANTKEEPER_ENTITY_COMPONENT_TOOL_HPP
+#define ANTKEEPER_ENTITY_COMPONENT_TOOL_HPP
-namespace ecs {
+namespace entity {
+namespace component {
-struct tool_component
+struct tool
{
bool active;
float idle_distance;
@@ -33,7 +34,8 @@ struct tool_component
//float activation_speed;
};
-} // namespace ecs
+} // namespace component
+} // namespace entity
-#endif // ANTKEEPER_ECS_TOOL_COMPONENT_HPP
+#endif // ANTKEEPER_ENTITY_COMPONENT_TOOL_HPP
diff --git a/src/ecs/components/trackable-component.hpp b/src/entity/components/trackable.hpp
similarity index 76%
rename from src/ecs/components/trackable-component.hpp
rename to src/entity/components/trackable.hpp
index a84b372..6193ba4 100644
--- a/src/ecs/components/trackable-component.hpp
+++ b/src/entity/components/trackable.hpp
@@ -17,18 +17,20 @@
* along with Antkeeper source code. If not, see .
*/
-#ifndef ANTKEEPER_ECS_TRACKABLE_COMPONENT_HPP
-#define ANTKEEPER_ECS_TRACKABLE_COMPONENT_HPP
+#ifndef ANTKEEPER_ENTITY_COMPONENT_TRACKABLE_HPP
+#define ANTKEEPER_ENTITY_COMPONENT_TRACKABLE_HPP
#include "utility/fundamental-types.hpp"
-namespace ecs {
+namespace entity {
+namespace component {
-struct trackable_component
+struct trackable
{
float distance;
};
-} // namespace ecs
+} // namespace component
+} // namespace entity
-#endif // ANTKEEPER_ECS_TRACKABLE_COMPONENT_HPP
+#endif // ANTKEEPER_ENTITY_COMPONENT_TRACKABLE_HPP
diff --git a/src/ecs/components/transform-component.hpp b/src/entity/components/transform.hpp
similarity index 77%
rename from src/ecs/components/transform-component.hpp
rename to src/entity/components/transform.hpp
index 46dc96e..c5f3a86 100644
--- a/src/ecs/components/transform-component.hpp
+++ b/src/entity/components/transform.hpp
@@ -17,21 +17,23 @@
* along with Antkeeper source code. If not, see .
*/
-#ifndef ANTKEEPER_ECS_TRANSFORM_COMPONENT_HPP
-#define ANTKEEPER_ECS_TRANSFORM_COMPONENT_HPP
+#ifndef ANTKEEPER_ENTITY_COMPONENT_TRANSFORM_HPP
+#define ANTKEEPER_ENTITY_COMPONENT_TRANSFORM_HPP
#include "math/math.hpp"
-namespace ecs {
+namespace entity {
+namespace component {
-struct transform_component
+struct transform
{
math::transform local;
math::transform world;
bool warp;
};
-} // namespace ecs
+} // namespace component
+} // namespace entity
-#endif // ANTKEEPER_ECS_TRANSFORM_COMPONENT_HPP
+#endif // ANTKEEPER_ENTITY_COMPONENT_TRANSFORM_HPP
diff --git a/src/ecs/ebt.cpp b/src/entity/ebt.cpp
similarity index 82%
rename from src/ecs/ebt.cpp
rename to src/entity/ebt.cpp
index 41c1044..c4bc7dc 100644
--- a/src/ecs/ebt.cpp
+++ b/src/entity/ebt.cpp
@@ -17,11 +17,11 @@
* along with Antkeeper source code. If not, see .
*/
-#include "ecs/ebt.hpp"
-#include "ecs/components/transform-component.hpp"
+#include "entity/ebt.hpp"
+#include "entity/components/transform.hpp"
#include
-namespace ecs {
+namespace entity {
namespace ebt {
status print(context& context, const std::string& text)
@@ -32,13 +32,13 @@ status print(context& context, const std::string& text)
status print_eid(context& context)
{
- std::cout << static_cast(context.entity) << std::endl;
+ std::cout << static_cast(context.entity_id) << std::endl;
return status::success;
}
status warp_to(context& context, float x, float y, float z)
{
- auto& transform = context.registry->get(context.entity);
+ auto& transform = context.registry->get(context.entity_id);
transform.local.translation = {x, y, z};
transform.warp = true;
return status::success;
@@ -50,4 +50,4 @@ bool is_carrying_food(const context& context)
}
} // namespace ebt
-} // namespace ecs
+} // namespace entity
diff --git a/src/ecs/ebt.hpp b/src/entity/ebt.hpp
similarity index 87%
rename from src/ecs/ebt.hpp
rename to src/entity/ebt.hpp
index 8edfcfb..eeb1da0 100644
--- a/src/ecs/ebt.hpp
+++ b/src/entity/ebt.hpp
@@ -17,14 +17,14 @@
* along with Antkeeper source code. If not, see .
*/
-#ifndef ANTKEEPER_ECS_EBT_HPP
-#define ANTKEEPER_ECS_EBT_HPP
+#ifndef ANTKEEPER_ENTITY_EBT_HPP
+#define ANTKEEPER_ENTITY_EBT_HPP
#include "ai/behavior-tree.hpp"
-#include "ecs/entity.hpp"
-#include "ecs/registry.hpp"
+#include "entity/id.hpp"
+#include "entity/registry.hpp"
-namespace ecs {
+namespace entity {
/// Entity behavior tree (EBT) nodes and context.
namespace ebt {
@@ -34,8 +34,8 @@ namespace ebt {
*/
struct context
{
- ecs::registry* registry;
- ecs::entity entity;
+ entity::registry* registry;
+ entity::id entity_id;
};
typedef ai::bt::status status;
@@ -60,7 +60,7 @@ status warp_to(context& context, float x, float y, float z);
bool is_carrying_food(const context& context);
} // namespace ebt
-} // namespace ecs
+} // namespace entity
-#endif // ANTKEEPER_ECS_EBT_HPP
+#endif // ANTKEEPER_ENTITY_EBT_HPP
diff --git a/src/ecs/ecs.hpp b/src/entity/ecs.hpp
similarity index 87%
rename from src/ecs/ecs.hpp
rename to src/entity/ecs.hpp
index 47ec38b..4becb40 100644
--- a/src/ecs/ecs.hpp
+++ b/src/entity/ecs.hpp
@@ -17,15 +17,15 @@
* along with Antkeeper source code. If not, see .
*/
-#ifndef ANTKEEPER_ECS_HPP
-#define ANTKEEPER_ECS_HPP
+#ifndef ANTKEEPER_ENTITY_HPP
+#define ANTKEEPER_ENTITY_HPP
/// Entity-component-system (ECS)
-namespace ecs {}
+namespace entity {}
#include "archetype.hpp"
#include "commands.hpp"
-#include "entity.hpp"
+#include "id.hpp"
#include "registry.hpp"
-#endif // ANTKEEPER_ECS_HPP
+#endif // ANTKEEPER_ENTITY_HPP
diff --git a/src/ecs/entity.hpp b/src/entity/id.hpp
similarity index 83%
rename from src/ecs/entity.hpp
rename to src/entity/id.hpp
index 966bd4b..b36c51d 100644
--- a/src/ecs/entity.hpp
+++ b/src/entity/id.hpp
@@ -17,16 +17,16 @@
* along with Antkeeper source code. If not, see .
*/
-#ifndef ANTKEEPER_ECS_ENTITY_HPP
-#define ANTKEEPER_ECS_ENTITY_HPP
+#ifndef ANTKEEPER_ENTITY_ID_HPP
+#define ANTKEEPER_ENTITY_ID_HPP
#include
-namespace ecs {
+namespace entity {
/// Entity ID type
-typedef entt::entity entity;
+typedef entt::entity id;
-} // namespace ecs
+} // namespace entity
-#endif // ANTKEEPER_ECS_ENTITY_HPP
+#endif // ANTKEEPER_ENTITY_ID_HPP
diff --git a/src/ecs/registry.hpp b/src/entity/registry.hpp
similarity index 84%
rename from src/ecs/registry.hpp
rename to src/entity/registry.hpp
index 5a50d88..f586002 100644
--- a/src/ecs/registry.hpp
+++ b/src/entity/registry.hpp
@@ -17,16 +17,16 @@
* along with Antkeeper source code. If not, see .
*/
-#ifndef ANTKEEPER_ECS_REGISTRY_HPP
-#define ANTKEEPER_ECS_REGISTRY_HPP
+#ifndef ANTKEEPER_ENTITY_REGISTRY_HPP
+#define ANTKEEPER_ENTITY_REGISTRY_HPP
#include
-namespace ecs {
+namespace entity {
/// Component registry type
typedef entt::registry registry;
-} // namespace ecs
+} // namespace entity
-#endif // ANTKEEPER_ECS_REGISTRY_HPP
+#endif // ANTKEEPER_ENTITY_REGISTRY_HPP
diff --git a/src/ecs/systems/astronomy-system.cpp b/src/entity/systems/astronomy.cpp
similarity index 80%
rename from src/ecs/systems/astronomy-system.cpp
rename to src/entity/systems/astronomy.cpp
index b2b7749..3d60135 100644
--- a/src/ecs/systems/astronomy-system.cpp
+++ b/src/entity/systems/astronomy.cpp
@@ -17,10 +17,10 @@
* along with Antkeeper source code. If not, see .
*/
-#include "ecs/systems/astronomy-system.hpp"
+#include "entity/systems/astronomy.hpp"
#include "astro/apparent-size.hpp"
-#include "ecs/components/blackbody-component.hpp"
-#include "ecs/components/transform-component.hpp"
+#include "entity/components/blackbody.hpp"
+#include "entity/components/transform.hpp"
#include "geom/intersection.hpp"
#include "color/color.hpp"
#include "physics/orbit/orbit.hpp"
@@ -32,7 +32,8 @@
#include "geom/cartesian.hpp"
#include
-namespace ecs {
+namespace entity {
+namespace system {
template
math::vector3 transmittance(T depth_r, T depth_m, T depth_o, const math::vector3& beta_r, const math::vector3& beta_m)
@@ -49,8 +50,8 @@ math::vector3 transmittance(T depth_r, T depth_m, T depth_o, const math::vect
return t;
}
-astronomy_system::astronomy_system(ecs::registry& registry):
- entity_system(registry),
+astronomy::astronomy(entity::registry& registry):
+ updatable(registry),
universal_time(0.0),
time_scale(1.0),
reference_entity(entt::null),
@@ -75,11 +76,11 @@ astronomy_system::astronomy_system(ecs::registry& registry):
// Construct reference frame which transforms coordinates from EZS to SEZ
ezs_to_sez = sez_to_ezs.inverse();
- registry.on_construct().connect<&astronomy_system::on_celestial_body_construct>(this);
- registry.on_replace().connect<&astronomy_system::on_celestial_body_replace>(this);
+ registry.on_construct().connect<&astronomy::on_celestial_body_construct>(this);
+ registry.on_replace().connect<&astronomy::on_celestial_body_replace>(this);
}
-void astronomy_system::update(double t, double dt)
+void astronomy::update(double t, double dt)
{
// Add scaled timestep to current time
set_universal_time(universal_time + dt * time_scale);
@@ -104,8 +105,8 @@ void astronomy_system::update(double t, double dt)
inertial_to_topocentric = inertial_to_bcbf * bcbf_to_topocentric;
// Set the transform component translations of orbiting bodies to their topocentric positions
- registry.view().each(
- [&](ecs::entity entity, const auto& celestial_body, const auto& orbit, auto& transform)
+ registry.view().each(
+ [&](entity::id entity_id, const auto& celestial_body, const auto& orbit, auto& transform)
{
// Transform Cartesian position vector (r) from inertial space to topocentric space
const math::vector3 r_topocentric = inertial_to_topocentric * orbit.state.r;
@@ -115,8 +116,8 @@ void astronomy_system::update(double t, double dt)
});
// Update blackbody lighting
- registry.view().each(
- [&](ecs::entity entity, const auto& celestial_body, const auto& orbit, const auto& blackbody)
+ registry.view().each(
+ [&](entity::id entity_id, const auto& celestial_body, const auto& orbit, const auto& blackbody)
{
// Calculate blackbody inertial basis
double3 blackbody_forward_inertial = math::normalize(reference_orbit->state.r - orbit.state.r);
@@ -219,67 +220,67 @@ void astronomy_system::update(double t, double dt)
}
}
-void astronomy_system::set_universal_time(double time)
+void astronomy::set_universal_time(double time)
{
universal_time = time;
}
-void astronomy_system::set_time_scale(double scale)
+void astronomy::set_time_scale(double scale)
{
time_scale = scale;
}
-void astronomy_system::set_reference_body(ecs::entity entity)
+void astronomy::set_reference_body(entity::id entity_id)
{
- reference_entity = entity;
+ reference_entity = entity_id;
reference_orbit = nullptr;
reference_body = nullptr;
reference_atmosphere = nullptr;
if (reference_entity != entt::null)
{
- if (registry.has(reference_entity))
- reference_orbit = ®istry.get(reference_entity);
+ if (registry.has(reference_entity))
+ reference_orbit = ®istry.get(reference_entity);
- if (registry.has(reference_entity))
- reference_body = ®istry.get(reference_entity);
+ if (registry.has(reference_entity))
+ reference_body = ®istry.get(reference_entity);
- if (registry.has(reference_entity))
- reference_atmosphere = ®istry.get(reference_entity);
+ if (registry.has(reference_entity))
+ reference_atmosphere = ®istry.get(reference_entity);
}
update_bcbf_to_topocentric();
}
-void astronomy_system::set_observer_location(const double3& location)
+void astronomy::set_observer_location(const double3& location)
{
observer_location = location;
update_bcbf_to_topocentric();
}
-void astronomy_system::set_sun_light(scene::directional_light* light)
+void astronomy::set_sun_light(scene::directional_light* light)
{
sun_light = light;
}
-void astronomy_system::set_sky_pass(::sky_pass* pass)
+void astronomy::set_sky_pass(::sky_pass* pass)
{
this->sky_pass = pass;
}
-void astronomy_system::on_celestial_body_construct(ecs::registry& registry, ecs::entity entity, ecs::celestial_body_component& celestial_body)
+void astronomy::on_celestial_body_construct(entity::registry& registry, entity::id entity_id, entity::component::celestial_body& celestial_body)
{
- if (entity == reference_entity)
+ if (entity_id == reference_entity)
update_bcbf_to_topocentric();
}
-void astronomy_system::on_celestial_body_replace(ecs::registry& registry, ecs::entity entity, ecs::celestial_body_component& celestial_body)
+void astronomy::on_celestial_body_replace(entity::registry& registry, entity::id entity_id, entity::component::celestial_body& celestial_body)
{
- if (entity == reference_entity)
+ if (entity_id == reference_entity)
update_bcbf_to_topocentric();
}
-void astronomy_system::update_bcbf_to_topocentric()
+void astronomy::update_bcbf_to_topocentric()
{
double radial_distance = observer_location[0];
@@ -297,4 +298,5 @@ void astronomy_system::update_bcbf_to_topocentric()
) * sez_to_ezs;
}
-} // namespace ecs
+} // namespace system
+} // namespace entity
diff --git a/src/ecs/systems/astronomy-system.hpp b/src/entity/systems/astronomy.hpp
similarity index 71%
rename from src/ecs/systems/astronomy-system.hpp
rename to src/entity/systems/astronomy.hpp
index f57bfd4..60d37b1 100644
--- a/src/ecs/systems/astronomy-system.hpp
+++ b/src/entity/systems/astronomy.hpp
@@ -17,29 +17,30 @@
* along with Antkeeper source code. If not, see .
*/
-#ifndef ANTKEEPER_ECS_ASTRONOMY_SYSTEM_HPP
-#define ANTKEEPER_ECS_ASTRONOMY_SYSTEM_HPP
+#ifndef ANTKEEPER_ENTITY_SYSTEM_ASTRONOMY_HPP
+#define ANTKEEPER_ENTITY_SYSTEM_ASTRONOMY_HPP
-#include "entity-system.hpp"
-#include "ecs/entity.hpp"
+#include "entity/systems/updatable.hpp"
+#include "entity/id.hpp"
#include "scene/directional-light.hpp"
#include "utility/fundamental-types.hpp"
#include "physics/frame.hpp"
#include "renderer/passes/sky-pass.hpp"
-#include "ecs/components/atmosphere-component.hpp"
-#include "ecs/components/celestial-body-component.hpp"
-#include "ecs/components/orbit-component.hpp"
+#include "entity/components/atmosphere.hpp"
+#include "entity/components/celestial-body.hpp"
+#include "entity/components/orbit.hpp"
-namespace ecs {
+namespace entity {
+namespace system {
/**
* Calculates apparent properties of celestial bodies relative to an observer.
*/
-class astronomy_system:
- public entity_system
+class astronomy:
+ public updatable
{
public:
- astronomy_system(ecs::registry& registry);
+ astronomy(entity::registry& registry);
/**
* Scales then adds the timestep `dt` to the current time, then recalculates the positions of celestial bodies.
@@ -68,7 +69,7 @@ public:
*
* @param entity Entity of the reference body.
*/
- void set_reference_body(ecs::entity entity);
+ void set_reference_body(entity::id entity_id);
/**
* Sets the location of the observer using spherical coordinates in BCBF space.
@@ -82,18 +83,18 @@ public:
void set_sky_pass(sky_pass* pass);
private:
- void on_celestial_body_construct(ecs::registry& registry, ecs::entity entity, ecs::celestial_body_component& celestial_body);
- void on_celestial_body_replace(ecs::registry& registry, ecs::entity entity, ecs::celestial_body_component& celestial_body);
+ void on_celestial_body_construct(entity::registry& registry, entity::id entity_id, entity::component::celestial_body& celestial_body);
+ void on_celestial_body_replace(entity::registry& registry, entity::id entity_id, entity::component::celestial_body& celestial_body);
void update_bcbf_to_topocentric();
double universal_time;
double time_scale;
- ecs::entity reference_entity;
- const ecs::orbit_component* reference_orbit;
- const ecs::celestial_body_component* reference_body;
- const ecs::atmosphere_component* reference_atmosphere;
+ entity::id reference_entity;
+ const entity::component::orbit* reference_orbit;
+ const entity::component::celestial_body* reference_body;
+ const entity::component::atmosphere* reference_atmosphere;
double3 observer_location;
@@ -107,6 +108,7 @@ private:
sky_pass* sky_pass;
};
-} // namespace ecs
+} // namespace system
+} // namespace entity
-#endif // ANTKEEPER_ECS_ASTRONOMY_SYSTEM_HPP
+#endif // ANTKEEPER_ENTITY_SYSTEM_ASTRONOMY_HPP
diff --git a/src/ecs/systems/atmosphere-system.cpp b/src/entity/systems/atmosphere.cpp
similarity index 66%
rename from src/ecs/systems/atmosphere-system.cpp
rename to src/entity/systems/atmosphere.cpp
index a912d5b..8d3b15b 100644
--- a/src/ecs/systems/atmosphere-system.cpp
+++ b/src/entity/systems/atmosphere.cpp
@@ -17,37 +17,38 @@
* along with Antkeeper source code. If not, see .
*/
-#include "ecs/systems/atmosphere-system.hpp"
+#include "entity/systems/atmosphere.hpp"
#include "physics/atmosphere.hpp"
-namespace ecs {
+namespace entity {
+namespace system {
-atmosphere_system::atmosphere_system(ecs::registry& registry):
- entity_system(registry),
+atmosphere::atmosphere(entity::registry& registry):
+ updatable(registry),
rgb_wavelengths_nm{0, 0, 0},
rgb_wavelengths_m{0, 0, 0}
{
- registry.on_construct().connect<&atmosphere_system::on_atmosphere_construct>(this);
- registry.on_replace().connect<&atmosphere_system::on_atmosphere_replace>(this);
+ registry.on_construct().connect<&atmosphere::on_atmosphere_construct>(this);
+ registry.on_replace().connect<&atmosphere::on_atmosphere_replace>(this);
}
-void atmosphere_system::update(double t, double dt)
+void atmosphere::update(double t, double dt)
{}
-void atmosphere_system::set_rgb_wavelengths(const double3& wavelengths)
+void atmosphere::set_rgb_wavelengths(const double3& wavelengths)
{
rgb_wavelengths_nm = wavelengths;
rgb_wavelengths_m = wavelengths * 1e-9;
}
-void atmosphere_system::update_coefficients(ecs::entity entity)
+void atmosphere::update_coefficients(entity::id entity_id)
{
// Abort if entity has no atmosphere component
- if (!registry.has(entity))
+ if (!registry.has(entity_id))
return;
// Get atmosphere component of the entity
- atmosphere_component& atmosphere = registry.get(entity);
+ component::atmosphere& atmosphere = registry.get(entity_id);
// Calculate polarization factors
const double rayleigh_polarization = physics::atmosphere::polarization(atmosphere.index_of_refraction, atmosphere.rayleigh_density);
@@ -71,14 +72,15 @@ void atmosphere_system::update_coefficients(ecs::entity entity)
};
}
-void atmosphere_system::on_atmosphere_construct(ecs::registry& registry, ecs::entity entity, ecs::atmosphere_component& atmosphere)
+void atmosphere::on_atmosphere_construct(entity::registry& registry, entity::id entity_id, entity::component::atmosphere& atmosphere)
{
- update_coefficients(entity);
+ update_coefficients(entity_id);
}
-void atmosphere_system::on_atmosphere_replace(ecs::registry& registry, ecs::entity entity, ecs::atmosphere_component& atmosphere)
+void atmosphere::on_atmosphere_replace(entity::registry& registry, entity::id entity_id, entity::component::atmosphere& atmosphere)
{
- update_coefficients(entity);
+ update_coefficients(entity_id);
}
-} // namespace ecs
+} // namespace system
+} // namespace entity
diff --git a/src/ecs/systems/atmosphere-system.hpp b/src/entity/systems/atmosphere.hpp
similarity index 64%
rename from src/ecs/systems/atmosphere-system.hpp
rename to src/entity/systems/atmosphere.hpp
index 442287c..03e600b 100644
--- a/src/ecs/systems/atmosphere-system.hpp
+++ b/src/entity/systems/atmosphere.hpp
@@ -17,24 +17,25 @@
* along with Antkeeper source code. If not, see .
*/
-#ifndef ANTKEEPER_ECS_ATMOSPHERE_SYSTEM_HPP
-#define ANTKEEPER_ECS_ATMOSPHERE_SYSTEM_HPP
+#ifndef ANTKEEPER_ENTITY_SYSTEM_ATMOSPHERE_HPP
+#define ANTKEEPER_ENTITY_SYSTEM_ATMOSPHERE_HPP
-#include "entity-system.hpp"
-#include "ecs/entity.hpp"
+#include "entity/systems/updatable.hpp"
+#include "entity/id.hpp"
#include "utility/fundamental-types.hpp"
-#include "ecs/components/atmosphere-component.hpp"
+#include "entity/components/atmosphere.hpp"
-namespace ecs {
+namespace entity {
+namespace system {
/**
* Updates variables related to atmospheric scattering.
*/
-class atmosphere_system:
- public entity_system
+class atmosphere:
+ public updatable
{
public:
- atmosphere_system(ecs::registry& registry);
+ atmosphere(entity::registry& registry);
virtual void update(double t, double dt);
@@ -46,15 +47,16 @@ public:
void set_rgb_wavelengths(const double3& wavelengths);
private:
- void update_coefficients(ecs::entity entity);
+ void update_coefficients(entity::id entity_id);
- void on_atmosphere_construct(ecs::registry& registry, ecs::entity entity, ecs::atmosphere_component& atmosphere);
- void on_atmosphere_replace(ecs::registry& registry, ecs::entity entity, ecs::atmosphere_component& atmosphere);
+ void on_atmosphere_construct(entity::registry& registry, entity::id entity_id, entity::component::atmosphere& atmosphere);
+ void on_atmosphere_replace(entity::registry& registry, entity::id entity_id, entity::component::atmosphere& atmosphere);
double3 rgb_wavelengths_nm;
double3 rgb_wavelengths_m;
};
-} // namespace ecs
+} // namespace system
+} // namespace entity
-#endif // ANTKEEPER_ECS_ATMOSPHERE_SYSTEM_HPP
+#endif // ANTKEEPER_ENTITY_SYSTEM_ATMOSPHERE_HPP
diff --git a/src/ecs/systems/behavior-system.cpp b/src/entity/systems/behavior.cpp
similarity index 69%
rename from src/ecs/systems/behavior-system.cpp
rename to src/entity/systems/behavior.cpp
index 485c491..7635516 100644
--- a/src/ecs/systems/behavior-system.cpp
+++ b/src/entity/systems/behavior.cpp
@@ -17,30 +17,32 @@
* along with Antkeeper source code. If not, see .
*/
-#include "ecs/systems/behavior-system.hpp"
-#include "ecs/components/behavior-component.hpp"
-#include "ecs/entity.hpp"
+#include "entity/systems/behavior.hpp"
+#include "entity/components/behavior.hpp"
+#include "entity/id.hpp"
-namespace ecs {
+namespace entity {
+namespace system {
-behavior_system::behavior_system(ecs::registry& registry):
- entity_system(registry)
+behavior::behavior(entity::registry& registry):
+ updatable(registry)
{}
-void behavior_system::update(double t, double dt)
+void behavior::update(double t, double dt)
{
ebt::context context;
context.registry = ®istry;
- registry.view().each(
- [&](ecs::entity entity, auto& behavior)
+ registry.view().each(
+ [&](entity::id entity_id, auto& behavior)
{
if (behavior.behavior_tree)
{
- context.entity = entity;
+ context.entity_id = entity_id;
behavior.behavior_tree->execute(context);
}
});
}
-} // namespace ecs
+} // namespace system
+} // namespace entity
diff --git a/src/ecs/systems/snapping-system.hpp b/src/entity/systems/behavior.hpp
similarity index 71%
rename from src/ecs/systems/snapping-system.hpp
rename to src/entity/systems/behavior.hpp
index a7279c6..68aae7a 100644
--- a/src/ecs/systems/snapping-system.hpp
+++ b/src/entity/systems/behavior.hpp
@@ -17,22 +17,24 @@
* along with Antkeeper source code. If not, see .
*/
-#ifndef ANTKEEPER_ECS_SNAPPING_SYSTEM_HPP
-#define ANTKEEPER_ECS_SNAPPING_SYSTEM_HPP
+#ifndef ANTKEEPER_ENTITY_SYSTEM_BEHAVIOR_HPP
+#define ANTKEEPER_ENTITY_SYSTEM_BEHAVIOR_HPP
-#include "entity-system.hpp"
+#include "entity/systems/updatable.hpp"
-namespace ecs {
+namespace entity {
+namespace system {
-class snapping_system:
- public entity_system
+class behavior:
+ public updatable
{
public:
- snapping_system(ecs::registry& registry);
+ behavior(entity::registry& registry);
virtual void update(double t, double dt);
};
-} // namespace ecs
+} // namespace system
+} // namespace entity
-#endif // ANTKEEPER_ECS_SNAPPING_SYSTEM_HPP
+#endif // ANTKEEPER_ENTITY_SYSTEM_BEHAVIOR_HPP
diff --git a/src/ecs/systems/blackbody-system.cpp b/src/entity/systems/blackbody.cpp
similarity index 61%
rename from src/ecs/systems/blackbody-system.cpp
rename to src/entity/systems/blackbody.cpp
index c9f7631..285427d 100644
--- a/src/ecs/systems/blackbody-system.cpp
+++ b/src/entity/systems/blackbody.cpp
@@ -17,16 +17,17 @@
* along with Antkeeper source code. If not, see .
*/
-#include "ecs/systems/blackbody-system.hpp"
+#include "entity/systems/blackbody.hpp"
#include "color/color.hpp"
#include "physics/light/blackbody.hpp"
#include "physics/light/photometry.hpp"
#include "math/quadrature.hpp"
-namespace ecs {
+namespace entity {
+namespace system {
-blackbody_system::blackbody_system(ecs::registry& registry):
- entity_system(registry),
+blackbody::blackbody(entity::registry& registry):
+ updatable(registry),
rgb_wavelengths_nm{0, 0, 0},
rgb_wavelengths_m{0, 0, 0}
{
@@ -34,40 +35,40 @@ blackbody_system::blackbody_system(ecs::registry& registry):
visible_wavelengths_nm.resize(780 - 280);
std::iota(visible_wavelengths_nm.begin(), visible_wavelengths_nm.end(), 280);
- registry.on_construct().connect<&blackbody_system::on_blackbody_construct>(this);
- registry.on_replace().connect<&blackbody_system::on_blackbody_replace>(this);
+ registry.on_construct().connect<&blackbody::on_blackbody_construct>(this);
+ registry.on_replace().connect<&blackbody::on_blackbody_replace>(this);
- registry.on_construct().connect<&blackbody_system::on_celestial_body_construct>(this);
- registry.on_replace().connect<&blackbody_system::on_celestial_body_replace>(this);
+ registry.on_construct().connect<&blackbody::on_celestial_body_construct>(this);
+ registry.on_replace().connect<&blackbody::on_celestial_body_replace>(this);
}
-void blackbody_system::update(double t, double dt)
+void blackbody::update(double t, double dt)
{}
-void blackbody_system::set_rgb_wavelengths(const double3& wavelengths)
+void blackbody::set_rgb_wavelengths(const double3& wavelengths)
{
rgb_wavelengths_nm = wavelengths;
rgb_wavelengths_m = wavelengths * 1e-9;
}
-void blackbody_system::update_luminous_intensity(ecs::entity entity)
+void blackbody::update_luminous_intensity(entity::id entity_id)
{
// Abort if entity has no blackbody component
- if (!registry.has(entity))
+ if (!registry.has(entity_id))
return;
// Get blackbody component of the entity
- blackbody_component& blackbody = registry.get(entity);
+ component::blackbody& blackbody = registry.get(entity_id);
// Clear luminous intensity
blackbody.luminous_intensity = {0, 0, 0};
// Abort if entity has no celestial body component
- if (!registry.has(entity))
+ if (!registry.has(entity_id))
return;
// Get celestial body component of the entity
- const celestial_body_component& celestial_body = registry.get(entity);
+ const component::celestial_body& celestial_body = registry.get(entity_id);
// Calculate (spherical) surface area of the celestial body
const double surface_area = 4.0 * math::pi * celestial_body.radius * celestial_body.radius;
@@ -92,24 +93,25 @@ void blackbody_system::update_luminous_intensity(ecs::entity entity)
blackbody.luminous_intensity = math::quadrature::simpson(rgb_luminous_intensity, visible_wavelengths_nm.begin(), visible_wavelengths_nm.end());
}
-void blackbody_system::on_blackbody_construct(ecs::registry& registry, ecs::entity entity, ecs::blackbody_component& blackbody)
+void blackbody::on_blackbody_construct(entity::registry& registry, entity::id entity_id, entity::component::blackbody& blackbody)
{
- update_luminous_intensity(entity);
+ update_luminous_intensity(entity_id);
}
-void blackbody_system::on_blackbody_replace(ecs::registry& registry, ecs::entity entity, ecs::blackbody_component& blackbody)
+void blackbody::on_blackbody_replace(entity::registry& registry, entity::id entity_id, entity::component::blackbody& blackbody)
{
- update_luminous_intensity(entity);
+ update_luminous_intensity(entity_id);
}
-void blackbody_system::on_celestial_body_construct(ecs::registry& registry, ecs::entity entity, ecs::celestial_body_component& celestial_body)
+void blackbody::on_celestial_body_construct(entity::registry& registry, entity::id entity_id, entity::component::celestial_body& celestial_body)
{
- update_luminous_intensity(entity);
+ update_luminous_intensity(entity_id);
}
-void blackbody_system::on_celestial_body_replace(ecs::registry& registry, ecs::entity entity, ecs::celestial_body_component& celestial_body)
+void blackbody::on_celestial_body_replace(entity::registry& registry, entity::id entity_id, entity::component::celestial_body& celestial_body)
{
- update_luminous_intensity(entity);
+ update_luminous_intensity(entity_id);
}
-} // namespace ecs
+} // namespace system
+} // namespace entity
diff --git a/src/ecs/systems/blackbody-system.hpp b/src/entity/systems/blackbody.hpp
similarity index 56%
rename from src/ecs/systems/blackbody-system.hpp
rename to src/entity/systems/blackbody.hpp
index 1c55ca2..8439f9b 100644
--- a/src/ecs/systems/blackbody-system.hpp
+++ b/src/entity/systems/blackbody.hpp
@@ -17,26 +17,27 @@
* along with Antkeeper source code. If not, see .
*/
-#ifndef ANTKEEPER_ECS_BLACKBODY_SYSTEM_HPP
-#define ANTKEEPER_ECS_BLACKBODY_SYSTEM_HPP
+#ifndef ANTKEEPER_ENTITY_SYSTEM_BLACKBODY_HPP
+#define ANTKEEPER_ENTITY_SYSTEM_BLACKBODY_HPP
-#include "entity-system.hpp"
-#include "ecs/entity.hpp"
+#include "entity/systems/updatable.hpp"
+#include "entity/id.hpp"
#include "utility/fundamental-types.hpp"
-#include "ecs/components/blackbody-component.hpp"
-#include "ecs/components/celestial-body-component.hpp"
+#include "entity/components/blackbody.hpp"
+#include "entity/components/celestial-body.hpp"
#include
-namespace ecs {
+namespace entity {
+namespace system {
/**
* Calculates the RGB luminous intensity of blackbody radiators.
*/
-class blackbody_system:
- public entity_system
+class blackbody:
+ public updatable
{
public:
- blackbody_system(ecs::registry& registry);
+ blackbody(entity::registry& registry);
virtual void update(double t, double dt);
@@ -48,19 +49,20 @@ public:
void set_rgb_wavelengths(const double3& wavelengths);
private:
- void update_luminous_intensity(ecs::entity entity);
+ void update_luminous_intensity(entity::id entity_id);
- void on_blackbody_construct(ecs::registry& registry, ecs::entity entity, ecs::blackbody_component& blackbody);
- void on_blackbody_replace(ecs::registry& registry, ecs::entity entity, ecs::blackbody_component& blackbody);
+ void on_blackbody_construct(entity::registry& registry, entity::id entity_id, entity::component::blackbody& blackbody);
+ void on_blackbody_replace(entity::registry& registry, entity::id entity_id, entity::component::blackbody& blackbody);
- void on_celestial_body_construct(ecs::registry& registry, ecs::entity entity, ecs::celestial_body_component& celestial_body);
- void on_celestial_body_replace(ecs::registry& registry, ecs::entity entity, ecs::celestial_body_component& celestial_body);
+ void on_celestial_body_construct(entity::registry& registry, entity::id entity_id, entity::component::celestial_body& celestial_body);
+ void on_celestial_body_replace(entity::registry& registry, entity::id entity_id, entity::component::celestial_body& celestial_body);
double3 rgb_wavelengths_nm;
double3 rgb_wavelengths_m;
std::vector visible_wavelengths_nm;
};
-} // namespace ecs
+} // namespace system
+} // namespace entity
-#endif // ANTKEEPER_ECS_BLACKBODY_SYSTEM_HPP
+#endif // ANTKEEPER_ENTITY_SYSTEM_BLACKBODY_HPP
diff --git a/src/ecs/systems/camera-system.cpp b/src/entity/systems/camera.cpp
similarity index 74%
rename from src/ecs/systems/camera-system.cpp
rename to src/entity/systems/camera.cpp
index 0445007..260b36b 100644
--- a/src/ecs/systems/camera-system.cpp
+++ b/src/entity/systems/camera.cpp
@@ -17,19 +17,20 @@
* along with Antkeeper source code. If not, see .
*/
-#include "camera-system.hpp"
-#include "ecs/components/camera-follow-component.hpp"
-#include "ecs/components/transform-component.hpp"
-#include "ecs/entity.hpp"
+#include "camera.hpp"
+#include "entity/components/camera-follow.hpp"
+#include "entity/components/transform.hpp"
+#include "entity/id.hpp"
#include "math/math.hpp"
#include
#include
-namespace ecs {
+namespace entity {
+namespace system {
-camera_system::camera_system(ecs::registry& registry):
- entity_system(registry),
- camera(nullptr),
+camera::camera(entity::registry& registry):
+ updatable(registry),
+ active_camera(nullptr),
viewport{0, 0, 0, 0},
mouse_position{0, 0}
{
@@ -53,16 +54,16 @@ camera_system::camera_system(ecs::registry& registry):
orbit_cam.reset_springs();
}
-void camera_system::update(double t, double dt)
+void camera::update(double t, double dt)
{
- if (!camera)
+ if (!active_camera)
return;
// Determine target focal point
int subject_count = 0;
float3 target_focal_point = {0, 0, 0};
- registry.view().each(
- [&](ecs::entity entity, auto& follow, auto& transform)
+ registry.view().each(
+ [&](entity::id entity_id, auto& follow, auto& transform)
{
target_focal_point += transform.local.translation;
++subject_count;
@@ -80,27 +81,27 @@ void camera_system::update(double t, double dt)
orbit_cam.update(static_cast(dt));
}
-void camera_system::pan(float angle)
+void camera::pan(float angle)
{
orbit_cam.pan(angle);
}
-void camera_system::tilt(float angle)
+void camera::tilt(float angle)
{
orbit_cam.tilt(angle);
}
-void camera_system::zoom(float factor)
+void camera::zoom(float factor)
{
orbit_cam.zoom(factor);
}
-void camera_system::set_camera(scene::camera* camera)
+void camera::set_camera(scene::camera* active_camera)
{
- this->camera = camera;
- if (camera)
+ this->active_camera = active_camera;
+ if (active_camera)
{
- orbit_cam.attach(camera);
+ orbit_cam.attach(active_camera);
}
else
{
@@ -108,21 +109,22 @@ void camera_system::set_camera(scene::camera* camera)
}
}
-void camera_system::set_viewport(const float4& viewport)
+void camera::set_viewport(const float4& viewport)
{
this->viewport = viewport;
orbit_cam.set_aspect_ratio(viewport[2] / viewport[3]);
}
-void camera_system::handle_event(const mouse_moved_event& event)
+void camera::handle_event(const mouse_moved_event& event)
{
mouse_position[0] = event.x;
mouse_position[1] = event.y;
}
-void camera_system::handle_event(const window_resized_event& event)
+void camera::handle_event(const window_resized_event& event)
{
set_viewport({0.0f, 0.0f, static_cast(event.w), static_cast(event.h)});
}
-} // namespace ecs
+} // namespace system
+} // namespace entity
diff --git a/src/ecs/systems/camera-system.hpp b/src/entity/systems/camera.hpp
similarity index 76%
rename from src/ecs/systems/camera-system.hpp
rename to src/entity/systems/camera.hpp
index f77cdc0..9d5e172 100644
--- a/src/ecs/systems/camera-system.hpp
+++ b/src/entity/systems/camera.hpp
@@ -17,10 +17,10 @@
* along with Antkeeper source code. If not, see .
*/
-#ifndef ANTKEEPER_ECS_CAMERA_SYSTEM_HPP
-#define ANTKEEPER_ECS_CAMERA_SYSTEM_HPP
+#ifndef ANTKEEPER_ENTITY_SYSTEM_CAMERA_HPP
+#define ANTKEEPER_ENTITY_SYSTEM_CAMERA_HPP
-#include "entity-system.hpp"
+#include "entity/systems/updatable.hpp"
#include "event/event-handler.hpp"
#include "event/input-events.hpp"
#include "event/window-events.hpp"
@@ -32,10 +32,11 @@
class orbit_cam;
-namespace ecs {
+namespace entity {
+namespace system {
-class camera_system:
- public entity_system,
+class camera:
+ public updatable,
public event_handler,
public event_handler
{
@@ -43,14 +44,14 @@ public:
typedef math::quaternion quaternion_type;
typedef math::transform transform_type;
- camera_system(ecs::registry& registry);
+ camera(entity::registry& registry);
virtual void update(double t, double dt);
void pan(float angle);
void tilt(float angle);
void zoom(float factor);
- void set_camera(scene::camera* camera);
+ void set_camera(scene::camera* active_camera);
void set_viewport(const float4& viewport);
const orbit_cam* get_orbit_cam() const;
@@ -62,29 +63,30 @@ private:
virtual void handle_event(const mouse_moved_event& event);
virtual void handle_event(const window_resized_event& event);
- scene::camera* camera;
+ scene::camera* active_camera;
float4 viewport;
float2 mouse_position;
orbit_cam orbit_cam;
};
-inline const orbit_cam* camera_system::get_orbit_cam() const
+inline const orbit_cam* camera::get_orbit_cam() const
{
return &orbit_cam;
}
-inline orbit_cam* camera_system::get_orbit_cam()
+inline orbit_cam* camera::get_orbit_cam()
{
return &orbit_cam;
}
-inline scene::camera* camera_system::get_camera()
+inline scene::camera* camera::get_camera()
{
- return camera;
+ return active_camera;
}
-} // namespace ecs
+} // namespace system
+} // namespace entity
-#endif // ANTKEEPER_ECS_CAMERA_SYSTEM_HPP
+#endif // ANTKEEPER_ENTITY_SYSTEM_CAMERA_HPP
diff --git a/src/entity/systems/collision.cpp b/src/entity/systems/collision.cpp
new file mode 100644
index 0000000..6d2b8de
--- /dev/null
+++ b/src/entity/systems/collision.cpp
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2021 Christopher J. Howard
+ *
+ * This file is part of Antkeeper source code.
+ *
+ * Antkeeper source code is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Antkeeper source code is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Antkeeper source code. If not, see .
+ */
+
+#include "collision.hpp"
+#include "entity/components/transform.hpp"
+
+namespace entity {
+namespace system {
+
+collision::collision(entity::registry& registry):
+ updatable(registry)
+{
+ registry.on_construct().connect<&collision::on_collision_construct>(this);
+ registry.on_replace().connect<&collision::on_collision_replace>(this);
+ registry.on_destroy().connect<&collision::on_collision_destroy>(this);
+}
+
+void collision::update(double t, double dt)
+{}
+
+void collision::on_collision_construct(entity::registry& registry, entity::id entity_id, component::collision& collision)
+{}
+
+void collision::on_collision_replace(entity::registry& registry, entity::id entity_id, component::collision& collision)
+{}
+
+void collision::on_collision_destroy(entity::registry& registry, entity::id entity_id)
+{}
+
+} // namespace system
+} // namespace entity
diff --git a/src/ecs/systems/collision-system.hpp b/src/entity/systems/collision.hpp
similarity index 58%
rename from src/ecs/systems/collision-system.hpp
rename to src/entity/systems/collision.hpp
index 3f35f98..8d81a00 100644
--- a/src/ecs/systems/collision-system.hpp
+++ b/src/entity/systems/collision.hpp
@@ -17,31 +17,33 @@
* along with Antkeeper source code. If not, see .
*/
-#ifndef ANTKEEPER_ECS_COLLISION_SYSTEM_HPP
-#define ANTKEEPER_ECS_COLLISION_SYSTEM_HPP
+#ifndef ANTKEEPER_ENTITY_SYSTEM_COLLISION_HPP
+#define ANTKEEPER_ENTITY_SYSTEM_COLLISION_HPP
-#include "entity-system.hpp"
-#include "ecs/entity.hpp"
-#include "ecs/components/collision-component.hpp"
+#include "entity/systems/updatable.hpp"
+#include "entity/id.hpp"
+#include "entity/components/collision.hpp"
-namespace ecs {
+namespace entity {
+namespace system {
/**
* Maintains a spatially partitioned set of collision meshes. The set of collision meshes isnot owned by the collision system, so it can be accessed by other systems as well.
*/
-class collision_system: public entity_system
+class collision: public updatable
{
public:
- collision_system(ecs::registry& registry);
+ collision(entity::registry& registry);
virtual void update(double t, double dt);
private:
- void on_collision_construct(ecs::registry& registry, ecs::entity entity, ecs::collision_component& collision);
- void on_collision_replace(ecs::registry& registry, ecs::entity entity, ecs::collision_component& collision);
- void on_collision_destroy(ecs::registry& registry, ecs::entity entity);
+ void on_collision_construct(entity::registry& registry, entity::id entity_id, entity::component::collision& collision);
+ void on_collision_replace(entity::registry& registry, entity::id entity_id, entity::component::collision& collision);
+ void on_collision_destroy(entity::registry& registry, entity::id entity_id);
};
-} // namespace ecs
+} // namespace system
+} // namespace entity
-#endif // ANTKEEPER_ECS_COLLISION_SYSTEM_HPP
+#endif // ANTKEEPER_ENTITY_SYSTEM_COLLISION_HPP
diff --git a/src/ecs/systems/constraint-system.cpp b/src/entity/systems/constraint.cpp
similarity index 60%
rename from src/ecs/systems/constraint-system.cpp
rename to src/entity/systems/constraint.cpp
index 021ab70..a025b03 100644
--- a/src/ecs/systems/constraint-system.cpp
+++ b/src/entity/systems/constraint.cpp
@@ -17,30 +17,31 @@
* along with Antkeeper source code. If not, see .
*/
-#include "constraint-system.hpp"
-#include "ecs/components/copy-translation-component.hpp"
-#include "ecs/components/copy-rotation-component.hpp"
-#include "ecs/components/copy-scale-component.hpp"
-#include "ecs/components/copy-transform-component.hpp"
-#include "ecs/components/transform-component.hpp"
+#include "constraint.hpp"
+#include "entity/components/copy-translation.hpp"
+#include "entity/components/copy-rotation.hpp"
+#include "entity/components/copy-scale.hpp"
+#include "entity/components/copy-transform.hpp"
+#include "entity/components/transform.hpp"
#include "utility/fundamental-types.hpp"
-namespace ecs {
+namespace entity {
+namespace system {
-constraint_system::constraint_system(ecs::registry& registry):
- entity_system(registry)
+constraint::constraint(entity::registry& registry):
+ updatable(registry)
{}
-void constraint_system::update(double t, double dt)
+void constraint::update(double t, double dt)
{
- auto transforms_view = registry.view();
+ auto transforms_view = registry.view();
// Handle copy translation constraints
- registry.view().each
+ registry.view().each
(
- [&](ecs::entity entity, auto& constraint, auto& transform)
+ [&](entity::id entity_id, auto& constraint, auto& transform)
{
- if (this->registry.has(constraint.target))
+ if (this->registry.has(constraint.target))
{
const float3& target_translation = transforms_view.get(constraint.target).world.translation;
if (constraint.use_x)
@@ -54,11 +55,11 @@ void constraint_system::update(double t, double dt)
);
// Handle copy rotation constraints
- registry.view().each
+ registry.view().each
(
- [&](ecs::entity entity, auto& constraint, auto& transform)
+ [&](entity::id entity_id, auto& constraint, auto& transform)
{
- if (this->registry.has(constraint.target))
+ if (this->registry.has(constraint.target))
{
transform.world.rotation = transforms_view.get(constraint.target).world.rotation;
}
@@ -66,11 +67,11 @@ void constraint_system::update(double t, double dt)
);
// Handle copy scale constraints
- registry.view().each
+ registry.view().each
(
- [&](ecs::entity entity, auto& constraint, auto& transform)
+ [&](entity::id entity_id, auto& constraint, auto& transform)
{
- if (this->registry.has(constraint.target))
+ if (this->registry.has(constraint.target))
{
const float3& target_scale = transforms_view.get(constraint.target).world.scale;
if (constraint.use_x)
@@ -84,11 +85,11 @@ void constraint_system::update(double t, double dt)
);
// Handle copy transform constraints
- registry.view().each
+ registry.view().each
(
- [&](ecs::entity entity, auto& constraint, auto& transform)
+ [&](entity::id entity_id, auto& constraint, auto& transform)
{
- if (this->registry.has(constraint.target))
+ if (this->registry.has(constraint.target))
{
transform.world = transforms_view.get(constraint.target).world;
}
@@ -96,4 +97,5 @@ void constraint_system::update(double t, double dt)
);
}
-} // namespace ecs
+} // namespace system
+} // namespace entity
diff --git a/src/ecs/systems/locomotion-system.hpp b/src/entity/systems/constraint.hpp
similarity index 71%
rename from src/ecs/systems/locomotion-system.hpp
rename to src/entity/systems/constraint.hpp
index c753b7e..24536c2 100644
--- a/src/ecs/systems/locomotion-system.hpp
+++ b/src/entity/systems/constraint.hpp
@@ -17,21 +17,23 @@
* along with Antkeeper source code. If not, see .
*/
-#ifndef ANTKEEPER_ECS_LOCOMOTION_SYSTEM_HPP
-#define ANTKEEPER_ECS_LOCOMOTION_SYSTEM_HPP
+#ifndef ANTKEEPER_ENTITY_SYSTEM_CONSTRAINT_HPP
+#define ANTKEEPER_ENTITY_SYSTEM_CONSTRAINT_HPP
-#include "entity-system.hpp"
+#include "entity/systems/updatable.hpp"
-namespace ecs {
+namespace entity {
+namespace system {
-class locomotion_system:
- public entity_system
+class constraint:
+ public updatable
{
public:
- locomotion_system(ecs::registry& registry);
+ constraint(entity::registry& registry);
virtual void update(double t, double dt);
};
-} // namespace ecs
+} // namespace system
+} // namespace entity
-#endif // ANTKEEPER_ECS_LOCOMOTION_SYSTEM_HPP
+#endif // ANTKEEPER_ENTITY_SYSTEM_CONSTRAINT_HPP
diff --git a/src/ecs/systems/control-system.cpp b/src/entity/systems/control.cpp
similarity index 89%
rename from src/ecs/systems/control-system.cpp
rename to src/entity/systems/control.cpp
index c312cd3..cf03f7b 100644
--- a/src/ecs/systems/control-system.cpp
+++ b/src/entity/systems/control.cpp
@@ -17,21 +17,22 @@
* along with Antkeeper source code. If not, see .
*/
-#include "control-system.hpp"
+#include "control.hpp"
#include "input/control.hpp"
#include "geom/intersection.hpp"
#include "animation/ease.hpp"
-#include "nest.hpp"
#include "math/math.hpp"
-#include "ecs/commands.hpp"
-#include "ecs/systems/camera-system.hpp"
+#include "entity/commands.hpp"
+#include "entity/systems/camera.hpp"
#include "animation/orbit-cam.hpp"
+#include "../../nest.hpp"
#include
-namespace ecs {
+namespace entity {
+namespace system {
-control_system::control_system(ecs::registry& registry):
- entity_system(registry),
+control::control(entity::registry& registry):
+ updatable(registry),
timestep(0.0f),
zoom(0.0f),
tool(nullptr),
@@ -97,7 +98,7 @@ control_system::control_system(ecs::registry& registry):
flashlight_turns_f = 0.0f;
}
-void control_system::update(double t, double dt)
+void control::update(double t, double dt)
{
timestep = dt;
@@ -193,42 +194,42 @@ void control_system::update(double t, double dt)
}
}
-void control_system::set_camera_system(ecs::camera_system* camera_system)
+void control::set_camera_system(system::camera* camera_system)
{
this->camera_system = camera_system;
}
-void control_system::set_nest(::nest* nest)
+void control::set_nest(::nest* nest)
{
this->nest = nest;
}
-void control_system::set_tool(scene::model_instance* tool)
+void control::set_tool(scene::model_instance* tool)
{
this->tool = tool;
}
-void control_system::set_flashlight(ecs::entity entity)
+void control::set_flashlight(entity::id entity_id)
{
- flashlight_entity = entity;
+ flashlight_entity = entity_id;
}
-void control_system::set_camera_subject(ecs::entity entity)
+void control::set_camera_subject(entity::id entity_id)
{
- camera_subject_entity = entity;
+ camera_subject_entity = entity_id;
}
-void control_system::set_viewport(const float4& viewport)
+void control::set_viewport(const float4& viewport)
{
this->viewport = viewport;
}
-void control_system::set_underworld_camera(scene::camera* camera)
+void control::set_underworld_camera(scene::camera* camera)
{
this->underworld_camera = camera;
}
-void control_system::handle_event(const mouse_moved_event& event)
+void control::handle_event(const mouse_moved_event& event)
{
if (adjust_camera_control.is_active())
{
@@ -261,9 +262,10 @@ void control_system::handle_event(const mouse_moved_event& event)
}
}
-void control_system::handle_event(const window_resized_event& event)
+void control::handle_event(const window_resized_event& event)
{
set_viewport({0.0f, 0.0f, static_cast(event.w), static_cast(event.h)});
}
-} // namespace ecs
+} // namespace system
+} // namespace entity
diff --git a/src/ecs/systems/control-system.hpp b/src/entity/systems/control.hpp
similarity index 69%
rename from src/ecs/systems/control-system.hpp
rename to src/entity/systems/control.hpp
index 3677e3d..ffa930a 100644
--- a/src/ecs/systems/control-system.hpp
+++ b/src/entity/systems/control.hpp
@@ -17,11 +17,11 @@
* along with Antkeeper source code. If not, see .
*/
-#ifndef ANTKEEPER_ECS_CONTROL_SYSTEM_HPP
-#define ANTKEEPER_ECS_CONTROL_SYSTEM_HPP
+#ifndef ANTKEEPER_ENTITY_SYSTEM_CONTROL_HPP
+#define ANTKEEPER_ENTITY_SYSTEM_CONTROL_HPP
-#include "ecs/systems/entity-system.hpp"
-#include "ecs/entity.hpp"
+#include "entity/systems/updatable.hpp"
+#include "entity/id.hpp"
#include "event/event-handler.hpp"
#include "event/input-events.hpp"
#include "event/window-events.hpp"
@@ -33,28 +33,29 @@
class nest;
-namespace ecs {
+namespace entity {
+namespace system {
-class camera_system;
+class camera;
-class control_system:
- public entity_system,
+class control:
+ public updatable,
public event_handler,
public event_handler
{
public:
- control_system(ecs::registry& registry);
+ control(entity::registry& registry);
virtual void update(double t, double dt);
void set_invert_mouse_x(bool invert);
void set_invert_mouse_y(bool invert);
- void set_camera_system(ecs::camera_system* camera_system);
+ void set_camera_system(system::camera* camera_system);
void set_nest(::nest* nest);
void set_tool(scene::model_instance* tool);
- void set_flashlight(ecs::entity entity);
- void set_camera_subject(ecs::entity entity);
+ void set_flashlight(entity::id entity_id);
+ void set_camera_subject(entity::id entity_id);
void set_viewport(const float4& viewport);
void set_underworld_camera(scene::camera* camera);
@@ -139,14 +140,14 @@ private:
float timestep;
float zoom;
- camera_system* camera_system;
+ system::camera* camera_system;
::nest* nest;
scene::model_instance* tool;
float2 mouse_position;
float4 viewport;
- entity flashlight_entity;
- entity camera_subject_entity;
+ entity::id flashlight_entity;
+ entity::id camera_subject_entity;
scene::camera* underworld_camera;
float mouse_angle;
@@ -156,152 +157,153 @@ private:
float flashlight_turns_f;
};
-inline input::control_set* control_system::get_control_set()
+inline input::control_set* control::get_control_set()
{
return &control_set;
}
-inline input::control* control_system::get_move_forward_control()
+inline input::control* control::get_move_forward_control()
{
return &move_forward_control;
}
-inline input::control* control_system::get_move_back_control()
+inline input::control* control::get_move_back_control()
{
return &move_back_control;
}
-inline input::control* control_system::get_move_left_control()
+inline input::control* control::get_move_left_control()
{
return &move_left_control;
}
-inline input::control* control_system::get_move_right_control()
+inline input::control* control::get_move_right_control()
{
return &move_right_control;
}
-inline input::control* control_system::get_rotate_ccw_control()
+inline input::control* control::get_rotate_ccw_control()
{
return &rotate_ccw_control;
}
-inline input::control* control_system::get_rotate_cw_control()
+inline input::control* control::get_rotate_cw_control()
{
return &rotate_cw_control;
}
-inline input::control* control_system::get_tilt_up_control()
+inline input::control* control::get_tilt_up_control()
{
return &tilt_up_control;
}
-inline input::control* control_system::get_tilt_down_control()
+inline input::control* control::get_tilt_down_control()
{
return &tilt_down_control;
}
-inline input::control* control_system::get_zoom_in_control()
+inline input::control* control::get_zoom_in_control()
{
return &zoom_in_control;
}
-inline input::control* control_system::get_zoom_out_control()
+inline input::control* control::get_zoom_out_control()
{
return &zoom_out_control;
}
-inline input::control* control_system::get_adjust_camera_control()
+inline input::control* control::get_adjust_camera_control()
{
return &adjust_camera_control;
}
-inline input::control* control_system::get_ascend_control()
+inline input::control* control::get_ascend_control()
{
return &ascend_control;
}
-inline input::control* control_system::get_descend_control()
+inline input::control* control::get_descend_control()
{
return &descend_control;
}
-inline input::control* control_system::get_toggle_view_control()
+inline input::control* control::get_toggle_view_control()
{
return &toggle_view_control;
}
-inline input::control* control_system::get_tool_menu_control()
+inline input::control* control::get_tool_menu_control()
{
return &tool_menu_control;
}
-inline input::control* control_system::get_equip_lens_control()
+inline input::control* control::get_equip_lens_control()
{
return &equip_lens_control;
}
-inline input::control* control_system::get_equip_brush_control()
+inline input::control* control::get_equip_brush_control()
{
return &equip_brush_control;
}
-inline input::control* control_system::get_equip_forceps_control()
+inline input::control* control::get_equip_forceps_control()
{
return &equip_forceps_control;
}
-inline input::control* control_system::get_equip_marker_control()
+inline input::control* control::get_equip_marker_control()
{
return &equip_marker_control;
}
-inline input::control* control_system::get_equip_container_control()
+inline input::control* control::get_equip_container_control()
{
return &equip_container_control;
}
-inline input::control* control_system::get_equip_twig_control()
+inline input::control* control::get_equip_twig_control()
{
return &equip_twig_control;
}
-inline input::control* control_system::get_next_marker_control()
+inline input::control* control::get_next_marker_control()
{
return &next_marker_control;
}
-inline input::control* control_system::get_previous_marker_control()
+inline input::control* control::get_previous_marker_control()
{
return &previous_marker_control;
}
-inline input::control* control_system::get_use_tool_control()
+inline input::control* control::get_use_tool_control()
{
return &use_tool_control;
}
-inline input::control* control_system::get_fast_forward_control()
+inline input::control* control::get_fast_forward_control()
{
return &fast_forward_control;
}
-inline input::control* control_system::get_rewind_control()
+inline input::control* control::get_rewind_control()
{
return &rewind_control;
}
-inline input::control* control_system::get_exposure_increase_control()
+inline input::control* control::get_exposure_increase_control()
{
return &exposure_increase_control;
}
-inline input::control* control_system::get_exposure_decrease_control()
+inline input::control* control::get_exposure_decrease_control()
{
return &exposure_decrease_control;
}
-} // namespace ecs
+} // namespace system
+} // namespace entity
-#endif // ANTKEEPER_ECS_CONTROL_SYSTEM_HPP
+#endif // ANTKEEPER_ENTITY_SYSTEM_CONTROL_HPP
diff --git a/src/ecs/systems/locomotion-system.cpp b/src/entity/systems/locomotion.cpp
similarity index 60%
rename from src/ecs/systems/locomotion-system.cpp
rename to src/entity/systems/locomotion.cpp
index 5153429..c1e3214 100644
--- a/src/ecs/systems/locomotion-system.cpp
+++ b/src/entity/systems/locomotion.cpp
@@ -17,24 +17,26 @@
* along with Antkeeper source code. If not, see .
*/
-#include "locomotion-system.hpp"
-#include "ecs/components/collision-component.hpp"
-#include "ecs/components/locomotion-component.hpp"
-#include "ecs/components/transform-component.hpp"
-#include "ecs/entity.hpp"
+#include "locomotion.hpp"
+#include "entity/components/collision.hpp"
+#include "entity/components/locomotion.hpp"
+#include "entity/components/transform.hpp"
+#include "entity/id.hpp"
-namespace ecs {
+namespace entity {
+namespace system {
-locomotion_system::locomotion_system(ecs::registry& registry):
- entity_system(registry)
+locomotion::locomotion(entity::registry& registry):
+ updatable(registry)
{}
-void locomotion_system::update(double t, double dt)
+void locomotion::update(double t, double dt)
{
- registry.view().each(
- [&](ecs::entity entity, auto& transform, auto& locomotion)
+ registry.view().each(
+ [&](entity::id entity_id, auto& transform, auto& locomotion)
{
});
}
-} // namespace ecs
+} // namespace system
+} // namespace entity
diff --git a/src/entity/systems/locomotion.hpp b/src/entity/systems/locomotion.hpp
new file mode 100644
index 0000000..7b55740
--- /dev/null
+++ b/src/entity/systems/locomotion.hpp
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 2021 Christopher J. Howard
+ *
+ * This file is part of Antkeeper source code.
+ *
+ * Antkeeper source code is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Antkeeper source code is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Antkeeper source code. If not, see .
+ */
+
+#ifndef ANTKEEPER_ENTITY_SYSTEM_LOCOMOTION_HPP
+#define ANTKEEPER_ENTITY_SYSTEM_LOCOMOTION_HPP
+
+#include "entity/systems/updatable.hpp"
+
+namespace entity {
+namespace system {
+
+class locomotion:
+ public updatable
+{
+public:
+ locomotion(entity::registry& registry);
+ virtual void update(double t, double dt);
+};
+
+} // namespace system
+} // namespace entity
+
+#endif // ANTKEEPER_ENTITY_SYSTEM_LOCOMOTION_HPP
diff --git a/src/ecs/systems/nest-system.cpp b/src/entity/systems/nest.cpp
similarity index 71%
rename from src/ecs/systems/nest-system.cpp
rename to src/entity/systems/nest.cpp
index 9464567..b725d91 100644
--- a/src/ecs/systems/nest-system.cpp
+++ b/src/entity/systems/nest.cpp
@@ -17,30 +17,32 @@
* along with Antkeeper source code. If not, see .
*/
-#include "nest-system.hpp"
#include "nest.hpp"
+#include "../../nest.hpp"
#include "math/math.hpp"
-namespace ecs {
+namespace entity {
+namespace system {
-nest_system::nest_system(ecs::registry& registry, ::resource_manager* resource_manager):
- entity_system(registry),
+nest::nest(entity::registry& registry, ::resource_manager* resource_manager):
+ updatable(registry),
resource_manager(resource_manager)
{
- registry.on_construct().connect<&nest_system::on_nest_construct>(this);
- registry.on_destroy().connect<&nest_system::on_nest_destroy>(this);
+ registry.on_construct().connect<&nest::on_nest_construct>(this);
+ registry.on_destroy().connect<&nest::on_nest_destroy>(this);
}
-nest_system::~nest_system()
+nest::~nest()
{}
-void nest_system::update(double t, double dt)
+void nest::update(double t, double dt)
{}
-void nest_system::on_nest_construct(ecs::registry& registry, ecs::entity entity, nest_component& component)
+void nest::on_nest_construct(entity::registry& registry, entity::id entity_id, component::nest& component)
{
+ /*
// Allocate a nest
- nest* nest = new ::nest();
+ ::nest* nest = new ::nest();
// Setup initial nest parameters
nest->set_tunnel_radius(1.15f);
@@ -62,9 +64,11 @@ void nest_system::on_nest_construct(ecs::registry& registry, ecs::entity entity,
chamber.outer_radius = 10.0f;
central_shaft->chambers.push_back(chamber);
}
+ */
}
-void nest_system::on_nest_destroy(ecs::registry& registry, ecs::entity entity)
+void nest::on_nest_destroy(entity::registry& registry, entity::id entity_id)
{}
-} // namespace ecs
+} // namespace system
+} // namespace entity
diff --git a/src/ecs/systems/nest-system.hpp b/src/entity/systems/nest.hpp
similarity index 61%
rename from src/ecs/systems/nest-system.hpp
rename to src/entity/systems/nest.hpp
index 9a84492..2ae843c 100644
--- a/src/ecs/systems/nest-system.hpp
+++ b/src/entity/systems/nest.hpp
@@ -17,32 +17,34 @@
* along with Antkeeper source code. If not, see .
*/
-#ifndef ANTKEEPER_ECS_NEST_SYSTEM_HPP
-#define ANTKEEPER_ECS_NEST_SYSTEM_HPP
+#ifndef ANTKEEPER_ENTITY_SYSTEM_NEST_HPP
+#define ANTKEEPER_ENTITY_SYSTEM_NEST_HPP
-#include "entity-system.hpp"
-#include "ecs/components/nest-component.hpp"
+#include "entity/systems/updatable.hpp"
+#include "entity/components/nest.hpp"
class nest;
class resource_manager;
-namespace ecs {
+namespace entity {
+namespace system {
-class nest_system: public entity_system
+class nest: public updatable
{
public:
- nest_system(ecs::registry& registry, ::resource_manager* resource_manager);
- ~nest_system();
+ nest(entity::registry& registry, ::resource_manager* resource_manager);
+ ~nest();
virtual void update(double t, double dt);
private:
resource_manager* resource_manager;
- void on_nest_construct(ecs::registry& registry, ecs::entity entity, ecs::nest_component& component);
- void on_nest_destroy(ecs::registry& registry, ecs::entity entity);
+ void on_nest_construct(entity::registry& registry, entity::id entity_id, entity::component::nest& component);
+ void on_nest_destroy(entity::registry& registry, entity::id entity_id);
};
-} // namespace ecs
+} // namespace system
+} // namespace entity
-#endif // ANTKEEPER_ECS_NEST_SYSTEM_HPP
+#endif // ANTKEEPER_ENTITY_SYSTEM_NEST_HPP
diff --git a/src/ecs/systems/orbit-system.cpp b/src/entity/systems/orbit.cpp
similarity index 85%
rename from src/ecs/systems/orbit-system.cpp
rename to src/entity/systems/orbit.cpp
index 9fcd627..7835f4a 100644
--- a/src/ecs/systems/orbit-system.cpp
+++ b/src/entity/systems/orbit.cpp
@@ -17,29 +17,30 @@
* along with Antkeeper source code. If not, see .
*/
-#include "ecs/systems/orbit-system.hpp"
-#include "ecs/components/orbit-component.hpp"
-#include "ecs/entity.hpp"
+#include "entity/systems/orbit.hpp"
+#include "entity/components/orbit.hpp"
+#include "entity/id.hpp"
#include "physics/orbit/orbit.hpp"
-namespace ecs {
+namespace entity {
+namespace system {
-orbit_system::orbit_system(ecs::registry& registry):
- entity_system(registry),
+orbit::orbit(entity::registry& registry):
+ updatable(registry),
universal_time(0.0),
time_scale(1.0),
ke_iterations(10),
ke_tolerance(1e-6)
{}
-void orbit_system::update(double t, double dt)
+void orbit::update(double t, double dt)
{
// Add scaled timestep to current time
set_universal_time(universal_time + dt * time_scale);
// Update the orbital state of orbiting bodies
- registry.view().each(
- [&](ecs::entity entity, auto& orbit)
+ registry.view().each(
+ [&](entity::id entity_id, auto& orbit)
{
// Calculate semi-minor axis (b)
const double b = physics::orbit::derive_semiminor_axis(orbit.elements.a, orbit.elements.e);
@@ -78,14 +79,15 @@ void orbit_system::update(double t, double dt)
});
}
-void orbit_system::set_universal_time(double time)
+void orbit::set_universal_time(double time)
{
universal_time = time;
}
-void orbit_system::set_time_scale(double scale)
+void orbit::set_time_scale(double scale)
{
time_scale = scale;
}
-} // namespace ecs
+} // namespace system
+} // namespace entity
diff --git a/src/ecs/systems/orbit-system.hpp b/src/entity/systems/orbit.hpp
similarity index 84%
rename from src/ecs/systems/orbit-system.hpp
rename to src/entity/systems/orbit.hpp
index ad6725b..da10d14 100644
--- a/src/ecs/systems/orbit-system.hpp
+++ b/src/entity/systems/orbit.hpp
@@ -17,22 +17,23 @@
* along with Antkeeper source code. If not, see .
*/
-#ifndef ANTKEEPER_ECS_SOLAR_SYSTEM_HPP
-#define ANTKEEPER_ECS_SOLAR_SYSTEM_HPP
+#ifndef ANTKEEPER_ENTITY_SYSTEM_SOLAR_HPP
+#define ANTKEEPER_ENTITY_SYSTEM_SOLAR_HPP
-#include "entity-system.hpp"
+#include "entity/systems/updatable.hpp"
#include "utility/fundamental-types.hpp"
-namespace ecs {
+namespace entity {
+namespace system {
/**
* Updates the Cartesian position and velocity of orbiting bodies given their Keplerian orbital elements and the current time.
*/
-class orbit_system:
- public entity_system
+class orbit:
+ public updatable
{
public:
- orbit_system(ecs::registry& registry);
+ orbit(entity::registry& registry);
/**
* Scales then adds the timestep `dt` to the current time, then recalculates the positions of orbiting bodies.
@@ -63,6 +64,7 @@ private:
double ke_tolerance;
};
-} // namespace ecs
+} // namespace system
+} // namespace entity
-#endif // ANTKEEPER_ECS_SOLAR_SYSTEM_HPP
+#endif // ANTKEEPER_ENTITY_SYSTEM_SOLAR_HPP
diff --git a/src/ecs/systems/painting-system.cpp b/src/entity/systems/painting.cpp
similarity index 89%
rename from src/ecs/systems/painting-system.cpp
rename to src/entity/systems/painting.cpp
index 924cea0..e624ac8 100644
--- a/src/ecs/systems/painting-system.cpp
+++ b/src/entity/systems/painting.cpp
@@ -17,33 +17,34 @@
* along with Antkeeper source code. If not, see .
*/
-#include "painting-system.hpp"
-#include "ecs/components/transform-component.hpp"
-#include "ecs/components/brush-component.hpp"
-#include "ecs/components/tool-component.hpp"
+#include "painting.hpp"
+#include "entity/components/transform.hpp"
+#include "entity/components/brush.hpp"
+#include "entity/components/tool.hpp"
#include "event/event-dispatcher.hpp"
#include "resources/resource-manager.hpp"
#include "math/math.hpp"
#include "renderer/material.hpp"
#include "renderer/model.hpp"
#include "utility/fundamental-types.hpp"
-#include "ecs/commands.hpp"
-#include "ecs/components/collision-component.hpp"
-#include "ecs/components/transform-component.hpp"
+#include "entity/commands.hpp"
+#include "entity/components/collision.hpp"
+#include "entity/components/transform.hpp"
#include "gl/vertex-buffer.hpp"
#include "gl/vertex-attribute-type.hpp"
#include "renderer/vertex-attributes.hpp"
#include "geom/mesh-functions.hpp"
#include
-namespace ecs {
+namespace entity {
+namespace system {
-painting_system::painting_system(ecs::registry& registry, ::event_dispatcher* event_dispatcher, ::resource_manager* resource_manager):
- entity_system(registry),
+painting::painting(entity::registry& registry, ::event_dispatcher* event_dispatcher, ::resource_manager* resource_manager):
+ updatable(registry),
event_dispatcher(event_dispatcher),
resource_manager(resource_manager),
scene_collection(nullptr),
- painting(false)
+ is_painting(false)
{
event_dispatcher->subscribe(this);
event_dispatcher->subscribe(this);
@@ -87,17 +88,17 @@ painting_system::painting_system(ecs::registry& registry, ::event_dispatcher* ev
midstroke = false;
}
-painting_system::~painting_system()
+painting::~painting()
{
event_dispatcher->unsubscribe(this);
event_dispatcher->unsubscribe(this);
}
-void painting_system::update(double t, double dt)
+void painting::update(double t, double dt)
{
- if (painting)
+ if (is_painting)
{
- const tool_component& tool = registry.get(brush_entity);
+ const component::tool& tool = registry.get(brush_entity);
auto cast_result = cast_ray(tool.cursor);
if (cast_result.has_value())
@@ -265,22 +266,22 @@ void painting_system::update(double t, double dt)
}
}
-void painting_system::set_scene(scene::collection* collection)
+void painting::set_scene(scene::collection* collection)
{
this->scene_collection = collection;
scene_collection->add_object(stroke_model_instance);
}
-void painting_system::handle_event(const tool_pressed_event& event)
+void painting::handle_event(const tool_pressed_event& event)
{
- if (registry.has(event.entity))
+ if (registry.has(event.entity_id))
{
auto cast_result = cast_ray(event.position);
if (cast_result.has_value())
{
- brush_entity = event.entity;
- painting = true;
+ brush_entity = event.entity_id;
+ is_painting = true;
stroke_start = std::get<0>(cast_result.value());
stroke_end = stroke_start;
p0 = stroke_start;
@@ -291,11 +292,11 @@ void painting_system::handle_event(const tool_pressed_event& event)
}
}
-void painting_system::handle_event(const tool_released_event& event)
+void painting::handle_event(const tool_released_event& event)
{
- if (registry.has(event.entity))
+ if (registry.has(event.entity_id))
{
- auto cast_result = cast_ray(command::get_world_transform(registry, event.entity).translation);
+ auto cast_result = cast_ray(command::get_world_transform(registry, event.entity_id).translation);
if (cast_result.has_value())
{
@@ -303,11 +304,11 @@ void painting_system::handle_event(const tool_released_event& event)
}
brush_entity = entt::null;
- painting = false;
+ is_painting = false;
}
}
-std::optional> painting_system::cast_ray(const float3& position) const
+std::optional> painting::cast_ray(const float3& position) const
{
std::optional> result;
@@ -318,8 +319,8 @@ std::optional> painting_system::cast_ray(const float3
geom::ray untransformed_ray = {position + float3{0.0f, 10000.0f, 0.0f}, {0, -1, 0}};
float min_distance = std::numeric_limits::infinity();
- registry.view().each(
- [&](ecs::entity entity, auto& collision_transform, auto& collision)
+ registry.view().each(
+ [&](entity::id entity_id, auto& collision_transform, auto& collision)
{
// Transform ray into local space of collision component
math::transform inverse_transform = math::inverse(collision_transform.local);
@@ -356,4 +357,5 @@ std::optional> painting_system::cast_ray(const float3
return result;
}
-} // namespace ecs
+} // namespace system
+} // namespace entity
diff --git a/src/ecs/systems/painting-system.hpp b/src/entity/systems/painting.hpp
similarity index 83%
rename from src/ecs/systems/painting-system.hpp
rename to src/entity/systems/painting.hpp
index e2ccae9..9c58b28 100644
--- a/src/ecs/systems/painting-system.hpp
+++ b/src/entity/systems/painting.hpp
@@ -17,11 +17,11 @@
* along with Antkeeper source code. If not, see .
*/
-#ifndef ANTKEEPER_ECS_PAINTING_SYSTEM_HPP
-#define ANTKEEPER_ECS_PAINTING_SYSTEM_HPP
+#ifndef ANTKEEPER_ENTITY_SYSTEM_PAINTING_HPP
+#define ANTKEEPER_ENTITY_SYSTEM_PAINTING_HPP
-#include "entity-system.hpp"
-#include "ecs/entity.hpp"
+#include "entity/systems/updatable.hpp"
+#include "entity/id.hpp"
#include "event/event-handler.hpp"
#include "game/events/tool-events.hpp"
#include "utility/fundamental-types.hpp"
@@ -37,15 +37,16 @@ class resource_manager;
class model;
class model_group;
-namespace ecs {
+namespace entity {
+namespace system {
-class painting_system: public entity_system,
+class painting: public updatable,
public event_handler,
public event_handler
{
public:
- painting_system(ecs::registry& registry, event_dispatcher* event_dispatcher, resource_manager* resource_manager);
- virtual ~painting_system();
+ painting(entity::registry& registry, event_dispatcher* event_dispatcher, resource_manager* resource_manager);
+ virtual ~painting();
virtual void update(double t, double dt);
void set_scene(scene::collection* collection);
@@ -60,8 +61,8 @@ private:
resource_manager* resource_manager;
scene::collection* scene_collection;
- bool painting;
- entity brush_entity;
+ bool is_painting;
+ entity::id brush_entity;
float3 stroke_start;
float3 stroke_end;
float min_stroke_length;
@@ -89,6 +90,7 @@ private:
scene::model_instance* stroke_model_instance;
};
-} // namespace ecs
+} // namespace system
+} // namespace entity
-#endif // ANTKEEPER_ECS_PAINTING_SYSTEM_HPP
+#endif // ANTKEEPER_ENTITY_SYSTEM_PAINTING_HPP
diff --git a/src/ecs/systems/render-system.cpp b/src/entity/systems/render.cpp
similarity index 57%
rename from src/ecs/systems/render-system.cpp
rename to src/entity/systems/render.cpp
index 61a46d7..4757878 100644
--- a/src/ecs/systems/render-system.cpp
+++ b/src/entity/systems/render.cpp
@@ -17,8 +17,8 @@
* along with Antkeeper source code. If not, see .
*/
-#include "render-system.hpp"
-#include "ecs/components/transform-component.hpp"
+#include "render.hpp"
+#include "entity/components/transform.hpp"
#include "renderer/renderer.hpp"
#include "scene/point-light.hpp"
#include "scene/directional-light.hpp"
@@ -26,29 +26,30 @@
#include "scene/spot-light.hpp"
#include
-namespace ecs {
+namespace entity {
+namespace system {
-render_system::render_system(ecs::registry& registry):
- entity_system(registry),
+render::render(entity::registry& registry):
+ updatable(registry),
renderer(nullptr)
{
- registry.on_construct().connect<&render_system::on_model_construct>(this);
- registry.on_replace().connect<&render_system::on_model_replace>(this);
- registry.on_destroy().connect<&render_system::on_model_destroy>(this);
+ registry.on_construct().connect<&render::on_model_construct>(this);
+ registry.on_replace().connect<&render::on_model_replace>(this);
+ registry.on_destroy().connect<&render::on_model_destroy>(this);
- registry.on_construct().connect<&render_system::on_light_construct>(this);
- registry.on_replace().connect<&render_system::on_light_replace>(this);
- registry.on_destroy().connect<&render_system::on_light_destroy>(this);
+ registry.on_construct().connect<&render::on_light_construct>(this);
+ registry.on_replace().connect<&render::on_light_replace>(this);
+ registry.on_destroy().connect<&render::on_light_destroy>(this);
}
-void render_system::update(double t, double dt)
+void render::update(double t, double dt)
{
// Update model instance transforms
- registry.view().each
+ registry.view().each
(
- [this](ecs::entity entity, auto& transform, auto& model)
+ [this](entity::id entity_id, auto& transform, auto& model)
{
- scene::model_instance* instance = model_instances[entity];
+ scene::model_instance* instance = model_instances[entity_id];
instance->set_transform(transform.world);
if (transform.warp)
@@ -61,11 +62,11 @@ void render_system::update(double t, double dt)
);
// Update light transforms
- registry.view().each
+ registry.view().each
(
- [this](ecs::entity entity, auto& transform, auto& light)
+ [this](entity::id entity_id, auto& transform, auto& light)
{
- scene::light* light_object = lights[entity];
+ scene::light* light_object = lights[entity_id];
light_object->set_transform(transform.world);
if (transform.warp)
@@ -78,7 +79,7 @@ void render_system::update(double t, double dt)
);
}
-void render_system::render(double alpha)
+void render::draw(double alpha)
{
if (renderer)
{
@@ -89,40 +90,40 @@ void render_system::render(double alpha)
}
}
-void render_system::add_layer(scene::collection* layer)
+void render::add_layer(scene::collection* layer)
{
layers.push_back(layer);
}
-void render_system::remove_layers()
+void render::remove_layers()
{
layers.clear();
}
-void render_system::set_renderer(::renderer* renderer)
+void render::set_renderer(::renderer* renderer)
{
this->renderer = renderer;
}
-scene::model_instance* render_system::get_model_instance(ecs::entity entity)
+scene::model_instance* render::get_model_instance(entity::id entity_id)
{
- if (auto it = model_instances.find(entity); it != model_instances.end())
+ if (auto it = model_instances.find(entity_id); it != model_instances.end())
return it->second;
return nullptr;
}
-scene::light* render_system::get_light(ecs::entity entity)
+scene::light* render::get_light(entity::id entity_id)
{
- if (auto it = lights.find(entity); it != lights.end())
+ if (auto it = lights.find(entity_id); it != lights.end())
return it->second;
return nullptr;
}
-void render_system::update_model_and_materials(ecs::entity entity, model_component& model)
+void render::update_model_and_materials(entity::id entity_id, component::model& model)
{
- if (auto model_it = model_instances.find(entity); model_it != model_instances.end())
+ if (auto model_it = model_instances.find(entity_id); model_it != model_instances.end())
{
- model_it->second->set_model(model.model);
+ model_it->second->set_model(model.render_model);
model_it->second->set_instanced((model.instance_count > 0), model.instance_count);
for (auto material_it = model.materials.begin(); material_it != model.materials.end(); ++material_it)
@@ -143,9 +144,9 @@ void render_system::update_model_and_materials(ecs::entity entity, model_compone
}
}
-void render_system::update_light(ecs::entity entity, ecs::light_component& component)
+void render::update_light(entity::id entity_id, entity::component::light& component)
{
- if (auto light_it = lights.find(entity); light_it != lights.end())
+ if (auto light_it = lights.find(entity_id); light_it != lights.end())
{
scene::light* light = light_it->second;
@@ -175,21 +176,21 @@ void render_system::update_light(ecs::entity entity, ecs::light_component& compo
}
}
-void render_system::on_model_construct(ecs::registry& registry, ecs::entity entity, model_component& model)
+void render::on_model_construct(entity::registry& registry, entity::id entity_id, component::model& model)
{
scene::model_instance* model_instance = new scene::model_instance();
- model_instances[entity] = model_instance;
- update_model_and_materials(entity, model);
+ model_instances[entity_id] = model_instance;
+ update_model_and_materials(entity_id, model);
}
-void render_system::on_model_replace(ecs::registry& registry, ecs::entity entity, model_component& model)
+void render::on_model_replace(entity::registry& registry, entity::id entity_id, component::model& model)
{
- update_model_and_materials(entity, model);
+ update_model_and_materials(entity_id, model);
}
-void render_system::on_model_destroy(ecs::registry& registry, ecs::entity entity)
+void render::on_model_destroy(entity::registry& registry, entity::id entity_id)
{
- if (auto it = model_instances.find(entity); it != model_instances.end())
+ if (auto it = model_instances.find(entity_id); it != model_instances.end())
{
scene::model_instance* model_instance = it->second;
@@ -202,7 +203,7 @@ void render_system::on_model_destroy(ecs::registry& registry, ecs::entity entity
}
}
-void render_system::on_light_construct(ecs::registry& registry, ecs::entity entity, light_component& component)
+void render::on_light_construct(entity::registry& registry, entity::id entity_id, component::light& component)
{
scene::light* light = nullptr;
@@ -230,22 +231,22 @@ void render_system::on_light_construct(ecs::registry& registry, ecs::entity enti
if (light)
{
- lights[entity] = light;
+ lights[entity_id] = light;
for (scene::collection* layer: layers)
layer->add_object(light);
- update_light(entity, component);
+ update_light(entity_id, component);
}
}
-void render_system::on_light_replace(ecs::registry& registry, ecs::entity entity, light_component& light)
+void render::on_light_replace(entity::registry& registry, entity::id entity_id, component::light& light)
{
- update_light(entity, light);
+ update_light(entity_id, light);
}
-void render_system::on_light_destroy(ecs::registry& registry, ecs::entity entity)
+void render::on_light_destroy(entity::registry& registry, entity::id entity_id)
{
- if (auto it = lights.find(entity); it != lights.end())
+ if (auto it = lights.find(entity_id); it != lights.end())
{
scene::light* light = it->second;
@@ -257,4 +258,5 @@ void render_system::on_light_destroy(ecs::registry& registry, ecs::entity entity
}
}
-} // namespace ecs
+} // namespace system
+} // namespace entity
diff --git a/src/entity/systems/render.hpp b/src/entity/systems/render.hpp
new file mode 100644
index 0000000..306828e
--- /dev/null
+++ b/src/entity/systems/render.hpp
@@ -0,0 +1,77 @@
+/*
+ * Copyright (C) 2021 Christopher J. Howard
+ *
+ * This file is part of Antkeeper source code.
+ *
+ * Antkeeper source code is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Antkeeper source code is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Antkeeper source code. If not, see .
+ */
+
+#ifndef ANTKEEPER_ENTITY_SYSTEM_RENDER_HPP
+#define ANTKEEPER_ENTITY_SYSTEM_RENDER_HPP
+
+#include "entity/systems/updatable.hpp"
+#include "scene/collection.hpp"
+#include "scene/model-instance.hpp"
+#include "scene/light.hpp"
+#include "entity/components/model.hpp"
+#include "entity/components/light.hpp"
+#include "entity/id.hpp"
+#include
+#include
+
+class renderer;
+
+namespace entity {
+namespace system {
+
+class render: public updatable
+{
+public:
+ render(entity::registry& registry);
+ virtual void update(double t, double dt);
+
+ void draw(double alpha);
+
+
+ void add_layer(scene::collection* layer);
+ void remove_layers();
+
+ void set_renderer(::renderer* renderer);
+
+ scene::model_instance* get_model_instance(entity::id entity_id);
+ scene::light* get_light(entity::id entity_id);
+
+private:
+ void update_model_and_materials(entity::id entity_id, entity::component::model& model);
+ void update_light(entity::id entity_id, entity::component::light& component);
+
+ void on_model_construct(entity::registry& registry, entity::id entity_id, entity::component::model& model);
+ void on_model_replace(entity::registry& registry, entity::id entity_id, entity::component::model& model);
+ void on_model_destroy(entity::registry& registry, entity::id entity_id);
+
+ void on_light_construct(entity::registry& registry, entity::id entity_id, entity::component::light& light);
+ void on_light_replace(entity::registry& registry, entity::id entity_id, entity::component::light& light);
+ void on_light_destroy(entity::registry& registry, entity::id entity_id);
+
+ renderer* renderer;
+ std::vector layers;
+ std::unordered_map model_instances;
+ std::unordered_map lights;
+};
+
+} // namespace system
+} // namespace entity
+
+#endif // ANTKEEPER_ENTITY_SYSTEM_RENDER_HPP
+
diff --git a/src/ecs/systems/samara-system.cpp b/src/entity/systems/samara.cpp
similarity index 79%
rename from src/ecs/systems/samara-system.cpp
rename to src/entity/systems/samara.cpp
index dd5805f..c50c4ac 100644
--- a/src/ecs/systems/samara-system.cpp
+++ b/src/entity/systems/samara.cpp
@@ -17,23 +17,24 @@
* along with Antkeeper source code. If not, see .
*/
-#include "samara-system.hpp"
-#include "ecs/components/transform-component.hpp"
-#include "ecs/components/samara-component.hpp"
-#include "ecs/entity.hpp"
+#include "samara.hpp"
+#include "entity/components/transform.hpp"
+#include "entity/components/samara.hpp"
+#include "entity/id.hpp"
#include "math/math.hpp"
#include "utility/fundamental-types.hpp"
-namespace ecs {
+namespace entity {
+namespace system {
-samara_system::samara_system(ecs::registry& registry):
- entity_system(registry)
+samara::samara(entity::registry& registry):
+ updatable(registry)
{}
-void samara_system::update(double t, double dt)
+void samara::update(double t, double dt)
{
- registry.view().each(
- [&](ecs::entity entity, auto& samara, auto& transform)
+ registry.view().each(
+ [&](entity::id entity_id, auto& samara, auto& transform)
{
samara.angle += samara.chirality * math::radians(360.0f * 6.0f) * dt;
@@ -56,4 +57,5 @@ void samara_system::update(double t, double dt)
});
}
-} // namespace ecs
+} // namespace system
+} // namespace entity
diff --git a/src/ecs/systems/behavior-system.hpp b/src/entity/systems/samara.hpp
similarity index 72%
rename from src/ecs/systems/behavior-system.hpp
rename to src/entity/systems/samara.hpp
index bd7c2ad..5cefe7d 100644
--- a/src/ecs/systems/behavior-system.hpp
+++ b/src/entity/systems/samara.hpp
@@ -17,22 +17,23 @@
* along with Antkeeper source code. If not, see .
*/
-#ifndef ANTKEEPER_ECS_BEHAVIOR_SYSTEM_HPP
-#define ANTKEEPER_ECS_BEHAVIOR_SYSTEM_HPP
+#ifndef ANTKEEPER_ENTITY_SYSTEM_SAMARA_HPP
+#define ANTKEEPER_ENTITY_SYSTEM_SAMARA_HPP
-#include "entity-system.hpp"
+#include "entity/systems/updatable.hpp"
-namespace ecs {
+namespace entity {
+namespace system {
-class behavior_system:
- public entity_system
+class samara: public updatable
{
public:
- behavior_system(ecs::registry& registry);
+ samara(entity::registry& registry);
virtual void update(double t, double dt);
};
-} // namespace ecs
+} // namespace system
+} // namespace entity
-#endif // ANTKEEPER_ECS_BEHAVIOR_SYSTEM_HPP
+#endif // ANTKEEPER_ENTITY_SYSTEM_SAMARA_HPP
diff --git a/src/ecs/systems/snapping-system.cpp b/src/entity/systems/snapping.cpp
similarity index 75%
rename from src/ecs/systems/snapping-system.cpp
rename to src/entity/systems/snapping.cpp
index e4c0d2a..a379980 100644
--- a/src/ecs/systems/snapping-system.cpp
+++ b/src/entity/systems/snapping.cpp
@@ -17,23 +17,24 @@
* along with Antkeeper source code. If not, see .
*/
-#include "snapping-system.hpp"
-#include "ecs/components/collision-component.hpp"
-#include "ecs/components/snap-component.hpp"
-#include "ecs/components/transform-component.hpp"
-#include "ecs/entity.hpp"
+#include "snapping.hpp"
+#include "entity/components/collision.hpp"
+#include "entity/components/snap.hpp"
+#include "entity/components/transform.hpp"
+#include "entity/id.hpp"
#include "utility/fundamental-types.hpp"
-namespace ecs {
+namespace entity {
+namespace system {
-snapping_system::snapping_system(ecs::registry& registry):
- entity_system(registry)
+snapping::snapping(entity::registry& registry):
+ updatable(registry)
{}
-void snapping_system::update(double t, double dt)
+void snapping::update(double t, double dt)
{
- registry.view().each(
- [&](ecs::entity entity, auto& snap_transform, auto& snap)
+ registry.view().each(
+ [&](entity::id entity_id, auto& snap_transform, auto& snap)
{
bool intersection = false;
float a = std::numeric_limits::infinity();
@@ -46,8 +47,8 @@ void snapping_system::update(double t, double dt)
snap_ray.direction = snap_transform.local.rotation * snap_ray.direction;
}
- this->registry.view().each(
- [&](ecs::entity entity, auto& collision_transform, auto& collision)
+ this->registry.view().each(
+ [&](entity::id entity_id, auto& collision_transform, auto& collision)
{
// Transform ray into local space of collision component
math::transform inverse_transform = math::inverse(collision_transform.local);
@@ -82,10 +83,11 @@ void snapping_system::update(double t, double dt)
if (snap.autoremove)
{
- this->registry.remove(entity);
+ this->registry.remove(entity_id);
}
}
});
}
-} // namespace ecs
+} // namespace system
+} // namespace entity
diff --git a/src/ecs/systems/samara-system.hpp b/src/entity/systems/snapping.hpp
similarity index 71%
rename from src/ecs/systems/samara-system.hpp
rename to src/entity/systems/snapping.hpp
index 544427b..67a1d9e 100644
--- a/src/ecs/systems/samara-system.hpp
+++ b/src/entity/systems/snapping.hpp
@@ -17,21 +17,24 @@
* along with Antkeeper source code. If not, see .
*/
-#ifndef ANTKEEPER_ECS_SAMARA_SYSTEM_HPP
-#define ANTKEEPER_ECS_SAMARA_SYSTEM_HPP
+#ifndef ANTKEEPER_ENTITY_SYSTEM_SNAPPING_HPP
+#define ANTKEEPER_ENTITY_SYSTEM_SNAPPING_HPP
-#include "entity-system.hpp"
+#include "entity/systems/updatable.hpp"
-namespace ecs {
+namespace entity {
+namespace system {
-class samara_system: public entity_system
+class snapping:
+ public updatable
{
public:
- samara_system(ecs::registry& registry);
+ snapping(entity::registry& registry);
virtual void update(double t, double dt);
};
-} // namespace ecs
+} // namespace system
+} // namespace entity
-#endif // ANTKEEPER_ECS_SAMARA_SYSTEM_HPP
+#endif // ANTKEEPER_ENTITY_SYSTEM_SNAPPING_HPP
diff --git a/src/ecs/systems/spatial-system.cpp b/src/entity/systems/spatial.cpp
similarity index 59%
rename from src/ecs/systems/spatial-system.cpp
rename to src/entity/systems/spatial.cpp
index bf901cf..5fc8ca5 100644
--- a/src/ecs/systems/spatial-system.cpp
+++ b/src/entity/systems/spatial.cpp
@@ -17,42 +17,44 @@
* along with Antkeeper source code. If not, see .
*/
-#include "spatial-system.hpp"
-#include "ecs/components/parent-component.hpp"
-#include "ecs/components/transform-component.hpp"
+#include "spatial.hpp"
+#include "entity/components/parent.hpp"
+#include "entity/components/transform.hpp"
-namespace ecs {
+namespace entity {
+namespace system {
-spatial_system::spatial_system(ecs::registry& registry):
- entity_system(registry)
+spatial::spatial(entity::registry& registry):
+ updatable(registry)
{}
-void spatial_system::update(double t, double dt)
+void spatial::update(double t, double dt)
{
/// @TODO: sort transforms by parent, for more multi-level hierarchies
// Process parent transforms first
- registry.view().each(
- [&](ecs::entity entity, auto& transform)
+ registry.view().each(
+ [&](entity::id entity_id, auto& transform)
{
- if (!this->registry.has(entity))
+ if (!this->registry.has(entity_id))
{
transform.world = transform.local;
}
});
// Process child transforms second
- registry.view().each(
- [&](ecs::entity entity, auto& transform)
+ registry.view().each(
+ [&](entity::id entity_id, auto& transform)
{
- if (this->registry.has(entity))
+ if (this->registry.has(entity_id))
{
- ecs::entity parent = this->registry.get