Luanti 5.16.0-dev
Loading...
Searching...
No Matches
LuaEntitySAO Class Reference

#include <luaentity_sao.h>

Inheritance diagram for LuaEntitySAO:
Collaboration diagram for LuaEntitySAO:

Public Member Functions

 LuaEntitySAO ()=delete
 LuaEntitySAO (ServerEnvironment *env, v3f pos, const std::string &data)
 LuaEntitySAO (ServerEnvironment *env, v3f pos, const std::string &name, const std::string &state)
 ~LuaEntitySAO ()
ActiveObjectType getType () const
ActiveObjectType getSendType () const
virtual void addedToEnvironment (u32 dtime_s)
void step (float dtime, bool send_recommended)
std::string getClientInitializationData (u16 protocol_version)
bool isStaticAllowed () const
bool shouldUnload () const
void getStaticData (std::string *result) const
u32 punch (v3f dir, const ToolCapabilities &toolcap, ServerActiveObject *puncher=nullptr, float time_from_last_punch=1000000.0f, u16 initial_wear=0)
void rightClick (ServerActiveObject *clicker)
void setPos (const v3f &pos)
void moveTo (v3f pos, bool continuous)
float getMinimumSavedMovement ()
std::string getDescription ()
void setHP (s32 hp, const PlayerHPChangeReason &reason)
u16 getHP () const
std::string getGUID () const
 Returns an unique ID for this object (persistent across unload, server restarts).
void setVelocity (v3f velocity)
void addVelocity (v3f velocity)
v3f getVelocity ()
void setAcceleration (v3f acceleration)
v3f getAcceleration ()
void setTextureMod (const std::string &mod)
std::string getTextureMod () const
void setSprite (v2s16 p, int num_frames, float framelength, bool select_horiz_by_yawpitch)
std::string getName ()
bool getCollisionBox (aabb3f *toset) const
bool getSelectionBox (aabb3f *toset) const
bool collideWithObjects () const
Public Member Functions inherited from UnitSAO
 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 void removingFromEnvironment ()
void markForRemoval ()
void markForDeactivation ()
v3f getBasePosition () const
void setBasePosition (v3f pos)
ServerEnvironmentgetEnv ()
virtual void addPos (const v3f &added_pos)
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 void clearParentAttachment ()

Protected Member Functions

void dispatchScriptDeactivate (bool removal)
virtual void onMarkedForDeactivation ()
virtual void onMarkedForRemoval ()
Protected Member Functions inherited from UnitSAO
void clearAnyAttachments ()

Private Member Functions

std::string getPropertyPacket ()
void sendPosition (bool do_interpolate, bool is_movement_end)
std::string generateSetTextureModCommand () const

Static Private Member Functions

static std::string generateSetSpriteCommand (v2s16 p, u16 num_frames, f32 framelength, bool select_horiz_by_yawpitch)

Private Attributes

std::string m_init_name
std::string m_init_state
bool m_registered = false
MyGUID m_guid
v3f m_velocity
v3f m_acceleration
v3f m_last_sent_position
v3f m_last_sent_velocity
v3f m_last_sent_rotation
float m_last_sent_position_timer = 0.0f
float m_last_sent_move_precision = 0.0f
std::string m_texture_modifier
bool m_texture_modifier_sent = 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
Static Public Member Functions inherited from UnitSAO
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)
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
Protected Attributes inherited from UnitSAO
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

Constructor & Destructor Documentation

◆ LuaEntitySAO() [1/3]

LuaEntitySAO::LuaEntitySAO ( )
delete

◆ LuaEntitySAO() [2/3]

LuaEntitySAO::LuaEntitySAO ( ServerEnvironment * env,
v3f pos,
const std::string & data )

References UnitSAO::UnitSAO(), and m_guid.

Here is the call graph for this function:

◆ LuaEntitySAO() [3/3]

