MCPcopy Create free account
hub / github.com/OpenStarbound/OpenStarbound / runAction

Method runAction

source/game/StarBehaviorState.cpp:203–237  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

201}
202
203NodeStatus BehaviorState::runAction(ActionNode const& node, NodeState& state) {
204 uint64_t id = (uint64_t)&node;
205
206 auto result = ActionReturn(NodeStatus::Invalid, LuaNil);
207 if (state.isNothing()) {
208 LuaTable parameters = board()->parameters(node.parameters, id);
209 LuaThread thread = nodeLuaThread(node.name);
210 try {
211 result = thread.resume<ActionReturn>(parameters, blackboardPtr(), id, m_lastDt).value(ActionReturn(NodeStatus::Invalid, LuaNil));
212 } catch (LuaException const& e) {
213 throw StarException(strf("Lua Exception caught running action node {} in behavior {}: {}", node.name, m_tree->name, outputException(e, false)));
214 }
215
216 auto status = get<0>(result);
217 if (status != NodeStatus::Success && status != NodeStatus::Failure)
218 state.set(ActionState{thread});
219 } else {
220 LuaThread const& thread = state->get<ActionState>().thread;
221
222 try {
223 result = thread.resume<ActionReturn>(m_lastDt).value(ActionReturn(NodeStatus::Invalid, LuaNil));
224 } catch (LuaException const& e) {
225 throw StarException(strf("Lua Exception caught resuming action node {} in behavior {}: {}", node.name, m_tree->name, outputException(e, false)));
226 }
227
228 auto status = get<0>(result);
229 if (status == NodeStatus::Success || status == NodeStatus::Failure)
230 m_threads.append(thread);
231 }
232
233 if (auto table = get<1>(result).maybe<LuaTable>())
234 board()->setOutput(node, *table);
235
236 return get<0>(result);
237}
238
239NodeStatus BehaviorState::runDecorator(DecoratorNode const& node, NodeState& state) {
240 uint64_t id = (uint64_t)&node;

Callers

nothing calls this directly

Calls 9

StarExceptionClass · 0.85
strfFunction · 0.85
isNothingMethod · 0.80
setOutputMethod · 0.80
outputExceptionFunction · 0.50
parametersMethod · 0.45
valueMethod · 0.45
setMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected