b3feddfef3
* try to resolve merge conflict * feat: TU19 (Dec 2014) Features & Content (#32) * December 2014 files * Working release build * Fix compilation issues * Add sound to Windows64Media * Add DLC content and force Tutorial DLC * Revert "Add DLC content and force Tutorial DLC" This reverts commit 97a43994725008e35fceb984d5549df9c8cea470. * Disable broken light packing * Disable breakpoint during DLC texture map load Allows DLC loading but the DLC textures are still broken * Fix post build not working * ... * fix vs2022 build * fix cmake build --------- Co-authored-by: Loki <lokirautio@gmail.com>
60 lines
1.9 KiB
C++
60 lines
1.9 KiB
C++
#include "stdafx.h"
|
|
#include "net.minecraft.world.entity.h"
|
|
#include "net.minecraft.world.entity.ai.control.h"
|
|
#include "net.minecraft.world.entity.ai.navigation.h"
|
|
#include "net.minecraft.world.entity.ai.util.h"
|
|
#include "net.minecraft.world.phys.h"
|
|
#include "SharedConstants.h"
|
|
#include "RandomStrollGoal.h"
|
|
|
|
RandomStrollGoal::RandomStrollGoal(PathfinderMob *mob, double speedModifier)
|
|
{
|
|
this->mob = mob;
|
|
this->speedModifier = speedModifier;
|
|
setRequiredControlFlags(Control::MoveControlFlag | Control::LookControlFlag);
|
|
}
|
|
|
|
bool RandomStrollGoal::canUse()
|
|
{
|
|
// 4J - altered a little so we can do some more random strolling when appropriate, to try and move any animals that aren't confined to a fenced-off region far enough to determine we can despawn them
|
|
if (mob->getNoActionTime() < SharedConstants::TICKS_PER_SECOND * 5)
|
|
{
|
|
if (mob->getRandom()->nextInt(120) == 0)
|
|
{
|
|
Vec3 *pos = RandomPos::getPos(dynamic_pointer_cast<PathfinderMob>(mob->shared_from_this()), 10, 7);
|
|
if (pos == NULL) return false;
|
|
wantedX = pos->x;
|
|
wantedY = pos->y;
|
|
wantedZ = pos->z;
|
|
return true;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
// This entity wouldn't normally be randomly strolling. However, if our management system says that it should do, then do. Don't
|
|
// bother waiting for random conditions to be met before picking a direction though as the point here is to see if it is possible to
|
|
// stroll out of a given area and so waiting around is just wasting time
|
|
|
|
if( mob->isExtraWanderingEnabled() )
|
|
{
|
|
Vec3 *pos = RandomPos::getPos(dynamic_pointer_cast<PathfinderMob>(mob->shared_from_this()), 10, 7,mob->getWanderingQuadrant());
|
|
if (pos == NULL) return false;
|
|
wantedX = pos->x;
|
|
wantedY = pos->y;
|
|
wantedZ = pos->z;
|
|
return true;
|
|
}
|
|
|
|
}
|
|
return false;
|
|
}
|
|
|
|
bool RandomStrollGoal::canContinueToUse()
|
|
{
|
|
return !mob->getNavigation()->isDone();
|
|
}
|
|
|
|
void RandomStrollGoal::start()
|
|
{
|
|
mob->getNavigation()->moveTo(wantedX, wantedY, wantedZ, speedModifier);
|
|
} |