LuaEntitySAO::LuaEntitySAO ( ServerEnvironment * env,
v3f pos,
const std::string & name,
const std::string & state )

References UnitSAO::UnitSAO(), m_guid, m_init_name, and m_init_state.

Here is the call graph for this function:

◆ ~LuaEntitySAO()

Member Function Documentation

◆ addedToEnvironment()

void LuaEntitySAO::addedToEnvironment ( u32 dtime_s)
virtual

Reimplemented from ServerActiveObject.

References ServerActiveObject::addedToEnvironment(), ServerActiveObject::m_env, UnitSAO::m_hp, ActiveObject::m_id, m_init_name, m_init_state, UnitSAO::m_prop, and m_registered.

Here is the call graph for this function:

◆ addVelocity()

void LuaEntitySAO::addVelocity ( v3f velocity)
inline

References m_velocity.

Referenced by ObjectRef::l_add_velocity().

Here is the caller graph for this function:

◆ collideWithObjects()

bool LuaEntitySAO::collideWithObjects ( ) const
virtual

Implements ActiveObject.

References UnitSAO::m_prop.

◆ dispatchScriptDeactivate()

void LuaEntitySAO::dispatchScriptDeactivate ( bool removal)
protected

References ServerActiveObject::isGone(), ServerActiveObject::m_env, ActiveObject::m_id, and m_registered.

Referenced by onMarkedForDeactivation(), and onMarkedForRemoval().

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

◆ generateSetSpriteCommand()

std::string LuaEntitySAO::generateSetSpriteCommand ( v2s16 p,
u16 num_frames,
f32 framelength,
bool select_horiz_by_yawpitch )
staticprivate

References AO_CMD_SET_SPRITE, p(), writeF32(), writeU16(), writeU8(), and writeV2S16().

Referenced by setSprite().

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

◆ generateSetTextureModCommand()

std::string LuaEntitySAO::generateSetTextureModCommand ( ) const
private

References AO_CMD_SET_TEXTURE_MOD, m_texture_modifier, serializeString16(), and writeU8().

Referenced by getClientInitializationData(), and step().

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

◆ getAcceleration()

v3f LuaEntitySAO::getAcceleration ( )

References m_acceleration.

Referenced by ObjectRef::l_get_acceleration().

Here is the caller graph for this function:

◆ getClientInitializationData()

◆ getCollisionBox()

bool LuaEntitySAO::getCollisionBox ( aabb3f * toset) const
virtual

Returns the collision box of the object. This box is translated by the object's location. The box's coordinates are world coordinates.

Returns
true if the object has a collision box.

Implements ActiveObject.

References BS, ServerActiveObject::getBasePosition(), and UnitSAO::m_prop.

Here is the call graph for this function:

◆ getDescription()

std::string LuaEntitySAO::getDescription ( )
virtual

Reimplemented from ServerActiveObject.

References BS, floatToInt(), ServerActiveObject::getBasePosition(), and m_init_name.

Referenced by punch().

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

◆ getGUID()

std::string LuaEntitySAO::getGUID ( ) const
virtual

Returns an unique ID for this object (persistent across unload, server restarts).

Note
Because these strings are very short, copying them is not expensive.

Implements ServerActiveObject.

References m_guid.

◆ getHP()

u16 LuaEntitySAO::getHP ( ) const
virtual

Reimplemented from ServerActiveObject.

References UnitSAO::m_hp.

Referenced by punch().

Here is the caller graph for this function:

◆ getMinimumSavedMovement()

float LuaEntitySAO::getMinimumSavedMovement ( )
virtual

Reimplemented from ServerActiveObject.

References BS.

◆ getName()

std::string LuaEntitySAO::getName ( )

References m_init_name.

Referenced by ObjectRef::l_get_entity_name().

Here is the caller graph for this function:

◆ getPropertyPacket()

std::string LuaEntitySAO::getPropertyPacket ( )
private

