TrinityCore
SceneMgr.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 SceneMgr_h__
19#define SceneMgr_h__
20
21#include "Common.h"
22#include "SceneDefines.h"
23#include <map>
24#include <memory>
25#include <vector>
26
27class Player;
28class WorldPacket;
29struct Position;
30struct SceneTemplate;
31
32using SceneTemplateByInstance = std::map<uint32, std::unique_ptr<SceneTemplate>>;
33
35{
36public:
37 SceneMgr(Player* player);
39
40 SceneMgr(SceneMgr const&) = delete;
41 SceneMgr(SceneMgr&&) = delete;
42
43 Player* GetPlayer() const { return _player; }
44
45 uint32 PlayScene(uint32 sceneId, Position const* position = nullptr);
46 uint32 PlaySceneByTemplate(SceneTemplate const* sceneTemplate, Position const* position = nullptr);
47 uint32 PlaySceneByPackageId(uint32 sceneScriptPackageId, EnumFlag<SceneFlag> playbackflags, Position const* position = nullptr);
48 void CancelScene(uint32 sceneInstanceID, bool removeFromMap = true);
49
50 void OnSceneTrigger(uint32 sceneInstanceID, std::string const& triggerName);
51 void OnSceneCancel(uint32 sceneInstanceID);
52 void OnSceneComplete(uint32 sceneInstanceID);
53
54 void RecreateScene(uint32 sceneScriptPackageId, EnumFlag<SceneFlag> playbackflags, Position const* position = nullptr)
55 {
56 CancelSceneByPackageId(sceneScriptPackageId);
57 PlaySceneByPackageId(sceneScriptPackageId, playbackflags, position);
58 }
59
60 bool HasScene(uint32 sceneInstanceID, uint32 sceneScriptPackageId = 0) const;
61
62 void AddInstanceIdToSceneMap(uint32 sceneInstanceID, SceneTemplate const* sceneTemplate);
63 void CancelSceneBySceneId(uint32 sceneId);
64 void CancelSceneByPackageId(uint32 sceneScriptPackageId);
65 void RemoveSceneInstanceId(uint32 sceneInstanceID);
66 void RemoveAurasDueToSceneId(uint32 sceneId);
67
68 SceneTemplate const* GetSceneTemplateFromInstanceId(uint32 sceneInstanceID) const;
69 uint32 GetActiveSceneCount(uint32 sceneScriptPackageId = 0) const;
70 SceneTemplateByInstance const& GetSceneTemplateByInstanceMap() const { return _scenesByInstance; }
71
72 uint32 GetNewStandaloneSceneInstanceID() { return ++_standaloneSceneInstanceID; }
73
74 void TriggerDelayedScenes();
75
76 void ToggleDebugSceneMode() { _isDebuggingScenes = !_isDebuggingScenes; }
77 bool IsInDebugSceneMode() const { return _isDebuggingScenes; }
78
79private:
83 std::vector<WorldPacket> _delayedScenes;
85};
86
87#endif // SceneMgr_h__
#define TC_GAME_API
Definition: Define.h:123
uint32_t uint32
Definition: Define.h:142
std::map< uint32, std::unique_ptr< SceneTemplate > > SceneTemplateByInstance
Definition: SceneMgr.h:32
void ToggleDebugSceneMode()
Definition: SceneMgr.h:76
SceneMgr(SceneMgr &&)=delete
Player * _player
Definition: SceneMgr.h:80
uint32 GetNewStandaloneSceneInstanceID()
Definition: SceneMgr.h:72
std::vector< WorldPacket > _delayedScenes
Definition: SceneMgr.h:83
uint32 _standaloneSceneInstanceID
Definition: SceneMgr.h:82
SceneMgr(SceneMgr const &)=delete
SceneTemplateByInstance const & GetSceneTemplateByInstanceMap() const
Definition: SceneMgr.h:70
void RecreateScene(uint32 sceneScriptPackageId, EnumFlag< SceneFlag > playbackflags, Position const *position=nullptr)
Definition: SceneMgr.h:54
bool IsInDebugSceneMode() const
Definition: SceneMgr.h:77
SceneTemplateByInstance _scenesByInstance
Definition: SceneMgr.h:81
Player * GetPlayer() const
Definition: SceneMgr.h:43
bool _isDebuggingScenes
Definition: SceneMgr.h:84