TrinityCore
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 "Containers.h"
20
22{
23 if (!std::holds_alternative<SmoothPhasingInfoViewerDependent>(_storage))
25
26 std::get<SmoothPhasingInfoViewerDependent>(_storage)[seer] = info;
27}
28
30{
31 if (std::holds_alternative<SmoothPhasingInfoViewerDependent>(_storage))
32 std::get<SmoothPhasingInfoViewerDependent>(_storage).erase(seer);
33}
34
36{
37 _storage.emplace<SmoothPhasingInfoSingle>() = info;
38}
39
41{
42 return std::holds_alternative<SmoothPhasingInfoSingle>(_storage) && std::get<SmoothPhasingInfoSingle>(_storage).ReplaceObject == guid;
43}
44
46{
47 if (std::holds_alternative<SmoothPhasingInfoViewerDependent>(_storage))
48 if (SmoothPhasingInfo const* smoothPhasingInfo = Trinity::Containers::MapGetValuePtr(std::get<SmoothPhasingInfoViewerDependent>(_storage), seer))
49 return !smoothPhasingInfo->Disabled;
50
51 return false;
52}
53
55{
56 if (std::holds_alternative<SmoothPhasingInfoViewerDependent>(_storage))
57 return Trinity::Containers::MapGetValuePtr(std::get<SmoothPhasingInfoViewerDependent>(_storage), seer);
58
59 return &std::get<SmoothPhasingInfoSingle>(_storage);
60}
61
63{
64 if (std::holds_alternative<SmoothPhasingInfoViewerDependent>(_storage))
65 if (SmoothPhasingInfo* smoothPhasingInfo = Trinity::Containers::MapGetValuePtr(std::get<SmoothPhasingInfoViewerDependent>(_storage), seer))
66 smoothPhasingInfo->Disabled = true;
67}
void SetSingleInfo(SmoothPhasingInfo const &info)
SmoothPhasingInfo const * GetInfoForSeer(ObjectGuid seer) const
bool IsBeingReplacedForSeer(ObjectGuid seer) const
std::variant< SmoothPhasingInfoSingle, SmoothPhasingInfoViewerDependent > _storage
Definition: SmoothPhasing.h:55
void SetViewerDependentInfo(ObjectGuid seer, SmoothPhasingInfo const &info)
bool IsReplacing(ObjectGuid guid) const
std::unordered_map< ObjectGuid, SmoothPhasingInfo > SmoothPhasingInfoViewerDependent
Definition: SmoothPhasing.h:52
void ClearViewerDependentInfo(ObjectGuid seer)
void DisableReplacementForSeer(ObjectGuid seer)
auto MapGetValuePtr(M &map, typename M::key_type const &key)
Definition: MapUtils.h:29