Core/Scenes: Defined more flags and implemented FadeToBlackscreenOnCancel (#26975)
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the
|
||||
* Free Software Foundation; either version 2 of the License, or (at your
|
||||
* option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef SceneDefines_h__
|
||||
#define SceneDefines_h__
|
||||
|
||||
#include "Define.h"
|
||||
#include "EnumFlag.h"
|
||||
|
||||
enum class SceneFlag : uint32
|
||||
{
|
||||
None = 0x00,
|
||||
PlayerNonInteractablePhased = 0x01, // Sets UNIT_FLAG_IMMUNE_TO_PC + UNIT_FLAG_IMMUNE_TO_NPC + UNIT_FLAG_PACIFIED
|
||||
FadeToBlackscreenOnComplete = 0x02,
|
||||
NotCancelable = 0x04,
|
||||
FadeToBlackscreenOnCancel = 0x08,
|
||||
|
||||
IgnoreTransport = 0x20
|
||||
};
|
||||
|
||||
DEFINE_ENUM_FLAG(SceneFlag);
|
||||
|
||||
#endif // SceneDefines_h__
|
||||
@@ -55,11 +55,11 @@ uint32 SceneMgr::PlaySceneByTemplate(SceneTemplate const* sceneTemplate, Positio
|
||||
uint32 sceneInstanceID = GetNewStandaloneSceneInstanceID();
|
||||
|
||||
if (_isDebuggingScenes)
|
||||
ChatHandler(GetPlayer()->GetSession()).PSendSysMessage(LANG_COMMAND_SCENE_DEBUG_PLAY, sceneInstanceID, sceneTemplate->ScenePackageId, sceneTemplate->PlaybackFlags);
|
||||
ChatHandler(GetPlayer()->GetSession()).PSendSysMessage(LANG_COMMAND_SCENE_DEBUG_PLAY, sceneInstanceID, sceneTemplate->ScenePackageId, sceneTemplate->PlaybackFlags.AsUnderlyingType());
|
||||
|
||||
WorldPackets::Scenes::PlayScene playScene;
|
||||
playScene.SceneID = sceneTemplate->SceneId;
|
||||
playScene.PlaybackFlags = sceneTemplate->PlaybackFlags;
|
||||
playScene.PlaybackFlags = sceneTemplate->PlaybackFlags.AsUnderlyingType();
|
||||
playScene.SceneInstanceID = sceneInstanceID;
|
||||
playScene.SceneScriptPackageID = sceneTemplate->ScenePackageId;
|
||||
playScene.Location = *position;
|
||||
@@ -79,7 +79,7 @@ uint32 SceneMgr::PlaySceneByTemplate(SceneTemplate const* sceneTemplate, Positio
|
||||
return sceneInstanceID;
|
||||
}
|
||||
|
||||
uint32 SceneMgr::PlaySceneByPackageId(uint32 sceneScriptPackageId, uint32 playbackflags /*= SCENEFLAG_UNK16*/, Position const* position /*= nullptr*/)
|
||||
uint32 SceneMgr::PlaySceneByPackageId(uint32 sceneScriptPackageId, EnumFlag<SceneFlag> playbackflags /*= SCENEFLAG_UNK16*/, Position const* position /*= nullptr*/)
|
||||
{
|
||||
SceneTemplate sceneTemplate;
|
||||
sceneTemplate.SceneId = 0;
|
||||
@@ -122,6 +122,8 @@ void SceneMgr::OnSceneCancel(uint32 sceneInstanceID)
|
||||
ChatHandler(GetPlayer()->GetSession()).PSendSysMessage(LANG_COMMAND_SCENE_DEBUG_CANCEL, sceneInstanceID);
|
||||
|
||||
SceneTemplate const* sceneTemplate = GetSceneTemplateFromInstanceId(sceneInstanceID);
|
||||
if (sceneTemplate->PlaybackFlags.HasFlag(SceneFlag::NotCancelable))
|
||||
return;
|
||||
|
||||
// Must be done before removing aura
|
||||
RemoveSceneInstanceId(sceneInstanceID);
|
||||
@@ -131,7 +133,7 @@ void SceneMgr::OnSceneCancel(uint32 sceneInstanceID)
|
||||
|
||||
sScriptMgr->OnSceneCancel(GetPlayer(), sceneInstanceID, sceneTemplate);
|
||||
|
||||
if (sceneTemplate->PlaybackFlags & SCENEFLAG_CANCEL_AT_END)
|
||||
if (sceneTemplate->PlaybackFlags.HasFlag(SceneFlag::FadeToBlackscreenOnCancel))
|
||||
CancelScene(sceneInstanceID, false);
|
||||
}
|
||||
|
||||
@@ -153,7 +155,7 @@ void SceneMgr::OnSceneComplete(uint32 sceneInstanceID)
|
||||
|
||||
sScriptMgr->OnSceneComplete(GetPlayer(), sceneInstanceID, sceneTemplate);
|
||||
|
||||
if (sceneTemplate->PlaybackFlags & SCENEFLAG_CANCEL_AT_END)
|
||||
if (sceneTemplate->PlaybackFlags.HasFlag(SceneFlag::FadeToBlackscreenOnComplete))
|
||||
CancelScene(sceneInstanceID, false);
|
||||
}
|
||||
|
||||
|
||||
@@ -19,19 +19,10 @@
|
||||
#define SceneMgr_h__
|
||||
|
||||
#include "Common.h"
|
||||
#include "SceneDefines.h"
|
||||
#include <map>
|
||||
#include <vector>
|
||||
|
||||
enum SceneFlags
|
||||
{
|
||||
SCENEFLAG_UNK1 = 0x01,
|
||||
SCENEFLAG_CANCEL_AT_END = 0x02,
|
||||
SCENEFLAG_NOT_CANCELABLE = 0x04,
|
||||
SCENEFLAG_UNK8 = 0x08,
|
||||
SCENEFLAG_UNK16 = 0x10, // 16, most common value
|
||||
SCENEFLAG_UNK32 = 0x20,
|
||||
};
|
||||
|
||||
class Player;
|
||||
class WorldPacket;
|
||||
struct Position;
|
||||
@@ -52,14 +43,14 @@ public:
|
||||
|
||||
uint32 PlayScene(uint32 sceneId, Position const* position = nullptr);
|
||||
uint32 PlaySceneByTemplate(SceneTemplate const* sceneTemplate, Position const* position = nullptr);
|
||||
uint32 PlaySceneByPackageId(uint32 sceneScriptPackageId, uint32 playbackflags = SCENEFLAG_UNK16, Position const* position = nullptr);
|
||||
uint32 PlaySceneByPackageId(uint32 sceneScriptPackageId, EnumFlag<SceneFlag> playbackflags, Position const* position = nullptr);
|
||||
void CancelScene(uint32 sceneInstanceID, bool removeFromMap = true);
|
||||
|
||||
void OnSceneTrigger(uint32 sceneInstanceID, std::string const& triggerName);
|
||||
void OnSceneCancel(uint32 sceneInstanceID);
|
||||
void OnSceneComplete(uint32 sceneInstanceID);
|
||||
|
||||
void RecreateScene(uint32 sceneScriptPackageId, uint32 playbackflags = SCENEFLAG_UNK16, Position const* position = nullptr)
|
||||
void RecreateScene(uint32 sceneScriptPackageId, EnumFlag<SceneFlag> playbackflags, Position const* position = nullptr)
|
||||
{
|
||||
CancelSceneByPackageId(sceneScriptPackageId);
|
||||
PlaySceneByPackageId(sceneScriptPackageId, playbackflags, position);
|
||||
|
||||
@@ -10492,7 +10492,7 @@ void ObjectMgr::LoadSceneTemplates()
|
||||
uint32 sceneId = fields[0].GetUInt32();
|
||||
SceneTemplate& sceneTemplate = _sceneTemplateStore[sceneId];
|
||||
sceneTemplate.SceneId = sceneId;
|
||||
sceneTemplate.PlaybackFlags = fields[1].GetUInt32();
|
||||
sceneTemplate.PlaybackFlags = static_cast<SceneFlag>(fields[1].GetUInt32());
|
||||
sceneTemplate.ScenePackageId = fields[2].GetUInt32();
|
||||
sceneTemplate.Encrypted = fields[3].GetUInt8() != 0;
|
||||
sceneTemplate.ScriptId = sObjectMgr->GetScriptId(fields[4].GetCString());
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
#include "Position.h"
|
||||
#include "QuestDef.h"
|
||||
#include "RaceMask.h"
|
||||
#include "SceneDefines.h"
|
||||
#include "SharedDefines.h"
|
||||
#include "Trainer.h"
|
||||
#include "VehicleDefines.h"
|
||||
@@ -796,7 +797,7 @@ typedef std::unordered_map<uint32, std::string> RealmNameContainer;
|
||||
struct SceneTemplate
|
||||
{
|
||||
uint32 SceneId = 0;
|
||||
uint32 PlaybackFlags = 0;
|
||||
EnumFlag<SceneFlag> PlaybackFlags = SceneFlag::None;
|
||||
uint32 ScenePackageId = 0;
|
||||
bool Encrypted = false;
|
||||
uint32 ScriptId = 0;
|
||||
|
||||
@@ -5767,7 +5767,7 @@ void Spell::EffectPlaySceneScriptPackage()
|
||||
if (m_caster->GetTypeId() != TYPEID_PLAYER)
|
||||
return;
|
||||
|
||||
m_caster->ToPlayer()->GetSceneMgr().PlaySceneByPackageId(effectInfo->MiscValue, SCENEFLAG_UNK1, destTarget);
|
||||
m_caster->ToPlayer()->GetSceneMgr().PlaySceneByPackageId(effectInfo->MiscValue, SceneFlag::PlayerNonInteractablePhased, destTarget);
|
||||
}
|
||||
|
||||
void Spell::EffectPlayScene()
|
||||
|
||||
@@ -95,7 +95,7 @@ public:
|
||||
return false;
|
||||
|
||||
uint32 scenePackageId = atoi(scenePackageIdStr);
|
||||
uint32 flags = flagsStr ? atoi(flagsStr) : SCENEFLAG_UNK16;
|
||||
EnumFlag<SceneFlag> flags = flagsStr ? static_cast<SceneFlag>(atoi(flagsStr)) : SceneFlag::None;
|
||||
Player* target = handler->getSelectedPlayerOrSelf();
|
||||
|
||||
if (!target)
|
||||
|
||||
Reference in New Issue
Block a user