TrinityCore
Loading...
Searching...
No Matches
Scenario.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 Scenario_h__
19#define Scenario_h__
20
21#include "CriteriaHandler.h"
22#include <unordered_set>
23
24class Map;
25struct ScenarioData;
26struct ScenarioEntry;
28
29namespace WorldPackets
30{
31 namespace Achievement
32 {
33 struct CriteriaProgress;
34 }
35
36 namespace Scenario
37 {
38 struct BonusObjectiveData;
39 class ScenarioState;
40 }
41}
42
44{
49};
50
52{
53 public:
54 Scenario(Map* map, ScenarioData const* scenarioData);
55 ~Scenario();
56
57 void Reset() override;
58 void SetStep(ScenarioStepEntry const* step);
59
60 virtual void CompleteStep(ScenarioStepEntry const* step);
61 virtual void CompleteScenario();
62
63 virtual void OnPlayerEnter(Player* player);
64 virtual void OnPlayerExit(Player* player);
65 virtual void Update(uint32 /*diff*/) { }
66
67 bool IsComplete();
68 bool IsCompletedStep(ScenarioStepEntry const* step);
69 void SetStepState(ScenarioStepEntry const* step, ScenarioStepState state) { _stepStates[step] = state; }
70 ScenarioEntry const* GetEntry() const;
71 ScenarioStepState GetStepState(ScenarioStepEntry const* step);
72 ScenarioStepEntry const* GetStep() const { return _currentstep; }
73 ScenarioStepEntry const* GetFirstStep() const;
74 ScenarioStepEntry const* GetLastStep() const;
75
76 void SendScenarioState(Player* player);
77 void SendBootPlayer(Player* player);
78
79 protected:
80 Map const* _map;
82
83 void SendCriteriaUpdate(Criteria const* criteria, CriteriaProgress const* progress, Seconds timeElapsed, bool timedCompleted) const override;
84 void SendCriteriaProgressRemoved(uint32 /*criteriaId*/) override { }
85
86 bool CanUpdateCriteriaTree(Criteria const* criteria, CriteriaTree const* tree, Player* referencePlayer) const override;
87 bool CanCompleteCriteriaTree(CriteriaTree const* tree) override;
88 void CompletedCriteriaTree(CriteriaTree const* tree, Player* referencePlayer) override;
89 void AfterCriteriaTreeUpdate(CriteriaTree const* /*tree*/, Player* /*referencePlayer*/) override { }
90
91 void SendPacket(WorldPacket const* data) const override;
92
93 void SendAllData(Player const* /*receiver*/) const override { }
94
95 void BuildScenarioState(WorldPackets::Scenario::ScenarioState* scenarioState);
96
97 std::vector<WorldPackets::Scenario::BonusObjectiveData> GetBonusObjectivesData();
98 std::vector<WorldPackets::Achievement::CriteriaProgress> GetCriteriasProgress();
99
100 CriteriaList const& GetCriteriaByType(CriteriaType type, uint32 asset) const override;
102
103 private:
106 std::map<ScenarioStepEntry const*, ScenarioStepState> _stepStates;
107};
108
109#endif // Scenario_h__
T GetEntry(std::unordered_map< uint32, T > const &map, CriteriaTreeEntry const *tree)
std::vector< Criteria const * > CriteriaList
CriteriaType
Definition: DBCEnums.h:449
#define TC_GAME_API
Definition: Define.h:124
uint32_t uint32
Definition: Define.h:143
std::chrono::seconds Seconds
Seconds shorthand typedef.
Definition: Duration.h:32
std::unordered_set< ObjectGuid > GuidUnorderedSet
Definition: ObjectGuid.h:394
ScenarioStepState
Definition: Scenario.h:44
@ SCENARIO_STEP_IN_PROGRESS
Definition: Scenario.h:47
@ SCENARIO_STEP_INVALID
Definition: Scenario.h:45
@ SCENARIO_STEP_DONE
Definition: Scenario.h:48
@ SCENARIO_STEP_NOT_STARTED
Definition: Scenario.h:46
Achievement
virtual CriteriaList const & GetCriteriaByType(CriteriaType type, uint32 asset) const =0
virtual void Reset()
virtual bool CanUpdateCriteriaTree(Criteria const *criteria, CriteriaTree const *tree, Player *referencePlayer) const
virtual void SendPacket(WorldPacket const *data) const =0
virtual void CompletedCriteriaTree(CriteriaTree const *tree, Player *referencePlayer)=0
virtual bool CanCompleteCriteriaTree(CriteriaTree const *tree)
virtual void SendCriteriaUpdate(Criteria const *criteria, CriteriaProgress const *progress, Seconds timeElapsed, bool timedCompleted) const =0
Definition: Map.h:187
virtual void Update(uint32)
Definition: Scenario.h:65
void SendCriteriaProgressRemoved(uint32) override
Definition: Scenario.h:84
ScenarioData const * _data
Definition: Scenario.h:101
Map const * _map
Definition: Scenario.h:80
std::map< ScenarioStepEntry const *, ScenarioStepState > _stepStates
Definition: Scenario.h:106
void AfterCriteriaTreeUpdate(CriteriaTree const *, Player *) override
Definition: Scenario.h:89
ObjectGuid const _guid
Definition: Scenario.h:104
GuidUnorderedSet _players
Definition: Scenario.h:81
ScenarioStepEntry const * _currentstep
Definition: Scenario.h:105
void SetStepState(ScenarioStepEntry const *step, ScenarioStepState state)
Definition: Scenario.h:69
ScenarioStepEntry const * GetStep() const
Definition: Scenario.h:72
void SendAllData(Player const *) const override
Definition: Scenario.h:93