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

Method runDynamic

source/game/StarBehaviorState.cpp:353–375  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

351}
352
353NodeStatus BehaviorState::runDynamic(DynamicNode const& node, NodeState& state) {
354 if (state.isNothing())
355 state.set(CompositeState(node.children.size()));
356
357 CompositeState& composite = state->get<CompositeState>();
358 for (size_t i = 0; i <= composite.index; i++) {
359 auto child = node.children.get(i);
360 auto status = runNode(*child, *composite.children.get(i));
361 if (status == NodeStatus::Failure && i == composite.index)
362 composite.index++;
363
364 if (i < composite.index && (status == NodeStatus::Success || status == NodeStatus::Running)) {
365 composite.children[composite.index]->reset();
366 composite.index = i;
367 }
368
369 if (status == NodeStatus::Success || composite.index >= node.children.size()) {
370 return status;
371 }
372 }
373
374 return NodeStatus::Running;
375}
376
377NodeStatus BehaviorState::runRandomize(RandomizeNode const& node, NodeState& state) {
378 if (state.isNothing())

Callers

nothing calls this directly

Calls 6

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

Tested by

no test coverage detected