Browse Source

Rename ecs namespace to entity, move components to entity::component namespace, move systems into entity::system namespace

master
C. J. Howard 3 months ago
parent
commit
7ec19ab5be
99 changed files with 1833 additions and 1773 deletions
  1. +0
    -143
      src/ecs/commands.cpp
  2. +0
    -49
      src/ecs/commands.hpp
  3. +0
    -34
      src/ecs/components/copy-transform-component.hpp
  4. +0
    -34
      src/ecs/components/ephemeris-component.hpp
  5. +0
    -34
      src/ecs/components/parent-component.hpp
  6. +0
    -45
      src/ecs/systems/collision-system.cpp
  7. +0
    -43
      src/ecs/systems/entity-system.hpp
  8. +0
    -75
      src/ecs/systems/render-system.hpp
  9. +0
    -37
      src/ecs/systems/spatial-system.hpp
  10. +0
    -22
      src/ecs/systems/updatable-system.cpp
  11. +5
    -5
      src/entity/archetype.hpp
  12. +143
    -0
      src/entity/commands.cpp
  13. +49
    -0
      src/entity/commands.hpp
  14. +8
    -6
      src/entity/components/atmosphere.hpp
  15. +9
    -7
      src/entity/components/behavior.hpp
  16. +8
    -6
      src/entity/components/blackbody.hpp
  17. +8
    -6
      src/entity/components/brush.hpp
  18. +8
    -6
      src/entity/components/camera-follow.hpp
  19. +8
    -6
      src/entity/components/cavity.hpp
  20. +8
    -6
      src/entity/components/celestial-body.hpp
  21. +9
    -7
      src/entity/components/chamber.hpp
  22. +8
    -6
      src/entity/components/collision.hpp
  23. +36
    -0
      src/entity/components/copy-rotation.hpp
  24. +10
    -8
      src/entity/components/copy-scale.hpp
  25. +36
    -0
      src/entity/components/copy-transform.hpp
  26. +10
    -8
      src/entity/components/copy-translation.hpp
  27. +8
    -6
      src/entity/components/diffuse-reflector.hpp
  28. +8
    -6
      src/entity/components/light.hpp
  29. +8
    -6
      src/entity/components/locomotion.hpp
  30. +8
    -6
      src/entity/components/marker.hpp
  31. +9
    -7
      src/entity/components/model.hpp
  32. +10
    -8
      src/entity/components/nest.hpp
  33. +8
    -6
      src/entity/components/orbit.hpp
  34. +10
    -8
      src/entity/components/parent.hpp
  35. +8
    -6
      src/entity/components/samara.hpp
  36. +8
    -6
      src/entity/components/snap.hpp
  37. +8
    -6
      src/entity/components/terrain.hpp
  38. +8
    -6
      src/entity/components/tool.hpp
  39. +8
    -6
      src/entity/components/trackable.hpp
  40. +8
    -6
      src/entity/components/transform.hpp
  41. +6
    -6
      src/entity/ebt.cpp
  42. +9
    -9
      src/entity/ebt.hpp
  43. +5
    -5
      src/entity/ecs.hpp
  44. +6
    -6
      src/entity/id.hpp
  45. +5
    -5
      src/entity/registry.hpp
  46. +34
    -32
      src/entity/systems/astronomy.cpp
  47. +22
    -20
      src/entity/systems/astronomy.hpp
  48. +18
    -16
      src/entity/systems/atmosphere.cpp
  49. +16
    -14
      src/entity/systems/atmosphere.hpp
  50. +13
    -11
      src/entity/systems/behavior.cpp
  51. +11
    -9
      src/entity/systems/behavior.hpp
  52. +26
    -24
      src/entity/systems/blackbody.cpp
  53. +19
    -17
      src/entity/systems/blackbody.hpp
  54. +25
    -23
      src/entity/systems/camera.cpp
  55. +17
    -15
      src/entity/systems/camera.hpp
  56. +47
    -0
      src/entity/systems/collision.cpp
  57. +15
    -13
      src/entity/systems/collision.hpp
  58. +26
    -24
      src/entity/systems/constraint.cpp
  59. +11
    -9
      src/entity/systems/constraint.hpp
  60. +22
    -20
      src/entity/systems/control.cpp
  61. +48
    -46
      src/entity/systems/control.hpp
  62. +14
    -12
      src/entity/systems/locomotion.cpp
  63. +39
    -0
      src/entity/systems/locomotion.hpp
  64. +16
    -12
      src/entity/systems/nest.cpp
  65. +14
    -12
      src/entity/systems/nest.hpp
  66. +14
    -12
      src/entity/systems/orbit.cpp
  67. +11
    -9
      src/entity/systems/orbit.hpp
  68. +30
    -28
      src/entity/systems/painting.cpp
  69. +14
    -12
      src/entity/systems/painting.hpp
  70. +48
    -46
      src/entity/systems/render.cpp
  71. +77
    -0
      src/entity/systems/render.hpp
  72. +13
    -11
      src/entity/systems/samara.cpp
  73. +10
    -9
      src/entity/systems/samara.hpp
  74. +17
    -15
      src/entity/systems/snapping.cpp
  75. +11
    -8
      src/entity/systems/snapping.hpp
  76. +18
    -16
      src/entity/systems/spatial.cpp
  77. +11
    -9
      src/entity/systems/spatial.hpp
  78. +25
    -23
      src/entity/systems/subterrain.cpp
  79. +14
    -12
      src/entity/systems/subterrain.hpp
  80. +31
    -29
      src/entity/systems/terrain.cpp
  81. +16
    -14
      src/entity/systems/terrain.hpp
  82. +34
    -32
      src/entity/systems/tool.cpp
  83. +17
    -15
      src/entity/systems/tool.hpp
  84. +24
    -22
      src/entity/systems/tracking.cpp
  85. +16
    -14
      src/entity/systems/tracking.hpp
  86. +20
    -18
      src/entity/systems/ui.cpp
  87. +9
    -7
      src/entity/systems/ui.hpp
  88. +6
    -5
      src/entity/systems/updatable.cpp
  89. +21
    -7
      src/entity/systems/updatable.hpp
  90. +24
    -22
      src/entity/systems/vegetation.cpp
  91. +15
    -13
      src/entity/systems/vegetation.hpp
  92. +65
    -65
      src/game/bootloader.cpp
  93. +2
    -2
      src/game/events/tool-events.cpp
  94. +3
    -3
      src/game/events/tool-events.hpp
  95. +59
    -56
      src/game/game-context.hpp
  96. +108
    -108
      src/game/states/play-state.cpp
  97. +0
    -1
      src/nest.hpp
  98. +22
    -22
      src/resources/behavior-tree-loader.cpp
  99. +64
    -66
      src/resources/entity-archetype-loader.cpp

