#include <unit_sao.h>
Public Member Functions | |
UnitSAO (ServerEnvironment *env, v3f pos) | |
virtual | ~UnitSAO ()=default |
u16 | getHP () const override |
bool | isDead () const |
void | setRotation (v3f rotation) |
const v3f & | getRotation () const |
const v3f | getTotalRotation () const |
v3f | getRadRotation () |
f32 | getRadYawDep () const |
bool | isImmortal () const |
void | setArmorGroups (const ItemGroupList &armor_groups) override |
const ItemGroupList & | getArmorGroups () 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 |
ServerActiveObject * | getParent () 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 |
ObjectProperties * | accessObjectProperties () 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) |
ServerEnvironment * | getEnv () |
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 Inventory * | getInventory () 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 Observers & | getEffectiveObservers () |
Cache m_effective_observers with the names of all observers, also indirect observers (object attachment chain). | |
const Observers & | recalculateEffectiveObservers () |
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, BoneOverride > | m_bone_override |
object_t | m_attachment_parent_id = 0 |
Protected Attributes inherited from ServerActiveObject | |
std::optional< Observers > | m_effective_observers |
ServerEnvironment * | m_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< ActiveObjectMessage > | m_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_t > | 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 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 |
UnitSAO::UnitSAO | ( | ServerEnvironment * | env, |
v3f | pos ) |
References m_armor_groups.
|
virtualdefault |
|
overridevirtual |
Reimplemented from ServerActiveObject.
References m_prop.
|
overridevirtual |
Reimplemented from ActiveObject.
References m_attachment_child_ids.
|
protected |
References clearChildAttachments(), and ActiveObject::clearParentAttachment().
Referenced by onMarkedForDeactivation(), and onMarkedForRemoval().
|
overridevirtual |
Reimplemented from ActiveObject.
References ServerEnvironment::getActiveObject(), m_attachment_child_ids, ServerActiveObject::m_env, and removeAttachmentChild().
Referenced by clearAnyAttachments().
|
private |
References AO_CMD_PUNCHED, writeU16(), and writeU8().
Referenced by sendPunchCommand().
std::string UnitSAO::generateSetPropertiesCommand | ( | const ObjectProperties & | prop | ) | const |
References AO_CMD_SET_PROPERTIES, ObjectProperties::serialize(), and writeU8().
Referenced by LuaEntitySAO::getPropertyPacket(), and PlayerSAO::getPropertyPacket().
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().
std::string UnitSAO::generateUpdateAnimationSpeedCommand | ( | ) | const |
References AO_CMD_SET_ANIMATION_SPEED, m_animation_speed, writeF32(), and writeU8().
Referenced by sendOutdatedData().
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().
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().
|
static |
References BoneOverride::PositionProperty::absolute, BoneOverride::RotationProperty::absolute, BoneOverride::ScaleProperty::absolute, AO_CMD_SET_BONE_POSITION, BoneOverride::PositionProperty::interp_timer, BoneOverride::RotationProperty::interp_timer, BoneOverride::ScaleProperty::interp_timer, BoneOverride::RotationProperty::next, BoneOverride::position, BoneOverride::rotation, BoneOverride::scale, serializeString16(), BoneOverride::PositionProperty::vector, BoneOverride::ScaleProperty::vector, writeF32(), writeU8(), and writeV3F32().
Referenced by LuaEntitySAO::getClientInitializationData(), PlayerSAO::getClientInitializationData(), and sendOutdatedData().
|
static |
References AO_CMD_UPDATE_POSITION, writeF32(), writeU8(), and writeV3F32().
Referenced by LuaEntitySAO::sendPosition(), and PlayerSAO::step().
|
overridevirtual |
Reimplemented from ServerActiveObject.
References m_animation_blend, m_animation_loop, m_animation_range, and m_animation_speed.
|
overridevirtual |
Reimplemented from ServerActiveObject.
References m_armor_groups.
Referenced by ServerEnvironment::getSelectedActiveObjects(), and isImmortal().
|
overridevirtual |
Reimplemented from ActiveObject.
References m_attachment_bone, m_attachment_parent_id, m_attachment_position, m_attachment_rotation, and m_force_visible.
|
inlineoverridevirtual |
Reimplemented from ServerActiveObject.
References m_attachment_child_ids.
Referenced by LuaEntitySAO::getClientInitializationData(), and PlayerSAO::getClientInitializationData().
|
overridevirtual |
Reimplemented from ServerActiveObject.
References m_bone_override.
|
inlineoverridevirtual |
Reimplemented from ServerActiveObject.
References m_bone_override.
|
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().
|
overridevirtual |
Reimplemented from ServerActiveObject.
References ServerEnvironment::getActiveObject(), m_attachment_parent_id, and ServerActiveObject::m_env.
Referenced by LuaEntitySAO::step(), and PlayerSAO::step().
|
inline |
References m_rotation.
Referenced by ObjectRef::l_get_look_horizontal().
|
inline |
References m_rotation.
Referenced by ObjectRef::l_get_look_dir(), and ObjectRef::l_get_look_yaw().
|
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().
|
inline |
References m_rotation, m_rotation_add_yaw, and setPitchYawRoll().
Referenced by ServerEnvironment::getSelectedActiveObjects().
|
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().
|
inline |
References m_hp.
Referenced by Server::handleCommand_Damage(), Server::handleCommand_Interact(), Server::handleCommand_InventoryAction(), Server::handleCommand_PlayerPos(), and Server::HandlePlayerHPChange().
|
inline |
References getArmorGroups(), and itemgroup_get().
Referenced by Server::handleCommand_Damage(), PlayerSAO::punch(), PlayerSAO::setHP(), and PlayerSAO::step().
|
overridevirtual |
Reimplemented from ServerActiveObject.
References m_properties_sent.
|
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().
|
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().
|
inlineoverrideprotectedvirtual |
Reimplemented from ServerActiveObject.
Reimplemented in LuaEntitySAO.
References clearAnyAttachments(), and ServerActiveObject::onMarkedForDeactivation().
Referenced by LuaEntitySAO::onMarkedForDeactivation().
|
inlineoverrideprotectedvirtual |
Reimplemented from ServerActiveObject.
Reimplemented in LuaEntitySAO.
References clearAnyAttachments(), and ServerActiveObject::onMarkedForRemoval().
Referenced by LuaEntitySAO::onMarkedForRemoval().
|
overridevirtual |
Reimplemented from ActiveObject.
References m_attachment_child_ids.
Referenced by clearChildAttachments().
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().
void UnitSAO::sendPunchCommand | ( | ) |
References generatePunchCommand(), getHP(), ActiveObject::getId(), and ServerActiveObject::m_messages_out.
Referenced by Server::HandlePlayerHPChange(), PlayerSAO::punch(), and LuaEntitySAO::setHP().
|
overridevirtual |
Reimplemented from ServerActiveObject.
References m_animation_blend, m_animation_loop, m_animation_range, m_animation_sent, and m_animation_speed.
|
overridevirtual |
Reimplemented from ServerActiveObject.
References m_animation_speed, and m_animation_speed_sent.
|
overridevirtual |
Reimplemented from ServerActiveObject.
References m_armor_groups, and m_armor_groups_sent.
|
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.
|
overridevirtual |
Reimplemented from ServerActiveObject.
References m_bone_override, and m_bone_override_sent.
|
inline |
References m_rotation.
Referenced by ObjectRef::l_set_rotation(), ObjectRef::l_set_yaw(), and PlayerSAO::setPlayerYaw().
|
private |
Referenced by generateUpdateAnimationCommand(), getAnimation(), and setAnimation().
|
private |
Referenced by generateUpdateAnimationCommand(), getAnimation(), and setAnimation().
|
private |
Referenced by generateUpdateAnimationCommand(), getAnimation(), and setAnimation().
|
private |
Referenced by sendOutdatedData(), and setAnimation().
|
private |
|
private |
Referenced by sendOutdatedData(), and setAnimationSpeed().
|
protected |
|
private |
Referenced by sendOutdatedData(), and setArmorGroups().
|
private |
Referenced by generateUpdateAttachmentCommand(), getAttachment(), and setAttachment().
|
private |
Referenced by setAttachment().
|
private |
Referenced by addAttachmentChild(), clearChildAttachments(), getAttachmentChildIds(), and removeAttachmentChild().
|
protected |
Referenced by generateUpdateAttachmentCommand(), getAttachment(), getParent(), isAttached(), setAttachment(), LuaEntitySAO::step(), and PlayerSAO::step().
|
private |
Referenced by generateUpdateAttachmentCommand(), getAttachment(), and setAttachment().
|
private |
Referenced by generateUpdateAttachmentCommand(), getAttachment(), and setAttachment().
|
private |
Referenced by sendOutdatedData(), and setAttachment().
|
protected |
|
private |
Referenced by sendOutdatedData(), and setBoneOverride().
|
private |
Referenced by generateUpdateAttachmentCommand(), getAttachment(), and setAttachment().
|
protected |
Referenced by LuaEntitySAO::LuaEntitySAO(), PlayerSAO::PlayerSAO(), LuaEntitySAO::addedToEnvironment(), LuaEntitySAO::getClientInitializationData(), LuaEntitySAO::getHP(), getHP(), LuaEntitySAO::getStaticData(), isDead(), LuaEntitySAO::punch(), PlayerSAO::punch(), LuaEntitySAO::setHP(), PlayerSAO::setHP(), PlayerSAO::setHPRaw(), and PlayerSAO::step().
|
protected |
Referenced by PlayerSAO::PlayerSAO(), accessObjectProperties(), LuaEntitySAO::addedToEnvironment(), LuaEntitySAO::collideWithObjects(), LuaEntitySAO::getCollisionBox(), PlayerSAO::getCollisionBox(), PlayerSAO::getEyeOffset(), LuaEntitySAO::getPropertyPacket(), PlayerSAO::getPropertyPacket(), LuaEntitySAO::getSelectionBox(), PlayerSAO::getSelectionBox(), PlayerSAO::getZoomFOV(), LuaEntitySAO::isStaticAllowed(), PlayerSAO::respawn(), PlayerSAO::setBreath(), PlayerSAO::setHP(), LuaEntitySAO::step(), and PlayerSAO::step().
|
protected |
Referenced by notifyObjectPropertiesModified(), PlayerSAO::setHP(), LuaEntitySAO::step(), and PlayerSAO::step().
|
protected |
Referenced by LuaEntitySAO::LuaEntitySAO(), LuaEntitySAO::getClientInitializationData(), PlayerSAO::getClientInitializationData(), getRadRotation(), getRadYawDep(), getRotation(), LuaEntitySAO::getStaticData(), getTotalRotation(), LuaEntitySAO::sendPosition(), PlayerSAO::setPlayerYaw(), setRotation(), LuaEntitySAO::step(), and PlayerSAO::step().
|
protected |
Referenced by getTotalRotation(), and LuaEntitySAO::step().