Luanti 5.15.0-dev
 
Loading...
Searching...
No Matches
ServerActiveObject Class Referenceabstract

#include <serveractiveobject.h>

+ Inheritance diagram for ServerActiveObject:
+ Collaboration diagram for ServerActiveObject:

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)
 
ServerEnvironmentgetEnv ()
 
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, 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 std::string getGUID () const =0
 Returns an unique ID for this object (persistent across unload, server restarts).
 
virtual void setArmorGroups (const ItemGroupList &armor_groups)
 
virtual const ItemGroupListgetArmorGroups () 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 BoneOverrideMapgetBoneOverrides () const
 
virtual const std::unordered_set< object_t > & getAttachmentChildIds () const
 
virtual ServerActiveObjectgetParent () const
 
virtual ObjectPropertiesaccessObjectProperties ()
 
virtual void notifyObjectPropertiesModified ()
 
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 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< 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
 

Private Attributes

v3f m_base_position
 

Member Typedef Documentation

◆ Observers

using ServerActiveObject::Observers = std::optional<std::unordered_set<std::string>>

Constructor & Destructor Documentation

◆ ServerActiveObject()

ServerActiveObject::ServerActiveObject ( ServerEnvironment * env,
v3f pos )

◆ ~ServerActiveObject()

virtual ServerActiveObject::~ServerActiveObject ( )
virtualdefault

Member Function Documentation

◆ accessObjectProperties()

virtual ObjectProperties * ServerActiveObject::accessObjectProperties ( )
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().

+ Here is the caller graph for this function:

◆ addedToEnvironment()

virtual void ServerActiveObject::addedToEnvironment ( u32 dtime_s)
inlinevirtual

Reimplemented in LuaEntitySAO, and PlayerSAO.

Referenced by LuaEntitySAO::addedToEnvironment(), and PlayerSAO::addedToEnvironment().

+ Here is the caller graph for this function:

◆ addPos()

virtual void ServerActiveObject::addPos ( const v3f & added_pos)
inlinevirtual

Reimplemented in PlayerSAO.

References m_base_position, and setBasePosition().

Referenced by ObjectRef::l_add_pos(), and LuaEntitySAO::step().

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

◆ attachParticleSpawner()

void ServerActiveObject::attachParticleSpawner ( u32 id)
inline

◆ detachParticleSpawner()

void ServerActiveObject::detachParticleSpawner ( u32 id)
inline

References m_attached_particle_spawners.

Referenced by ServerEnvironment::deleteParticleSpawner().

+ Here is the caller graph for this function:

◆ dumpAOMessagesToQueue()

void ServerActiveObject::dumpAOMessagesToQueue ( std::queue< ActiveObjectMessage > & queue)

References m_messages_out.

◆ generateUpdateInfantCommand()

std::string ServerActiveObject::generateUpdateInfantCommand ( u16 infant_id,
u16 protocol_version )

References AO_CMD_SPAWN_INFANT, getClientInitializationData(), getSendType(), serializeString32(), writeU16(), and writeU8().

+ Here is the call graph for this function:

◆ getAnimation()

virtual void ServerActiveObject::getAnimation ( v2f * frames,
float * frame_speed,
float * frame_blend,
bool * frame_loop )
inlinevirtual

Reimplemented in UnitSAO.

Referenced by ObjectRef::l_get_animation().

+ Here is the caller graph for this function:

◆ getArmorGroups()

virtual const ItemGroupList & ServerActiveObject::getArmorGroups ( ) const
inlinevirtual

Reimplemented in UnitSAO.

Referenced by ObjectRef::l_get_armor_groups().

+ Here is the caller graph for this function:

◆ getAttachmentChildIds()

virtual const std::unordered_set< object_t > & ServerActiveObject::getAttachmentChildIds ( ) const
inlinevirtual

Reimplemented in UnitSAO.

Referenced by ObjectRef::l_get_children().

+ Here is the caller graph for this function:

◆ getBasePosition()

