TrinityCore
Loading...
Searching...
No Matches
SmoothPhasing.cpp
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#include "SmoothPhasing.h"
19#include "MapUtils.h"
20
24SmoothPhasing& SmoothPhasing::operator=(SmoothPhasing const&) = default;
25SmoothPhasing& SmoothPhasing::operator=(SmoothPhasing&&) noexcept = default;
26SmoothPhasing::~SmoothPhasing() = default;
27
28void SmoothPhasing::SetViewerDependentInfo(ObjectGuid seer, SmoothPhasingInfo const& info)
29{
30 if (!std::holds_alternative<SmoothPhasingInfoViewerDependent>(_storage))
31 _storage.emplace<SmoothPhasingInfoViewerDependent>();
32
33 std::get<SmoothPhasingInfoViewerDependent>(_storage)[seer] = info;
34}
35
37{
38 if (std::holds_alternative<SmoothPhasingInfoViewerDependent>(_storage))
39 std::get<SmoothPhasingInfoViewerDependent>(_storage).erase(seer);
40}
41
46
48{
49 return std::holds_alternative<SmoothPhasingInfoSingle>(_storage) && std::get<SmoothPhasingInfoSingle>(_storage).ReplaceObject == guid;
50}
51
53{
54 if (std::holds_alternative<SmoothPhasingInfoViewerDependent>(_storage))
55 if (SmoothPhasingInfo const* smoothPhasingInfo = Trinity::Containers::MapGetValuePtr(std::get<SmoothPhasingInfoViewerDependent>(_storage), seer))
56 return !smoothPhasingInfo->Disabled;
57
58 return false;
59}
60
62{
63 if (std::holds_alternative<SmoothPhasingInfoViewerDependent>(_storage))
64 return Trinity::Containers::MapGetValuePtr(std::get<SmoothPhasingInfoViewerDependent>(_storage), seer);
65
66 return &std::get<SmoothPhasingInfoSingle>(_storage);
67}
68
70{
71 if (std::holds_alternative<SmoothPhasingInfoViewerDependent>(_storage))
72 if (SmoothPhasingInfo* smoothPhasingInfo = Trinity::Containers::MapGetValuePtr(std::get<SmoothPhasingInfoViewerDependent>(_storage), seer))
73 smoothPhasingInfo->Disabled = true;
74}
void SetSingleInfo(SmoothPhasingInfo const &info)
SmoothPhasingInfo const * GetInfoForSeer(ObjectGuid seer) const
bool IsBeingReplacedForSeer(ObjectGuid seer) const
std::variant< SmoothPhasingInfoSingle, SmoothPhasingInfoViewerDependent > _storage
bool IsReplacing(ObjectGuid guid) const
std::unordered_map< ObjectGuid, SmoothPhasingInfo > SmoothPhasingInfoViewerDependent
void ClearViewerDependentInfo(ObjectGuid seer)
void DisableReplacementForSeer(ObjectGuid seer)
auto MapGetValuePtr(M &map, typename M::key_type const &key)
Definition MapUtils.h:37
Optional< ObjectGuid > ReplaceObject