Integrating up through commit 90f050496
This commit is contained in:
@@ -0,0 +1,93 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "ILevelSystem.h"
|
||||
#include <AzCore/Console/IConsole.h>
|
||||
#include <AzFramework/Archive/IArchive.h>
|
||||
#include <AzFramework/Spawnable/RootSpawnableInterface.h>
|
||||
|
||||
namespace LegacyLevelSystem
|
||||
{
|
||||
|
||||
class SpawnableLevelSystem
|
||||
: public ILevelSystem
|
||||
, public AzFramework::RootSpawnableNotificationBus::Handler
|
||||
{
|
||||
public:
|
||||
explicit SpawnableLevelSystem(ISystem* pSystem);
|
||||
~SpawnableLevelSystem() override;
|
||||
|
||||
// ILevelSystem
|
||||
void Release() override;
|
||||
|
||||
void AddListener(ILevelSystemListener* pListener) override;
|
||||
void RemoveListener(ILevelSystemListener* pListener) override;
|
||||
|
||||
bool LoadLevel(const char* levelName) override;
|
||||
void UnloadLevel() override;
|
||||
bool IsLevelLoaded() override;
|
||||
const char* GetCurrentLevelName() const override;
|
||||
|
||||
// If the level load failed then we need to have a different shutdown procedure vs when a level is naturally unloaded
|
||||
void SetLevelLoadFailed(bool loadFailed) override;
|
||||
bool GetLevelLoadFailed() override;
|
||||
AZ::Data::AssetType GetLevelAssetType() const override;
|
||||
|
||||
// The following methods are deprecated from ILevelSystem and will be removed once slice support is removed.
|
||||
|
||||
// [LYN-2376] Remove once legacy slice support is removed
|
||||
void Rescan([[maybe_unused]] const char* levelsFolder) override;
|
||||
int GetLevelCount() override;
|
||||
ILevelInfo* GetLevelInfo([[maybe_unused]] int level) override;
|
||||
ILevelInfo* GetLevelInfo([[maybe_unused]] const char* levelName) override;
|
||||
|
||||
private:
|
||||
void OnRootSpawnableAssigned(AZ::Data::Asset<AzFramework::Spawnable> rootSpawnable, uint32_t generation) override;
|
||||
void OnRootSpawnableReleased(uint32_t generation) override;
|
||||
|
||||
void PrepareNextLevel(const char* levelName);
|
||||
bool LoadLevelInternal(const char* levelName);
|
||||
|
||||
// Methods to notify ILevelSystemListener
|
||||
void OnPrepareNextLevel(const char* levelName);
|
||||
void OnLevelNotFound(const char* levelName);
|
||||
void OnLoadingStart(const char* levelName);
|
||||
void OnLoadingComplete(const char* levelName);
|
||||
void OnLoadingError(const char* levelName, const char* error);
|
||||
void OnLoadingProgress(const char* levelName, int progressAmount);
|
||||
void OnUnloadComplete(const char* levelName);
|
||||
|
||||
void LogLoadingTime();
|
||||
|
||||
ISystem* m_pSystem{nullptr};
|
||||
|
||||
AZStd::string m_lastLevelName;
|
||||
float m_fLastLevelLoadTime{0.0f};
|
||||
float m_fLastTime{0.0f};
|
||||
|
||||
bool m_bLevelLoaded{false};
|
||||
bool m_levelLoadFailed{false};
|
||||
|
||||
int m_nLoadedLevelsCount{0};
|
||||
|
||||
CTimeValue m_levelLoadStartTime;
|
||||
|
||||
AZStd::vector<ILevelSystemListener*> m_listeners;
|
||||
|
||||
// Information about the currently-loaded root spawnable, used for tracking loads and unloads.
|
||||
uint64_t m_rootSpawnableGeneration{0};
|
||||
AZ::Data::AssetId m_rootSpawnableId{};
|
||||
};
|
||||
|
||||
} // namespace LegacyLevelSystem
|
||||
Reference in New Issue
Block a user