References UnitSAO::generateSetPropertiesCommand(), and UnitSAO::m_prop.

Referenced by getClientInitializationData(), and step().

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

◆ getSelectionBox()

bool LuaEntitySAO::getSelectionBox ( aabb3f * toset) const
virtual

Returns the selection box of the object. This box is not translated when the object moves. The box's coordinates are world coordinates.

Returns
true if the object has a selection box.

Implements ActiveObject.

References BS, and UnitSAO::m_prop.

◆ getSendType()

ActiveObjectType LuaEntitySAO::getSendType ( ) const
inlinevirtual

Reimplemented from ServerActiveObject.

References ACTIVEOBJECT_TYPE_GENERIC.

◆ getStaticData()

void LuaEntitySAO::getStaticData ( std::string * result) const
virtual

Reimplemented from ServerActiveObject.

References clampToF1000(), isStaticAllowed(), ServerActiveObject::m_env, m_guid, UnitSAO::m_hp, ActiveObject::m_id, m_init_name, m_init_state, m_registered, UnitSAO::m_rotation, m_velocity, serializeString16(), serializeString32(), writeF1000(), writeU16(), writeU8(), and writeV3F1000().

Here is the call graph for this function:

◆ getTextureMod()

std::string LuaEntitySAO::getTextureMod ( ) const

References m_texture_modifier.

Referenced by ObjectRef::l_get_texture_mod().

Here is the caller graph for this function:

◆ getType()

ActiveObjectType LuaEntitySAO::getType ( ) const
inlinevirtual

Implements ActiveObject.

References ACTIVEOBJECT_TYPE_LUAENTITY.

◆ getVelocity()

v3f LuaEntitySAO::getVelocity ( )

References m_velocity.

Referenced by RemoteClient::GetNextBlocks(), and ObjectRef::l_get_velocity().

Here is the caller graph for this function:

◆ isStaticAllowed()

bool LuaEntitySAO::isStaticAllowed ( ) const
inlinevirtual

Reimplemented from ServerActiveObject.

References UnitSAO::m_prop.

Referenced by getStaticData().

Here is the caller graph for this function:

◆ moveTo()

void LuaEntitySAO::moveTo ( v3f pos,
bool continuous )
virtual

Reimplemented from ServerActiveObject.

References UnitSAO::isAttached(), sendPosition(), and ServerActiveObject::setBasePosition().

Here is the call graph for this function:

◆ onMarkedForDeactivation()

virtual void LuaEntitySAO::onMarkedForDeactivation ( )
inlineprotectedvirtual

Reimplemented from UnitSAO.

References dispatchScriptDeactivate(), and UnitSAO::onMarkedForDeactivation().

Here is the call graph for this function:

◆ onMarkedForRemoval()

virtual void LuaEntitySAO::onMarkedForRemoval ( )
inlineprotectedvirtual

Reimplemented from UnitSAO.

References dispatchScriptDeactivate(), and UnitSAO::onMarkedForRemoval().

Here is the call graph for this function:

◆ punch()

u32 LuaEntitySAO::punch ( v3f dir,
const ToolCapabilities & toolcap,
ServerActiveObject * puncher = nullptr,
float time_from_last_punch = 1000000.0f,
u16 initial_wear = 0 )
virtual

◆ rightClick()

void LuaEntitySAO::rightClick ( ServerActiveObject * clicker)
virtual

Reimplemented from ServerActiveObject.

References ServerActiveObject::ServerActiveObject(), ServerActiveObject::m_env, ActiveObject::m_id, and m_registered.

Here is the call graph for this function:

◆ sendPosition()

void LuaEntitySAO::sendPosition ( bool do_interpolate,
bool is_movement_end )
private

