TrinityCore
Loading...
Searching...
No Matches
Conversation.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_CONVERSATION_H
19#define TRINITYCORE_CONVERSATION_H
20
21#include "Object.h"
22#include "GridObject.h"
23
24class ConversationAI;
25class Unit;
26class SpellInfo;
27enum class ConversationActorType : uint32;
28
29class TC_GAME_API Conversation final : public WorldObject, public GridObject<Conversation>
30{
31 public:
34
35 protected:
36 void BuildValuesCreate(UF::UpdateFieldFlag flags, ByteBuffer& data, Player const* target) const override;
37 void BuildValuesUpdate(UF::UpdateFieldFlag flags, ByteBuffer& data, Player const* target) const override;
38 void ClearValuesChangesMask() override;
39
40 public:
41 void BuildValuesUpdateForPlayerWithMask(UpdateData* data, UF::ObjectData::Mask const& requestedObjectMask,
42 UF::ConversationData::Mask const& requestedConversationMask, Player const* target, bool ignoreNestedChangesMask) const;
43
44 struct ValuesUpdateForPlayerWithMaskSender // sender compatible with MessageDistDeliverer
45 {
46 explicit ValuesUpdateForPlayerWithMaskSender(Conversation const* owner) : Owner(owner), IgnoreNestedChangesMask(false) { }
47
52
53 void operator()(Player const* player) const;
54 };
55
56 void AddToWorld() override;
57 void RemoveFromWorld() override;
58
59 void Update(uint32 diff) override;
60 void Remove();
61 Milliseconds GetDuration() const { return _duration; }
62 uint32 GetTextureKitId() const { return _textureKitId; }
63
64 static Conversation* CreateConversation(uint32 conversationEntry, Unit* creator, Position const& pos, ObjectGuid privateObjectOwner, SpellInfo const* spellInfo = nullptr, bool autoStart = true);
65 void Create(ObjectGuid::LowType lowGuid, uint32 conversationEntry, Map* map, Unit* creator, Position const& pos, ObjectGuid privateObjectOwner, SpellInfo const* spellInfo = nullptr);
66 bool Start();
67 void AddActor(int32 actorId, uint32 actorIdx, ObjectGuid const& actorGuid);
68 void AddActor(int32 actorId, uint32 actorIdx, ConversationActorType type, uint32 creatureId, uint32 creatureDisplayInfoId);
69
70 ObjectGuid GetCreatorGUID() const override { return _creatorGuid; }
71 ObjectGuid GetOwnerGUID() const override { return GetCreatorGUID(); }
72 uint32 GetFaction() const override { return 0; }
73
74 Position const& GetStationaryPosition() const override { return _stationaryPosition; }
75 void RelocateStationaryPosition(Position const& pos) { _stationaryPosition.Relocate(pos); }
76
77 Milliseconds const* GetLineStartTime(LocaleConstant locale, int32 lineId) const;
78 Milliseconds GetLastLineEndTime(LocaleConstant locale) const;
79 static int32 GetLineDuration(LocaleConstant locale, int32 lineId);
80 Milliseconds GetLineEndTime(LocaleConstant locale, int32 lineId) const;
81
82 LocaleConstant GetPrivateObjectOwnerLocale() const;
83 Unit* GetActorUnit(uint32 actorIdx) const;
84 Creature* GetActorCreature(uint32 actorIdx) const;
85
86 void AI_Initialize();
87 void AI_Destroy();
88
89 ConversationAI* AI() { return _ai.get(); }
90 uint32 GetScriptId() const;
91
93
94 private:
99
100 std::unordered_map<int32 /*lineId*/, std::array<Milliseconds, TOTAL_LOCALES> /*startTime*/> _lineStartTimes;
102
103 std::unique_ptr<ConversationAI> _ai;
104};
105
106#endif // TRINITYCORE_CONVERSATION_H
LocaleConstant
Definition Common.h:51
@ TOTAL_LOCALES
Definition Common.h:65
ConversationActorType
#define TC_GAME_API
Definition Define.h:129
int32_t int32
Definition Define.h:150
uint32_t uint32
Definition Define.h:154
uint16 flags
std::chrono::milliseconds Milliseconds
Milliseconds shorthand typedef.
Definition Duration.h:24
@ TYPEID_CONVERSATION
Definition ObjectGuid.h:51
void RelocateStationaryPosition(Position const &pos)
ObjectGuid GetCreatorGUID() const override
std::unique_ptr< ConversationAI > _ai
std::array< Milliseconds, TOTAL_LOCALES > _lastLineEndTimes
ConversationAI * AI()
uint32 GetFaction() const override
Milliseconds _duration
Milliseconds GetDuration() const
uint32 _textureKitId
ObjectGuid _creatorGuid
std::unordered_map< int32, std::array< Milliseconds, TOTAL_LOCALES > > _lineStartTimes
UF::UpdateField< UF::ConversationData, int32(WowCS::EntityFragment::CGObject), TYPEID_CONVERSATION > m_conversationData
Position _stationaryPosition
Position const & GetStationaryPosition() const override
uint32 GetTextureKitId() const
ObjectGuid GetOwnerGUID() const override
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
Definition Unit.h:635
void AddToWorld() override
Definition Object.cpp:365
virtual ObjectGuid GetCreatorGUID() const =0
void RemoveFromWorld() override
Definition Object.cpp:371
virtual void Update(uint32 diff)
Definition Object.cpp:245
UpdateFieldFlag
Definition UpdateField.h:37
ValuesUpdateForPlayerWithMaskSender(Conversation const *owner)