Minetest  5.4.0
UnitSAO Class Reference

#include <unit_sao.h>

+ Inheritance diagram for UnitSAO:
+ Collaboration diagram for UnitSAO:

Public Member Functions

 UnitSAO (ServerEnvironment *env, v3f pos)
 
virtual ~UnitSAO ()=default
 
u16 getHP () const
 
bool isDead () const
 
void setRotation (v3f rotation)
 
const v3fgetRotation () const
 
v3f getRadRotation ()
 
f32 getRadYawDep () const
 
bool isImmortal () const
 
void setArmorGroups (const ItemGroupList &armor_groups)
 
const ItemGroupListgetArmorGroups () const
 
void setAnimation (v2f frame_range, float frame_speed, float frame_blend, bool frame_loop)
 
void getAnimation (v2f *frame_range, float *frame_speed, float *frame_blend, bool *frame_loop)
 
void setAnimationSpeed (float frame_speed)
 
void setBonePosition (const std::string &bone, v3f position, v3f rotation)
 
void getBonePosition (const std::string &bone, v3f *position, v3f *rotation)
 
ServerActiveObjectgetParent () const
 
bool isAttached () const
 
void setAttachment (int parent_id, const std::string &bone, v3f position, v3f rotation, bool force_visible)
 
void getAttachment (int *parent_id, std::string *bone, v3f *position, v3f *rotation, bool *force_visible) const
 
void clearChildAttachments ()
 
void clearParentAttachment ()
 
void addAttachmentChild (int child_id)
 
void removeAttachmentChild (int child_id)
 
const std::unordered_set< int > & getAttachmentChildIds () const
 
ObjectPropertiesaccessObjectProperties ()
 
void notifyObjectPropertiesModified ()
 
void sendOutdatedData ()
 
std::string generateUpdateAttachmentCommand () const
 
std::string generateUpdateAnimationSpeedCommand () const
 
std::string generateUpdateAnimationCommand () const
 
std::string generateUpdateArmorGroupsCommand () const
 
std::string generateSetPropertiesCommand (const ObjectProperties &prop) const
 
void sendPunchCommand ()
 
- Public Member Functions inherited from ServerActiveObject
 ServerActiveObject (ServerEnvironment *env, v3f pos)
 
virtual ~ServerActiveObject ()=default
 
virtual ActiveObjectType getSendType () const
 
virtual void addedToEnvironment (u32 dtime_s)
 
virtual void removingFromEnvironment ()
 
virtual bool environmentDeletes () const
 
void markForRemoval ()
 
void markForDeactivation ()
 
v3f getBasePosition () const
 
void setBasePosition (v3f pos)
 
ServerEnvironmentgetEnv ()
 
virtual void setPos (const v3f &pos)
 
virtual void moveTo (v3f pos, bool continuous)
 
virtual float getMinimumSavedMovement ()
 
virtual std::string getDescription ()
 
virtual void step (float dtime, bool send_recommended)
 
virtual std::string getClientInitializationData (u16 protocol_version)
 
virtual void getStaticData (std::string *result) const
 
virtual bool isStaticAllowed () const
 
virtual bool shouldUnload () const
 
virtual u16 punch (v3f dir, const ToolCapabilities *toolcap=nullptr, ServerActiveObject *puncher=nullptr, float time_from_last_punch=1000000.0f)
 
virtual void rightClick (ServerActiveObject *clicker)
 
virtual void setHP (s32 hp, const PlayerHPChangeReason &reason)
 
virtual InventorygetInventory () const
 
virtual InventoryLocation getInventoryLocation () const
 
virtual void setInventoryModified ()
 
virtual std::string getWieldList () const
 
virtual u16 getWieldIndex () const
 
virtual ItemStack getWieldedItem (ItemStack *selected, ItemStack *hand=nullptr) const
 
virtual bool setWieldedItem (const ItemStack &item)
 
void attachParticleSpawner (u32 id)
 
void detachParticleSpawner (u32 id)
 
std::string generateUpdateInfantCommand (u16 infant_id, u16 protocol_version)
 
void dumpAOMessagesToQueue (std::queue< ActiveObjectMessage > &queue)
 
bool isGone () const
 
bool isPendingRemoval () const
 
- Public Member Functions inherited from ActiveObject
 ActiveObject (u16 id)
 
u16 getId () const
 
