Luanti 5.18.0-dev
Loading...
Searching...
No Matches
UnitSAO Class Reference

#include <unit_sao.h>

Inheritance diagram for UnitSAO:
Collaboration diagram for UnitSAO:

Classes

struct  TrackAnimation
struct  Animation

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
core::quaternion getTotalRotation () const
v3f getRadRotation ()
f32 getRadYawDep () const
bool isImmortal () const
void setArmorGroups (const ItemGroupList &armor_groups) override
const ItemGroupListgetArmorGroups () const override
void setAnimation (const scene::TrackId &track, scene::TrackAnimSpec anim_spec) override
void stopAnimation (const scene::TrackId &track) override
std::optional< scene::TrackAnimSpec > getAnimation (const scene::TrackId &track) const override
std::vector< std::pair< scene::TrackId, scene::TrackAnimSpec > > getAllAnimations () const override
void setAnimationSpeed (const scene::TrackId &track, f32 fps) override
const AnimationgetAnimation () const
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
bool isAttachmentOutdated () const
void sendOutdatedData ()
std::string generateUpdateAttachmentCommand () const
std::string generateUpdateAnimationSpeedCommand (const scene::TrackId &track) const
std::string generateUpdateAnimationCommand (const scene::TrackId &track) const
std::string generateStopAnimationCommand (const scene::TrackId &track) 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, 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 std::string getGUID () const =0
 Returns a unique ID for this object (persistent across unload, server restarts).
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
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
Animation m_animation
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 ServerActiveObject::ServerActiveObject(), and m_armor_groups.

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

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

◆ ~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 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:

◆ generateStopAnimationCommand()

std::string UnitSAO::generateStopAnimationCommand ( const scene::TrackId & track) const

References AO_CMD_STOP_ANIMATION, writeTrackIdentifier(), and writeU8().

Referenced by sendOutdatedData().

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

◆ generateUpdateAnimationCommand()

std::string UnitSAO::generateUpdateAnimationCommand ( const scene::TrackId & track) const

References AO_CMD_SET_ANIMATION, m_animation, writeF32(), writeS32(), writeTrackIdentifier(), 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:

◆ generateUpdateAnimationSpeedCommand()

std::string UnitSAO::generateUpdateAnimationSpeedCommand ( const scene::TrackId & track) const

References AO_CMD_SET_ANIMATION_SPEED, m_animation, writeF32(), writeTrackIdentifier(), 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(), Server::SendMovePlayer(), 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:

◆ getAllAnimations()

std::vector< std::pair< scene::TrackId, scene::TrackAnimSpec > > UnitSAO::getAllAnimations ( ) const
overridevirtual

Reimplemented from ServerActiveObject.

References m_animation, and UnitSAO::TrackAnimation::STOPPED.

◆ getAnimation() [1/2]

const Animation & UnitSAO::getAnimation ( ) const
inline

References m_animation.

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

Here is the caller graph for this function:

◆ getAnimation() [2/2]

std::optional< scene::TrackAnimSpec > UnitSAO::getAnimation ( const scene::TrackId & track) const
overridevirtual

Reimplemented from ServerActiveObject.

References m_animation, and UnitSAO::TrackAnimation::STOPPED.

◆ 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 ServerActiveObject::ServerActiveObject(), 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()

core::quaternion UnitSAO::getTotalRotation ( ) const

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(), Server::SendMovePlayer(), LuaEntitySAO::sendPosition(), LuaEntitySAO::setPos(), PlayerSAO::setPos(), LuaEntitySAO::step(), and PlayerSAO::step().

Here is the caller graph for this function:

◆ isAttachmentOutdated()

bool UnitSAO::isAttachmentOutdated ( ) const
inline

References m_attachment_sent.

Referenced by Server::SendMovePlayer().

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 ServerActiveObject::ServerActiveObject(), ACTIVEOBJECT_TYPE_LUAENTITY, ActiveObject::addAttachmentChild(), ActiveObject::getId(), ActiveObject::getType(), ServerActiveObject::isGone(), 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 ServerActiveObject::ServerActiveObject(), ACTIVEOBJECT_TYPE_LUAENTITY, ActiveObject::getId(), ActiveObject::getType(), ServerActiveObject::isGone(), 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 ( )

◆ 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 ( const scene::TrackId & track,
scene::TrackAnimSpec anim_spec )
overridevirtual

◆ setAnimationSpeed()

void UnitSAO::setAnimationSpeed ( const scene::TrackId & track,
f32 fps )
overridevirtual

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

◆ stopAnimation()

void UnitSAO::stopAnimation ( const scene::TrackId & track)
overridevirtual

Reimplemented from ServerActiveObject.

References m_animation, and UnitSAO::TrackAnimation::STOPPED.

Member Data Documentation

◆ m_animation

◆ 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

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