#include <luaentity_sao.h>
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=nullptr, 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 |
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 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 void | removingFromEnvironment () |
void | markForRemoval () |
void | markForDeactivation () |
v3f | getBasePosition () const |
void | setBasePosition (v3f pos) |
ServerEnvironment * | getEnv () |
virtual void | addPos (const v3f &added_pos) |
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 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 |
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, 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 |
|
delete |
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().
|
inline |
LuaEntitySAO::~LuaEntitySAO | ( | ) |
References ServerEnvironment::deleteParticleSpawner(), ServerEnvironment::getScriptIface(), ScriptApiEntity::luaentity_Remove(), ServerActiveObject::m_attached_particle_spawners, ServerActiveObject::m_env, ActiveObject::m_id, and m_registered.
|
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, m_registered, and ObjectProperties::textures.
|
inline |
References m_velocity.
Referenced by ObjectRef::l_add_velocity().
|
virtual |
Implements ActiveObject.
References ObjectProperties::collideWithObjects, and UnitSAO::m_prop.
|
protected |
References ServerEnvironment::getScriptIface(), ServerActiveObject::isGone(), ScriptApiEntity::luaentity_Deactivate(), ServerActiveObject::m_env, ActiveObject::m_id, and m_registered.
Referenced by onMarkedForDeactivation(), and onMarkedForRemoval().
|
staticprivate |
References AO_CMD_SET_SPRITE, p(), writeF32(), writeU16(), writeU8(), and writeV2S16().
Referenced by setSprite().
|
private |
References AO_CMD_SET_TEXTURE_MOD, m_texture_modifier, serializeString16(), and writeU8().
Referenced by getClientInitializationData(), and step().
v3f LuaEntitySAO::getAcceleration | ( | ) |
References m_acceleration.
Referenced by ObjectRef::l_get_acceleration().
|
virtual |
Reimplemented from ServerActiveObject.
References generateSetTextureModCommand(), UnitSAO::generateUpdateAnimationCommand(), UnitSAO::generateUpdateArmorGroupsCommand(), UnitSAO::generateUpdateAttachmentCommand(), UnitSAO::generateUpdateBoneOverrideCommand(), ServerEnvironment::getActiveObject(), UnitSAO::getAttachmentChildIds(), ActiveObject::getId(), getPropertyPacket(), ServerActiveObject::m_base_position, UnitSAO::m_bone_override, ServerActiveObject::m_env, UnitSAO::m_hp, m_init_name, UnitSAO::m_rotation, serializeString16(), serializeString32(), writeU16(), writeU8(), and writeV3F32().
|
virtual |
Returns the collision box of the object. This box is translated by the object's location. The box's coordinates are world coordinates.
Implements ActiveObject.
References BS, ObjectProperties::collisionbox, ServerActiveObject::m_base_position, UnitSAO::m_prop, and ObjectProperties::physical.
|
virtual |
Reimplemented from ServerActiveObject.
References BS, floatToInt(), ServerActiveObject::m_base_position, and m_init_name.
Referenced by punch().
|
virtual |
Reimplemented from ServerActiveObject.
References UnitSAO::m_hp.
Referenced by punch().
|
virtual |
Reimplemented from ServerActiveObject.
References BS.
std::string LuaEntitySAO::getName | ( | ) |
References m_init_name.
Referenced by ObjectRef::l_get_entity_name().
|
private |
References UnitSAO::generateSetPropertiesCommand(), and UnitSAO::m_prop.
Referenced by getClientInitializationData(), and step().
|
virtual |
Returns the selection box of the object. This box is not translated when the object moves. The box's coordinates are world coordinates.
Implements ActiveObject.
References BS, ObjectProperties::is_visible, UnitSAO::m_prop, and ObjectProperties::selectionbox.
|
inlinevirtual |
Reimplemented from ServerActiveObject.
References ACTIVEOBJECT_TYPE_GENERIC.
|
virtual |
Reimplemented from ServerActiveObject.
References clampToF1000(), ServerEnvironment::getScriptIface(), isStaticAllowed(), ServerActiveObject::m_env, 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().
std::string LuaEntitySAO::getTextureMod | ( | ) | const |
References m_texture_modifier.
Referenced by ObjectRef::l_get_texture_mod().
|
inlinevirtual |
Implements ActiveObject.
References ACTIVEOBJECT_TYPE_LUAENTITY.
v3f LuaEntitySAO::getVelocity | ( | ) |
References m_velocity.
Referenced by RemoteClient::GetNextBlocks(), and ObjectRef::l_get_velocity().
|
inlinevirtual |
Reimplemented from ServerActiveObject.
References UnitSAO::m_prop, and ObjectProperties::static_save.
Referenced by getStaticData().
|
virtual |
Reimplemented from ServerActiveObject.
References UnitSAO::isAttached(), ServerActiveObject::m_base_position, and sendPosition().
|
inlineprotectedvirtual |
Reimplemented from UnitSAO.
References dispatchScriptDeactivate(), and UnitSAO::onMarkedForDeactivation().
|
inlineprotectedvirtual |
Reimplemented from UnitSAO.
References dispatchScriptDeactivate(), and UnitSAO::onMarkedForRemoval().
|
virtual |
Reimplemented from ServerActiveObject.
References actionstream, PunchDamageResult::damage, PunchDamageResult::did_punch, dir(), getDescription(), ServerActiveObject::getDescription(), getHP(), ServerActiveObject::getHP(), ActiveObject::getId(), getPunchDamage(), ServerEnvironment::getScriptIface(), ServerActiveObject::getWieldedItem(), ScriptApiEntity::luaentity_Punch(), UnitSAO::m_armor_groups, ServerActiveObject::m_env, UnitSAO::m_hp, ActiveObject::m_id, m_registered, ServerActiveObject::markForRemoval(), PlayerHPChangeReason::PLAYER_PUNCH, setHP(), and PunchDamageResult::wear.
|
virtual |
Reimplemented from ServerActiveObject.
References ServerEnvironment::getScriptIface(), ScriptApiEntity::luaentity_Rightclick(), ServerActiveObject::m_env, ActiveObject::m_id, and m_registered.
|
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().
void LuaEntitySAO::setAcceleration | ( | v3f | acceleration | ) |
References m_acceleration.
Referenced by ObjectRef::l_set_acceleration().
|
virtual |
Reimplemented from ServerActiveObject.
References ServerEnvironment::getScriptIface(), ServerActiveObject::isGone(), ScriptApiEntity::luaentity_on_death(), 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().
|
virtual |
Reimplemented from ServerActiveObject.
References UnitSAO::isAttached(), ServerActiveObject::m_base_position, and sendPosition().
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().
void LuaEntitySAO::setTextureMod | ( | const std::string & | mod | ) |
References m_texture_modifier, and m_texture_modifier_sent.
Referenced by ObjectRef::l_set_texture_mod().
void LuaEntitySAO::setVelocity | ( | v3f | velocity | ) |
References m_velocity.
Referenced by ObjectRef::l_set_velocity().
|
inlinevirtual |
Reimplemented from ServerActiveObject.
|
virtual |
Reimplemented from ServerActiveObject.
References ObjectProperties::automatic_face_movement_dir, ObjectProperties::automatic_face_movement_dir_offset, ObjectProperties::automatic_face_movement_max_rotation_per_sec, ObjectProperties::automatic_rotate, BS, ActiveObject::clearParentAttachment(), ObjectProperties::collideWithObjects, ObjectProperties::collisionbox, collisionMoveSimple(), generateSetTextureModCommand(), ServerEnvironment::getGameDef(), ActiveObject::getId(), UnitSAO::getParent(), getPropertyPacket(), ServerEnvironment::getScriptIface(), UnitSAO::isAttached(), ScriptApiEntity::luaentity_Step(), m_acceleration, UnitSAO::m_attachment_parent_id, ServerActiveObject::m_base_position, ServerActiveObject::m_env, ActiveObject::m_id, m_init_name, 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_prop, UnitSAO::m_properties_sent, m_registered, UnitSAO::m_rotation, UnitSAO::m_rotation_add_yaw, m_texture_modifier_sent, m_velocity, modulo360f(), ObjectProperties::physical, UnitSAO::sendOutdatedData(), sendPosition(), ObjectProperties::stepheight, warningstream, wrapDegrees_0_360(), and wrappedApproachShortest().
|
private |
Referenced by getAcceleration(), sendPosition(), setAcceleration(), and step().
|
private |
Referenced by LuaEntitySAO(), addedToEnvironment(), getClientInitializationData(), getDescription(), getName(), getStaticData(), and step().
|
private |
Referenced by LuaEntitySAO(), addedToEnvironment(), and getStaticData().
|
private |
Referenced by sendPosition(), and step().
|
private |
Referenced by sendPosition(), and step().
|
private |
Referenced by sendPosition(), and step().
|
private |
Referenced by sendPosition(), and step().
|
private |
Referenced by sendPosition(), and step().
|
private |
Referenced by ~LuaEntitySAO(), addedToEnvironment(), dispatchScriptDeactivate(), getStaticData(), punch(), rightClick(), setHP(), and step().
|
private |
Referenced by generateSetTextureModCommand(), getTextureMod(), and setTextureMod().
|
private |
Referenced by setTextureMod(), and step().
|
private |
Referenced by LuaEntitySAO(), addVelocity(), getStaticData(), getVelocity(), sendPosition(), setVelocity(), and step().