void setId (u16 id)
 
virtual ActiveObjectType getType () const =0
 
virtual bool getCollisionBox (aabb3f *toset) const =0
 
virtual bool getSelectionBox (aabb3f *toset) const =0
 
virtual bool collideWithObjects () const =0
 

Static Public Member Functions

static std::string generateUpdatePositionCommand (const v3f &position, const v3f &velocity, const v3f &acceleration, const v3f &rotation, bool do_interpolate, bool is_movement_end, f32 update_interval)
 
static std::string generateUpdateBonePositionCommand (const std::string &bone, const v3f &position, const v3f &rotation)
 
- Static Public Member Functions inherited from ServerActiveObject
static ServerActiveObjectcreate (ActiveObjectType type, ServerEnvironment *env, u16 id, v3f pos, const std::string &data)
 

Protected Attributes

u16 m_hp = 1
 
v3f m_rotation
 
ItemGroupList m_armor_groups
 
bool m_properties_sent = true
 
ObjectProperties m_prop
 
std::unordered_map< std::string, core::vector2d< v3f > > m_bone_position
 
int m_attachment_parent_id = 0
 
- Protected Attributes inherited from ServerActiveObject
ServerEnvironmentm_env
 
v3f m_base_position
 
std::unordered_set< u32 > m_attached_particle_spawners
 
bool m_pending_deactivation = false
 
bool m_pending_removal = false
 
std::queue< ActiveObjectMessagem_messages_out
 
- Protected Attributes inherited from ActiveObject
u16 m_id
 

Private Member Functions

void onAttach (int parent_id)
 
void onDetach (int parent_id)
 
std::string generatePunchCommand (u16 result_hp) const
 

Private Attributes

bool m_armor_groups_sent = false
 
v2f m_animation_range
 
float m_animation_speed = 0.0f
 
float m_animation_blend = 0.0f
 
bool m_animation_loop = true
 
bool m_animation_sent = false
 
bool m_animation_speed_sent = false
 
bool m_bone_position_sent = false
 
std::unordered_set< int > m_attachment_child_ids
 
std::string m_attachment_bone = ""
 
v3f m_attachment_position
 
v3f m_attachment_rotation
 
bool m_attachment_sent = false
 
bool m_force_visible = false
 

Additional Inherited Members

- Public Attributes inherited from ServerActiveObject
u16 m_known_by_count = 0
 
bool m_static_exists = false
 
v3s16 m_static_block = v3s16(1337,1337,1337)
 
- Protected Member Functions inherited from ServerActiveObject
virtual void onMarkedForDeactivation ()
 
virtual void onMarkedForRemoval ()
 

Constructor & Destructor Documentation

◆ UnitSAO()

UnitSAO::UnitSAO ( ServerEnvironment env,
v3f  pos 
)

References m_armor_groups.

◆ ~UnitSAO()

virtual UnitSAO::~UnitSAO ( )
virtualdefault

Member Function Documentation

◆ accessObjectProperties()

ObjectProperties * UnitSAO::accessObjectProperties ( )
virtual

Reimplemented from ServerActiveObject.

References m_prop.

Referenced by Server::RespawnPlayer().

+ Here is the caller graph for this function:

◆ addAttachmentChild()

void UnitSAO::addAttachmentChild ( int  child_id)
virtual

Reimplemented from ActiveObject.

References m_attachment_child_ids.

◆ clearChildAttachments()

void UnitSAO::clearChildAttachments ( )
virtual

Reimplemented from ActiveObject.

References ServerEnvironment::getActiveObject(), m_attachment_child_ids, and ServerActiveObject::m_env.

Referenced by Server::DeleteClient(), and LuaEntitySAO::punch().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ clearParentAttachment()

void UnitSAO::clearParentAttachment ( )
virtual

Reimplemented from ActiveObject.

References ServerEnvironment::getActiveObject(), m_attachment_parent_id, m_attachment_position, m_attachment_rotation, ServerActiveObject::m_env, ActiveObject::m_id, ActiveObject::removeAttachmentChild(), and setAttachment().

Referenced by Server::DeleteClient(), Server::DiePlayer(), LuaEntitySAO::punch(), LuaEntitySAO::step(), and PlayerSAO::step().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ generatePunchCommand()

std::string UnitSAO::generatePunchCommand ( u16  result_hp) const
private

