TrinityCore
Loading...
Searching...
No Matches
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
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(UF::UpdateFieldFlag flags, ByteBuffer& data, Player const* target) const override;
44 void BuildValuesUpdate(UF::UpdateFieldFlag flags, ByteBuffer& data, Player const* target) const override;
45 void ClearValuesChangesMask() override;
46
47 public:
48 void BuildValuesUpdateForPlayerWithMask(UpdateData* data, UF::ObjectData::Mask const& requestedObjectMask,
49 UF::DynamicObjectData::Mask const& requestedDynamicObjectMask, Player const* target, bool ignoreNestedChangesMask) const;
50
51 struct ValuesUpdateForPlayerWithMaskSender // sender compatible with MessageDistDeliverer
52 {
53 explicit ValuesUpdateForPlayerWithMaskSender(DynamicObject const* owner) : Owner(owner), IgnoreNestedChangesMask(false) { }
54
59
60 void operator()(Player const* player) const;
61 };
62
63 void AddToWorld() override;
64 void RemoveFromWorld() override;
65
66 bool CreateDynamicObject(ObjectGuid::LowType guidlow, Unit* caster, SpellInfo const* spell, Position const& pos, float radius, DynamicObjectType type, SpellCastVisual spellVisual);
67 void Update(uint32 p_time) override;
68 void Remove();
69 void SetDuration(int32 newDuration);
70 int32 GetDuration() const;
71 void Delay(int32 delaytime);
72 void SetAura(Aura* aura);
73 void RemoveAura();
74 void SetCasterViewpoint();
75 void RemoveCasterViewpoint();
76 Unit* GetCaster() const { return _caster; }
77 uint32 GetFaction() const override;
78 void BindToCaster();
79 void UnbindFromCaster();
80 uint32 GetSpellId() const { return m_dynamicObjectData->SpellID; }
81 SpellInfo const* GetSpellInfo() const;
82 ObjectGuid GetCasterGUID() const { return m_dynamicObjectData->Caster; }
83 ObjectGuid GetCreatorGUID() const override { return GetCasterGUID(); }
84 ObjectGuid GetOwnerGUID() const override { return GetCasterGUID(); }
85 float GetRadius() const { return m_dynamicObjectData->Radius; }
86
88
89 protected:
93 int32 _duration; // for non-aura dynobjects
95};
96#endif
#define TC_GAME_API
Definition Define.h:129
int32_t int32
Definition Define.h:150
uint32_t uint32
Definition Define.h:154
uint16 flags
DynamicObjectType
@ DYNAMIC_OBJECT_PORTAL
@ DYNAMIC_OBJECT_FARSIGHT_FOCUS
@ DYNAMIC_OBJECT_AREA_SPELL
@ TYPEID_DYNAMICOBJECT
Definition ObjectGuid.h:47
UF::UpdateField< UF::DynamicObjectData, int32(WowCS::EntityFragment::CGObject), TYPEID_DYNAMICOBJECT > m_dynamicObjectData
Unit * GetCaster() const
ObjectGuid GetOwnerGUID() const override
uint32 GetSpellId() const
ObjectGuid GetCreatorGUID() const override
ObjectGuid GetCasterGUID() const
Aura * _removedAura
float GetRadius() const
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
Definition Unit.h:635
void AddToWorld() override
Definition Object.cpp:365
void RemoveFromWorld() override
Definition Object.cpp:371
virtual uint32 GetFaction() const =0
virtual void Update(uint32 diff)
Definition Object.cpp:245
UpdateFieldFlag
Definition UpdateField.h:37
ValuesUpdateForPlayerWithMaskSender(DynamicObject const *owner)