+ 0
- 143
src/ecs/commands.cpp View File

@ -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 <http://www.gnu.org/licenses/>.
*/
#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 <limits>
namespace ecs {
namespace command {
void translate(ecs::registry& registry, ecs::entity entity, const float3& translation)
{
if (registry.has<transform_component>(entity))
{
transform_component& transform = registry.get<transform_component>(entity);
transform.local.translation += translation;
}
}
void move_to(ecs::registry& registry, ecs::entity entity, const float3& position)
{
if (registry.has<transform_component>(entity))
{
transform_component& transform = registry.get<transform_component>(entity);
transform.local.translation = position;
}
}
void warp_to(ecs::registry& registry, ecs::entity entity, const float3& position)
{
if (registry.has<transform_component>(entity))
{
transform_component& transform = registry.get<transform_component>(entity);
transform.local.translation = position;
transform.warp = true;
}
}
void set_scale(ecs::registry& registry, ecs::entity entity, const float3& scale)
{
if (registry.has<transform_component>(entity))
{
transform_component& transform = registry.get<transform_component>(entity);
transform.local.scale = scale;
}
}
void set_transform(ecs::registry& registry, ecs::entity entity, const math::transform<float>& transform, bool warp)
{
if (registry.has<transform_component>(entity))
{
transform_component& component = registry.get<transform_component>(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<snap_component>(entity, component);
}
void assign_render_layers(ecs::registry& registry, ecs::entity entity, unsigned int layers)
{
if (registry.has<model_component>(entity))
{
model_component model = registry.get<model_component>(entity);
model.layers = layers;
registry.replace<model_component>(entity, model);
// Apply to child layers
registry.view<parent_component>().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<copy_transform_component>(source, copy_transform);
}
math::transform<float> get_local_transform(ecs::registry& registry, ecs::entity entity)
{
if (registry.has<transform_component>(entity))
{
const transform_component& component = registry.get<transform_component>(entity);
return component.local;
}
return math::identity_transform<float>;
}
math::transform<float> get_world_transform(ecs::registry& registry, ecs::entity entity)
{
if (registry.has<transform_component>(entity))
{
const transform_component& component = registry.get<transform_component>(entity);
return component.world;
}
return math::identity_transform<float>;
}
void parent(ecs::registry& registry, entity child, entity parent)
{
parent_component component;
component.parent = parent;
registry.assign_or_replace<parent_component>(child, component);
}
} // namespace command
} // namespace ecs

+ 0
- 49
src/ecs/commands.hpp View File

@ -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 <http://www.gnu.org/licenses/>.
*/
#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<float>& 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<float> get_local_transform(ecs::registry& registry, ecs::entity entity);
math::transform<float> 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

+ 0
- 34
src/ecs/components/copy-transform-component.hpp View File

@ -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 <http://www.gnu.org/licenses/>.
*/
#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

+ 0
- 34
src/ecs/components/ephemeris-component.hpp View File

@ -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 <http://www.gnu.org/licenses/>.
*/
#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

+ 0
- 34
src/ecs/components/parent-component.hpp View File

@ -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 <http://www.gnu.org/licenses/>.
*/
#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

+ 0
- 45
src/ecs/systems/collision-system.cpp View File

@ -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 <http://www.gnu.org/licenses/>.
*/
#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<collision_component>().connect<&collision_system::on_collision_construct>(this);
registry.on_replace<collision_component>().connect<&collision_system::on_collision_replace>(this);
registry.on_destroy<collision_component>().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

+ 0
- 43
src/ecs/systems/entity-system.hpp View File

@ -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 <http://www.gnu.org/licenses/>.
*/
#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

+ 0
- 75
src/ecs/systems/render-system.hpp View File

@ -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 <http://www.gnu.org/licenses/>.
*/
#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 <unordered_map>
#include <vector>
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<scene::collection*> layers;
std::unordered_map<entity, scene::model_instance*> model_instances;
std::unordered_map<entity, scene::light*> lights;
};
} // namespace ecs
#endif // ANTKEEPER_ECS_RENDER_SYSTEM_HPP

+ 0
- 37
src/ecs/systems/spatial-system.hpp View File

@ -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 <http://www.gnu.org/licenses/>.
*/
#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

+ 0
- 22
src/ecs/systems/updatable-system.cpp View File

@ -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 <http://www.gnu.org/licenses/>.
*/
#include "updatable-system.hpp"

src/ecs/archetype.hpp → src/entity/archetype.hpp View File

@ -17,16 +17,16 @@
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef ANTKEEPER_ECS_ARCHETYPE_HPP
#define ANTKEEPER_ECS_ARCHETYPE_HPP
#ifndef ANTKEEPER_ENTITY_ARCHETYPE_HPP
#define ANTKEEPER_ENTITY_ARCHETYPE_HPP
#include <entt/entt.hpp>
namespace ecs {
namespace entity {
typedef entt::prototype archetype;
} // namespace ecs
} // namespace entity
#endif // ANTKEEPER_ECS_ARCHETYPE_HPP
#endif // ANTKEEPER_ENTITY_ARCHETYPE_HPP

+ 143
- 0
src/entity/commands.cpp View File

@ -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 <http://www.gnu.org/licenses/>.
*/
#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 <limits>
namespace entity {
namespace command {
void translate(entity::registry& registry, entity::id entity_id, const float3& translation)
{
if (registry.has<component::transform>(entity_id))
{
component::transform& transform = registry.get<component::transform>(entity_id);
transform.local.translation += translation;
}
}
void move_to(entity::registry& registry, entity::id entity_id, const float3& position)
{
if (registry.has<component::transform>(entity_id))
{
component::transform& transform = registry.get<component::transform>(entity_id);
transform.local.translation = position;
}
}
void warp_to(entity::registry& registry, entity::id entity_id, const float3& position)
{
if (registry.has<component::transform>(entity_id))
{
component::transform& transform = registry.get<component::transform>(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<component::transform>(entity_id))
{
component::transform& transform = registry.get<component::transform>(entity_id);
transform.local.scale = scale;
}
}
void set_transform(entity::registry& registry, entity::id entity_id, const math::transform<float>& transform, bool warp)
{
if (registry.has<component::transform>(entity_id))
{
component::transform& component = registry.get<component::transform>(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<component::snap>(entity_id, component);
}
void assign_render_layers(entity::registry& registry, entity::id entity_id, unsigned int layers)
{
if (registry.has<component::model>(entity_id))
{
component::model model = registry.get<component::model>(entity_id);
model.layers = layers;
registry.replace<component::model>(entity_id, model);
// Apply to child layers
registry.view<component::parent>().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<component::copy_transform>(source, copy_transform);
}
math::transform<float> get_local_transform(entity::registry& registry, entity::id entity_id)
{
if (registry.has<component::transform>(entity_id))
{
const component::transform& component = registry.get<component::transform>(entity_id);
return component.local;
}
return math::identity_transform<float>;
}
math::transform<float> get_world_transform(entity::registry& registry, entity::id entity_id)
{
if (registry.has<component::transform>(entity_id))
{
const component::transform& component = registry.get<component::transform>(entity_id);
return component.world;
}
return math::identity_transform<float>;
}
void parent(entity::registry& registry, entity::id child, entity::id parent)
{
component::parent component;
component.parent = parent;
registry.assign_or_replace<component::parent>(child, component);
}
} // namespace command
} // namespace entity

+ 49
- 0
src/entity/commands.hpp View File

@ -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 <http://www.gnu.org/licenses/>.
*/
#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<float>& 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<float> get_local_transform(entity::registry& registry, entity::id entity_id);
math::transform<float> 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

src/ecs/components/atmosphere-component.hpp → src/entity/components/atmosphere.hpp View File

@ -17,15 +17,16 @@
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#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

src/ecs/components/behavior-component.hpp → src/entity/components/behavior.hpp View File

@ -17,19 +17,21 @@
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#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

src/ecs/components/blackbody-component.hpp → src/entity/components/blackbody.hpp View File

@ -17,13 +17,14 @@
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#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

src/ecs/components/brush-component.hpp → src/entity/components/brush.hpp View File

@ -17,16 +17,18 @@
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#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

src/ecs/components/camera-follow-component.hpp → src/entity/components/camera-follow.hpp View File

@ -17,17 +17,19 @@
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#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

src/ecs/components/cavity-component.hpp → src/entity/components/cavity.hpp View File

@ -17,20 +17,22 @@
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#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

src/ecs/components/celestial-body-component.hpp → src/entity/components/celestial-body.hpp View File

@ -17,13 +17,14 @@
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#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

src/ecs/components/chamber-component.hpp → src/entity/components/chamber.hpp View File

@ -17,16 +17,17 @@
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#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 <array>
#include <unordered_set>
#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<std::array<int, 2>> tiles;
}
} // namespace ecs
} // namespace component
} // namespace entity
#endif // ANTKEEPER_ECS_CHAMBER_COMPONENT_HPP
#endif // ANTKEEPER_ENTITY_COMPONENT_CHAMBER_HPP

src/ecs/components/collision-component.hpp → src/entity/components/collision.hpp View File

@ -17,23 +17,25 @@
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#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<float> bounds;
geom::mesh_accelerator mesh_accelerator;
};
} // namespace ecs
} // namespace component
} // namespace entity
#endif // ANTKEEPER_ECS_COLLISION_COMPONENT_HPP
#endif // ANTKEEPER_ENTITY_COMPONENT_COLLISION_HPP

