Skip to content

Commit a8df5d5

Browse files
committed
gamestate: Rename condition_t to condition_function_t.
1 parent b0d6eb4 commit a8df5d5

File tree

6 files changed

+20
-20
lines changed

6 files changed

+20
-20
lines changed

libopenage/gamestate/activity/tests.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -233,10 +233,10 @@ void activity_demo() {
233233

234234
// Conditional branch
235235
static size_t counter = 0;
236-
activity::condition_t branch_task1 = [&](const time::time_t & /* time */,
237-
const std::shared_ptr<gamestate::GameEntity> & /* entity */,
238-
const std::shared_ptr<gamestate::GameState> & /* state */,
239-
const std::shared_ptr<nyan::Object> & /* api_object */) {
236+
activity::condition_function_t branch_task1 = [&](const time::time_t & /* time */,
237+
const std::shared_ptr<gamestate::GameEntity> & /* entity */,
238+
const std::shared_ptr<gamestate::GameState> & /* state */,
239+
const std::shared_ptr<nyan::Object> & /* api_object */) {
240240
log::log(INFO << "Checking condition (counter < 4): counter=" << counter);
241241
if (counter < 4) {
242242
log::log(INFO << "Selecting path 1 (back to task node " << task1->get_id() << ")");
@@ -249,10 +249,10 @@ void activity_demo() {
249249
xor_node->add_output(task1,
250250
{nullptr, // API object set to nullptr as it's never used by condition func
251251
branch_task1});
252-
activity::condition_t branch_event = [&](const time::time_t & /* time */,
253-
const std::shared_ptr<gamestate::GameEntity> & /* entity */,
254-
const std::shared_ptr<gamestate::GameState> & /* state */,
255-
const std::shared_ptr<nyan::Object> & /* api_object */) {
252+
activity::condition_function_t branch_event = [&](const time::time_t & /* time */,
253+
const std::shared_ptr<gamestate::GameEntity> & /* entity */,
254+
const std::shared_ptr<gamestate::GameState> & /* state */,
255+
const std::shared_ptr<nyan::Object> & /* api_object */) {
256256
// No check needed here, the event node is always selected
257257
log::log(INFO << "Selecting path 2 (to event node " << event_node->get_id() << ")");
258258
return true;

libopenage/gamestate/activity/types.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,10 @@ using event_primer_t = std::function<std::shared_ptr<openage::event::Event>(cons
6868
*
6969
* @return true if the output node is chosen, false otherwise.
7070
*/
71-
using condition_t = std::function<bool(const time::time_t &time,
72-
const std::shared_ptr<gamestate::GameEntity> &entity,
73-
const std::shared_ptr<gamestate::GameState> &state,
74-
const std::shared_ptr<nyan::Object> &api_object)>;
71+
using condition_function_t = std::function<bool(const time::time_t &time,
72+
const std::shared_ptr<gamestate::GameEntity> &entity,
73+
const std::shared_ptr<gamestate::GameState> &state,
74+
const std::shared_ptr<nyan::Object> &api_object)>;
7575

7676
/**
7777
* Condition used to determine if an output node is chosen.
@@ -81,7 +81,7 @@ struct condition {
8181
std::shared_ptr<nyan::Object> api_object;
8282
/// Checks whether the condition is true.
8383
/// TODO: We could look this function up at runtime.
84-
condition_t function;
84+
condition_function_t function;
8585
};
8686

8787
/**

libopenage/gamestate/api/activity.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ bool APIActivityCondition::is_condition(const nyan::Object &obj) {
151151
return api_parent == "engine.util.activity.condition.Condition";
152152
}
153153

154-
activity::condition_t APIActivityCondition::get_condition(const nyan::Object &condition) {
154+
activity::condition_function_t APIActivityCondition::get_condition(const nyan::Object &condition) {
155155
nyan::fqon_t api_parent = get_api_parent(condition);
156156

157157
return ACTIVITY_CONDITION_LOOKUP.get(api_parent);

libopenage/gamestate/api/activity.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ class APIActivityCondition {
107107
*
108108
* @return Condition function.
109109
*/
110-
static activity::condition_t get_condition(const nyan::Object &condition);
110+
static activity::condition_function_t get_condition(const nyan::Object &condition);
111111
};
112112

113113
/**

libopenage/gamestate/api/definitions.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ static const auto ACTIVITY_TASK_SYSTEM_LOOKUP = datastructure::create_const_map<
311311
/**
312312
* Maps API activity condition types to engine condition types.
313313
*/
314-
static const auto ACTIVITY_CONDITION_LOOKUP = datastructure::create_const_map<std::string, activity::condition_t>(
314+
static const auto ACTIVITY_CONDITION_LOOKUP = datastructure::create_const_map<std::string, activity::condition_function_t>(
315315
std::pair("engine.util.activity.condition.type.CommandInQueue",
316316
std::function(gamestate::activity::command_in_queue)),
317317
std::pair("engine.util.activity.condition.type.NextCommand",

libopenage/gamestate/entity_factory.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,10 @@ std::shared_ptr<activity::Activity> create_test_activity() {
8080
idle->set_system_id(system::system_id_t::IDLE);
8181

8282
// branch 1: check if the entity is moveable
83-
activity::condition_t command_branch = [&](const time::time_t & /* time */,
84-
const std::shared_ptr<gamestate::GameEntity> &entity,
85-
const std::shared_ptr<gamestate::GameState> & /* state */,
86-
const std::shared_ptr<nyan::Object> & /* api_object */) {
83+
activity::condition_function_t command_branch = [&](const time::time_t & /* time */,
84+
const std::shared_ptr<gamestate::GameEntity> &entity,
85+
const std::shared_ptr<gamestate::GameState> & /* state */,
86+
const std::shared_ptr<nyan::Object> & /* api_object */) {
8787
return entity->has_component(component::component_t::MOVE);
8888
};
8989
condition_moveable->add_output(condition_command,

0 commit comments

Comments
 (0)