#include "Goal.hpp"
+#include "IdleGoal.hpp"
#include "LocateResourceGoal.hpp"
#include "Creature.hpp"
+#include "../app/Assets.hpp"
#include "../world/Planet.hpp"
#include "../world/Resource.hpp"
#include "../world/Simulation.hpp"
return c.GetSteering();
}
+app::Assets &Goal::Assets() noexcept {
+ return c.GetSimulation().Assets();
+}
+
+const app::Assets &Goal::Assets() const noexcept {
+ return c.GetSimulation().Assets();
+}
+
void Goal::SetComplete() noexcept {
if (!complete) {
complete = true;
}
+IdleGoal::IdleGoal(Creature &c)
+: Goal(c) {
+ Urgency(-1.0);
+ Interruptible(true);
+}
+
+IdleGoal::~IdleGoal() {
+}
+
+std::string IdleGoal::Describe() const {
+ return "idle";
+}
+
+void IdleGoal::Enable() {
+}
+
+void IdleGoal::Tick(double dt) {
+}
+
+void IdleGoal::Action() {
+ double fert = GetCreature().Fertility();
+ double rand = Assets().random.UNorm();
+ if (fert > rand) {
+ std::cout << "[" << int(GetCreature().GetSimulation().Time())
+ << "s] splitting " << GetCreature().Name()
+ << " because " << fert << " > " << rand << std::endl;
+ Split(GetCreature());
+ }
+}
+
+
LocateResourceGoal::LocateResourceGoal(Creature &c, int res)
: Goal(c)
, res(res)
target_srf = srf;
target_tile = best_pos;
GetSteering().GoTo(target_pos);
- std::cout << "found resource at " << target_pos << std::endl;
} else {
// oh crap
}