◆ getBoneOverride()

virtual BoneOverride ServerActiveObject::getBoneOverride ( const std::string & bone)
inlinevirtual

Reimplemented in UnitSAO.

Referenced by ObjectRef::l_get_bone_override(), and ObjectRef::l_get_bone_position().

+ Here is the caller graph for this function:

◆ getBoneOverrides()

virtual const BoneOverrideMap & ServerActiveObject::getBoneOverrides ( ) const
inlinevirtual

Reimplemented in UnitSAO.

Referenced by ObjectRef::l_get_bone_overrides().

+ Here is the caller graph for this function:

◆ getClientInitializationData()

virtual std::string ServerActiveObject::getClientInitializationData ( u16 protocol_version)
inlinevirtual

Reimplemented in LuaEntitySAO, and PlayerSAO.

Referenced by generateUpdateInfantCommand(), and Server::SendActiveObjectRemoveAdd().

+ Here is the caller graph for this function:

◆ getDescription()

virtual std::string ServerActiveObject::getDescription ( )
inlinevirtual

Reimplemented in LuaEntitySAO, and PlayerSAO.

Referenced by ICraftAction::apply(), Server::handleCommand_Interact(), LuaEntitySAO::punch(), and PlayerSAO::punch().

+ Here is the caller graph for this function:

◆ getEffectiveObservers()

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().

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

◆ getEnv()

ServerEnvironment * ServerActiveObject::getEnv ( )
inline

References m_env.

Referenced by setBasePosition().

+ Here is the caller graph for this function:

◆ getGUID()

virtual std::string ServerActiveObject::getGUID ( ) const
pure 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.

Implemented in LuaEntitySAO, MockServerActiveObject, and PlayerSAO.

Referenced by ScriptApiBase::addObjectReference(), ObjectRef::l_get_guid(), and ScriptApiBase::removeObjectReference().

+ Here is the caller graph for this function:

◆ getHP()

virtual u16 ServerActiveObject::getHP ( ) const
inlinevirtual

Reimplemented in LuaEntitySAO, and UnitSAO.

Referenced by ObjectRef::l_get_hp(), LuaEntitySAO::punch(), PlayerSAO::punch(), and read_object_properties().

+ Here is the caller graph for this function:

◆ getInventory()

virtual Inventory * ServerActiveObject::getInventory ( ) const
inlinevirtual

Reimplemented in PlayerSAO.

◆ getInventoryLocation()

InventoryLocation ServerActiveObject::getInventoryLocation ( ) const
virtual

Reimplemented in PlayerSAO.

Referenced by ObjectRef::l_get_inventory().

+ Here is the caller graph for this function:

◆ getMinimumSavedMovement()

float ServerActiveObject::getMinimumSavedMovement ( )
virtual

Reimplemented in LuaEntitySAO.

References BS.

Referenced by ServerEnvironment::deactivateFarObjects().

+ Here is the caller graph for this function:

◆ getParent()

virtual ServerActiveObject * ServerActiveObject::getParent ( ) const
inlinevirtual

Reimplemented in UnitSAO.

Referenced by Server::AsyncRunStep(), getAttachedObject(), and getEffectiveObservers().

+ Here is the caller graph for this function:

◆ getSendType()

virtual ActiveObjectType ServerActiveObject::getSendType ( ) const
inlinevirtual

Reimplemented in LuaEntitySAO, and PlayerSAO.

References ActiveObject::getType().

Referenced by generateUpdateInfantCommand(), and Server::SendActiveObjectRemoveAdd().

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

◆ getStaticData()

virtual void ServerActiveObject::getStaticData ( std::string * result) const
inlinevirtual

Reimplemented in LuaEntitySAO, and PlayerSAO.

References isStaticAllowed().

Referenced by StaticObject::StaticObject().

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

◆ getWieldedItem()

ItemStack ServerActiveObject::getWieldedItem ( ItemStack * selected,
ItemStack * hand = nullptr ) const
virtual

Reimplemented in PlayerSAO.

Referenced by ObjectRef::l_get_wielded_item(), and LuaEntitySAO::punch().

+ Here is the caller graph for this function:

◆ getWieldIndex()

virtual u16 ServerActiveObject::getWieldIndex ( ) const
inlinevirtual

Reimplemented in PlayerSAO.

Referenced by ObjectRef::l_get_wield_index().

+ Here is the caller graph for this function:

◆ getWieldList()

virtual std::string ServerActiveObject::getWieldList ( ) const
inlinevirtual

Reimplemented in PlayerSAO.

Referenced by ObjectRef::l_get_wield_list().

+ Here is the caller graph for this function:

◆ invalidateEffectiveObservers()

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().

+ Here is the caller graph for this function:

◆ isEffectivelyObservedBy()

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().

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

◆ isGone()

◆ isPendingRemoval()

bool ServerActiveObject::isPendingRemoval ( ) const
inline

References m_pending_removal.

Referenced by ServerEnvironment::removeRemovedObjects().

+ Here is the caller graph for this function:

◆ isStaticAllowed()

virtual bool ServerActiveObject::isStaticAllowed ( ) const
inlinevirtual

Reimplemented in LuaEntitySAO, and PlayerSAO.

Referenced by StaticObject::StaticObject(), ServerEnvironment::deactivateFarObjects(), and getStaticData().

+ Here is the caller graph for this function:

◆ markForDeactivation()

void ServerActiveObject::markForDeactivation ( )

References m_pending_deactivation, and onMarkedForDeactivation().

Referenced by ServerEnvironment::deactivateFarObjects().

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

◆ markForRemoval()

void ServerActiveObject::markForRemoval ( )

References m_pending_removal, and onMarkedForRemoval().

Referenced by ServerEnvironment::clearObjects(), PlayerSAO::disconnected(), ObjectRef::l_remove(), LuaEntitySAO::punch(), and LuaEntitySAO::setHP().

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

◆ moveTo()

virtual void ServerActiveObject::moveTo ( v3f pos,
bool continuous )
inlinevirtual

Reimplemented in LuaEntitySAO, and PlayerSAO.

References setBasePosition().

Referenced by ObjectRef::l_move_to().

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

◆ notifyObjectPropertiesModified()

virtual void ServerActiveObject::notifyObjectPropertiesModified ( )
inlinevirtual

Reimplemented in UnitSAO.

Referenced by ObjectRef::l_set_nametag_attributes(), and ObjectRef::l_set_properties().

+ Here is the caller graph for this function:

◆ onMarkedForDeactivation()

virtual void ServerActiveObject::onMarkedForDeactivation ( )
inlineprotectedvirtual

Reimplemented in LuaEntitySAO, and UnitSAO.

Referenced by markForDeactivation(), and UnitSAO::onMarkedForDeactivation().

+ Here is the caller graph for this function:

◆ onMarkedForRemoval()

virtual void ServerActiveObject::onMarkedForRemoval ( )
inlineprotectedvirtual

Reimplemented in LuaEntitySAO, and UnitSAO.

Referenced by markForRemoval(), and UnitSAO::onMarkedForRemoval().

+ Here is the caller graph for this function:

◆ punch()

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

Reimplemented in LuaEntitySAO, and PlayerSAO.

Referenced by Server::handleCommand_Interact(), and ObjectRef::l_punch().

+ Here is the caller graph for this function:

◆ recalculateEffectiveObservers()

const Observers & ServerActiveObject::recalculateEffectiveObservers ( )

Force a recalculation of final observers (including all parents).

References getEffectiveObservers().

+ Here is the call graph for this function:

◆ removingFromEnvironment()

virtual void ServerActiveObject::removingFromEnvironment ( )
inlinevirtual

Reimplemented in PlayerSAO.

Referenced by ServerEnvironment::processActiveObjectRemove(), and PlayerSAO::removingFromEnvironment().

+ Here is the caller graph for this function:

◆ rightClick()

virtual void ServerActiveObject::rightClick ( ServerActiveObject * clicker)
inlinevirtual

Reimplemented in LuaEntitySAO, and PlayerSAO.

Referenced by Server::handleCommand_Interact(), and ObjectRef::l_right_click().

+ Here is the caller graph for this function:

◆ setAnimation()

virtual void ServerActiveObject::setAnimation ( v2f frames,
float frame_speed,
float frame_blend,
bool frame_loop )
inlinevirtual

Reimplemented in UnitSAO.

Referenced by ObjectRef::l_set_animation().

+ Here is the caller graph for this function:

◆ setAnimationSpeed()

virtual void ServerActiveObject::setAnimationSpeed ( float frame_speed)
inlinevirtual

Reimplemented in UnitSAO.

Referenced by ObjectRef::l_set_animation_frame_speed().

+ Here is the caller graph for this function:

◆ setArmorGroups()

virtual void ServerActiveObject::setArmorGroups ( const ItemGroupList & armor_groups)
inlinevirtual

Reimplemented in UnitSAO.

Referenced by ObjectRef::l_set_armor_groups().

+ Here is the caller graph for this function:

◆ setBasePosition()

void ServerActiveObject::setBasePosition ( v3f pos)

References getEnv(), ActiveObject::getId(), m_base_position, and ServerEnvironment::updateObjectPos().

Referenced by addPos(), LuaEntitySAO::moveTo(), moveTo(), PlayerSAO::setBasePosition(), LuaEntitySAO::setPos(), setPos(), and LuaEntitySAO::step().

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

◆ setBoneOverride()

virtual void ServerActiveObject::setBoneOverride ( const std::string & bone,
const BoneOverride & props )
inlinevirtual

Reimplemented in UnitSAO.

Referenced by ObjectRef::l_set_bone_override(), and ObjectRef::l_set_bone_position().

+ Here is the caller graph for this function:

◆ setHP()

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

Reimplemented in LuaEntitySAO, and PlayerSAO.

Referenced by ObjectRef::l_set_hp(), and read_object_properties().

+ Here is the caller graph for this function:

◆ setInventoryModified()

virtual void ServerActiveObject::setInventoryModified ( )
inlinevirtual

Reimplemented in PlayerSAO.

◆ setPos()

virtual void ServerActiveObject::setPos ( const v3f & pos)
inlinevirtual

Reimplemented in LuaEntitySAO, and PlayerSAO.

References setBasePosition().

Referenced by ObjectRef::l_set_pos().

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

◆ setWieldedItem()

bool ServerActiveObject::setWieldedItem ( const ItemStack & item)
virtual

Reimplemented in PlayerSAO.

Referenced by ObjectRef::l_set_wielded_item().

+ Here is the caller graph for this function:

◆ shouldUnload()

virtual bool ServerActiveObject::shouldUnload ( ) const
inlinevirtual

Reimplemented in LuaEntitySAO, and PlayerSAO.

Referenced by ServerEnvironment::deactivateFarObjects().

+ Here is the caller graph for this function:

◆ step()

virtual void ServerActiveObject::step ( float dtime,
bool send_recommended )
inlinevirtual

Reimplemented in LuaEntitySAO, and PlayerSAO.

Member Data Documentation

◆ m_attached_particle_spawners

std::unordered_set<u32> ServerActiveObject::m_attached_particle_spawners
protected

◆ m_base_position

v3f ServerActiveObject::m_base_position
private

◆ m_effective_observers

std::optional<Observers> ServerActiveObject::m_effective_observers
protected

◆ m_env

◆ m_known_by_count

◆ m_messages_out

◆ m_observers

Observers ServerActiveObject::m_observers

◆ m_pending_deactivation

bool ServerActiveObject::m_pending_deactivation = false
protected

Referenced by isGone(), and markForDeactivation().

◆ m_pending_removal

bool ServerActiveObject::m_pending_removal = false
protected

◆ m_static_block

◆ m_static_exists


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