Minetest  5.4.0
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
 
u16 punch (v3f dir, const ToolCapabilities *toolcap=nullptr, ServerActiveObject *puncher=nullptr, float time_from_last_punch=1000000.0f)
 
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
 
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
 
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 void removingFromEnvironment ()
 
virtual bool environmentDeletes () const
 
void markForRemoval ()
 
void markForDeactivation ()
 
v3f getBasePosition () const
 
void setBasePosition (v3f pos)
 
ServerEnvironmentgetEnv ()
 
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)
 

Protected Member Functions

void dispatchScriptDeactivate ()
 
virtual void onMarkedForDeactivation ()
 
virtual void onMarkedForRemoval ()
 

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
 
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_current_texture_modifier = ""
 

Additional Inherited Members

- 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 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)
 
- 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 Attributes inherited from UnitSAO
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
 

Constructor & Destructor Documentation

◆ LuaEntitySAO() [1/3]

LuaEntitySAO::LuaEntitySAO ( )
delete

◆ LuaEntitySAO() [2/3]

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

References deSerializeString16(), deSerializeString32(), infostream, UnitSAO::m_hp, m_init_name, m_init_state, UnitSAO::m_rotation, m_velocity, readF1000(), readU16(), readU8(), and readV3F1000().

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

◆ ~LuaEntitySAO()

LuaEntitySAO::~LuaEntitySAO ( )

References ServerEnvironment::deleteParticleSpawner(), ServerEnvironment::getScriptIface(), ScriptApiEntity::luaentity_Remove(), ServerActiveObject::m_attached_particle_spawners, ServerActiveObject::m_env, ActiveObject::m_id, and m_registered.

+ Here is the call graph for this function:

Member Function Documentation

◆ addedToEnvironment()

void LuaEntitySAO::addedToEnvironment ( u32  dtime_s)
virtual

Reimplemented from ServerActiveObject.

References ServerActiveObject::addedToEnvironment(), ServerEnvironment::getScriptIface(), ObjectProperties::hp_max, ObjectProperties::infotext, 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

◆ dispatchScriptDeactivate()

void LuaEntitySAO::dispatchScriptDeactivate ( )
protected

References ServerEnvironment::getScriptIface(), ServerActiveObject::isGone(), ScriptApiEntity::luaentity_Deactivate(), 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_current_texture_modifier, serializeString16(), and writeU8().

Referenced by getClientInitializationData(), and setTextureMod().

+ 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, ObjectProperties::collisionbox, ServerActiveObject::m_base_position, UnitSAO::m_prop, and ObjectProperties::physical.

◆ getDescription()

std::string LuaEntitySAO::getDescription ( )
virtual

Reimplemented from ServerActiveObject.

References BS, floatToInt(), ServerActiveObject::m_base_position, m_init_name, and PP.

Referenced by punch().

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

◆ 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, ObjectProperties::is_visible, UnitSAO::m_prop, ObjectProperties::pointable, and ObjectProperties::selectionbox.

◆ 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 FUNCTION_NAME, ServerEnvironment::getScriptIface(), ServerActiveObject::m_env, UnitSAO::m_hp, ActiveObject::m_id, m_init_name, m_init_state, m_registered, UnitSAO::m_rotation, m_velocity, serializeString16(), serializeString32(), verbosestream, writeF1000(), writeU16(), writeU8(), and writeV3F1000().

+ Here is the call graph for this function:

◆ getTextureMod()

std::string LuaEntitySAO::getTextureMod ( ) const

References m_current_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

◆ moveTo()

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

Reimplemented from ServerActiveObject.

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

+ Here is the call graph for this function:

◆ onMarkedForDeactivation()

virtual void LuaEntitySAO::onMarkedForDeactivation ( )
inlineprotectedvirtual

Reimplemented from ServerActiveObject.

References dispatchScriptDeactivate().

+ Here is the call graph for this function:

◆ onMarkedForRemoval()

virtual void LuaEntitySAO::onMarkedForRemoval ( )
inlineprotectedvirtual

Reimplemented from ServerActiveObject.

References dispatchScriptDeactivate().

+ Here is the call graph for this function:

◆ punch()

◆ rightClick()

void LuaEntitySAO::rightClick ( ServerActiveObject clicker)
virtual

Reimplemented from ServerActiveObject.

References ServerEnvironment::getScriptIface(), ScriptApiEntity::luaentity_Rightclick(), 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(), ActiveObject::getId(), ServerEnvironment::getSendRecommendedInterval(), UnitSAO::isAttached(), m_acceleration, ServerActiveObject::m_base_position, 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 UnitSAO::m_hp, rangelim, and U16_MAX.

Referenced by punch().

+ Here is the caller graph for this function:

◆ setPos()

void LuaEntitySAO::setPos ( const v3f pos)
virtual

Reimplemented from ServerActiveObject.

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

+ 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 generateSetTextureModCommand(), ActiveObject::getId(), m_current_texture_modifier, and ServerActiveObject::m_messages_out.

Referenced by ObjectRef::l_set_texture_mod().

+ Here is the call graph for this function:
+ 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_current_texture_modifier

std::string LuaEntitySAO::m_current_texture_modifier = ""
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_velocity

v3f LuaEntitySAO::m_velocity
private

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