| 201 | } |
| 202 | |
| 203 | NodeStatus 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 | |
| 239 | NodeStatus BehaviorState::runDecorator(DecoratorNode const& node, NodeState& state) { |
| 240 | uint64_t id = (uint64_t)&node; |
nothing calls this directly
no test coverage detected