References AO_CMD_PUNCHED, writeU16(), and writeU8().

Referenced by sendPunchCommand().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ generateSetPropertiesCommand()

std::string UnitSAO::generateSetPropertiesCommand ( const ObjectProperties prop) const

References AO_CMD_SET_PROPERTIES, ObjectProperties::serialize(), and writeU8().

Referenced by LuaEntitySAO::getPropertyPacket(), and PlayerSAO::getPropertyPacket().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ generateUpdateAnimationCommand()

std::string UnitSAO::generateUpdateAnimationCommand ( ) const

References AO_CMD_SET_ANIMATION, m_animation_blend, m_animation_loop, m_animation_range, m_animation_speed, writeF32(), writeU8(), and writeV2F32().

Referenced by LuaEntitySAO::getClientInitializationData(), PlayerSAO::getClientInitializationData(), and sendOutdatedData().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ generateUpdateAnimationSpeedCommand()

std::string UnitSAO::generateUpdateAnimationSpeedCommand ( ) const

References AO_CMD_SET_ANIMATION_SPEED, m_animation_speed, writeF32(), and writeU8().

Referenced by sendOutdatedData().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ generateUpdateArmorGroupsCommand()

std::string UnitSAO::generateUpdateArmorGroupsCommand ( ) const

References AO_CMD_UPDATE_ARMOR_GROUPS, m_armor_groups, serializeString16(), writeS16(), writeU16(), and writeU8().

Referenced by LuaEntitySAO::getClientInitializationData(), PlayerSAO::getClientInitializationData(), and sendOutdatedData().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ generateUpdateAttachmentCommand()

std::string UnitSAO::generateUpdateAttachmentCommand ( ) const

References AO_CMD_ATTACH_TO, m_attachment_bone, m_attachment_parent_id, m_attachment_position, m_attachment_rotation, m_force_visible, serializeString16(), writeS16(), writeU8(), and writeV3F32().

Referenced by LuaEntitySAO::getClientInitializationData(), PlayerSAO::getClientInitializationData(), and sendOutdatedData().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ generateUpdateBonePositionCommand()

std::string UnitSAO::generateUpdateBonePositionCommand ( const std::string &  bone,
const v3f position,
const v3f rotation 
)
static

References AO_CMD_SET_BONE_POSITION, serializeString16(), writeU8(), and writeV3F32().

Referenced by LuaEntitySAO::getClientInitializationData(), PlayerSAO::getClientInitializationData(), and sendOutdatedData().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ generateUpdatePositionCommand()

std::string UnitSAO::generateUpdatePositionCommand ( const v3f position,
const v3f velocity,
const v3f acceleration,
const v3f rotation,
bool  do_interpolate,
bool  is_movement_end,
f32  update_interval 
)
static

References AO_CMD_UPDATE_POSITION, writeF32(), writeU8(), and writeV3F32().

Referenced by LuaEntitySAO::sendPosition(), and PlayerSAO::step().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getAnimation()

void UnitSAO::getAnimation ( v2f frame_range,
float *  frame_speed,
float *  frame_blend,
bool *  frame_loop 
)
virtual

◆ getArmorGroups()

const ItemGroupList & UnitSAO::getArmorGroups ( ) const
virtual

Reimplemented from ServerActiveObject.

References m_armor_groups.

Referenced by isImmortal().

+ Here is the caller graph for this function:

◆ getAttachment()

void UnitSAO::getAttachment ( int *  parent_id,
std::string *  bone,
v3f position,
v3f rotation,
bool *  force_visible 
) const
virtual

Reimplemented from ActiveObject.

References m_attachment_bone, m_attachment_parent_id, m_attachment_position, m_attachment_rotation, and m_force_visible.

Referenced by getAttachedObject().

+ Here is the caller graph for this function:

◆ getAttachmentChildIds()

const std::unordered_set< int > & UnitSAO::getAttachmentChildIds ( ) const
virtual

Reimplemented from ServerActiveObject.

References m_attachment_child_ids.

Referenced by LuaEntitySAO::getClientInitializationData(), and PlayerSAO::getClientInitializationData().

+ Here is the caller graph for this function:

◆ getBonePosition()

void UnitSAO::getBonePosition ( const std::string &  bone,
v3f position,
v3f rotation 
)
virtual

Reimplemented from ServerActiveObject.

