Skip to content

Commit 70c6229

Browse files
committed
gamestate: Handle XorSwichGate in activity system.
1 parent 9d817bc commit 70c6229

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

libopenage/gamestate/activity/types.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2023-2023 the openage authors. See copying.md for legal info.
1+
// Copyright 2023-2024 the openage authors. See copying.md for legal info.
22

33
#pragma once
44

libopenage/gamestate/system/activity.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include "gamestate/activity/types.h"
1717
#include "gamestate/activity/xor_event_gate.h"
1818
#include "gamestate/activity/xor_gate.h"
19+
#include "gamestate/activity/xor_switch_gate.h"
1920
#include "gamestate/component/internal/activity.h"
2021
#include "gamestate/component/types.h"
2122
#include "gamestate/game_entity.h"
@@ -112,6 +113,15 @@ void Activity::advance(const time::time_t &start_time,
112113
event_wait_time = 0;
113114
stop = true;
114115
} break;
116+
case activity::node_t::XOR_SWITCH_GATE: {
117+
auto node = std::dynamic_pointer_cast<activity::XorSwitchGate>(current_node);
118+
auto next_id = node->get_default()->get_id();
119+
auto key = node->get_lookup_func()(start_time, entity);
120+
if (node->get_lookup_dict().contains(key)) {
121+
next_id = node->get_lookup_dict().at(key)->get_id();
122+
}
123+
current_node = node->next(next_id);
124+
} break;
115125
default:
116126
throw Error{ERR << "Unhandled node type for node " << current_node->str()};
117127
}

0 commit comments

Comments
 (0)