References UnitSAO::generateUpdatePositionCommand(), ServerActiveObject::getBasePosition(), ActiveObject::getId(), UnitSAO::isAttached(), m_acceleration, ServerActiveObject::m_env, m_last_sent_move_precision, m_last_sent_position, m_last_sent_position_timer, m_last_sent_rotation, m_last_sent_velocity, ServerActiveObject::m_messages_out, UnitSAO::m_rotation, m_velocity, and UnitSAO::sendOutdatedData().

Referenced by moveTo(), setPos(), and step().

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

◆ setAcceleration()

void LuaEntitySAO::setAcceleration ( v3f acceleration)

References m_acceleration.

Referenced by ObjectRef::l_set_acceleration().

Here is the caller graph for this function:

◆ setHP()

void LuaEntitySAO::setHP ( s32 hp,
const PlayerHPChangeReason & reason )
virtual

Reimplemented from ServerActiveObject.

References ServerActiveObject::ServerActiveObject(), ServerActiveObject::isGone(), ServerActiveObject::m_env, UnitSAO::m_hp, ActiveObject::m_id, m_registered, ServerActiveObject::markForRemoval(), PlayerHPChangeReason::object, PlayerHPChangeReason::PLAYER_PUNCH, rangelim(), UnitSAO::sendPunchCommand(), PlayerHPChangeReason::type, and U16_MAX.

Referenced by punch().

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

◆ setPos()

void LuaEntitySAO::setPos ( const v3f & pos)
virtual

Reimplemented from ServerActiveObject.

References UnitSAO::isAttached(), sendPosition(), and ServerActiveObject::setBasePosition().

Here is the call graph for this function:

◆ setSprite()

void LuaEntitySAO::setSprite ( v2s16 p,
int num_frames,
float framelength,
bool select_horiz_by_yawpitch )

References generateSetSpriteCommand(), ActiveObject::getId(), ServerActiveObject::m_messages_out, and p().

Referenced by ObjectRef::l_set_sprite().

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

◆ setTextureMod()

void LuaEntitySAO::setTextureMod ( const std::string & mod)

References m_texture_modifier, and m_texture_modifier_sent.

Referenced by ObjectRef::l_set_texture_mod().

Here is the caller graph for this function:

◆ setVelocity()

void LuaEntitySAO::setVelocity ( v3f velocity)

References m_velocity.

Referenced by ObjectRef::l_set_velocity().

Here is the caller graph for this function:

◆ shouldUnload()

bool LuaEntitySAO::shouldUnload ( ) const
inlinevirtual

Reimplemented from ServerActiveObject.

◆ step()

Member Data Documentation

◆ m_acceleration

v3f LuaEntitySAO::m_acceleration
private

◆ m_guid

MyGUID LuaEntitySAO::m_guid
private

◆ m_init_name

std::string LuaEntitySAO::m_init_name
private

◆ m_init_state

std::string LuaEntitySAO::m_init_state
private

◆ m_last_sent_move_precision

float LuaEntitySAO::m_last_sent_move_precision = 0.0f
private

Referenced by sendPosition(), and step().

◆ m_last_sent_position

v3f LuaEntitySAO::m_last_sent_position
private

Referenced by sendPosition(), and step().

◆ m_last_sent_position_timer

float LuaEntitySAO::m_last_sent_position_timer = 0.0f
private

Referenced by sendPosition(), and step().

◆ m_last_sent_rotation

v3f LuaEntitySAO::m_last_sent_rotation
private

Referenced by sendPosition(), and step().

◆ m_last_sent_velocity

v3f LuaEntitySAO::m_last_sent_velocity
private

Referenced by sendPosition(), and step().

◆ m_registered

bool LuaEntitySAO::m_registered = false
private

◆ m_texture_modifier

std::string LuaEntitySAO::m_texture_modifier
private

◆ m_texture_modifier_sent

bool LuaEntitySAO::m_texture_modifier_sent = false
private

Referenced by setTextureMod(), and step().

◆ m_velocity

v3f LuaEntitySAO::m_velocity
private

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