| 204 | } |
| 205 | |
| 206 | bool Unit::update(double deltaTime) { |
| 207 | if (_flags.isOff(Node::Updating)) { |
| 208 | return Body::update(deltaTime); |
| 209 | } |
| 210 | if (_currentAction) { |
| 211 | if (_currentAction->isDoing()) { |
| 212 | _currentAction->update(s_cast<float>(deltaTime)); |
| 213 | if (_currentAction) { |
| 214 | if (_currentAction->isDoing()) { |
| 215 | _currentAction->_status = Behavior::Status::Running; |
| 216 | } else { |
| 217 | _currentAction->_status = Behavior::Status::Success; |
| 218 | _currentAction = nullptr; |
| 219 | } |
| 220 | } |
| 221 | } else { |
| 222 | _currentAction->_status = Behavior::Status::Success; |
| 223 | _currentAction = nullptr; |
| 224 | } |
| 225 | } else { |
| 226 | SharedAI.runDecisionTree(this); |
| 227 | } |
| 228 | if (_behaviorTree) { |
| 229 | _blackboard->setDeltaTime(deltaTime); |
| 230 | auto status = _behaviorTree->tick(_blackboard.get()); |
| 231 | if (status != Behavior::Status::Running) { |
| 232 | _blackboard->clear(); |
| 233 | _behaviorTree = nullptr; |
| 234 | } |
| 235 | } |
| 236 | return Body::update(deltaTime); |
| 237 | } |
| 238 | |
| 239 | void Unit::cleanup() { |
| 240 | if (_flags.isOff(Node::Cleanup)) { |
nothing calls this directly
no test coverage detected