References m_bone_position.

◆ getHP()

u16 UnitSAO::getHP ( ) const
inlinevirtual

Reimplemented from ServerActiveObject.

References m_hp.

Referenced by PlayerSAO::getClientInitializationData(), Server::handleCommand_Damage(), Server::handleCommand_Interact(), PlayerSAO::punch(), PlayerDatabaseLevelDB::savePlayer(), PlayerDatabaseSQLite3::savePlayer(), Server::SendPlayerHP(), sendPunchCommand(), and PlayerDatabaseFiles::serialize().

+ Here is the caller graph for this function:

◆ getParent()

ServerActiveObject * UnitSAO::getParent ( ) const
virtual

Reimplemented from ServerActiveObject.

References ServerEnvironment::getActiveObject(), m_attachment_parent_id, and ServerActiveObject::m_env.

Referenced by isAttached(), LuaEntitySAO::step(), and PlayerSAO::step().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getRadRotation()

v3f UnitSAO::getRadRotation ( )
inline

References m_rotation.

Referenced by ObjectRef::l_get_look_horizontal().

+ Here is the caller graph for this function:

◆ getRadYawDep()

f32 UnitSAO::getRadYawDep ( ) const
inline

References m_rotation.

Referenced by ObjectRef::l_get_look_dir(), and ObjectRef::l_get_look_yaw().

+ Here is the caller graph for this function:

◆ getRotation()

const v3f& UnitSAO::getRotation ( ) const
inline

References m_rotation.

Referenced by RemoteClient::GetNextBlocks(), ObjectRef::l_get_rotation(), ObjectRef::l_get_yaw(), PlayerDatabaseLevelDB::savePlayer(), PlayerDatabaseSQLite3::savePlayer(), Server::SendMovePlayer(), and PlayerDatabaseFiles::serialize().

+ Here is the caller graph for this function:

◆ isAttached()

bool UnitSAO::isAttached ( ) const
inline

References getParent().

Referenced by PlayerSAO::checkMovementCheat(), getAttachedObject(), LuaEntitySAO::moveTo(), PlayerSAO::moveTo(), Server::process_PlayerPos(), LuaEntitySAO::sendPosition(), LuaEntitySAO::setPos(), PlayerSAO::setPos(), LuaEntitySAO::step(), and PlayerSAO::step().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isDead()

bool UnitSAO::isDead ( ) const
inline

References m_hp.

Referenced by Server::handleCommand_Damage(), Server::handleCommand_Interact(), Server::handleCommand_InventoryAction(), Server::handleCommand_PlayerPos(), Server::handleCommand_Respawn(), Server::SendPlayerHPOrDie(), and Server::StageTwoClientInit().

+ Here is the caller graph for this function:

◆ isImmortal()

bool UnitSAO::isImmortal ( ) const
inline

References getArmorGroups(), and itemgroup_get().

Referenced by Server::handleCommand_Damage(), PlayerSAO::punch(), Server::SendPlayerHPOrDie(), PlayerSAO::setHP(), and PlayerSAO::step().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ notifyObjectPropertiesModified()

void UnitSAO::notifyObjectPropertiesModified ( )
virtual

Reimplemented from ServerActiveObject.

References m_properties_sent.

◆ onAttach()

void UnitSAO::onAttach ( int  parent_id)
privatevirtual

Reimplemented from ServerActiveObject.

References ACTIVEOBJECT_TYPE_LUAENTITY, ServerEnvironment::getActiveObject(), ServerEnvironment::getScriptIface(), ActiveObject::getType(), ServerActiveObject::isGone(), ScriptApiEntity::luaentity_on_attach_child(), and ServerActiveObject::m_env.

Referenced by setAttachment().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ onDetach()

void UnitSAO::onDetach ( int  parent_id)
privatevirtual

Reimplemented from ServerActiveObject.

References ACTIVEOBJECT_TYPE_LUAENTITY, ServerEnvironment::getActiveObject(), ServerEnvironment::getScriptIface(), ActiveObject::getType(), ServerActiveObject::isGone(), ScriptApiEntity::luaentity_on_detach(), ScriptApiEntity::luaentity_on_detach_child(), ServerActiveObject::m_env, and ActiveObject::m_id.

Referenced by setAttachment().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ removeAttachmentChild()

void UnitSAO::removeAttachmentChild ( int  child_id)
virtual

