Divide Framework 0.1
A free and open-source 3D Framework under heavy development
Loading...
Searching...
No Matches
Divide::NPC Class Referencefinal

NPC base class. Every character in the game is an NPC by default except the Player. More...

#include <NPC.h>

+ Inheritance diagram for Divide::NPC:

Public Member Functions

 NPC (const vec3< F32 > &currentPosition, std::string_view name)
 NPCs don't need AI by default.
 
 ~NPC () override=default
 
void update (U64 deltaTimeUS) override
 
AI::AIEntitygetAIEntity () const noexcept
 
- Public Member Functions inherited from Divide::Character
 Character (CharacterType type)
 
virtual void update (U64 deltaTimeUS)
 
virtual void setPosition (const vec3< F32 > &newPosition)
 Set the current position of this charater.
 
virtual void setVelocity (const vec3< F32 > &newVelocity)
 Update character velocity.
 
virtual vec3< F32getPosition () const
 The current position of this character.
 
virtual vec3< F32getLookingDirection ()
 The direction in which the character is currently looking.
 
virtual void lookAt (const vec3< F32 > &targetPos)
 Rotate the character to look at another character.
 
const vec3< F32 > & getRelativeLookingDirection () const noexcept
 
void setRelativeLookingDirection (const vec3< F32 > &direction) noexcept
 
void playAnimation (U32 index) const
 
void playNextAnimation () const
 
void playPreviousAnimation () const
 
void pauseAnimation (bool state) const
 
 PROPERTY_RW (CharacterType, characterType, CharacterType::COUNT)
 
- Public Member Functions inherited from Divide::Unit
 Unit (UnitType type)
 
virtual bool moveTo (const vec3< F32 > &targetPosition, const U64 deltaTimeUS)
 
virtual bool moveToX (F32 targetPosition, const U64 deltaTimeUS)
 Move along the X axis.
 
virtual bool moveToY (F32 targetPosition, const U64 deltaTimeUS)
 Move along the Y axis.
 
virtual bool moveToZ (F32 targetPosition, const U64 deltaTimeUS)
 Move along the Z axis.
 
virtual bool teleportTo (const vec3< F32 > &targetPosition)
 teleportTo instantly places the unit at the desired position
 
const vec3< F32 > & getCurrentPosition () const
 
const vec3< F32 > & getTargetPosition () const
 Get the unit's target coordinates in the world.
 
virtual void setMovementSpeed (const F32 movementSpeed)
 
virtual void setAcceleration (const F32 acceleration)
 Set the unit's acceleration in metres per second squared.
 
virtual F32 getMovementSpeed () const
 Get the unit's current movement speed.
 
virtual F32 getAcceleration () const
 Get the unit's acceleration rate.
 
void setMovementTolerance (const F32 movementTolerance)
 Set destination tolerance.
 
F32 getMovementTolerance () const
 Get the units current movement tolerance.
 
SceneGraphNodegetBoundNode () const
 Get bound node.
 
virtual void setAttribute (U32 attributeID, I32 initialValue)
 
virtual I32 getAttribute (U32 attributeID) const
 
 PROPERTY_RW (UnitType, type, UnitType::COUNT)
 
- Public Member Functions inherited from Divide::GUIDWrapper
 GUIDWrapper () noexcept
 
 GUIDWrapper (const GUIDWrapper &old) noexcept
 
 GUIDWrapper (GUIDWrapper &&old) noexcept
 
virtual ~GUIDWrapper ()=default
 
FORCE_INLINE I64 getGUID () const noexcept
 
GUIDWrapperoperator= (const GUIDWrapper &old)=delete
 
GUIDWrapperoperator= (GUIDWrapper &&other)=delete
 

Protected Attributes

std::unique_ptr< AI::AIEntity_aiUnit
 
- Protected Attributes inherited from Divide::Unit
F32 _moveSpeed
 Movement speed (meters per second)
 
F32 _acceleration
 Acceleration (meters per second squared.
 
F32 _moveTolerance
 acceptable distance from target
 
vec3< F32_currentPosition
 Unit position in world.
 
vec3< F32_currentTargetPosition
 Current destination point cached.
 
SceneGraphNode_node
 
AttributeMap _attributes
 
SharedMutex _unitUpdateMutex
 
- Protected Attributes inherited from Divide::GUIDWrapper
const I64 _guid
 

Additional Inherited Members

- Public Types inherited from Divide::Character
enum class  CharacterType : U8 { CHARACTER_TYPE_PLAYER = 0 , CHARACTER_TYPE_NPC , COUNT }
 Currently supported character types. More...
 
- Public Types inherited from Divide::Unit
using AttributeMap = hashMap< U32, I32 >
 
- Static Public Member Functions inherited from Divide::GUIDWrapper
static I64 generateGUID () noexcept
 
- Protected Member Functions inherited from Divide::Character
void setParentNode (SceneGraphNode *node) override
 
virtual void setParentNode (SceneGraphNode *node)
 

Detailed Description

NPC base class. Every character in the game is an NPC by default except the Player.

Definition at line 45 of file NPC.h.

Constructor & Destructor Documentation

◆ NPC()

Divide::NPC::NPC ( const vec3< F32 > &  currentPosition,
std::string_view  name 
)
explicit

NPCs don't need AI by default.

Definition at line 8 of file NPC.cpp.

◆ ~NPC()

Divide::NPC::~NPC ( )
overridedefault

Member Function Documentation

◆ getAIEntity()

AI::AIEntity * Divide::NPC::getAIEntity ( ) const
noexcept

Definition at line 20 of file NPC.cpp.

◆ update()

void Divide::NPC::update ( U64  deltaTimeUS)
overridevirtual

Update this character for drawing a new frame. Updates one tick in the render loop. In order for the agents to be updated, you first need to call the detourCrowd update function. What is updated specifically is up to a specific implementation of Character, but at the very least the position in the scene should be updated to reflect the detour agent position (possibly with additional physics engine clipping and collision testing).

Reimplemented from Divide::Character.

Definition at line 15 of file NPC.cpp.

Member Data Documentation

◆ _aiUnit

std::unique_ptr<AI::AIEntity> Divide::NPC::_aiUnit
protected

Definition at line 56 of file NPC.h.


The documentation for this class was generated from the following files: