Luanti 5.10.0-dev
 
Loading...
Searching...
No Matches
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 override
 
bool isDead () const
 
void setRotation (v3f rotation)
 
const v3fgetRotation () const
 
const v3f getTotalRotation () const
 
v3f getRadRotation ()
 
f32 getRadYawDep () const
 
bool isImmortal () const
 
void setArmorGroups (const ItemGroupList &armor_groups) override
 
const ItemGroupListgetArmorGroups () const override
 
void setAnimation (v2f frame_range, float frame_speed, float frame_blend, bool frame_loop) override
 
void getAnimation (v2f *frame_range, float *frame_speed, float *frame_blend, bool *frame_loop) override
 
void setAnimationSpeed (float frame_speed) override
 
void setBoneOverride (const std::string &bone, const BoneOverride &props) override
 
BoneOverride getBoneOverride (const std::string &bone) override
 
const std::unordered_map< std::string, BoneOverride > & getBoneOverrides () const override
 
ServerActiveObjectgetParent () const override
 
bool isAttached () const
 
void setAttachment (object_t parent_id, const std::string &bone, v3f position, v3f rotation, bool force_visible) override
 
void getAttachment (object_t *parent_id, std::string *bone, v3f *position, v3f *rotation, bool *force_visible) const override
 
void clearChildAttachments () override
 
void addAttachmentChild (object_t child_id) override
 
void removeAttachmentChild (object_t child_id) override
 
const std::unordered_set< object_t > & getAttachmentChildIds () const override
 
ObjectPropertiesaccessObjectProperties () override
 
void notifyObjectPropertiesModified () override
 
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 ()
 
void markForRemoval ()
 
void markForDeactivation ()
 
v3f getBasePosition () const
 
void setBasePosition (v3f pos)
 
ServerEnvironmentgetEnv ()
 
virtual void setPos (const v3f &pos)
 
