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

Method runParallel

source/game/StarBehaviorState.cpp:330–351  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

328}
329
330NodeStatus BehaviorState::runParallel(ParallelNode const& node, NodeState& state) {
331 if (state.isNothing())
332 state.set(CompositeState(node.children.size()));
333
334 CompositeState& composite = state->get<CompositeState>();
335
336 int failed = 0;
337 int succeeded = 0;
338 for (size_t i = 0; i < node.children.size(); i++) {
339 NodeStatus status = runNode(*node.children[i], *composite.children[i]);
340 if (status == NodeStatus::Success)
341 succeeded++;
342 else if (status == NodeStatus::Failure)
343 failed++;
344
345 if (succeeded >= node.succeed || failed >= node.fail) {
346 return succeeded >= node.succeed ? NodeStatus::Success : NodeStatus::Failure;
347 }
348 }
349
350 return NodeStatus::Running;
351}
352
353NodeStatus BehaviorState::runDynamic(DynamicNode const& node, NodeState& state) {
354 if (state.isNothing())

Callers

nothing calls this directly

Calls 4

CompositeStateClass · 0.85
isNothingMethod · 0.80
setMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected