- for (Need &need : needs) {
- need.Tick(dt);
- if (!need.IsSatisfied()) {
- health = std::max(0.0, health - need.penalty * dt);
+ // TODO: better integration method
+ glm::dvec3 acc(steering.Acceleration(*this));
+ situation.Move(vel * dt);
+ vel += acc * dt;
+
+ for (auto &need : needs) {
+ need->Tick(dt);
+ }
+ for (auto &goal : goals) {
+ goal->Tick(dt);
+ }
+ // do background stuff
+ for (auto &need : needs) {
+ need->ApplyEffect(*this, dt);
+ }
+ if (goals.empty()) {
+ return;
+ }
+ // if active goal can be interrupted, check priorities
+ if (goals.size() > 1 && goals[0]->Interruptible()) {
+ Goal *old_top = &*goals[0];
+ std::sort(goals.begin(), goals.end(), GoalCompare);
+ Goal *new_top = &*goals[0];
+ if (new_top != old_top) {
+ std::cout << "changing goal from " << old_top->Describe()
+ << " to " << new_top->Describe() << std::endl;
+ }
+ }
+ goals[0]->Action();
+ for (auto goal = goals.begin(); goal != goals.end();) {
+ if ((*goal)->Complete()) {
+ std::cout << "complete goal: " << (*goal)->Describe() << std::endl;
+ goals.erase(goal);
+ } else {
+ ++goal;