virtual void addPos (const v3f &added_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 u32 punch (v3f dir, const ToolCapabilities *toolcap=nullptr, ServerActiveObject *puncher=nullptr, float time_from_last_punch=1000000.0f, u16 initial_wear=0)
 
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
 
void invalidateEffectiveObservers ()
 Invalidate final observer cache.
 
const ObserversgetEffectiveObservers ()
 Cache m_effective_observers with the names of all observers, also indirect observers (object attachment chain).
 
const ObserversrecalculateEffectiveObservers ()
 Force a recalculation of final observers (including all parents).
 
bool isEffectivelyObservedBy (const std::string &player_name)
 Whether the object is sent to player_name
 
- Public Member Functions inherited from ActiveObject
 ActiveObject (object_t id)
 
object_t getId () const
 
void setId (object_t 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
 
virtual void clearParentAttachment ()
 

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 generateUpdateBoneOverrideCommand (const std::string &bone, const BoneOverride &props)
 

Protected Member Functions

void clearAnyAttachments ()
 
virtual void onMarkedForDeactivation () override
 
virtual void onMarkedForRemoval () override
 

Protected Attributes

u16 m_hp = 1
 
v3f m_rotation
 
f32 m_rotation_add_yaw = 0
 
ItemGroupList m_armor_groups
 
bool m_properties_sent = true
 
ObjectProperties m_prop
 
std::unordered_map< std::string, BoneOverridem_bone_override
 
object_t m_attachment_parent_id = 0
 
- Protected Attributes inherited from ServerActiveObject
std::optional< Observersm_effective_observers
 
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
object_t m_id
 

Private Member Functions

void onAttach (ServerActiveObject *parent)
 
void onDetach (ServerActiveObject *parent)
 
std::string generatePunchCommand (u16 result_hp) const
 

Private Attributes

u8 m_attachment_call_counter = 0
 
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_override_sent = false
 
std::unordered_set< object_tm_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 Types inherited from ServerActiveObject
using Observers = std::optional<std::unordered_set<std::string>>
 
- Public Types inherited from ActiveObject
typedef u16 object_t
 
- Public Attributes inherited from ServerActiveObject
u16 m_known_by_count = 0
 
bool m_static_exists = false
 
v3s16 m_static_block = v3s16(1337,1337,1337)
 
Observers m_observers
 

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 ( )
overridevirtual

Reimplemented from ServerActiveObject.

References m_prop.

◆ addAttachmentChild()

void UnitSAO::addAttachmentChild ( object_t child_id)
overridevirtual

Reimplemented from ActiveObject.

References m_attachment_child_ids.

◆ clearAnyAttachments()

void UnitSAO::clearAnyAttachments ( )
protected

References clearChildAttachments(), and ActiveObject::clearParentAttachment().

Referenced by onMarkedForDeactivation(), and onMarkedForRemoval().

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

◆ clearChildAttachments()

void UnitSAO::clearChildAttachments ( )
overridevirtual

Reimplemented from ActiveObject.

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

Referenced by clearAnyAttachments().

+ 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:

◆ generateUpdateBoneOverrideCommand()

std::string UnitSAO::generateUpdateBoneOverrideCommand ( const std::string & bone,
const BoneOverride & props )
static

◆ 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 )
overridevirtual

◆ getArmorGroups()

const ItemGroupList & UnitSAO::getArmorGroups ( ) const
overridevirtual

Reimplemented from ServerActiveObject.

References m_armor_groups.

Referenced by ServerEnvironment::getSelectedActiveObjects(), and isImmortal().

+ Here is the caller graph for this function:

◆ getAttachment()

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

◆ getAttachmentChildIds()

const std::unordered_set< object_t > & UnitSAO::getAttachmentChildIds ( ) const
inlineoverridevirtual

Reimplemented from ServerActiveObject.

References m_attachment_child_ids.

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

+ Here is the caller graph for this function:

◆ getBoneOverride()

BoneOverride UnitSAO::getBoneOverride ( const std::string & bone)
overridevirtual

Reimplemented from ServerActiveObject.

References m_bone_override.

◆ getBoneOverrides()

const std::unordered_map< std::string, BoneOverride > & UnitSAO::getBoneOverrides ( ) const
inlineoverridevirtual

Reimplemented from ServerActiveObject.

References m_bone_override.

◆ getHP()

u16 UnitSAO::getHP ( ) const
inlineoverridevirtual

Reimplemented from ServerActiveObject.

References m_hp.

Referenced by PlayerSAO::getClientInitializationData(), Server::handleCommand_Damage(), 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
overridevirtual

Reimplemented from ServerActiveObject.

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

Referenced by 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:

◆ getTotalRotation()

const v3f UnitSAO::getTotalRotation ( ) const
inline

References m_rotation, m_rotation_add_yaw, and setPitchYawRoll().

Referenced by ServerEnvironment::getSelectedActiveObjects().

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

◆ isAttached()

bool UnitSAO::isAttached ( ) const
inline

References m_attachment_parent_id.

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

+ 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(), and Server::HandlePlayerHPChange().

+ 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(), 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 ( )
overridevirtual

Reimplemented from ServerActiveObject.

References m_properties_sent.

◆ onAttach()

void UnitSAO::onAttach ( ServerActiveObject * parent)
private

References ACTIVEOBJECT_TYPE_LUAENTITY, ActiveObject::addAttachmentChild(), ActiveObject::getId(), ServerEnvironment::getScriptIface(), ActiveObject::getType(), ServerActiveObject::isGone(), ScriptApiEntity::luaentity_on_attach_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:

◆ onDetach()

void UnitSAO::onDetach ( ServerActiveObject * parent)
private

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

Referenced by setAttachment().

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

◆ onMarkedForDeactivation()

virtual void UnitSAO::onMarkedForDeactivation ( )
inlineoverrideprotectedvirtual

Reimplemented from ServerActiveObject.

Reimplemented in LuaEntitySAO.

References clearAnyAttachments(), and ServerActiveObject::onMarkedForDeactivation().

Referenced by LuaEntitySAO::onMarkedForDeactivation().

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

◆ onMarkedForRemoval()

virtual void UnitSAO::onMarkedForRemoval ( )
inlineoverrideprotectedvirtual

Reimplemented from ServerActiveObject.

Reimplemented in LuaEntitySAO.

References clearAnyAttachments(), and ServerActiveObject::onMarkedForRemoval().

Referenced by LuaEntitySAO::onMarkedForRemoval().

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

◆ removeAttachmentChild()

void UnitSAO::removeAttachmentChild ( object_t child_id)
overridevirtual

Reimplemented from ActiveObject.

References m_attachment_child_ids.

Referenced by clearChildAttachments().

+ Here is the caller graph for this function:

◆ sendOutdatedData()

void UnitSAO::sendOutdatedData ( )

References generateUpdateAnimationCommand(), generateUpdateAnimationSpeedCommand(), generateUpdateArmorGroupsCommand(), generateUpdateAttachmentCommand(), generateUpdateBoneOverrideCommand(), ActiveObject::getId(), m_animation_sent, m_animation_speed_sent, m_armor_groups_sent, m_attachment_sent, m_bone_override, m_bone_override_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 Server::HandlePlayerHPChange(), PlayerSAO::punch(), and LuaEntitySAO::setHP().

+ 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 )
overridevirtual

◆ setAnimationSpeed()

void UnitSAO::setAnimationSpeed ( float frame_speed)
overridevirtual

Reimplemented from ServerActiveObject.

References m_animation_speed, and m_animation_speed_sent.

◆ setArmorGroups()

void UnitSAO::setArmorGroups ( const ItemGroupList & armor_groups)
overridevirtual

Reimplemented from ServerActiveObject.

References m_armor_groups, and m_armor_groups_sent.

◆ setAttachment()

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

Reimplemented from ActiveObject.

References ServerEnvironment::getActiveObject(), ServerActiveObject::isGone(), m_attachment_bone, m_attachment_call_counter, m_attachment_parent_id, m_attachment_position, m_attachment_rotation, m_attachment_sent, ServerActiveObject::m_env, m_force_visible, ActiveObject::m_id, onAttach(), onDetach(), verbosestream, and warningstream.

+ Here is the call graph for this function:

◆ setBoneOverride()

void UnitSAO::setBoneOverride ( const std::string & bone,
const BoneOverride & props )
overridevirtual

Reimplemented from ServerActiveObject.

References m_bone_override, and m_bone_override_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_call_counter

u8 UnitSAO::m_attachment_call_counter = 0
private

Referenced by setAttachment().

◆ m_attachment_child_ids

std::unordered_set<object_t> 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_override

◆ m_bone_override_sent

bool UnitSAO::m_bone_override_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

◆ m_rotation_add_yaw

f32 UnitSAO::m_rotation_add_yaw = 0
protected

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