#include <serveractiveobject.h>
Public Types | |
using | Observers = std::optional<std::unordered_set<std::string>> |
Public Types inherited from ActiveObject | |
typedef u16 | object_t |
Public Member Functions | |
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 u16 | getHP () const |
virtual void | setArmorGroups (const ItemGroupList &armor_groups) |
virtual const ItemGroupList & | getArmorGroups () const |
virtual void | setAnimation (v2f frames, float frame_speed, float frame_blend, bool frame_loop) |
virtual void | getAnimation (v2f *frames, float *frame_speed, float *frame_blend, bool *frame_loop) |
virtual void | setAnimationSpeed (float frame_speed) |
virtual void | setBoneOverride (const std::string &bone, const BoneOverride &props) |
virtual BoneOverride | getBoneOverride (const std::string &bone) |
virtual const BoneOverrideMap & | getBoneOverrides () const |
virtual const std::unordered_set< object_t > & | getAttachmentChildIds () const |
virtual ServerActiveObject * | getParent () const |
virtual ObjectProperties * | accessObjectProperties () |
virtual void | notifyObjectPropertiesModified () |
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 | setAttachment (object_t parent_id, const std::string &bone, v3f position, v3f rotation, bool force_visible) |
virtual void | getAttachment (object_t *parent_id, std::string *bone, v3f *position, v3f *rotation, bool *force_visible) const |
virtual void | clearChildAttachments () |
virtual void | clearParentAttachment () |
virtual void | addAttachmentChild (object_t child_id) |
virtual void | removeAttachmentChild (object_t child_id) |
Public Attributes | |
u16 | m_known_by_count = 0 |
bool | m_static_exists = false |
v3s16 | m_static_block = v3s16(1337,1337,1337) |
Observers | m_observers |
Protected Member Functions | |
virtual void | onMarkedForDeactivation () |
virtual void | onMarkedForRemoval () |
Protected Attributes | |
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 |
using ServerActiveObject::Observers = std::optional<std::unordered_set<std::string>> |
ServerActiveObject::ServerActiveObject | ( | ServerEnvironment * | env, |
v3f | pos ) |
|
virtualdefault |
|
inlinevirtual |
Reimplemented in UnitSAO.
Referenced by ObjectRef::l_get_nametag_attributes(), ObjectRef::l_get_properties(), ObjectRef::l_set_nametag_attributes(), and ObjectRef::l_set_properties().
|
inlinevirtual |
Reimplemented in LuaEntitySAO, and PlayerSAO.
Referenced by LuaEntitySAO::addedToEnvironment(), and PlayerSAO::addedToEnvironment().
|
inlinevirtual |
Reimplemented in PlayerSAO.
References m_base_position, and setBasePosition().
Referenced by ObjectRef::l_add_pos().
|
inline |
References m_attached_particle_spawners.
|
inline |
References m_attached_particle_spawners.
Referenced by ServerEnvironment::deleteParticleSpawner().
void ServerActiveObject::dumpAOMessagesToQueue | ( | std::queue< ActiveObjectMessage > & | queue | ) |
References m_messages_out.
std::string ServerActiveObject::generateUpdateInfantCommand | ( | u16 | infant_id, |
u16 | protocol_version ) |
References AO_CMD_SPAWN_INFANT, getClientInitializationData(), getSendType(), serializeString32(), writeU16(), and writeU8().
|
inlinevirtual |
Reimplemented in UnitSAO.
Referenced by ObjectRef::l_get_animation().
|
inlinevirtual |
Reimplemented in UnitSAO.
Referenced by ObjectRef::l_get_armor_groups().
|
inlinevirtual |
Reimplemented in UnitSAO.
Referenced by ObjectRef::l_get_children().
|
inline |
References m_base_position.
Referenced by PlayerSAO::addPos(), ICraftAction::apply(), IDropAction::apply(), ServerEnvironment::deactivateFarObjects(), ServerEnvironment::getAddedActiveObjects(), server::ActiveObjectMgr::getAddedActiveObjectsAroundPos(), RemoteClient::GetNextBlocks(), server::ActiveObjectMgr::getObjectsInArea(), server::ActiveObjectMgr::getObjectsInsideRadius(), ServerPlayingSound::getPos(), ServerEnvironment::getRemovedActiveObjects(), Server::handleCommand_Damage(), Server::handleCommand_Interact(), ObjectRef::l_get_pos(), ObjectRef::l_punch(), PlayerSAO::moveTo(), Server::playSound(), PlayerDatabaseLevelDB::savePlayer(), PlayerDatabaseSQLite3::savePlayer(), Server::SendAddParticleSpawner(), Server::sendMetadataChanged(), Server::SendMovePlayer(), Server::sendNodeChangePkt(), Server::SendSpawnParticle(), PlayerDatabaseFiles::serialize(), and PlayerSAO::setPos().
|
inlinevirtual |
Reimplemented in UnitSAO.
Referenced by ObjectRef::l_get_bone_override(), and ObjectRef::l_get_bone_position().
|
inlinevirtual |
Reimplemented in UnitSAO.
Referenced by ObjectRef::l_get_bone_overrides().
|
inlinevirtual |
Reimplemented in LuaEntitySAO, and PlayerSAO.
Referenced by generateUpdateInfantCommand(), and Server::SendActiveObjectRemoveAdd().
|
inlinevirtual |
Reimplemented in LuaEntitySAO, and PlayerSAO.
Referenced by ICraftAction::apply(), Server::handleCommand_Interact(), LuaEntitySAO::punch(), and PlayerSAO::punch().
const Observers & ServerActiveObject::getEffectiveObservers | ( | ) |
Cache m_effective_observers
with the names of all observers, also indirect observers (object attachment chain).
References getParent(), m_effective_observers, and m_observers.
Referenced by isEffectivelyObservedBy(), and recalculateEffectiveObservers().
|
inline |
References m_env.
|
inlinevirtual |
Reimplemented in LuaEntitySAO, and UnitSAO.
Referenced by ObjectRef::l_get_hp(), LuaEntitySAO::punch(), PlayerSAO::punch(), and read_object_properties().
|
inlinevirtual |
Reimplemented in PlayerSAO.
|
virtual |
Reimplemented in PlayerSAO.
Referenced by ObjectRef::l_get_inventory().
|
virtual |
Reimplemented in LuaEntitySAO.
References BS.
Referenced by ServerEnvironment::deactivateFarObjects().
|
inlinevirtual |
Reimplemented in UnitSAO.
Referenced by Server::AsyncRunStep(), getAttachedObject(), and getEffectiveObservers().
|
inlinevirtual |
Reimplemented in LuaEntitySAO, and PlayerSAO.
References ActiveObject::getType().
Referenced by generateUpdateInfantCommand(), and Server::SendActiveObjectRemoveAdd().
|
inlinevirtual |
Reimplemented in LuaEntitySAO, and PlayerSAO.
References isStaticAllowed().
Referenced by StaticObject::StaticObject().
|
virtual |
Reimplemented in PlayerSAO.
Referenced by ObjectRef::l_get_wielded_item(), and LuaEntitySAO::punch().
|
inlinevirtual |
Reimplemented in PlayerSAO.
Referenced by ObjectRef::l_get_wield_index().
|
inlinevirtual |
Reimplemented in PlayerSAO.
Referenced by ObjectRef::l_get_wield_list().
void ServerActiveObject::invalidateEffectiveObservers | ( | ) |
Invalidate final observer cache.
This needs to be done whenever the observers of this object or any of its ancestors may have changed.
References m_effective_observers.
Referenced by server::ActiveObjectMgr::invalidateActiveObjectObserverCaches().
bool ServerActiveObject::isEffectivelyObservedBy | ( | const std::string & | player_name | ) |
Whether the object is sent to player_name
References getEffectiveObservers().
Referenced by ServerEnvironment::getAddedActiveObjects(), server::ActiveObjectMgr::getAddedActiveObjectsAroundPos(), and ServerEnvironment::getRemovedActiveObjects().
|
inline |
References m_pending_deactivation, and m_pending_removal.
Referenced by ServerEnvironment::deactivateFarObjects(), LuaEntitySAO::dispatchScriptDeactivate(), server::ActiveObjectMgr::getAddedActiveObjectsAroundPos(), ObjectRef::getobject(), ServerEnvironment::getRemovedActiveObjects(), Server::handleCommand_Interact(), ModApiEnv::l_get_connected_players(), ModApiEnv::l_get_player_by_name(), ScriptApiBase::objectrefGetOrCreate(), UnitSAO::onAttach(), UnitSAO::onDetach(), ServerEnvironment::processActiveObjectRemove(), ServerEnvironment::removeRemovedObjects(), UnitSAO::setAttachment(), and LuaEntitySAO::setHP().
|
inline |
References m_pending_removal.
Referenced by ServerEnvironment::removeRemovedObjects().
|
inlinevirtual |
Reimplemented in LuaEntitySAO, and PlayerSAO.
Referenced by StaticObject::StaticObject(), ServerEnvironment::deactivateFarObjects(), and getStaticData().
void ServerActiveObject::markForDeactivation | ( | ) |
References m_pending_deactivation, and onMarkedForDeactivation().
Referenced by ServerEnvironment::deactivateFarObjects().
void ServerActiveObject::markForRemoval | ( | ) |
References m_pending_removal, and onMarkedForRemoval().
Referenced by ServerEnvironment::clearObjects(), PlayerSAO::disconnected(), ObjectRef::l_remove(), LuaEntitySAO::punch(), and LuaEntitySAO::setHP().
|
inlinevirtual |
Reimplemented in LuaEntitySAO, and PlayerSAO.
References setBasePosition().
Referenced by ObjectRef::l_move_to().
|
inlinevirtual |
Reimplemented in UnitSAO.
Referenced by ObjectRef::l_set_nametag_attributes(), and ObjectRef::l_set_properties().
|
inlineprotectedvirtual |
Reimplemented in LuaEntitySAO, and UnitSAO.
Referenced by markForDeactivation(), and UnitSAO::onMarkedForDeactivation().
|
inlineprotectedvirtual |
Reimplemented in LuaEntitySAO, and UnitSAO.
Referenced by markForRemoval(), and UnitSAO::onMarkedForRemoval().
|
inlinevirtual |
Reimplemented in LuaEntitySAO, and PlayerSAO.
Referenced by Server::handleCommand_Interact(), and ObjectRef::l_punch().
const Observers & ServerActiveObject::recalculateEffectiveObservers | ( | ) |
Force a recalculation of final observers (including all parents).
References getEffectiveObservers().
|
inlinevirtual |
Reimplemented in PlayerSAO.
Referenced by ServerEnvironment::processActiveObjectRemove(), and PlayerSAO::removingFromEnvironment().
|
inlinevirtual |
Reimplemented in LuaEntitySAO, and PlayerSAO.
Referenced by Server::handleCommand_Interact(), and ObjectRef::l_right_click().
|
inlinevirtual |
Reimplemented in UnitSAO.
Referenced by ObjectRef::l_set_animation().
|
inlinevirtual |
Reimplemented in UnitSAO.
Referenced by ObjectRef::l_set_animation_frame_speed().
|
inlinevirtual |
Reimplemented in UnitSAO.
Referenced by ObjectRef::l_set_armor_groups().
|
inline |
References m_base_position.
Referenced by PlayerSAO::addedToEnvironment(), addPos(), moveTo(), PlayerSAO::setBasePosition(), and setPos().
|
inlinevirtual |
Reimplemented in UnitSAO.
Referenced by ObjectRef::l_set_bone_override(), and ObjectRef::l_set_bone_position().
|
inlinevirtual |
Reimplemented in LuaEntitySAO, and PlayerSAO.
Referenced by ObjectRef::l_set_hp(), and read_object_properties().
|
inlinevirtual |
Reimplemented in PlayerSAO.
|
inlinevirtual |
Reimplemented in LuaEntitySAO, and PlayerSAO.
References setBasePosition().
Referenced by ObjectRef::l_set_pos().
|
virtual |
Reimplemented in PlayerSAO.
Referenced by ObjectRef::l_set_wielded_item().
|
inlinevirtual |
Reimplemented in LuaEntitySAO, and PlayerSAO.
Referenced by ServerEnvironment::deactivateFarObjects().
|
inlinevirtual |
Reimplemented in LuaEntitySAO, and PlayerSAO.
|
protected |
|
protected |
Referenced by PlayerSAO::addedToEnvironment(), addPos(), PlayerSAO::checkMovementCheat(), getBasePosition(), LuaEntitySAO::getClientInitializationData(), PlayerSAO::getClientInitializationData(), LuaEntitySAO::getCollisionBox(), PlayerSAO::getCollisionBox(), LuaEntitySAO::getDescription(), PlayerSAO::getEyePosition(), LuaEntitySAO::moveTo(), LuaEntitySAO::sendPosition(), PlayerSAO::setBasePosition(), setBasePosition(), LuaEntitySAO::setPos(), LuaEntitySAO::step(), and PlayerSAO::step().
|
protected |
Referenced by getEffectiveObservers(), and invalidateEffectiveObservers().
|
protected |
Referenced by LuaEntitySAO::~LuaEntitySAO(), LuaEntitySAO::addedToEnvironment(), PlayerSAO::addPos(), PlayerSAO::checkMovementCheat(), UnitSAO::clearChildAttachments(), LuaEntitySAO::dispatchScriptDeactivate(), LuaEntitySAO::getClientInitializationData(), PlayerSAO::getClientInitializationData(), getEnv(), UnitSAO::getParent(), LuaEntitySAO::getStaticData(), PlayerSAO::moveTo(), UnitSAO::onAttach(), UnitSAO::onDetach(), LuaEntitySAO::punch(), PlayerSAO::punch(), PlayerSAO::removingFromEnvironment(), PlayerSAO::respawn(), LuaEntitySAO::rightClick(), PlayerSAO::rightClick(), LuaEntitySAO::sendPosition(), UnitSAO::setAttachment(), PlayerSAO::setBasePosition(), PlayerSAO::setBreath(), LuaEntitySAO::setHP(), PlayerSAO::setHP(), PlayerSAO::setLookPitchAndSend(), PlayerSAO::setPlayerYawAndSend(), PlayerSAO::setPos(), LuaEntitySAO::step(), PlayerSAO::step(), and PlayerSAO::unlinkPlayerSessionAndSave().
u16 ServerActiveObject::m_known_by_count = 0 |
|
protected |
Observers ServerActiveObject::m_observers |
Referenced by getEffectiveObservers(), and ObjectRef::l_set_observers().
|
protected |
Referenced by isGone(), and markForDeactivation().
|
protected |
Referenced by isGone(), isPendingRemoval(), and markForRemoval().
bool ServerActiveObject::m_static_exists = false |