28 _detourCrowd(nullptr),
30 _distanceToTarget(-1.f),
31 _previousDistanceToTarget(-1.f),
87 const std::any& msg_content) {
96 const std::any& msg_content) {
102 const std::any& msg_content) {
105 _processor->processMessage(sender, msg, msg_content);
110 const SensorMap::const_iterator it =
_sensorList.find(type);
112 return it->second.get();
120 std::unique_ptr<Sensor>& sensor =
_sensorList[type];
125 sensor = std::make_unique<AudioSensor>(
this);
129 sensor = std::make_unique<VisualSensor>(
this);
246 DIVIDE_ASSERT(isPointOnNavMesh,
"AIEntity::setPosition error: Invalid NavMesh position returned!");
292 DIVIDE_ASSERT(isPointOnNavMesh,
"AIEntity::updatePosition error: Invalid NavMesh position returned!");
326 bool isPointOnNavMesh =
332 if (!isPointOnNavMesh) {
340 if (isPointOnNavMesh) {
346 return isPointOnNavMesh;
372 if (!isAgentLoaded()) {
376 _destination = destination;
436 return "Error_" +
name();
const string & name() const noexcept
bool setAndSurrenderAIProcessor(AIProcessor *processor)
bool updateDestination(const vec3< F32 > &destination, bool updatePreviousPath=false)
bool update(U64 deltaTimeUS)
AIEntity(NPC *parent, const vec3< F32 > ¤tPosition, std::string_view name)
void resetCrowd()
Update the crowding system.
vec3< F32 > _currentPosition
F32 _previousDistanceToTarget
bool _stopped
True if this character is stopped.
F32 getAgentRadius() const noexcept
The radius of the agent for this character.
bool processData(U64 deltaTimeUS)
bool isAgentLoaded() const noexcept
F32 getMaxAcceleration() const noexcept
void processMessage(AIEntity &sender, AIMsg msg, const std::any &msg_content)
void moveBackwards()
Manually control the character moving it backwards.
void setTeamPtr(AITeam *teamPtr)
void updatePosition(U64 deltaTimeUS)
void receiveMessage(AIEntity &sender, AIMsg msg, const std::any &msg_content)
I32 getAgentID() const noexcept
const dtCrowdAgent * _agent
The agent controlling this character.
vec3< F32 > getVelocity() const noexcept
void setVelocity(const vec3< F32 > &velocity)
F32 getAgentHeight() const noexcept
The height of the agent for this character.
bool processInput(U64 deltaTimeUS)
F32 getMaxSpeed() const noexcept
Navigation::DivideDtCrowd * _detourCrowd
Crowd in which the agent of this character is.
const dtCrowdAgent * getAgent() const noexcept
The agent that steers this character within the crowd.
bool setPosition(const vec3< F32 > &position)
Place agent at new position.
void sendMessage(AIEntity &receiver, AIMsg msg, const std::any &msg_content)
const vec3< F32 > & getPosition() const noexcept
void setDestination(const vec3< F32 > &destination) noexcept
bool destinationReached() const
Returns true when this agent has reached its set destination.
void load(const vec3< F32 > ¤tPosition)
bool addSensor(SensorType type)
const vec3< F32 > & getDestination() const noexcept
The destination set for this agent.
std::unique_ptr< AIProcessor > _processor
Sensor * getSensor(SensorType type)
PresetAgentRadius _agentRadiusCategory
void moveForward()
Manually control the character moving it forward.
PresetAgentRadius getAgentRadiusCategory() const noexcept
The radius category of this character.
vec3< F32 > _currentVelocity
Provides a scene-level AI implementation.
bool removeTeamMember(AIEntity *entity)
Navigation::DivideDtCrowd * getCrowd(const AIEntity::PresetAgentRadius radius) const
vec3< F32 > getLastDestination() const noexcept
void setMoveTarget(const vec3< F32 > &position, bool adjust)
static bool destinationReached(const dtCrowdAgent *agent, F32 maxDistanceFromTarget)
const dtCrowdAgent * getAgent(const I32 id) const
Retrieve agent with specified ID from the crowd.
bool isValidNavMesh() const
Check if the navMesh is valid.
F32 getAgentHeight() const noexcept
void removeAgent(I32 idx)
Remove agent with specified ID from the crowd.
bool stopAgent(I32 agentID) const
const NavigationMesh & getNavMesh() const noexcept
Get the navigation mesh associated with this crowd.
F32 getAgentRadius() const noexcept
bool requestVelocity(I32 agentID, const vec3< F32 > &velocity) const
I32 addAgent(const vec3< F32 > &position, F32 maxSpeed, F32 acceleration)
bool getClosestPosition(const vec3< F32 > &destination, const vec3< F32 > &extents, F32 delta, vec3< F32 > &result) const
bool getRandomPositionInCircle(const vec3< F32 > ¢er, F32 radius, const vec3< F32 > &extents, vec3< F32 > &result, U8 maxIters=15) const
virtual vec3< F32 > getPosition() const
The current position of this character.
virtual void setVelocity(const vec3< F32 > &newVelocity)
Update character velocity.
virtual void setPosition(const vec3< F32 > &newPosition)
Set the current position of this charater.
virtual vec3< F32 > getLookingDirection()
The direction in which the character is currently looking.
Utility class that adds basic GUID management to objects.
FORCE_INLINE I64 getGUID() const noexcept
NPC base class. Every character in the game is an NPC by default except the Player.
void update(U64 deltaTimeUS) override
virtual bool moveTo(const vec3< F32 > &targetPosition, const U64 deltaTimeUS)
virtual F32 getMovementSpeed() const
Get the unit's current movement speed.
virtual F32 getAcceleration() const
Get the unit's acceleration rate.
void reset() noexcept
set all the components back to 0
void set(const T *v) noexcept
set the 3 components of the vector manually using a source pointer to a (large enough) array
T distanceSquared(const vec3 &v) const noexcept
compute the vector's squared distance to another specified vector
Handle console commands that start with a forward slash.
vec2< T > Normalized(vec2< T > vector) noexcept
std::lock_guard< mutex > LockGuard
constexpr F32 DESTINATION_RADIUS
constexpr F32 to_F32(const T value)
std::shared_lock< mutex > SharedLock
constexpr F32 DESTINATION_RADIUS_SQ
constexpr F32 DESTINATION_RADIUS_F
static const vec3< F32 > WORLD_Z_NEG_AXIS