MCPcopy Create free account
hub / github.com/IppClub/Dora-SSR / start

Method start

Source/Platformer/Unit.cpp:327–357  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

325}
326
327bool Unit::start(String name) {
328 auto it = _actions.find(name);
329 if (it != _actions.end()) {
330 UnitAction* action = it->second.get();
331 if (action->isDoing()) return true;
332 if (action->isAvailable()) {
333 if (_currentAction && _currentAction->isDoing()) {
334 if (_currentAction->getPriority() < action->getPriority()) {
335 _currentAction->stop();
336 _currentAction->_status = Behavior::Status::Failure;
337 } else if (_currentAction->getPriority() == action->getPriority() && !_currentAction->isQueued()) {
338 _currentAction->stop();
339 _currentAction->_status = Behavior::Status::Failure;
340 } else {
341 action->_status = Behavior::Status::Failure;
342 return false;
343 }
344 }
345 action->run();
346 if (action->isDoing()) {
347 action->_status = Behavior::Status::Running;
348 _currentAction = action;
349 } else {
350 action->_status = Behavior::Status::Success;
351 _currentAction = nullptr;
352 }
353 return true;
354 }
355 }
356 return false;
357}
358
359void Unit::stop() {
360 if (_currentAction && _currentAction->isDoing()) {

Callers

nothing calls this directly

Calls 9

getPriorityMethod · 0.80
findMethod · 0.65
getMethod · 0.65
stopMethod · 0.65
runMethod · 0.65
endMethod · 0.45
isDoingMethod · 0.45
isAvailableMethod · 0.45
isQueuedMethod · 0.45

Tested by

no test coverage detected