+ 36
- 0
src/entity/components/copy-rotation.hpp View File

@ -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 <http://www.gnu.org/licenses/>.
*/
#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

src/ecs/components/copy-scale-component.hpp → src/entity/components/copy-scale.hpp View File

@ -17,21 +17,23 @@
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#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

+ 36
- 0
src/entity/components/copy-transform.hpp View File

@ -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 <http://www.gnu.org/licenses/>.
*/
#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

src/ecs/components/copy-translation-component.hpp → src/entity/components/copy-translation.hpp View File

@ -17,16 +17,17 @@
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#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

src/ecs/components/diffuse-reflector-component.hpp → src/entity/components/diffuse-reflector.hpp View File

@ -17,16 +17,18 @@
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#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

src/ecs/components/light-component.hpp → src/entity/components/light.hpp View File

@ -17,15 +17,16 @@
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#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

src/ecs/components/locomotion-component.hpp → src/entity/components/locomotion.hpp View File

@ -17,21 +17,23 @@
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#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

src/ecs/components/marker-component.hpp → src/entity/components/marker.hpp View File

@ -17,16 +17,18 @@
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#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

src/ecs/components/model-component.hpp → src/entity/components/model.hpp View File

@ -17,23 +17,25 @@
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#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 <unordered_map>
namespace ecs {
namespace entity {
namespace component {
struct model_component
struct model
{
model* model;
::model* render_model;
std::unordered_map<int, material*> 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

src/ecs/components/nest-component.hpp → src/entity/components/nest.hpp View File

@ -17,23 +17,25 @@
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#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 <vector>
#include "ecs/entity.hpp"
#include "entity/id.hpp"
namespace ecs {
namespace entity {
namespace component {
struct nest_component
struct nest
{
std::vector<entity> chambers;
std::vector<entity::id> 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

src/ecs/components/orbit-component.hpp → src/entity/components/orbit.hpp View File

@ -17,20 +17,22 @@
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#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<double> elements;
physics::orbit::state<double> state;
};
} // namespace ecs
} // namespace component
} // namespace entity
#endif // ANTKEEPER_ECS_ORBIT_COMPONENT_HPP
#endif // ANTKEEPER_ENTITY_COMPONENT_ORBIT_HPP

src/ecs/components/copy-rotation-component.hpp → src/entity/components/parent.hpp View File

@ -17,18 +17,20 @@
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#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

src/ecs/components/samara-component.hpp → src/entity/components/samara.hpp View File

@ -17,21 +17,23 @@
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#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

src/ecs/components/snap-component.hpp → src/entity/components/snap.hpp View File

@ -17,14 +17,15 @@
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#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<float> 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

src/ecs/components/terrain-component.hpp → src/entity/components/terrain.hpp View File

@ -17,19 +17,21 @@
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#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

src/ecs/component