Browse Source

Standalone Game Client, Gameplay loop, CharacterManager

- Visual Studio Code debug launch configuration now has standalone options
- I fucked with various options in order to get the standalone game client working. Event Driven Loader is now disabled, Anonymous Usage Data is now disabled (this is more because I didn't want to wait for it at shutdown), and Oculus and SteamVR are disabled
- Added some Input Bindings for controlling Standalone game client which are not yet hooked up
- Did some work on getting a player HUD set up. At the moment it doesn't do anything
- Added GalavantUnreal command for pausing/resuming Galavant tick (Gameplay time)
- Commented my Slate High DPI hack and moved it into a command instead. This hack broke cooking and packaging
- Hooked GalavantUnreal update into Gameplay time system for pausing etc.
- Added CharacterManager. The idea is that this system will manage things like setting ragdoll etc. on Unreal ACharacters. It doesn't do anything yet
master
Macoy Madson 4 years ago
parent
commit
45d2b7ea98
24 changed files with 377 additions and 45 deletions
  1. +3
    -1
      .gitignore
  2. +59
    -2
      GalavantUnreal/.vscode/launch.json
  3. +1
    -0
      GalavantUnreal/CMakeLists.txt
  4. +7
    -1
      GalavantUnreal/Config/DefaultEngine.ini
  5. +37
    -0
      GalavantUnreal/Config/DefaultGame.ini
  6. +17
    -13
      GalavantUnreal/Config/DefaultInput.ini
  7. BIN
      GalavantUnreal/Content/Blueprints/UI/SimplePlayerHUD.uasset
  8. BIN
      GalavantUnreal/Content/FirstPersonCPP/Blueprints/GalavantUnrealFPCharacterTrueBP.uasset
  9. BIN
      GalavantUnreal/Content/Materials/MinimapDynamicMaterial_UI.uasset
  10. BIN
      GalavantUnreal/Content/TopDownCPP/Maps/TopDownExampleMap.umap
  11. BIN
      GalavantUnreal/Content/TopDownCPP/Maps/TopDownExampleMap_BuiltData.uasset
  12. +13
    -0
      GalavantUnreal/GalavantUnreal.uproject
  13. +1
    -0
      GalavantUnreal/GalavantUnrealCodeLitePreProcessor.txt
  14. +1
    -0
      GalavantUnreal/GalavantUnrealDefines.pri
  15. +1
    -0
      GalavantUnreal/GalavantUnrealSource.pri
  16. +104
    -0
      GalavantUnreal/Source/GalavantUnreal/CharacterManager.cpp
  17. +20
    -0
      GalavantUnreal/Source/GalavantUnreal/CharacterManager.hpp
  18. +15
    -5
      GalavantUnreal/Source/GalavantUnreal/Characters/GalavantUnrealFPCharacter.cpp
  19. +1
    -0
      GalavantUnreal/Source/GalavantUnreal/CombatFx.hpp
  20. +22
    -1
      GalavantUnreal/Source/GalavantUnreal/GalaEntityComponents/UnrealMovementComponent.cpp
  21. +2
    -0
      GalavantUnreal/Source/GalavantUnreal/GalaEntityComponents/UnrealMovementComponent.hpp
  22. +6
    -0
      GalavantUnreal/Source/GalavantUnreal/GalavantUnreal.Build.cs
  23. +57
    -22
      GalavantUnreal/Source/GalavantUnreal/GalavantUnrealMain.cpp
  24. +10
    -0
      GalavantUnreal/Source/GalavantUnreal/GalavantUnrealMain.h

+ 3
- 1
.gitignore View File

@ -71,4 +71,6 @@ GalavantUnreal/Content/MedievalTown/*
# Ignore core dumps
core
*.blend1
*.blend1
LOCAL*

+ 59
- 2
GalavantUnreal/.vscode/launch.json View File

@ -17,7 +17,7 @@
]
},
{
"name": "(gdb) Launch",
"name": "(gdb) Launch No Debug",
"type": "cppdbg",
"request": "launch",
"program": "/home/macoy/Development/code/3rdParty/repositories/UnrealEngine/Engine/Binaries/Linux/UE4Editor",
@ -34,6 +34,63 @@
"ignoreFailures": true
}
]
}
},
{
"name": "(gdb) Launch Debug",
"type": "cppdbg",
"request": "launch",
"program": "/home/macoy/Development/code/3rdParty/repositories/UnrealEngine/Engine/Binaries/Linux/UE4Editor-Linux-Debug",
"args": ["/home/macoy/Development/code/repositories/galavant-unreal/GalavantUnreal/GalavantUnreal.uproject"],
"stopAtEntry": false,
"cwd": "${workspaceRoot}",
"environment": [],
"externalConsole": true,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
},
{
"name": "(gdb) Launch Standalone",
"type": "cppdbg",
"request": "launch",
"program": "/home/macoy/Development/code/repositories/galavant-unreal/GalavantUnreal/LOCAL_package/package/LinuxNoEditor/GalavantUnreal/Binaries/Linux/GalavantUnreal",
"args": ["-windowed", "-resx=1920", "-resy=1080"],
"stopAtEntry": false,
"cwd": "${workspaceRoot}",
"environment": [],
"externalConsole": true,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
},
{
"name": "(gdb) Launch Standalone Debug",
"type": "cppdbg",
"request": "launch",
"program": "/home/macoy/Development/code/repositories/galavant-unreal/GalavantUnreal/LOCAL_package/package/LinuxNoEditor/GalavantUnreal/Binaries/Linux/GalavantUnreal-Linux-Debug",
"args": ["-windowed", "-resx=1920", "-resy=1080"],
"stopAtEntry": false,
"cwd": "${workspaceRoot}",
"environment": [],
"externalConsole": true,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
},
]
}

+ 1
- 0
GalavantUnreal/CMakeLists.txt View File

@ -7059,6 +7059,7 @@ set(SOURCE_FILES
"${UE4_ROOT_PATH}/Engine/Plugins/Tests/RuntimeTests/Source/RuntimeTests/Private/Slate/RichTextMarkupProcessingTest.cpp"
"${UE4_ROOT_PATH}/Engine/Plugins/Tests/ScreenshotTools/Source/ScreenshotTools/Private/ScreenshotTools.cpp"
"${GAME_ROOT_PATH}/Source/GalavantUnreal/ActorEntityManagement.cpp"
"${GAME_ROOT_PATH}/Source/GalavantUnreal/CharacterManager.cpp"
"${GAME_ROOT_PATH}/Source/GalavantUnreal/CombatFx.cpp"
"${GAME_ROOT_PATH}/Source/GalavantUnreal/GalavantUnreal.cpp"
"${GAME_ROOT_PATH}/Source/GalavantUnreal/GalavantUnrealGameMode.cpp"


+ 7
- 1
GalavantUnreal/Config/DefaultEngine.ini View File

@ -2,7 +2,7 @@
GameDefaultMap=/Game/TopDownCPP/Maps/TopDownExampleMap
EditorStartupMap=/Game/TopDownCPP/Maps/TopDownExampleMap
GlobalDefaultGameMode=/Script/GalavantUnreal.GalavantUnrealMain
ServerDefaultMap=/Game/TopDownCPP/Maps/TopDownExampleMap.TopDownExampleMap
[/Script/Engine.Engine]
+ActiveGameNameRedirects=(OldGameName="TP_TopDown",NewGameName="/Script/GalavantUnreal")
@ -71,6 +71,9 @@ CellSize=4.000000
AgentMaxSlope=89.000000
AgentMaxStepHeight=120.000000
[/Script/Engine.StreamingSettings]
s.EventDrivenLoaderEnabled=False
[/Script/Engine.PhysicsSettings]
DefaultGravityZ=-980.000000
DefaultTerminalVelocity=4000.000000
@ -112,3 +115,6 @@ AsyncSceneSmoothingFactor=0.990000
InitialAverageFrameRate=0.016667
PhysXTreeRebuildRate=10
[/Script/Engine.EndUserSettings]
bSendAnonymousUsageDataToEpic=False

+ 37
- 0
GalavantUnreal/Config/DefaultGame.ini View File

@ -12,3 +12,40 @@ FixedCameraDistance=1500.0
[StartupActions]
bAddPacks=True
InsertPack=(PackSource="StarterContent.upack,PackName="StarterContent")
[/Script/UnrealEd.ProjectPackagingSettings]
BuildConfiguration=PPBC_Development
StagingDirectory=(Path="")
FullRebuild=False
ForDistribution=False
IncludeDebugFiles=False
BlueprintNativizationMethod=Inclusive
bWarnIfPackagedWithoutNativizationFlag=True
UsePakFile=True
bGenerateChunks=False
bGenerateNoChunks=False
bChunkHardReferencesOnly=False
bBuildHttpChunkInstallData=False
HttpChunkInstallDataDirectory=(Path="")
HttpChunkInstallDataVersion=
IncludePrerequisites=True
IncludeAppLocalPrerequisites=False
bShareMaterialShaderCode=False
bSharedMaterialNativeLibraries=False
ApplocalPrerequisitesDirectory=(Path="")
IncludeCrashReporter=False
InternationalizationPreset=English
-CulturesToStage=en
+CulturesToStage=en
DefaultCulture=en
bCookAll=False
bCookMapsOnly=False
bCompressed=False
bEncryptIniFiles=False
bEncryptPakIndex=False
bSkipEditorContent=False
-MapsToCook=(FilePath="")
+MapsToCook=(FilePath="/Game/TopDownCPP/Maps/TopDownExampleMap")
bNativizeBlueprintAssets=False
bNativizeOnlySelectedBlueprints=False

+ 17
- 13
GalavantUnreal/Config/DefaultInput.ini View File

@ -1,5 +1,11 @@
[/Script/Engine.InputSettings]
-AxisConfig=(AxisKeyName="MotionController_Left_Thumbstick_X",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
-AxisConfig=(AxisKeyName="MotionController_Left_Thumbstick_Y",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
-AxisConfig=(AxisKeyName="MotionController_Left_TriggerAxis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
-AxisConfig=(AxisKeyName="MotionController_Left_Grip1Axis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
-AxisConfig=(AxisKeyName="MotionController_Left_Grip2Axis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
-AxisConfig=(AxisKeyName="MotionController_Right_Thumbstick_X",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
-AxisConfig=(AxisKeyName="MotionController_Right_Thumbstick_Y",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
-AxisConfig=(AxisKeyName="MotionController_Right_TriggerAxis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
-AxisConfig=(AxisKeyName="MotionController_Right_Grip1Axis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
@ -15,12 +21,12 @@
-AxisConfig=(AxisKeyName="MouseWheelAxis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
-AxisConfig=(AxisKeyName="Gamepad_LeftTriggerAxis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
-AxisConfig=(AxisKeyName="Gamepad_RightTriggerAxis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
-AxisConfig=(AxisKeyName="MotionController_Left_Thumbstick_X",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
-AxisConfig=(AxisKeyName="MotionController_Left_Thumbstick_Y",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
-AxisConfig=(AxisKeyName="MotionController_Left_TriggerAxis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
-AxisConfig=(AxisKeyName="MotionController_Left_Grip1Axis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
-AxisConfig=(AxisKeyName="MotionController_Left_Grip2Axis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
-AxisConfig=(AxisKeyName="MotionController_Right_Thumbstick_X",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="MotionController_Left_Thumbstick_X",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="MotionController_Left_Thumbstick_Y",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="MotionController_Left_TriggerAxis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="MotionController_Left_Grip1Axis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="MotionController_Left_Grip2Axis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="MotionController_Right_Thumbstick_X",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="MotionController_Right_Thumbstick_Y",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="MotionController_Right_TriggerAxis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="MotionController_Right_Grip1Axis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
@ -36,12 +42,6 @@
+AxisConfig=(AxisKeyName="MouseWheelAxis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="Gamepad_LeftTriggerAxis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="Gamepad_RightTriggerAxis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="MotionController_Left_Thumbstick_X",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="MotionController_Left_Thumbstick_Y",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="MotionController_Left_TriggerAxis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="MotionController_Left_Grip1Axis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="MotionController_Left_Grip2Axis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="MotionController_Right_Thumbstick_X",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
bAltEnterTogglesFullscreen=True
bF11TogglesFullscreen=True
bUseMouseForTouch=False
@ -60,7 +60,9 @@ DefaultViewportMouseLockMode=LockOnCapture
-ActionMappings=(ActionName="UseTertiary",Key=R,bShift=False,bCtrl=False,bAlt=False,bCmd=False)
-ActionMappings=(ActionName="UsePrimary",Key=E,bShift=False,bCtrl=False,bAlt=False,bCmd=False)
-ActionMappings=(ActionName="UseSecondary",Key=RightMouseButton,bShift=False,bCtrl=False,bAlt=False,bCmd=False)
-ActionMappings=(ActionName="UseTertiary",Key=MouseScrollDown,bShift=False,bCtrl=False,bAlt=False,bCmd=False)
-ActionMappings=(ActionName="UseTertiary",Key=MiddleMouseButton,bShift=False,bCtrl=False,bAlt=False,bCmd=False)
-ActionMappings=(ActionName="ExitGalavant",Key=Escape,bShift=False,bCtrl=False,bAlt=False,bCmd=False)
-ActionMappings=(ActionName="PauseGalavant",Key=P,bShift=False,bCtrl=False,bAlt=False,bCmd=False)
+ActionMappings=(ActionName="Jump",Key=SpaceBar,bShift=False,bCtrl=False,bAlt=False,bCmd=False)
+ActionMappings=(ActionName="Interact",Key=E,bShift=False,bCtrl=False,bAlt=False,bCmd=False)
+ActionMappings=(ActionName="UsePrimary",Key=LeftMouseButton,bShift=False,bCtrl=False,bAlt=False,bCmd=False)
@ -69,6 +71,8 @@ DefaultViewportMouseLockMode=LockOnCapture
+ActionMappings=(ActionName="UsePrimary",Key=E,bShift=False,bCtrl=False,bAlt=False,bCmd=False)
+ActionMappings=(ActionName="UseSecondary",Key=RightMouseButton,bShift=False,bCtrl=False,bAlt=False,bCmd=False)
+ActionMappings=(ActionName="UseTertiary",Key=MiddleMouseButton,bShift=False,bCtrl=False,bAlt=False,bCmd=False)
+ActionMappings=(ActionName="ExitGalavant",Key=Escape,bShift=False,bCtrl=False,bAlt=False,bCmd=False)
+ActionMappings=(ActionName="TogglePlayGalavant",Key=P,bShift=False,bCtrl=False,bAlt=False,bCmd=False)
-AxisMappings=(AxisName="MoveForward",Key=W,Scale=1.000000)
-AxisMappings=(AxisName="MoveForward",Key=S,Scale=-1.000000)
-AxisMappings=(AxisName="MoveRight",Key=D,Scale=1.000000)


BIN
GalavantUnreal/Content/Blueprints/UI/SimplePlayerHUD.uasset View File


BIN
GalavantUnreal/Content/FirstPersonCPP/Blueprints/GalavantUnrealFPCharacterTrueBP.uasset View File


BIN
GalavantUnreal/Content/Materials/MinimapDynamicMaterial_UI.uasset View File


BIN
GalavantUnreal/Content/TopDownCPP/Maps/TopDownExampleMap.umap View File


BIN
GalavantUnreal/Content/TopDownCPP/Maps/TopDownExampleMap_BuiltData.uasset View File


+ 13
- 0
GalavantUnreal/GalavantUnreal.uproject View File

@ -13,5 +13,18 @@
"AIModule"
]
}
],
"Plugins": [
{
"Name": "OculusVR",
"Enabled": false
},
{
"Name": "SteamVR",
"Enabled": false
}
],
"AdditionalPluginDirectories": [
"Intermediate/Plugins"
]
}

+ 1
- 0
GalavantUnreal/GalavantUnrealCodeLitePreProcessor.txt View File

@ -32,6 +32,7 @@ ORIGINAL_FILE_NAME="libUE4Editor-GalavantUnreal.so"
UE_IS_ENGINE_MODULE=0
UE_BUILD_DEVELOPMENT_WITH_DEBUGGAME=0
UE_PROJECT_NAME=GalavantUnreal
UE_ENGINE_DIRECTORY=/home/macoy/LinkToUEngine/
DEPRECATED_FORGAME=DEPRECATED
GALAVANTUNREAL_API=
UE_ENABLE_ICU=1


+ 1
- 0
GalavantUnreal/GalavantUnrealDefines.pri View File

@ -33,6 +33,7 @@ DEFINES += \
UE_IS_ENGINE_MODULE=0 \
UE_BUILD_DEVELOPMENT_WITH_DEBUGGAME=0 \
UE_PROJECT_NAME=GalavantUnreal \
UE_ENGINE_DIRECTORY=/home/macoy/LinkToUEngine/ \
DEPRECATED_FORGAME=DEPRECATED \
GALAVANTUNREAL_API= \
UE_ENABLE_ICU=1 \


+ 1
- 0
GalavantUnreal/GalavantUnrealSource.pri View File

@ -7048,6 +7048,7 @@ SOURCES += \
"$$unrealRootPath/Engine/Plugins/Tests/RuntimeTests/Source/RuntimeTests/Private/Slate/RichTextMarkupProcessingTest.cpp" \
"$$unrealRootPath/Engine/Plugins/Tests/ScreenshotTools/Source/ScreenshotTools/Private/ScreenshotTools.cpp" \
"$$GalavantUnrealRootPath/Source/GalavantUnreal/ActorEntityManagement.cpp" \
"$$GalavantUnrealRootPath/Source/GalavantUnreal/CharacterManager.cpp" \
"$$GalavantUnrealRootPath/Source/GalavantUnreal/CombatFx.cpp" \
"$$GalavantUnrealRootPath/Source/GalavantUnreal/GalavantUnreal.cpp" \
"$$GalavantUnrealRootPath/Source/GalavantUnreal/GalavantUnrealGameMode.cpp" \


+ 104
- 0
GalavantUnreal/Source/GalavantUnreal/CharacterManager.cpp View File

@ -0,0 +1,104 @@
#include "GalavantUnreal.h"
#include "CharacterManager.hpp"
#include "game/agent/AgentComponentManager.hpp"
#include "ActorEntityManagement.h"
namespace CharacterManager
{
struct CharacterManager
{
gv::EntityList Subscribers;
typedef std::vector<TWeakObjectPtr<ACharacter>> CharacterList;
CharacterList Characters;
};
static CharacterManager s_Characters;
// void UnsubscribeEntities(const gv::EntityList& entitiesToUnsubscribe)
// {
// // TODO: Why did I make this callback thing if I just copy paste ComponentManager
// // UnsubscribeEntities? This is dumb
// if (!entities.empty())
// {
// // Copy for modification
// EntityList entitiesToUnsubscribe;
// EntityListAppendList(entitiesToUnsubscribe, entities);
// // Make sure they're actually subscribed
// EntityListRemoveUniqueEntitiesInSuspect(Subscribers, entitiesToUnsubscribe);
// if (!entitiesToUnsubscribe.empty())
// {
// UnsubscribeEntitiesInternal(entitiesToUnsubscribe);
// // Remove from subscribers
// EntityListRemoveNonUniqueEntitiesInSuspect(entitiesToUnsubscribe, Subscribers);
// LOGD << "Manager "
// << " unsubscribed " << entitiesToUnsubscribe.size() << " entities";
// }
// }
// UnsubscribeEntities(Subscribers, UnsubscribeEntitiesInternal);
// }
void Update(float deltaTime)
{
gv::AgentConsciousStateList subscriberConsciousStates;
gv::g_AgentComponentManager.GetAgentConsciousStates(s_Characters.Subscribers,
subscriberConsciousStates);
for (TWeakObjectPtr<ACharacter>& character : s_Characters.Characters)
{
if (character.IsValid())
{
}
else
character = nullptr;
}
}
TWeakObjectPtr<ACharacter> CreateCharacterForEntity(
UWorld* world, TSubclassOf<ACharacter> characterType, gv::Entity entity,
const gv::Position& position, ActorEntityManager::TrackActorLifetimeCallback callback)
{
if (!world)
return nullptr;
/*gv::EntityListIterator findIt = std::find(s_Characters.Subscribers.begin(), s_Characters.Subscribers.end(), entity);
TWeakObjectPtr<ACharacter>* entityAssociatedCharacter = nullptr;
if (findIt != s_Characters.Subscribers.end())
{
for (TWeakObjectPtr<ACharacter>* character : s_Characters.Characters)
{
if (character->IsValid())
{
if ((*character)->Entity == entity)
return character;
else
{
entityAssociatedCharacter = character;
break;
}
}
}
}*/
TWeakObjectPtr<ACharacter> newCharacter = ActorEntityManager::CreateActorForEntity<ACharacter>(
world, characterType, entity, position, callback);
/*if (entityAssociatedCharacter)
find
newCharacter*/
return newCharacter;
}
}

+ 20
- 0
GalavantUnreal/Source/GalavantUnreal/CharacterManager.hpp View File

@ -0,0 +1,20 @@
#pragma once
#include "ActorEntityManagement.h"
#include "entityComponentSystem/EntityTypes.hpp"
#include "entityComponentSystem/EntityComponentManager.hpp"
#include "world/Position.hpp"
// Character Manager - Handle Unreal Characters (movement, animation, ragdoll, etc.)
namespace CharacterManager
{
void Update(float deltaTime);
// void UnsubscribeEntities(const gv::EntityList& entitiesToUnsubscribe);
TWeakObjectPtr<ACharacter> CreateCharacterForEntity(
UWorld* world, TSubclassOf<ACharacter> characterType, gv::Entity entity,
const gv::Position& position, ActorEntityManager::TrackActorLifetimeCallback callback);
}

+ 15
- 5
GalavantUnreal/Source/GalavantUnreal/Characters/GalavantUnrealFPCharacter.cpp View File

@ -134,6 +134,15 @@ void AGalavantUnrealFPCharacter::BeginPlay()
}
LOGI << "Initializing Player done";
// Create HUD
{
/*template< class T >
T* CreateWidget(APlayerController* OwningPlayer, UClass* UserWidgetClass = T::StaticClass())
{
return Cast<T>(UUserWidget::CreateWidgetOfClass(UserWidgetClass, nullptr, nullptr, OwningPlayer));
}*/
}
}
void AGalavantUnrealFPCharacter::EndPlay(const EEndPlayReason::Type EndPlayReason)
@ -199,6 +208,12 @@ void AGalavantUnrealFPCharacter::SetupPlayerInputComponent(class UInputComponent
InputComponent->BindAction("UseTertiary", IE_Pressed, this,
&AGalavantUnrealFPCharacter::OnUseTertiary);
}
// Game bindings (not gameplay related)
{
// InputComponent->BindAction("ExitGalavant", IE_Pressed, this, );
// InputComponent->BindAction("TogglePlayGalavant", IE_Pressed, this, );
}
}
void AGalavantUnrealFPCharacter::OnFire()
@ -276,8 +291,6 @@ bool AGalavantUnrealFPCharacter::CombatAttemptAction(PlayerCombatAction& playerA
if (currentTime - s_lastActionTime < 0.5f)
return false;
LOGD << "Performing combat action of type " << (int)playerAction.Type;
s_lastActionTime = currentTime;
// TODO: This is not sustainable. Figure out CombatFx
@ -294,7 +307,6 @@ bool AGalavantUnrealFPCharacter::CombatAttemptAction(PlayerCombatAction& playerA
void AGalavantUnrealFPCharacter::OnUsePrimary()
{
LOGD << "Player Use Primary!";
PlayerCombatAction attemptAction = {PlayerCombatAction::ActionType::MeleeAttack,
TempPrimaryAttackAnimation};
CombatAttemptAction(attemptAction);
@ -302,7 +314,6 @@ void AGalavantUnrealFPCharacter::OnUsePrimary()
void AGalavantUnrealFPCharacter::OnUseSecondary()
{
LOGD << "Player Use Secondary!";
PlayerCombatAction attemptAction = {PlayerCombatAction::ActionType::MeleeBlock,
TempSecondaryAttackAnimation};
CombatAttemptAction(attemptAction);
@ -310,7 +321,6 @@ void AGalavantUnrealFPCharacter::OnUseSecondary()
void AGalavantUnrealFPCharacter::OnUseTertiary()
{
LOGD << "Player Use Tertiary!";
PlayerCombatAction attemptAction = {PlayerCombatAction::ActionType::MeleeAttack,
TempTertiaryAttackAnimation};
CombatAttemptAction(attemptAction);


+ 1
- 0
GalavantUnreal/Source/GalavantUnreal/CombatFx.hpp View File

@ -7,6 +7,7 @@ typedef class UAnimMontage UAnimMontage;
namespace gv
{
// @LatelinkDef
struct CombatFx
{
// TODO: @Stability: Make these TWeakPtrs? TWeakObjectPtrs?


+ 22
- 1
GalavantUnreal/Source/GalavantUnreal/GalaEntityComponents/UnrealMovementComponent.cpp View File

@ -5,6 +5,7 @@
#include "Characters/AgentCharacter.h"
#include "RandomStream.h"
#include "ActorEntityManagement.h"
#include "CharacterManager.hpp"
#include "Utilities/ConversionHelpers.h"
#include "util/Logging.hpp"
@ -16,6 +17,8 @@
#include "world/ProceduralWorld.hpp"
#include "game/EntityLevelOfDetail.hpp"
#include "util/Math.hpp"
#include <functional>
#include "GalavantUnrealMain.h"
@ -272,6 +275,24 @@ void UnrealMovementComponent::PathEntitiesTo(const gv::EntityList& entities,
}
}
void UnrealMovementComponent::SetEntitySpeeds(const gv::EntityList& entities,
const std::vector<float>& speeds)
{
gv::PooledComponentManager<UnrealMovementComponentData>::FragmentedPoolIterator it =
gv::PooledComponentManager<UnrealMovementComponentData>::NULL_POOL_ITERATOR;
for (gv::PooledComponent<UnrealMovementComponentData>* currentComponent = ActivePoolBegin(it);
currentComponent != nullptr &&
it != gv::PooledComponentManager<UnrealMovementComponentData>::NULL_POOL_ITERATOR;
currentComponent = GetNextActivePooledComponent(it))
{
for (size_t i = 0; i < MIN(entities.size(), speeds.size()); i++)
{
if (currentComponent->entity == entities[i])
currentComponent->data.MaxSpeed = speeds[i];
}
}
}
void UnrealMovementComponent::SpawnActorIfNecessary(
gv::PooledComponent<UnrealMovementComponentData>* component)
{
@ -327,7 +348,7 @@ void UnrealMovementComponent::SpawnActorIfNecessary(
}
else if (component->data.SpawnParams.CharacterToSpawn)
{
component->data.Character = ActorEntityManager::CreateActorForEntity<ACharacter>(
component->data.Character = CharacterManager::CreateCharacterForEntity(
World, component->data.SpawnParams.CharacterToSpawn, component->entity,
ToPosition(position),
std::bind(&UnrealMovementComponent::OnActorDestroyed, this, std::placeholders::_1));


+ 2
- 0
GalavantUnreal/Source/GalavantUnreal/GalaEntityComponents/UnrealMovementComponent.hpp View File

@ -80,7 +80,9 @@ public:
// TODO: This should return whether it was actually successful (i.e. the entity exists)
virtual void PathEntitiesTo(const gv::EntityList& entities, const gv::PositionList& positions);
virtual void SetEntitySpeeds(const gv::EntityList& entities, const std::vector<float>& speeds);
// Callback
void OnActorDestroyed(gv::Entity entity);
};

+ 6
- 0
GalavantUnreal/Source/GalavantUnreal/GalavantUnreal.Build.cs View File

@ -17,6 +17,12 @@ public class GalavantUnreal : ModuleRules
PrivateDependencyModuleNames.AddRange(new string[] {"CustomMeshComponent"});
PrivateIncludePathModuleNames.AddRange(new string[] {"CustomMeshComponent"});
// Make debug game builds work
// See https://answers.unrealengine.com/questions/607072/unreal-4161-debug-game-build-error-icu-data-direct.html
// This isn't needed if you package first!
//Definitions.Add("UE_ENGINE_DIRECTORY=/home/macoy/Development/code/3rdParty/repositories/UnrealEngine/Engine/");
//Definitions.Add("UE_ENGINE_DIRECTORY=/home/macoy/Development/code/repositories/galavant-unreal/GalavantUnreal/Saved/Cooked/LinuxNoEditor/Engine/");
////////////////////////
// External libraries //


+ 57
- 22
GalavantUnreal/Source/GalavantUnreal/GalavantUnrealMain.cpp View File

@ -10,6 +10,9 @@
#include "Utilities/GalavantUnrealLog.h"
#include "util/Logging.hpp"
#include "util/StringHashing.hpp"
#include "util/Time.hpp"
#include "world/WorldResourceLocator.hpp"
#include "world/ProceduralWorld.hpp"
#include "entityComponentSystem/EntityTypes.hpp"
@ -21,7 +24,7 @@
#include "game/agent/Needs.hpp"
#include "ai/htn/HTNTasks.hpp"
#include "game/EntityLevelOfDetail.hpp"
#include "util/StringHashing.hpp"
static gv::Logging::Logger s_UnrealLogger(gv::Logging::Severity::debug, &UnrealLogOutput);
@ -98,11 +101,6 @@ AGalavantUnrealMain::AGalavantUnrealMain()
}
InitializeProceduralWorld();
// This is a complete hack and should only be for Macoy's setup
// Scale everything (including the engine UI) to my DPI settings
// https://answers.unrealengine.com/questions/247475/why-would-setting-games-screen-resolution-in-gameu.html
FSlateApplication::Get().SetApplicationScale(1.53f);
}
void InitializeResources()
@ -332,6 +330,8 @@ void AGalavantUnrealMain::InitializeGalavant()
{
LOGI << "Initializing Galavant...";
gv::ResetGameplayTime();
InitializeProceduralWorld();
gv::WorldResourceLocator::ClearResources();
@ -348,16 +348,23 @@ void AGalavantUnrealMain::InitializeGalavant()
gv::g_EntityComponentManager.AddComponentManager(&gv::g_PlanComponentManager);
gv::g_EntityComponentManager.AddComponentManager(&g_UnrealMovementComponentManager);
g_UnrealMovementComponentManager.Initialize(GetWorld(), &TaskEventCallbacks);
// g_UnrealMovementComponentManager.DebugPrint = true;
// I've put this here only because of paranoia involving Unreal Play In Editor/hotreloading
gv::g_EntityComponentManager.ClearUnsubscribeOnlyManagers();
// Initialize managers
{
g_UnrealMovementComponentManager.Initialize(GetWorld(), &TaskEventCallbacks);
// g_UnrealMovementComponentManager.DebugPrint = true;
gv::g_PlanComponentManager.Initialize(&WorldStateManager, &TaskEventCallbacks);
// gv::g_PlanComponentManager.DebugPrint = true;
gv::g_PlanComponentManager.Initialize(&WorldStateManager, &TaskEventCallbacks);
// gv::g_PlanComponentManager.DebugPrint = true;
gv::g_AgentComponentManager.Initialize(&gv::g_PlanComponentManager);
gv::g_AgentComponentManager.DebugPrint = true;
gv::g_AgentComponentManager.Initialize(&gv::g_PlanComponentManager,
&g_UnrealMovementComponentManager);
gv::g_AgentComponentManager.DebugPrint = true;
gv::g_CombatComponentManager.Initialize(&CombatFxHandler);
gv::g_CombatComponentManager.Initialize(&CombatFxHandler);
}
}
// Initialize Tasks
@ -426,20 +433,28 @@ void AGalavantUnrealMain::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
UWorld* world = GetWorld();
g_UnrealMovementComponentManager.Initialize(world, &TaskEventCallbacks);
// Destroy entities now because Unreal might have destroyed actors, so we don't want our code to
// break not knowing that
gv::g_EntityComponentManager.DestroyEntitiesPendingDestruction();
GalavantMain.Update(DeltaTime);
if (gv::GameIsPlaying())
{
GalavantMain.Update(DeltaTime);
gv::g_CombatComponentManager.Update(DeltaTime);
gv::g_AgentComponentManager.Update(DeltaTime);
gv::g_PlanComponentManager.Update(DeltaTime);
g_UnrealMovementComponentManager.Update(DeltaTime);
}
else
{
//
// Paused
//
gv::g_CombatComponentManager.Update(DeltaTime);
gv::g_AgentComponentManager.Update(DeltaTime);
gv::g_PlanComponentManager.Update(DeltaTime);
g_UnrealMovementComponentManager.Update(DeltaTime);
// Exception: update UnrealMovementComponentManager because we want LOD etc. to work
g_UnrealMovementComponentManager.Update(0.f);
}
}
void AGalavantUnrealMain::EndPlay(const EEndPlayReason::Type EndPlayReason)
@ -452,9 +467,29 @@ void AGalavantUnrealMain::EndPlay(const EEndPlayReason::Type EndPlayReason)
gv::ResourceDictionaryBase::ClearAllDictionaries();
}
void AGalavantUnrealMain::PauseGalaUpdate(bool pause)
{
if (pause)
LOGI << "Pausing Galavant Update";
else
LOGI << "Resuming Galavant Update";
gv::GameSetPlaying(!pause);
}
void AGalavantUnrealMain::HighDPI()
{
// This is a complete hack and should only be for Macoy's setup
// Scale everything (including the engine UI) to my DPI settings
// https://answers.unrealengine.com/questions/247475/why-would-setting-games-screen-resolution-in-gameu.html
// Note that this breaks during cooking
FSlateApplication::Get().SetApplicationScale(1.53f);
}
// Latelinked functions
namespace gv
{
// @LatelinkDef
float GetWorldTime()
{
UWorld* world = GEngine->GetWorld();


+ 10
- 0
GalavantUnreal/Source/GalavantUnreal/GalavantUnrealMain.h View File

@ -87,4 +87,14 @@ public:
private:
void InitializeEntityTests();
void InitializeProceduralWorld();
//
// Commands
//
public:
UFUNCTION(Exec, Category = "Gala")
void PauseGalaUpdate(bool pause);
UFUNCTION(Exec, Category = "Gala")
void HighDPI();
};

Loading…
Cancel
Save