Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "MyProject123_precompiled.h"
- #include <AzCore/Module/Module.h>
- #include <AzCore/Component/Entity.h>
- #include <platform_impl.h>
- #include <AzCore/Memory/SystemAllocator.h>
- #include <IGem.h>
- #include <IActionMapManager.h>
- #include <IGameObjectSystem.h>
- #include <AzFramework/Input/Devices/Mouse/InputDeviceMouse.h>
- #include <AzFramework/Input/Events/InputChannelEventListener.h>
- #include "MyProject123SystemComponent.h"
- #include "Components/MyComponent.h"
- #include "Components/SimpleCameraController.h"
- #include "Components/Jumper.h"
- #include "Components/TrackViewExposed.h"
- #include "Systems/MyCustomSystemComponent.h"
- namespace MyProject123
- {
- class MyProject123Module :
- public CryHooksModule,
- public IActionListener
- {
- public:
- AZ_RTTI(MyProject123Module, "{75E7F080-AFD0-40C6-9A29-833B20E74EA8}", CryHooksModule);
- AZ_CLASS_ALLOCATOR(MyProject123Module, AZ::SystemAllocator, 0);
- MyProject123Module() : CryHooksModule()
- {
- // Push results of [MyComponent]::CreateDescriptor() into m_descriptors here.
- m_descriptors.push_back(MyComponent::CreateDescriptor());
- m_descriptors.push_back(SimpleCameraControllerComponent::CreateDescriptor());
- m_descriptors.push_back(MyProject123SystemComponent::CreateDescriptor());
- m_descriptors.push_back(JumperComponent::CreateDescriptor());
- m_descriptors.push_back(TrackViewExposedComponent::CreateDescriptor());
- // System Components
- RegisterSystemComponent<MyProject123SystemComponent>(); // default system created with project
- RegisterSystemComponent<MyCustomSystemComponent>(); // my system
- }
- AZ::ComponentTypeList GetRequiredSystemComponents() const override
- {
- return m_systemComponents;
- }
- void OnSystemEvent(ESystemEvent systemEvent, UINT_PTR wparam, UINT_PTR lparam)
- {
- CryHooksModule::OnSystemEvent(systemEvent, wparam, lparam);
- switch (systemEvent)
- {
- case ESYSTEM_EVENT_GAME_POST_INIT_DONE:
- {
- RegisterForInput();
- // load level here?
- }
- break;
- case ESYSTEM_EVENT_FULL_SHUTDOWN:
- {
- UnregisterFromInput();
- }
- break;
- default:
- break;
- }
- }
- template<class T>
- void RegisterSystemComponent()
- {
- m_descriptors.push_back(T::CreateDescriptor());
- m_systemComponents.push_back(azrtti_typeid<T>());
- }
- // IActionListener
- void OnAction(const ActionId& action, int activationMode, float value) override
- {
- if (activationMode & eAAM_OnPress)
- {
- OnActionPressed(action, value);
- }
- else if (activationMode & eAAM_OnHold)
- {
- //OnActionHeld(action, value);
- }
- else if (activationMode & eAAM_OnRelease)
- {
- //OnActionReleased(action, value);
- }
- else if (activationMode & eAAM_Always)
- {
- //OnActionAlways(action, value);
- }
- }
- void OnActionPressed(const ActionId & action, float value)
- {
- const char* actionString = action.c_str();
- if (azstricmp(actionString, "exitgame") == 0)
- {
- // hey! plz stop spinning of the Earth, here I'm out!
- }
- else
- {
- AZ_Error("SimpleCameraControllerComponent", false, "Unknown command - %s", action.c_str());
- }
- }
- void RegisterForInput()
- {
- IGame* pGame = gEnv ? gEnv->pGame : nullptr;
- IGameFramework* pGameFramework = pGame ? pGame->GetIGameFramework() : nullptr;
- IActionMapManager* actionMapManager = pGameFramework ? pGameFramework->GetIActionMapManager() : nullptr;
- if (!actionMapManager)
- {
- return;
- }
- actionMapManager->EnableActionMap("gamelauncher", true);
- actionMapManager->AddExtraActionListener(this, "gamelauncher");
- }
- void UnregisterFromInput()
- {
- IGame* pGame = gEnv ? gEnv->pGame : nullptr;
- IGameFramework* pGameFramework = pGame ? pGame->GetIGameFramework() : nullptr;
- IActionMapManager* actionMapManager = pGameFramework ? pGameFramework->GetIActionMapManager() : nullptr;
- if (!actionMapManager)
- {
- return;
- }
- actionMapManager->RemoveExtraActionListener(this, "gamelauncher");
- actionMapManager->EnableActionMap("gamelauncher", false);
- }
- protected:
- AZ::ComponentTypeList m_systemComponents;
- };
- }
- // DO NOT MODIFY THIS LINE UNLESS YOU RENAME THE GEM
- // The first parameter should be GemName_GemIdLower
- // The second should be the fully qualified name of the class above
- AZ_DECLARE_MODULE_CLASS(MyProject123_99921f26970945c38f23c14f164ae6f9, MyProject123::MyProject123Module)
- //AZ_DECLARE_MODULE_CLASS(MyProject123Module, MyProject123::MyProject123Module)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement