feat(Core/Maps): Improve map object updater (#22392)

This commit is contained in:
Takenbacon
2025-07-11 07:00:16 -07:00
committed by GitHub
parent 9d6c7ad7ea
commit 1c3cbd3d9e
16 changed files with 285 additions and 181 deletions

View File

@@ -405,14 +405,58 @@ class MovableMapObject
protected:
MovableMapObject() = default;
private:
[[nodiscard]] Cell const& GetCurrentCell() const { return _currentCell; }
private:
void SetCurrentCell(Cell const& cell) { _currentCell = cell; }
Cell _currentCell;
MapObjectCellMoveState _moveState{MAP_OBJECT_CELL_MOVE_NONE};
};
class UpdatableMapObject
{
friend class Map;
public:
enum UpdateState : uint8
{
NotUpdating,
PendingAdd,
Updating
};
protected:
UpdatableMapObject() : _mapUpdateListOffset(0), _mapUpdateState(NotUpdating) { }
private:
void SetMapUpdateListOffset(std::size_t const offset)
{
ASSERT(_mapUpdateState == Updating, "Attempted to set update list offset when object is not in map update list");
_mapUpdateListOffset = offset;
}
size_t GetMapUpdateListOffset() const
{
ASSERT(_mapUpdateState == Updating, "Attempted to get update list offset when object is not in map update list");
return _mapUpdateListOffset;
}
void SetUpdateState(UpdateState state)
{
_mapUpdateState = state;
}
UpdateState GetUpdateState() const
{
return _mapUpdateState;
}
private:
std::size_t _mapUpdateListOffset;
UpdateState _mapUpdateState;
};
class WorldObject : public Object, public WorldLocation
{
protected:
@@ -639,6 +683,9 @@ public:
[[nodiscard]] GuidUnorderedSet const& GetAllowedLooters() const;
void RemoveAllowedLooter(ObjectGuid guid);
virtual bool IsUpdateNeeded();
bool CanBeAddedToMapUpdateList();
std::string GetDebugInfo() const override;
// Event handler