Initial commit

This commit is contained in:
alexpete
2021-03-05 11:26:34 -08:00
commit a10351f38d
27091 changed files with 5521199 additions and 0 deletions
@@ -0,0 +1,79 @@
/*
* 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.
*
*/
#include "GameEffectSystem_precompiled.h"
#include "GameEffectSystemGem.h"
namespace
{
/**
* Console command function for reloading the game effect system's data.
*/
void CmdReloadGameFx([[maybe_unused]] IConsoleCmdArgs* pArgs)
{
IGameEffectSystem* iGameEffectSystem = nullptr;
GameEffectSystemRequestBus::BroadcastResult(iGameEffectSystem, &GameEffectSystemRequestBus::Events::GetIGameEffectSystem);
if (iGameEffectSystem)
{
CGameEffectsSystem* cGameEffectsSystem = reinterpret_cast<CGameEffectsSystem*>(iGameEffectSystem);
cGameEffectsSystem->ReloadData();
}
}
}
GameEffectSystemGem::GameEffectSystemGem()
: CryHooksModule()
, m_gameEffectSystem(nullptr)
, g_gameFXSystemDebug(0)
{
GameEffectSystemRequestBus::Handler::BusConnect();
}
GameEffectSystemGem::~GameEffectSystemGem()
{
GameEffectSystemRequestBus::Handler::BusDisconnect();
}
void GameEffectSystemGem::OnSystemEvent(ESystemEvent event, [[maybe_unused]] UINT_PTR wparam, [[maybe_unused]] UINT_PTR lparam)
{
switch (event)
{
case ESYSTEM_EVENT_GAME_POST_INIT:
// Put your init code here
// All other Gems will exist at this point
REGISTER_CVAR(g_gameFXSystemDebug, 0, 0, "Toggles game effects system debug state");
REGISTER_COMMAND("g_reloadGameFx", &CmdReloadGameFx, 0, "Reload all game fx");
m_gameEffectSystem = new CGameEffectsSystem();
m_gameEffectSystem->Initialize();
m_gameEffectSystem->LoadData();
break;
case ESYSTEM_EVENT_FULL_SHUTDOWN:
case ESYSTEM_EVENT_FAST_SHUTDOWN:
if (m_gameEffectSystem)
{
m_gameEffectSystem->ReleaseData();
m_gameEffectSystem->Destroy();
delete m_gameEffectSystem;
m_gameEffectSystem = nullptr;
}
break;
}
}
IGameEffectSystem* GameEffectSystemGem::GetIGameEffectSystem()
{
return m_gameEffectSystem;
}
AZ_DECLARE_MODULE_CLASS(Gem_GameEffectSystem, GameEffectSystemGem)
@@ -0,0 +1,36 @@
/*
* 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.
*
*/
#ifndef _GEM_GAMEEFFECTSYSTEM_H_
#define _GEM_GAMEEFFECTSYSTEM_H_
#include "GameEffectsSystem.h"
class GameEffectSystemGem
: public CryHooksModule
, public GameEffectSystemRequestBus::Handler
{
public:
AZ_RTTI(GameEffectSystemGem, "{44350C39-A90B-46EB-AC1C-DB505113F4A6}", CryHooksModule);
public:
GameEffectSystemGem();
~GameEffectSystemGem() override;
void OnSystemEvent(ESystemEvent event, UINT_PTR wparam, UINT_PTR lparam) override;
IGameEffectSystem* GetIGameEffectSystem() override;
private:
CGameEffectsSystem* m_gameEffectSystem;
int g_gameFXSystemDebug;
};
#endif//_GEM_GAMEEFFECTSYSTEM_H_
@@ -0,0 +1,12 @@
/*
* 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.
*
*/
#include "GameEffectSystem_precompiled.h"
@@ -0,0 +1,21 @@
/*
* 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.
*
*/
#ifndef AFX_GAMEEFFECTSYSTEM_PRECOMPILED_H__140A8406_81F3_42C3_B6BB_0B14734012DE__INCLUDED_
#define AFX_GAMEEFFECTSYSTEM_PRECOMPILED_H__140A8406_81F3_42C3_B6BB_0B14734012DE__INCLUDED_
#include <platform.h>
#include <CryName.h>
#include <I3DEngine.h>
#include <ISerialize.h>
#include <IGem.h>
#endif//AFX_GAMEEFFECTSYSTEM_PRECOMPILED_H__140A8406_81F3_42C3_B6BB_0B14734012DE__INCLUDED_
@@ -0,0 +1,23 @@
/*
* 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.
*
*/
//==================================================================================================
// Name: GameEffectSoftCodeLibrary
// Desc: Game Effect Soft Code Library
// Author: James Chilvers
//==================================================================================================
// Includes
#include "GameEffectSystem_precompiled.h"
#include "GameEffectSystem/GameEffectsSystemDefines.h"
#include "GameEffectSystem/GameEffects/IGameEffect.h"
IMPLEMENT_TYPELIB(IGameEffect, GAME_FX_LIBRARY_NAME); // Implementation of Soft Coding library
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,137 @@
/*
* 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.
*
*/
#ifndef _EFFECTS_GAMEEFFECTSSYSTEM_H_
#define _EFFECTS_GAMEEFFECTSSYSTEM_H_
#pragma once
// Includes
#include "GameEffectSystem/IGameEffectSystem.h"
#include "GameEffectSystem/GameEffectsSystemDefines.h"
#include <AzCore/Component/TickBus.h>
#include <AzFramework/Input/Events/InputChannelEventListener.h>
//==================================================================================================
// Name: CGameEffectsSystem
// Desc: System to handle game effects, game render nodes and game render elements
// Game effect: separates out effect logic from game logic
// Game render node: handles the render object in 3d space
// Game render element: handles the rendering of the object
// CVar activation system: system used to have data driven cvars activated in game
//effects
// Post effect activation system: system used to have data driven post effects
//activated in game effects
// Author: James Chilvers
//==================================================================================================
class CGameEffectsSystem
: public IGameEffectSystem
, public AzFramework::InputChannelEventListener
, public ISoftCodeListener
, public AZ::TickBus::Handler
{
friend struct SGameEffectSystemStaticData;
public:
void Destroy();
void Initialize();
void LoadData();
void ReleaseData();
template <class T>
T* CreateEffect() // Use if dynamic memory allocation is required for the game effect
{ // Using this function then allows easy changing of memory allocator for all dynamically
// created effects
T* newEffect = new T;
return newEffect;
}
// Each effect automatically registers and unregisters itself
SC_API void RegisterEffect(IGameEffect* effect) override;
SC_API void UnRegisterEffect(IGameEffect* effect) override;
void Update(float frameTime);
SC_API void RegisterGameRenderNode(IGameRenderNodePtr& pGameRenderNode);
SC_API void UnregisterGameRenderNode(IGameRenderNodePtr& pGameRenderNode);
SC_API void RegisterGameRenderElement(IGameRenderElementPtr& pGameRenderElement);
SC_API void UnregisterGameRenderElement(IGameRenderElementPtr& pGameRenderElement);
#ifdef SOFTCODE_ENABLED
SC_API void*
CreateSoftCodeInstance(const char* pTypeName) override; // Create soft code instance using libs
SC_API void
RegisterSoftCodeLib(ITypeLibrary* pLib) override; // Register soft code lib for creation of instances
#endif
bool OnInputChannelEventFiltered(const AzFramework::InputChannel& inputChannel) override;
// ISoftCodeListener implementation
void InstanceReplaced(void* pOldInstance, void* pNewInstance) override;
void GameRenderNodeInstanceReplaced(void* pOldInstance, void* pNewInstance) override;
void GameRenderElementInstanceReplaced(void* pOldInstance, void* pNewInstance) override;
// SGameRulesListener implementation
void GameRulesInitialise();
// #TODO: Have this receive events from GameRules
void EnteredGame();// override;
void ReloadData();
CGameEffectsSystem();
virtual ~CGameEffectsSystem();
// AZ::TickBus::Handler implementation
void OnTick(float deltaTime, AZ::ScriptTimePoint time) override;
private:
void Reset();
void AutoReleaseAndDeleteFlaggedEffects(IGameEffect* effectList);
void AutoDeleteEffects(IGameEffect* effectList);
void SetPostEffectCVarCallbacks();
static void PostEffectCVarCallback(ICVar* cvar);
#if DEBUG_GAME_FX_SYSTEM
void DrawDebugDisplay();
void OnActivateDebugView(int debugView);
void OnDeActivateDebugView(int debugView);
int GetDebugView() const { return m_debugView; }
SC_API IGameEffect* GetDebugEffect(const char* pEffectName) const;
static int s_currentDebugEffectId;
int m_debugView;
#endif
static int s_postEffectCVarNameOffset;
#ifdef SOFTCODE_ENABLED
std::vector<ITypeLibrary*> m_softCodeTypeLibs;
typedef std::vector<IGameRenderNodePtr*> TGameRenderNodeVec;
TGameRenderNodeVec m_gameRenderNodes;
CGameRenderNodeSoftCodeListener* m_gameRenderNodeSoftCodeListener;
typedef std::vector<IGameRenderElementPtr*> TGameRenderElementVec;
TGameRenderElementVec m_gameRenderElements;
CGameRenderElementSoftCodeListener* m_gameRenderElementSoftCodeListener;
#endif
IGameEffect* m_effectsToUpdate;
IGameEffect* m_effectsNotToUpdate;
// If in update loop, this is the next effect to be updated this will get changed if the effect is unregistered
IGameEffect* m_nextEffectToUpdate;
bool m_isInitialised;
bool s_hasLoadedData;
}; //------------------------------------------------------------------------------------------------
#endif//_EFFECTS_GAMEEFFECTSSYSTEM_H_
@@ -0,0 +1,79 @@
/*
* 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.
*
*/
//==================================================================================================
// Name: CGameRenderElement
// Desc: Base class for all game render elements
// Author: James Chilvers
//==================================================================================================
// Includes
#include "GameEffectSystem_precompiled.h"
#include "GameRenderElement.h"
//--------------------------------------------------------------------------------------------------
// Name: CGameRenderElement
// Desc: Constructor
//--------------------------------------------------------------------------------------------------
CGameRenderElement::CGameRenderElement()
{
m_pREGameEffect = NULL;
} //-------------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------------
// Name: InitialiseGameRenderElement
// Desc: Initialises game render element
//--------------------------------------------------------------------------------------------------
bool CGameRenderElement::InitialiseGameRenderElement()
{
m_pREGameEffect = (CREGameEffect*)gEnv->pRenderer->EF_CreateRE(eDATA_GameEffect);
if (m_pREGameEffect)
{
m_pREGameEffect->SetPrivateImplementation(this);
m_pREGameEffect->mfUpdateFlags(FCEF_TRANSFORM);
}
return true;
} //-------------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------------
// Name: ReleaseGameRenderElement
// Desc: Releases game render element
//--------------------------------------------------------------------------------------------------
void CGameRenderElement::ReleaseGameRenderElement()
{
if (m_pREGameEffect)
{
m_pREGameEffect->SetPrivateImplementation(NULL);
m_pREGameEffect->Release(false);
}
} //-------------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------------
// Name: UpdatePrivateImplementation
// Desc: Updates private implementation
//--------------------------------------------------------------------------------------------------
void CGameRenderElement::UpdatePrivateImplementation()
{
if (m_pREGameEffect)
{
m_pREGameEffect->SetPrivateImplementation(this);
}
} //-------------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------------
// Name: GetCREGameEffect
// Desc: returns the game effect render element
//--------------------------------------------------------------------------------------------------
CREGameEffect* CGameRenderElement::GetCREGameEffect()
{
return m_pREGameEffect;
} //-------------------------------------------------------------------------------------------------
@@ -0,0 +1,78 @@
/*
* 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.
*
*/
#ifndef _EFFECTS_RENDERELEMENTS_GAMERENDERELEMENT_H_
#define _EFFECTS_RENDERELEMENTS_GAMERENDERELEMENT_H_
#pragma once
// Includes
#include "GameEffectsSystem.h"
#include <CREGameEffect.h>
// Forward declares
struct IGameRenderElementParams;
//==================================================================================================
// Name: IGameRenderElement
// Desc: Base interface for all game render elements
// Author: James Chilvers
//==================================================================================================
struct IGameRenderElement
: public IREGameEffect
, public _i_reference_target_t
{
DECLARE_TYPELIB(IGameRenderElement); // Allow soft coding on this interface
virtual ~IGameRenderElement() {}
virtual bool InitialiseGameRenderElement() = 0;
virtual void ReleaseGameRenderElement() = 0;
virtual void UpdatePrivateImplementation() = 0;
virtual CREGameEffect* GetCREGameEffect() = 0;
virtual IGameRenderElementParams* GetParams() = 0;
}; //------------------------------------------------------------------------------------------------
//==================================================================================================
// Name: CGameRenderElement
// Desc: Base class for all game render elements
// Author: James Chilvers
//==================================================================================================
class CGameRenderElement
: public IGameRenderElement
{
DECLARE_TYPE(CGameRenderElement, IGameRenderElement); // Exposes this type for SoftCoding
public:
CGameRenderElement();
virtual ~CGameRenderElement() {}
virtual bool InitialiseGameRenderElement();
virtual void ReleaseGameRenderElement();
virtual void UpdatePrivateImplementation();
virtual CREGameEffect* GetCREGameEffect();
protected:
CREGameEffect* SOFT(m_pREGameEffect);
}; //------------------------------------------------------------------------------------------------
//==================================================================================================
// Name: IGameRenderElementParams
// Desc: Game Render Element params
// Author: James Chilvers
//==================================================================================================
struct IGameRenderElementParams
{
virtual ~IGameRenderElementParams() {}
}; //------------------------------------------------------------------------------------------------
#endif//_EFFECTS_RENDERELEMENTS_GAMERENDERELEMENT_H_
@@ -0,0 +1,24 @@
/*
* 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.
*
*/
//==================================================================================================
// Name: GameRenderElementSoftCodeLibrary
// Desc: Render Node Soft Code Library
// Author: James Chilvers
//==================================================================================================
// Includes
#include "GameEffectSystem_precompiled.h"
#include <TypeLibrary.h>
#include "RenderElements/GameRenderElement.h"
IMPLEMENT_TYPELIB(IGameRenderElement,
GAME_RENDER_ELEMENT_LIBRARY_NAME); // Implementation of Soft Coding library
@@ -0,0 +1,24 @@
/*
* 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.
*
*/
//==================================================================================================
// Name: GameRenderNodeSoftCodeLibrary
// Desc: Render Node Soft Code Library
// Author: James Chilvers
//==================================================================================================
// Includes
#include "GameEffectSystem_precompiled.h"
#include <TypeLibrary.h>
#include <GameEffectSystem/IGameRenderNode.h>
#include <GameEffectSystem/GameEffectsSystemDefines.h>
IMPLEMENT_TYPELIB(IGameRenderNode, GAME_RENDER_NODE_LIBRARY_NAME); // Implementation of Soft Coding library
@@ -0,0 +1,51 @@
/*
* 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.
*
*/
#ifndef CRYINCLUDE_GAMEDLL_EFFECTS_RENDERNODES_IGAMERENDERNODE_H
#define CRYINCLUDE_GAMEDLL_EFFECTS_RENDERNODES_IGAMERENDERNODE_H
#pragma once
#include "Effects/RenderElements/GameRenderElement.h"
#include "Effects/GameEffectsSystem.h"
// Forward declares
struct IGameRenderNodeParams;
//==================================================================================================
// Name: IGameRenderNode
// Desc: Base interface for all game render nodes
// Author: James Chilvers
//==================================================================================================
struct IGameRenderNode
: public IRenderNode
, public _i_reference_target_t
{
DECLARE_TYPELIB(IGameRenderNode); // Allow soft coding on this interface
virtual ~IGameRenderNode() {}
virtual bool InitialiseGameRenderNode() = 0;
virtual void ReleaseGameRenderNode() = 0;
virtual void SetParams(const IGameRenderNodeParams* pParams = NULL) = 0;
}; //------------------------------------------------------------------------------------------------
//==================================================================================================
// Name: IGameRenderNodeParams
// Desc: Game render node params
// Author: James Chilvers
//==================================================================================================
struct IGameRenderNodeParams
{
virtual ~IGameRenderNodeParams() {}
}; //------------------------------------------------------------------------------------------------
#endif // CRYINCLUDE_GAMEDLL_EFFECTS_RENDERNODES_IGAMERENDERNODE_H