This commit is contained in:
Arnaud Jamin
2023-10-11 01:38:41 -04:00
+41 -7
View File
@@ -196,8 +196,8 @@ The Cog repository has the following structure:
Cog has multiple plugins to ease the integration for projects that do not use the `Ability System Component` or `Enhanced Input`. For the next steps, it is assumed all the plugins are used. Cog has multiple plugins to ease the integration for projects that do not use the `Ability System Component` or `Enhanced Input`. For the next steps, it is assumed all the plugins are used.
1. Setup up module dependencies:
- Setup up module dependencies:
```c# ```c#
// CogSample.Build.cs // CogSample.Build.cs
using UnrealBuildTool; using UnrealBuildTool;
@@ -238,8 +238,8 @@ public class CogSample : ModuleRules
} }
``` ```
2. In the class of your choice (in the sample we use the GameState class) add a reference to the CogWindowManager:
- In the class of your choice (in the sample we use the GameState class) add a reference to the CogWindowManager:
```cpp ```cpp
// ACogSampleGameState.h // ACogSampleGameState.h
#pragma once #pragma once
@@ -267,8 +267,9 @@ class ACogSampleGameState : public AGameStateBase
#endif //ENABLE_COG #endif //ENABLE_COG
}; };
``` ```
3. Instantiate the CogWindowManager and add some windows:
- Instantiate the CogWindowManager and add some windows:
```cpp ```cpp
// ACogSampleGameState.cpp // ACogSampleGameState.cpp
void ACogSampleGameState::BeginPlay() void ACogSampleGameState::BeginPlay()
@@ -279,24 +280,33 @@ void ACogSampleGameState::BeginPlay()
CogWindowManager = NewObject<UCogWindowManager>(this); CogWindowManager = NewObject<UCogWindowManager>(this);
CogWindowManagerRef = CogWindowManager; CogWindowManagerRef = CogWindowManager;
// Add some windows // Add windows
CogWindowManager->CreateWindow<UCogEngineWindow_DebugSettings>("Engine.Debug Settings"); CogWindowManager->CreateWindow<UCogEngineWindow_DebugSettings>("Engine.Debug Settings");
CogWindowManager->CreateWindow<UCogEngineWindow_ImGui>("Engine.ImGui"); CogWindowManager->CreateWindow<UCogEngineWindow_ImGui>("Engine.ImGui");
// Add windows that uses a data asset. The data asset must be created inside Unreal Editor.
const UCogAbilityDataAsset* AbilitiesAsset = GetFirstAssetByClass<UCogAbilityDataAsset>();
UCogAbilityWindow_Abilities* AbilitiesWindow = CogWindowManager->CreateWindow<UCogAbilityWindow_Abilities>("Gameplay.Abilities");
AbilitiesWindow->Asset = AbilitiesAsset;
UCogAbilityWindow_Attributes* AttributesWindow = CogWindowManager->CreateWindow<UCogAbilityWindow_Attributes>("Gameplay.Attributes");
AttributesWindow->Asset = AbilitiesAsset;
[...] [...]
#endif //ENABLE_COG #endif //ENABLE_COG
} }
``` ```
3. Define which key will toggle the input from the game to Imgui:
- Define which key will toggle the input from the game to Imgui:
```cpp ```cpp
// ACogSampleGameState.cpp // ACogSampleGameState.cpp
FCogImguiModule::Get().SetToggleInputKey(FCogImGuiKeyInfo(EKeys::Insert)); FCogImguiModule::Get().SetToggleInputKey(FCogImGuiKeyInfo(EKeys::Insert));
``` ```
4. Tick the CogWindowManager:
- Tick the CogWindowManager:
```cpp ```cpp
// ACogSampleGameState.cpp // ACogSampleGameState.cpp
void ACogSampleGameState::Tick(float DeltaSeconds) void ACogSampleGameState::Tick(float DeltaSeconds)
@@ -308,3 +318,27 @@ void ACogSampleGameState::Tick(float DeltaSeconds)
#endif //ENABLE_COG #endif //ENABLE_COG
} }
``` ```
- Implement Cog Interfaces on your desired actor classes:
```cpp
// CogSampleCharacter.h
UCLASS(config=Game)
class ACogSampleCharacter : public ACharacter
, public IAbilitySystemInterface
, public ICogCommonDebugFilteredActorInterface
, public ICogCommonAllegianceActorInterface
, public ICogSampleTeamInterface
, public ICogSampleTargetableInterface
```
```cpp
// CogSamplePlayerController.h
UCLASS(config=Game)
class ACogSamplePlayerController
: public APlayerController
, public ICogCommonPossessorInterface
```
__
- In Unreal Editor create and configure the Data Assets