Not using Weapon anymore.

master
Zed A. Shaw 19 hours ago
parent 57d69015c2
commit 7602fb0b31
  1. 1
      components.cpp
  2. 5
      components.hpp
  3. 4
      dinkyecs.hpp
  4. 1
      pathing.cpp
  5. 53
      tests/dinkyecs.cpp

@ -19,7 +19,6 @@ namespace components {
components::enroll<BossFight>(MAP); components::enroll<BossFight>(MAP);
components::enroll<Combat>(MAP); components::enroll<Combat>(MAP);
components::enroll<Position>(MAP); components::enroll<Position>(MAP);
components::enroll<Weapon>(MAP);
components::enroll<Curative>(MAP); components::enroll<Curative>(MAP);
components::enroll<EnemyConfig>(MAP); components::enroll<EnemyConfig>(MAP);
components::enroll<Personality>(MAP); components::enroll<Personality>(MAP);

@ -63,10 +63,6 @@ namespace components {
std::string ai_goal_name; std::string ai_goal_name;
}; };
struct Weapon {
int damage = 0;
};
struct Curative { struct Curative {
int hp = 10; int hp = 10;
}; };
@ -145,7 +141,6 @@ namespace components {
ENROLL_COMPONENT(Sprite, name, width, height, scale); ENROLL_COMPONENT(Sprite, name, width, height, scale);
ENROLL_COMPONENT(Curative, hp); ENROLL_COMPONENT(Curative, hp);
ENROLL_COMPONENT(LightSource, strength, radius); ENROLL_COMPONENT(LightSource, strength, radius);
ENROLL_COMPONENT(Weapon, damage);
ENROLL_COMPONENT(Position, location.x, location.y); ENROLL_COMPONENT(Position, location.x, location.y);
ENROLL_COMPONENT(EnemyConfig, ai_script, ai_start_name, ai_goal_name); ENROLL_COMPONENT(EnemyConfig, ai_script, ai_start_name, ai_goal_name);
ENROLL_COMPONENT(Personality, hearing_distance, tough); ENROLL_COMPONENT(Personality, hearing_distance, tough);

@ -40,6 +40,10 @@ namespace DinkyECS
Entity entity() { return ++entity_count; } Entity entity() { return ++entity_count; }
void destroy(DinkyECS::Entity entity) {
(void)entity;
}
void clone_into(DinkyECS::World &to_world) { void clone_into(DinkyECS::World &to_world) {
to_world.$constants = $constants; to_world.$constants = $constants;
to_world.$facts = $facts; to_world.$facts = $facts;

@ -112,7 +112,6 @@ bool Pathing::random_walk(Point &out, bool random,
int cur = $paths[out.y][out.x]; int cur = $paths[out.y][out.x];
// pick a random start of directions // pick a random start of directions
// BUG: is uniform inclusive of the dir.size()?
int rand_start = Random::uniform<int>(0, dist_size); int rand_start = Random::uniform<int>(0, dist_size);
// go through all possible directions // go through all possible directions

@ -192,54 +192,11 @@ TEST_CASE("confirm copying and constants", "[ecs-constants]") {
REQUIRE(player2.eid == player_info.eid); REQUIRE(player2.eid == player_info.eid);
} }
TEST_CASE("can destroy all entity", "[ecs-destroy]") {
TEST_CASE("test serialization with nlohmann::json", "[ecs-serialize]") {
/*
DinkyECS::ComponentMap component_map;
DinkyECS::Component<Position>(component_map);
DinkyECS::Component<Velocity>(component_map);
DinkyECS::Component<Motion>(component_map);
DinkyECS::Component<Gravity>(component_map);
DinkyECS::Component<DaGUI>(component_map);
auto data = R"(
[
{
"_type": "Position",
"location": {
"x": 10,
"y": 5
}
},
{
"_type": "Motion",
"dx": 0,
"dy": 1
},
{
"_type": "Velocity",
"x": 0.1,
"y": 10.2
}
]
)"_json;
DinkyECS::World world; DinkyECS::World world;
DinkyECS::Entity ent1 = world.entity(); auto entity = world.entity();
DinkyECS::Entity ent2 = world.entity();
DinkyECS::configure(component_map, world, ent1, data);
DinkyECS::configure(component_map, world, ent2, data);
world.query<Position, Motion>([&](const auto ent, auto &pos, auto &motion) { world.set<Velocity>(entity, {10,10});
fmt::println("entity: {}; position={},{} and motion={},{} motion.random={}", world.set<Gravity>(entity, {1});
ent, pos.location.x, pos.location.y, world.set<Motion>(entity, {0,0});
motion.dx, motion.dy, motion.random);
REQUIRE(pos.location.x == 10);
REQUIRE(pos.location.y == 5);
REQUIRE(motion.dx == 0);
REQUIRE(motion.dy == 1);
REQUIRE(motion.random == false);
});
*/
} }

Loading…
Cancel
Save