TrinityCore
DynamicObject.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 TRINITYCORE_DYNAMICOBJECT_H
19#define TRINITYCORE_DYNAMICOBJECT_H
20
21#include "Object.h"
22#include "GridObject.h"
23#include "MapObject.h"
24
25class Unit;
26class Aura;
27class SpellInfo;
28
30{
31 DYNAMIC_OBJECT_PORTAL = 0x0, // unused
34};
35
36class TC_GAME_API DynamicObject final : public WorldObject, public GridObject<DynamicObject>, public MapObject
37{
38 public:
39 DynamicObject(bool isWorldObject);
41
42 protected:
43 void BuildValuesCreate(ByteBuffer* data, Player const* target) const override;
44 void BuildValuesUpdate(ByteBuffer* data, Player const* target) const override;
45 void ClearUpdateMask(bool remove) override;
46
47 public:
48 void BuildValuesUpdateForPlayerWithMask(UpdateData* data, UF::ObjectData::Mask const& requestedObjectMask,
49 UF::DynamicObjectData::Mask const& requestedDynamicObjectMask, Player const* target) const;
50
51 struct ValuesUpdateForPlayerWithMaskSender // sender compatible with MessageDistDeliverer
52 {
53 explicit ValuesUpdateForPlayerWithMaskSender(DynamicObject const* owner) : Owner(owner) { }
54
58
59 void operator()(Player const* player) const;
60 };
61
62 void AddToWorld() override;
63 void RemoveFromWorld() override;
64
65 bool CreateDynamicObject(ObjectGuid::LowType guidlow, Unit* caster, SpellInfo const* spell, Position const& pos, float radius, DynamicObjectType type, SpellCastVisual spellVisual);
66 void Update(uint32 p_time) override;
67 void Remove();
68 void SetDuration(int32 newDuration);
69 int32 GetDuration() const;
70 void Delay(int32 delaytime);
71 void SetAura(Aura* aura);
72 void RemoveAura();
73 void SetCasterViewpoint();
74 void RemoveCasterViewpoint();
75 Unit* GetCaster() const { return _caster; }
76 uint32 GetFaction() const override;
77 void BindToCaster();
78 void UnbindFromCaster();
79 uint32 GetSpellId() const { return m_dynamicObjectData->SpellID; }
80 SpellInfo const* GetSpellInfo() const;
81 ObjectGuid GetCasterGUID() const { return m_dynamicObjectData->Caster; }
82 ObjectGuid GetCreatorGUID() const override { return GetCasterGUID(); }
83 ObjectGuid GetOwnerGUID() const override { return GetCasterGUID(); }
84 float GetRadius() const { return m_dynamicObjectData->Radius; }
85
87
88 protected:
92 int32 _duration; // for non-aura dynobjects
94};
95#endif
#define TC_GAME_API
Definition: Define.h:123
int32_t int32
Definition: Define.h:138
uint32_t uint32
Definition: Define.h:142
DynamicObjectType
Definition: DynamicObject.h:30
@ DYNAMIC_OBJECT_PORTAL
Definition: DynamicObject.h:31
@ DYNAMIC_OBJECT_FARSIGHT_FOCUS
Definition: DynamicObject.h:33
@ DYNAMIC_OBJECT_AREA_SPELL
Definition: DynamicObject.h:32
Unit * GetCaster() const
Definition: DynamicObject.h:75
ObjectGuid GetOwnerGUID() const override
Definition: DynamicObject.h:83
uint32 GetSpellId() const
Definition: DynamicObject.h:79
ObjectGuid GetCreatorGUID() const override
Definition: DynamicObject.h:82
ObjectGuid GetCasterGUID() const
Definition: DynamicObject.h:81
Aura * _removedAura
Definition: DynamicObject.h:90
UF::UpdateField< UF::DynamicObjectData, 0, TYPEID_DYNAMICOBJECT > m_dynamicObjectData
Definition: DynamicObject.h:86
float GetRadius() const
Definition: DynamicObject.h:84
uint64 LowType
Definition: ObjectGuid.h:278
virtual void BuildValuesCreate(ByteBuffer *data, Player const *target) const =0
virtual void ClearUpdateMask(bool remove)
Definition: Object.cpp:790
virtual void BuildValuesUpdate(ByteBuffer *data, Player const *target) const =0
Definition: Unit.h:627
void AddToWorld() override
Definition: Object.cpp:1011
void RemoveFromWorld() override
Definition: Object.cpp:1017
virtual uint32 GetFaction() const =0
virtual void Update(uint32 diff)
Definition: Object.cpp:898
Definition: wmo.h:163
void Remove(VignetteData &vignette, WorldObject const *owner)
Definition: Vignette.cpp:100
ValuesUpdateForPlayerWithMaskSender(DynamicObject const *owner)
Definition: DynamicObject.h:53