summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLogicParrot <LogicParrot@users.noreply.github.com>2017-08-24 09:25:50 +0200
committerLogicParrot <LogicParrot@users.noreply.github.com>2017-08-24 09:25:50 +0200
commit4e5baf3f39c6972fb525b0d4aed58f59de3005bd (patch)
tree4bdf3c28f92ea2fdd469f0ec9c404df96fd6b78f
parentInitial Monster Behavior vector logic (diff)
downloadcuberite-4e5baf3f39c6972fb525b0d4aed58f59de3005bd.tar
cuberite-4e5baf3f39c6972fb525b0d4aed58f59de3005bd.tar.gz
cuberite-4e5baf3f39c6972fb525b0d4aed58f59de3005bd.tar.bz2
cuberite-4e5baf3f39c6972fb525b0d4aed58f59de3005bd.tar.lz
cuberite-4e5baf3f39c6972fb525b0d4aed58f59de3005bd.tar.xz
cuberite-4e5baf3f39c6972fb525b0d4aed58f59de3005bd.tar.zst
cuberite-4e5baf3f39c6972fb525b0d4aed58f59de3005bd.zip
-rw-r--r--src/Mobs/AggressiveMonster.cpp8
-rw-r--r--src/Mobs/Behaviors/BehaviorAggressive.cpp2
-rw-r--r--src/Mobs/Behaviors/BehaviorBreeder.cpp12
-rw-r--r--src/Mobs/Behaviors/BehaviorChaser.cpp10
-rw-r--r--src/Mobs/Behaviors/BehaviorCoward.cpp8
-rw-r--r--src/Mobs/Behaviors/BehaviorDayLightBurner.cpp2
-rw-r--r--src/Mobs/Behaviors/BehaviorItemFollower.cpp8
-rw-r--r--src/Mobs/Monster.cpp12
-rw-r--r--src/Mobs/PassiveMonster.cpp2
9 files changed, 42 insertions, 22 deletions
diff --git a/src/Mobs/AggressiveMonster.cpp b/src/Mobs/AggressiveMonster.cpp
index 7d44e36b9..9d9532573 100644
--- a/src/Mobs/AggressiveMonster.cpp
+++ b/src/Mobs/AggressiveMonster.cpp
@@ -28,16 +28,16 @@ void cAggressiveMonster::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
{
super::Tick(a_Dt, a_Chunk);
- cBehaviorChaser * BehaviorChaser = GetBehaviorChaser();
+ /* cBehaviorChaser * BehaviorChaser = GetBehaviorChaser();
cBehaviorWanderer * BehaviorWanderer = GetBehaviorWanderer();
for (;;)
{
m_BehaviorAggressive.Tick();
- /*if (BehaviorChaser->Tick())
+ if (BehaviorChaser->Tick())
{
break;
- }*/
+ }
if ((BehaviorWanderer != nullptr) && BehaviorWanderer->ActiveTick(a_Dt, a_Chunk))
{
break;
@@ -47,5 +47,5 @@ void cAggressiveMonster::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
break;
}
- BehaviorChaser->Tick();
+ BehaviorChaser->Tick();*/
}
diff --git a/src/Mobs/Behaviors/BehaviorAggressive.cpp b/src/Mobs/Behaviors/BehaviorAggressive.cpp
index d629d83ac..f7c553f52 100644
--- a/src/Mobs/Behaviors/BehaviorAggressive.cpp
+++ b/src/Mobs/Behaviors/BehaviorAggressive.cpp
@@ -19,7 +19,7 @@ cBehaviorAggressive::cBehaviorAggressive(cMonster * a_Parent) : m_Parent(a_Paren
-void cBehaviorAggressive::PreTick()
+void cBehaviorAggressive::PreTick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
{
// Target something new if we have no target
if (m_ParentChaser->GetTarget() == nullptr)
diff --git a/src/Mobs/Behaviors/BehaviorBreeder.cpp b/src/Mobs/Behaviors/BehaviorBreeder.cpp
index 219846367..b2bd8da5d 100644
--- a/src/Mobs/Behaviors/BehaviorBreeder.cpp
+++ b/src/Mobs/Behaviors/BehaviorBreeder.cpp
@@ -24,8 +24,10 @@ cBehaviorBreeder::cBehaviorBreeder(cMonster * a_Parent) :
-void cBehaviorBreeder::Tick()
+void cBehaviorBreeder::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
{
+ UNUSED(a_Dt);
+ UNUSED(a_Chunk);
cWorld * World = m_Parent->GetWorld();
// if we have a partner, mate
if (m_LovePartner != nullptr)
@@ -74,8 +76,10 @@ void cBehaviorBreeder::Tick()
-void cBehaviorBreeder::PostTick()
+void cBehaviorBreeder::PostTick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
{
+ UNUSED(a_Dt);
+ UNUSED(a_Chunk);
if (m_MatingTimer > 0)
{
m_MatingTimer--;
@@ -94,8 +98,10 @@ void cBehaviorBreeder::PostTick()
-bool cBehaviorBreeder::IsControlDesired()
+bool cBehaviorBreeder::IsControlDesired(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
{
+ UNUSED(a_Dt);
+ UNUSED(a_Chunk);
cWorld * World = m_Parent->GetWorld();
// if we have a love partner, we should control the mob
diff --git a/src/Mobs/Behaviors/BehaviorChaser.cpp b/src/Mobs/Behaviors/BehaviorChaser.cpp
index c486c049a..025c60dd0 100644
--- a/src/Mobs/Behaviors/BehaviorChaser.cpp
+++ b/src/Mobs/Behaviors/BehaviorChaser.cpp
@@ -23,8 +23,10 @@ cBehaviorChaser::cBehaviorChaser(cMonster * a_Parent) :
-bool cBehaviorChaser::IsControlDesired()
+bool cBehaviorChaser::IsControlDesired(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
{
+ UNUSED(a_Dt);
+ UNUSED(a_Chunk);
// If we have a target, we have something to do! Return true and control the mob Ticks.
// Otherwise return false.
return (GetTarget() != nullptr);
@@ -34,8 +36,10 @@ bool cBehaviorChaser::IsControlDesired()
-void cBehaviorChaser::Tick()
+void cBehaviorChaser::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
{
+ UNUSED(a_Dt);
+ UNUSED(a_Chunk);
/*
* if ((GetTarget() != nullptr))
{
@@ -83,7 +87,7 @@ void cBehaviorChaser::ApproachTarget()
-void cBehaviorChaser::PostTick()
+void cBehaviorChaser::PostTick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
{
if (m_TicksSinceLastDamaged < 100)
{
diff --git a/src/Mobs/Behaviors/BehaviorCoward.cpp b/src/Mobs/Behaviors/BehaviorCoward.cpp
index 31927a5e8..43be5c49c 100644
--- a/src/Mobs/Behaviors/BehaviorCoward.cpp
+++ b/src/Mobs/Behaviors/BehaviorCoward.cpp
@@ -16,8 +16,10 @@ cBehaviorCoward::cBehaviorCoward(cMonster * a_Parent) :
-bool cBehaviorCoward::IsControlDesired()
+bool cBehaviorCoward::IsControlDesired(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
{
+ UNUSED(a_Dt);
+ UNUSED(a_Chunk);
return (m_Attacker != nullptr); //mobTodo probably not so safe pointer (and cChaser m_Target too)
}
@@ -25,8 +27,10 @@ bool cBehaviorCoward::IsControlDesired()
-void cBehaviorCoward::Tick()
+void cBehaviorCoward::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
{
+ UNUSED(a_Dt);
+ UNUSED(a_Chunk);
if (m_Attacker == nullptr)
{
return;
diff --git a/src/Mobs/Behaviors/BehaviorDayLightBurner.cpp b/src/Mobs/Behaviors/BehaviorDayLightBurner.cpp
index 81307f36a..b28c3c49c 100644
--- a/src/Mobs/Behaviors/BehaviorDayLightBurner.cpp
+++ b/src/Mobs/Behaviors/BehaviorDayLightBurner.cpp
@@ -15,6 +15,8 @@ cBehaviorDayLightBurner::cBehaviorDayLightBurner(cMonster * a_Parent) : m_Parent
void cBehaviorDayLightBurner::PostTick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
{
// mobTodo WouldBurn
+ bool WouldBurn = false; // TEMP
+
int RelY = static_cast<int>(m_Parent->GetPosY());
if ((RelY < 0) || (RelY >= cChunkDef::Height))
{
diff --git a/src/Mobs/Behaviors/BehaviorItemFollower.cpp b/src/Mobs/Behaviors/BehaviorItemFollower.cpp
index 22c20d6b4..c6cb0df04 100644
--- a/src/Mobs/Behaviors/BehaviorItemFollower.cpp
+++ b/src/Mobs/Behaviors/BehaviorItemFollower.cpp
@@ -17,8 +17,10 @@ cBehaviorItemFollower::cBehaviorItemFollower(cMonster * a_Parent) :
-bool cBehaviorItemFollower::IsControlDesired()
+bool cBehaviorItemFollower::IsControlDesired(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
{
+ UNUSED(a_Dt);
+ UNUSED(a_Chunk);
cItems FollowedItems;
m_Parent->GetFollowedItems(FollowedItems);
if (FollowedItems.Size() > 0)
@@ -40,8 +42,10 @@ bool cBehaviorItemFollower::IsControlDesired()
-void cBehaviorItemFollower::Tick()
+void cBehaviorItemFollower::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
{
+ UNUSED(a_Dt);
+ UNUSED(a_Chunk);
cItems FollowedItems;
m_Parent->GetFollowedItems(FollowedItems);
if (FollowedItems.Size() > 0)
diff --git a/src/Mobs/Monster.cpp b/src/Mobs/Monster.cpp
index 7a33f3ce5..80da3b03a 100644
--- a/src/Mobs/Monster.cpp
+++ b/src/Mobs/Monster.cpp
@@ -306,7 +306,7 @@ void cMonster::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
// They MUST NOT control mob movement or interefere with the main Tick.
for (cBehavior * Behavior : PreTickBehaviors)
{
- Behavior->PreTick();
+ Behavior->PreTick(a_Dt, a_Chunk);
}
// Note 1: Each monster tick, at most one Behavior executes its Tick method.
@@ -320,7 +320,7 @@ void cMonster::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
// Stop at the first one that says yes.
for (cBehavior * Behavior : TickBehaviors)
{
- if (Behavior->IsControlDesired())
+ if (Behavior->IsControlDesired(a_Dt, a_Chunk))
{
m_NewTickControllingBehavior = Behavior;
break;
@@ -331,7 +331,7 @@ void cMonster::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
{
// The Behavior asking for control is the same as the behavior from last tick.
// Nothing special, just tick it.
- m_CurrentTickControllingBehavior->Tick();
+ m_CurrentTickControllingBehavior->Tick(a_Dt, a_Chunk);
}
else
{
@@ -345,7 +345,7 @@ void cMonster::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
// Make the current controlling behavior clean up
if (m_TickControllingBehaviorState == OldControlEnding)
{
- if (m_CurrentTickControllingBehavior->ControlEnding())
+ if (m_CurrentTickControllingBehavior->ControlEnding(a_Dt, a_Chunk))
{
// The current behavior told us it is ready for letting go of control
m_TickControllingBehaviorState = NewControlStarting;
@@ -360,7 +360,7 @@ void cMonster::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
// Make the new controlling behavior set up
else if (m_TickControllingBehaviorState == NewControlStarting)
{
- if (m_NewTickControllingBehavior->ControlStarting())
+ if (m_NewTickControllingBehavior->ControlStarting(a_Dt, a_Chunk))
{
// The new behavior told us it is ready for taking control
// The new behavior is now the current behavior. Next tick it will execute its Tick.
@@ -380,7 +380,7 @@ void cMonster::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
// They MUST NOT control mob movement or interefere with the main Tick.
for (cBehavior * Behavior : PostTickBehaviors)
{
- Behavior->PostTick();
+ Behavior->PostTick(a_Dt, a_Chunk);
}
bool a_IsFollowingPath = false;
diff --git a/src/Mobs/PassiveMonster.cpp b/src/Mobs/PassiveMonster.cpp
index d4fa1840e..81bf681ea 100644
--- a/src/Mobs/PassiveMonster.cpp
+++ b/src/Mobs/PassiveMonster.cpp
@@ -95,7 +95,7 @@ void cPassiveMonster::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
break;
}
- m_BehaviorBreeder.PostTick();
+ m_BehaviorBreeder.PostTick(a_Dt, a_Chunk);
}