Skip to content

Commit a6cef6c

Browse files
committed
gamestate: Add LineOfSight component.
1 parent 16a1df3 commit a6cef6c

File tree

5 files changed

+37
-0
lines changed

5 files changed

+37
-0
lines changed

libopenage/gamestate/component/api/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
add_sources(libopenage
22
apply_effect.cpp
33
idle.cpp
4+
line_of_sight.cpp
45
live.cpp
56
move.cpp
67
resistance.cpp
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// Copyright 2024-2024 the openage authors. See copying.md for legal info.
2+
3+
#include "line_of_sight.h"
4+
5+
6+
namespace openage::gamestate::component {
7+
8+
component_t LineOfSight::get_type() const {
9+
return component_t::LINE_OF_SIGHT;
10+
}
11+
12+
} // namespace openage::gamestate::component
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Copyright 2024-2024 the openage authors. See copying.md for legal info.
2+
3+
#pragma once
4+
5+
#include "gamestate/component/api_component.h"
6+
#include "gamestate/component/types.h"
7+
8+
9+
namespace openage::gamestate::component {
10+
11+
class LineOfSight final : public APIComponent {
12+
public:
13+
using APIComponent::APIComponent;
14+
15+
component_t get_type() const override;
16+
};
17+
18+
} // namespace openage::gamestate::component

libopenage/gamestate/component/types.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ enum class component_t {
2323
MOVE,
2424
SELECTABLE,
2525
LIVE,
26+
LINE_OF_SIGHT,
2627
};
2728

2829
} // namespace openage::gamestate::component

libopenage/gamestate/entity_factory.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include "gamestate/api/activity.h"
2626
#include "gamestate/component/api/apply_effect.h"
2727
#include "gamestate/component/api/idle.h"
28+
#include "gamestate/component/api/line_of_sight.h"
2829
#include "gamestate/component/api/live.h"
2930
#include "gamestate/component/api/move.h"
3031
#include "gamestate/component/api/resistance.h"
@@ -221,6 +222,10 @@ void EntityFactory::init_components(const std::shared_ptr<openage::event::EventL
221222
auto resistance = std::make_shared<component::Resistance>(loop, ability_obj);
222223
entity->add_component(resistance);
223224
}
225+
else if (ability_parent == "engine.ability.type.LineOfSight") {
226+
auto line_of_sight = std::make_shared<component::LineOfSight>(loop, ability_obj);
227+
entity->add_component(line_of_sight);
228+
}
224229
else {
225230
log::log(DBG << "Entity has unrecognized ability type: " << ability_parent);
226231
}

0 commit comments

Comments
 (0)