Reimplemented from ActiveObject.

References m_attachment_child_ids.

◆ sendOutdatedData()

void UnitSAO::sendOutdatedData ( )

References generateUpdateAnimationCommand(), generateUpdateAnimationSpeedCommand(), generateUpdateArmorGroupsCommand(), generateUpdateAttachmentCommand(), generateUpdateBonePositionCommand(), ActiveObject::getId(), m_animation_sent, m_animation_speed_sent, m_armor_groups_sent, m_attachment_sent, m_bone_position, m_bone_position_sent, and ServerActiveObject::m_messages_out.

Referenced by Server::SendMovePlayer(), LuaEntitySAO::sendPosition(), LuaEntitySAO::step(), and PlayerSAO::step().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ sendPunchCommand()

void UnitSAO::sendPunchCommand ( )

References generatePunchCommand(), getHP(), ActiveObject::getId(), and ServerActiveObject::m_messages_out.

Referenced by PlayerSAO::punch(), LuaEntitySAO::punch(), and Server::SendPlayerHP().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setAnimation()

void UnitSAO::setAnimation ( v2f  frame_range,
float  frame_speed,
float  frame_blend,
bool  frame_loop 
)
virtual

◆ setAnimationSpeed()

void UnitSAO::setAnimationSpeed ( float  frame_speed)
virtual

Reimplemented from ServerActiveObject.

References m_animation_speed, and m_animation_speed_sent.

◆ setArmorGroups()

void UnitSAO::setArmorGroups ( const ItemGroupList armor_groups)
virtual

Reimplemented from ServerActiveObject.

References m_armor_groups, and m_armor_groups_sent.

◆ setAttachment()

void UnitSAO::setAttachment ( int  parent_id,
const std::string &  bone,
v3f  position,
v3f  rotation,
bool  force_visible 
)
virtual

Reimplemented from ActiveObject.

References m_attachment_bone, m_attachment_parent_id, m_attachment_position, m_attachment_rotation, m_attachment_sent, m_force_visible, onAttach(), and onDetach().

Referenced by clearParentAttachment().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setBonePosition()

void UnitSAO::setBonePosition ( const std::string &  bone,
v3f  position,
v3f  rotation 
)
virtual

Reimplemented from ServerActiveObject.

References m_bone_position, and m_bone_position_sent.

◆ setRotation()

void UnitSAO::setRotation ( v3f  rotation)
inline

References m_rotation.

Referenced by ObjectRef::l_set_rotation(), ObjectRef::l_set_yaw(), and PlayerSAO::setPlayerYaw().

+ Here is the caller graph for this function:

Member Data Documentation

◆ m_animation_blend

float UnitSAO::m_animation_blend = 0.0f
private

◆ m_animation_loop

bool UnitSAO::m_animation_loop = true
private

◆ m_animation_range

v2f UnitSAO::m_animation_range
private

◆ m_animation_sent

bool UnitSAO::m_animation_sent = false
private

Referenced by sendOutdatedData(), and setAnimation().

◆ m_animation_speed

◆ m_animation_speed_sent

bool UnitSAO::m_animation_speed_sent = false
private

◆ m_armor_groups

◆ m_armor_groups_sent

bool UnitSAO::m_armor_groups_sent = false
private

Referenced by sendOutdatedData(), and setArmorGroups().

◆ m_attachment_bone

std::string UnitSAO::m_attachment_bone = ""
private

◆ m_attachment_child_ids

std::unordered_set<int> UnitSAO::m_attachment_child_ids
private

◆ m_attachment_parent_id

◆ m_attachment_position

v3f UnitSAO::m_attachment_position
private

◆ m_attachment_rotation

v3f UnitSAO::m_attachment_rotation
private

◆ m_attachment_sent

bool UnitSAO::m_attachment_sent = false
private

Referenced by sendOutdatedData(), and setAttachment().

◆ m_bone_position

std::unordered_map<std::string, core::vector2d<v3f> > UnitSAO::m_bone_position
protected

◆ m_bone_position_sent

bool UnitSAO::m_bone_position_sent = false
private

◆ m_force_visible

bool UnitSAO::m_force_visible = false
private

◆ m_hp

◆ m_prop

◆ m_properties_sent

bool UnitSAO::m_properties_sent = true
protected

◆ m_rotation


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