TrinityCore
Loading...
Searching...
No Matches
SceneObject.h
Go to the documentation of this file.
1/*
2 * This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your
7 * option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#ifndef SceneObject_h__
19#define SceneObject_h__
20
21#include "Object.h"
22#include "GridObject.h"
23
24struct SceneTemplate;
25
26enum class SceneType : uint32
27{
28 Normal = 0,
29 PetBattle = 1
30};
31
32class TC_GAME_API SceneObject final : public WorldObject, public GridObject<SceneObject>
33{
34public:
37
38protected:
39 void BuildValuesCreate(UF::UpdateFieldFlag flags, ByteBuffer& data, Player const* target) const override;
40 void BuildValuesUpdate(UF::UpdateFieldFlag flags, ByteBuffer& data, Player const* target) const override;
41 void ClearValuesChangesMask() override;
42
43public:
44 void BuildValuesUpdateForPlayerWithMask(UpdateData* data, UF::ObjectData::Mask const& requestedObjectMask,
45 UF::SceneObjectData::Mask const& requestedSceneObjectMask, Player const* target, bool ignoreNestedChangesMask) const;
46
47 struct ValuesUpdateForPlayerWithMaskSender // sender compatible with MessageDistDeliverer
48 {
49 explicit ValuesUpdateForPlayerWithMaskSender(SceneObject const* owner) : Owner(owner), IgnoreNestedChangesMask(false) { }
50
55
56 void operator()(Player const* player) const;
57 };
58
59 void AddToWorld() override;
60 void RemoveFromWorld() override;
61
62 void Update(uint32 diff) override;
63 void Remove();
64
65 static SceneObject* CreateSceneObject(uint32 sceneId, Unit* creator, Position const& pos, ObjectGuid privateObjectOwner);
66 bool Create(ObjectGuid::LowType lowGuid, SceneType type, uint32 sceneId, uint32 scriptPackageId, Map* map, Unit* creator,
67 Position const& pos, ObjectGuid privateObjectOwner);
68
69 ObjectGuid GetCreatorGUID() const override { return *m_sceneObjectData->CreatedBy; }
70 ObjectGuid GetOwnerGUID() const override { return *m_sceneObjectData->CreatedBy; }
71 uint32 GetFaction() const override { return 0; }
72
73 Position const& GetStationaryPosition() const override { return _stationaryPosition; }
74 void RelocateStationaryPosition(Position const& pos) { _stationaryPosition.Relocate(pos); }
75
76 void SetCreatedBySpellCast(ObjectGuid castId) { _createdBySpellCast = castId; }
77
79
80private:
81 bool ShouldBeRemoved() const;
82
85};
86
87#endif // SceneObject_h__
#define TC_GAME_API
Definition Define.h:129
int32_t int32
Definition Define.h:150
uint32_t uint32
Definition Define.h:154
uint16 flags
@ TYPEID_SCENEOBJECT
Definition ObjectGuid.h:50
SceneType
Definition SceneObject.h:27
Definition Map.h:225
uint64 LowType
Definition ObjectGuid.h:321
virtual void BuildValuesCreate(UF::UpdateFieldFlag flags, ByteBuffer &data, Player const *target) const =0
virtual void BuildValuesUpdate(UF::UpdateFieldFlag flags, ByteBuffer &data, Player const *target) const =0
virtual void ClearValuesChangesMask()
Definition Object.cpp:130
uint32 GetFaction() const override
Definition SceneObject.h:71
Position _stationaryPosition
Definition SceneObject.h:83
void RelocateStationaryPosition(Position const &pos)
Definition SceneObject.h:74
ObjectGuid GetOwnerGUID() const override
Definition SceneObject.h:70
ObjectGuid _createdBySpellCast
Definition SceneObject.h:84
UF::UpdateField< UF::SceneObjectData, int32(WowCS::EntityFragment::CGObject), TYPEID_SCENEOBJECT > m_sceneObjectData
Definition SceneObject.h:78
ObjectGuid GetCreatorGUID() const override
Definition SceneObject.h:69
Position const & GetStationaryPosition() const override
Definition SceneObject.h:73
void SetCreatedBySpellCast(ObjectGuid castId)
Definition SceneObject.h:76
Definition Unit.h:635
void AddToWorld() override
Definition Object.cpp:365
void RemoveFromWorld() override
Definition Object.cpp:371
virtual void Update(uint32 diff)
Definition Object.cpp:245
UpdateFieldFlag
Definition UpdateField.h:37
ValuesUpdateForPlayerWithMaskSender(SceneObject const *owner)
Definition SceneObject.h:49