diff --git a/Config/DefaultEditorPerProjectUserSettings.ini b/Config/DefaultEditorPerProjectUserSettings.ini new file mode 100644 index 0000000..54117e8 --- /dev/null +++ b/Config/DefaultEditorPerProjectUserSettings.ini @@ -0,0 +1,10 @@ +[/Script/LiveCoding.LiveCodingSettings] +bEnabled=False +Startup=AutomaticButHidden +bEnableReinstancing=True +bAutomaticallyCompileNewClasses=True +bPreloadEngineModules=False +bPreloadEnginePluginModules=False +bPreloadProjectModules=True +bPreloadProjectPluginModules=True + diff --git a/Config/DefaultEngine.ini b/Config/DefaultEngine.ini index 9d29ed7..8fa97e0 100644 --- a/Config/DefaultEngine.ini +++ b/Config/DefaultEngine.ini @@ -4,6 +4,8 @@ GameDefaultMap=/Engine/Maps/Templates/OpenWorld EditorStartupMap=/Game/Levels/Test/L_Test.L_Test bUseSplitscreen=False +GlobalDefaultGameMode=/Game/Blueprints/GameModes/BP_MainGameMode.BP_MainGameMode_C +GameInstanceClass=/Game/Blueprints/Other/BP_CustomGameInstance.BP_CustomGameInstance_C [/Script/WindowsTargetPlatform.WindowsTargetSettings] DefaultGraphicsRHI=DefaultGraphicsRHI_DX12 @@ -55,6 +57,7 @@ CommandletClass=Class'/Script/UnrealEd.WorldPartitionConvertCommandlet' +ActiveGameNameRedirects=(OldGameName="TP_Blank",NewGameName="/Script/Lost_Edge") +ActiveGameNameRedirects=(OldGameName="/Script/TP_Blank",NewGameName="/Script/Lost_Edge") +ActiveClassRedirects=(OldClassName="TP_BlankGameModeBase",NewClassName="Lost_EdgeGameModeBase") +GameUserSettingsClassName=/Script/Lost_Edge.CustomGameUserSettings [/Script/AndroidFileServerEditor.AndroidFileServerRuntimeSettings] bEnablePlugin=True diff --git a/Config/DefaultGameUserSettings.ini b/Config/DefaultGameUserSettings.ini new file mode 100644 index 0000000..df3d264 --- /dev/null +++ b/Config/DefaultGameUserSettings.ini @@ -0,0 +1,35 @@ +[/Script/Lost_Edge.CustomGameUserSettings] +bUseMotionBlur=False +bShowFps=False +bMouseInverted=False +fMouseSensetivity=1.000000 +bUseVSync=False +bUseDynamicResolution=False +ResolutionSizeX=1920 +ResolutionSizeY=1080 +LastUserConfirmedResolutionSizeX=1920 +LastUserConfirmedResolutionSizeY=1080 +WindowPosX=-1 +WindowPosY=-1 +FullscreenMode=1 +LastConfirmedFullscreenMode=1 +PreferredFullscreenMode=1 +Version=5 +AudioQualityLevel=0 +LastConfirmedAudioQualityLevel=0 +FrameRateLimit=0.000000 +DesiredScreenWidth=1280 +DesiredScreenHeight=720 +LastUserConfirmedDesiredScreenWidth=1280 +LastUserConfirmedDesiredScreenHeight=720 +LastRecommendedScreenWidth=-1.000000 +LastRecommendedScreenHeight=-1.000000 +LastCPUBenchmarkResult=-1.000000 +LastGPUBenchmarkResult=-1.000000 +LastGPUBenchmarkMultiplier=1.000000 +bUseHDRDisplayOutput=False +HDRDisplayOutputNits=1000 + +[/Script/Engine.GameUserSettings] +bUseDesiredScreenHeight=False + diff --git a/Config/DefaultInput.ini b/Config/DefaultInput.ini index 717d0eb..411619e 100644 --- a/Config/DefaultInput.ini +++ b/Config/DefaultInput.ini @@ -67,6 +67,7 @@ bCaptureMouseOnLaunch=True bEnableLegacyInputScales=True bEnableMotionControls=True bFilterInputByPlatformUser=False +bEnableInputDeviceSubsystem=True bShouldFlushPressedKeysOnViewportFocusLost=True bEnableDynamicComponentInputBinding=True bAlwaysShowTouchInterface=False @@ -77,21 +78,6 @@ DefaultViewportMouseCaptureMode=CapturePermanently_IncludingInitialMouseDown DefaultViewportMouseLockMode=LockOnCapture FOVScale=0.011110 DoubleClickTime=0.200000 -+ActionMappings=(ActionName="Pause",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=Escape) -+ActionMappings=(ActionName="Pause",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=P) -+ActionMappings=(ActionName="Interact",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=E) -+ActionMappings=(ActionName="SkipAny",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=SpaceBar) -+ActionMappings=(ActionName="Run",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=LeftShift) -+ActionMappings=(ActionName="Jump",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=SpaceBar) -+ActionMappings=(ActionName="ChangeCamera",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=V) -+ActionMappings=(ActionName="Crouch",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=LeftControl) -+ActionMappings=(ActionName="Crouch",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=C) -+AxisMappings=(AxisName="RotateX",Scale=1.000000,Key=MouseX) -+AxisMappings=(AxisName="RotateY",Scale=-1.000000,Key=MouseY) -+AxisMappings=(AxisName="MoveFB",Scale=1.000000,Key=W) -+AxisMappings=(AxisName="MoveLR",Scale=1.000000,Key=A) -+AxisMappings=(AxisName="MoveFB",Scale=-1.000000,Key=S) -+AxisMappings=(AxisName="MoveLR",Scale=-1.000000,Key=D) DefaultPlayerInputClass=/Script/EnhancedInput.EnhancedPlayerInput DefaultInputComponentClass=/Script/EnhancedInput.EnhancedInputComponent DefaultTouchInterface=/Engine/MobileResources/HUD/DefaultVirtualJoysticks.DefaultVirtualJoysticks @@ -99,3 +85,15 @@ DefaultTouchInterface=/Engine/MobileResources/HUD/DefaultVirtualJoysticks.Defaul +ConsoleKeys=Tilde +ConsoleKeys=Caret +[/Script/EnhancedInput.EnhancedInputDeveloperSettings] +UserSettingsClass=/Script/EnhancedInput.EnhancedInputUserSettings +DefaultPlayerMappableKeyProfileClass=/Script/EnhancedInput.EnhancedPlayerMappableKeyProfile +DefaultWorldInputClass=/Script/EnhancedInput.EnhancedPlayerInput +bSendTriggeredEventsWhenInputIsFlushed=True +bEnableUserSettings=False +EnhancedInput.EnableDefaultMappingContexts=True +EnhancedInput.OnlyTriggerLastActionInChord=True +bLogOnDeprecatedConfigUsed=True +bEnableWorldSubsystem=False +EnhancedInput.bShouldLogAllWorldSubsystemInputs=False + diff --git a/Content/Blueprints/Characters/BP_CameraMode.uasset b/Content/Blueprints/Characters/BP_CameraMode.uasset new file mode 100644 index 0000000..538b093 Binary files /dev/null and b/Content/Blueprints/Characters/BP_CameraMode.uasset differ diff --git a/Content/Blueprints/Other/BP_CustomGameInstance.uasset b/Content/Blueprints/Other/BP_CustomGameInstance.uasset new file mode 100644 index 0000000..e20fab3 Binary files /dev/null and b/Content/Blueprints/Other/BP_CustomGameInstance.uasset differ diff --git a/Content/Fonts/FF_good_timing_bd_Raymond_Larabie_Font.uasset b/Content/Fonts/FF_good_timing_bd_Raymond_Larabie_Font.uasset new file mode 100644 index 0000000..add038d --- /dev/null +++ b/Content/Fonts/FF_good_timing_bd_Raymond_Larabie_Font.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6bf578d2c645a942eeb2e627d8b67c0c799ecb757ef323250b930836ca3186d8 +size 7342 diff --git a/Content/Fonts/FontFaces/FF_bowhouse_bold_Takuminokami.uasset b/Content/Fonts/FontFaces/FF_bowhouse_bold_Takuminokami.uasset new file mode 100644 index 0000000..7f3071d --- /dev/null +++ b/Content/Fonts/FontFaces/FF_bowhouse_bold_Takuminokami.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:df36743b386103100debd146f200c4cda21a18de2b56523bfa9654687aad0f05 +size 33709 diff --git a/Content/Fonts/FontFaces/FF_bowhouse_regular_Takuminokami.uasset b/Content/Fonts/FontFaces/FF_bowhouse_regular_Takuminokami.uasset new file mode 100644 index 0000000..ff3511b --- /dev/null +++ b/Content/Fonts/FontFaces/FF_bowhouse_regular_Takuminokami.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d01e0ec03b3c21a7683da2518554a8fa2167628bd0202a208626aa2d0d430908 +size 37751 diff --git a/Content/Fonts/FontFaces/FF_good_times_rg_Raymond_Larabie.uasset b/Content/Fonts/FontFaces/FF_good_times_rg_Raymond_Larabie.uasset new file mode 100644 index 0000000..dbc72a5 --- /dev/null +++ b/Content/Fonts/FontFaces/FF_good_times_rg_Raymond_Larabie.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e9f773c88c7f647472d23df3b04cdebf7982451b733fe834f1e36765e57739b6 +size 70103 diff --git a/Content/Fonts/FontFaces/FF_good_timing_bd_Raymond_Larabie.uasset b/Content/Fonts/FontFaces/FF_good_timing_bd_Raymond_Larabie.uasset new file mode 100644 index 0000000..bb91888 --- /dev/null +++ b/Content/Fonts/FontFaces/FF_good_timing_bd_Raymond_Larabie.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f4d1db4ea87791c0a489e55c698262a7a0a3f91d2f4a1af580c9568a3037fffc +size 184649 diff --git a/Content/Fonts/FontFaces/FF_good_timing_bd_Raymond_Larabie_original.uasset b/Content/Fonts/FontFaces/FF_good_timing_bd_Raymond_Larabie_original.uasset new file mode 100644 index 0000000..250beb1 --- /dev/null +++ b/Content/Fonts/FontFaces/FF_good_timing_bd_Raymond_Larabie_original.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:efb64586ed1724c6458273998c6b4c8603a31f30aefee5e6ae6191b7c78d1a49 +size 149207 diff --git a/Content/Fonts/FontFaces/FF_primer_print_Raymond_Larabie.uasset b/Content/Fonts/FontFaces/FF_primer_print_Raymond_Larabie.uasset new file mode 100644 index 0000000..cc265bb --- /dev/null +++ b/Content/Fonts/FontFaces/FF_primer_print_Raymond_Larabie.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0b90f896fbdebbda10b76c30e8e5041c1f5f08cf629da632fc210453cb9f9ea7 +size 97813 diff --git a/Content/Fonts/FontFaces/FF_primer_print_bold_Raymond_Larabie.uasset b/Content/Fonts/FontFaces/FF_primer_print_bold_Raymond_Larabie.uasset new file mode 100644 index 0000000..4e5a1bf --- /dev/null +++ b/Content/Fonts/FontFaces/FF_primer_print_bold_Raymond_Larabie.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:41b92f05ad499796192ea75208b8b61b58ba1a8a90b2924234c044d6bd229492 +size 98143 diff --git a/Content/Fonts/Font_bowhouse_bold_Takuminokami_Font.uasset b/Content/Fonts/Font_bowhouse_bold_Takuminokami_Font.uasset new file mode 100644 index 0000000..6ac2e66 --- /dev/null +++ b/Content/Fonts/Font_bowhouse_bold_Takuminokami_Font.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c4ff497a0db7d4554b0df323a178fb855ed62fd5446afd5900c331e8a542e15f +size 7478 diff --git a/Content/Fonts/Font_bowhouse_regular_Takuminokami_Font.uasset b/Content/Fonts/Font_bowhouse_regular_Takuminokami_Font.uasset new file mode 100644 index 0000000..4b63479 --- /dev/null +++ b/Content/Fonts/Font_bowhouse_regular_Takuminokami_Font.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2c472eabd5fbc0ff109a0436eaccc036bb49e5c793ec0d49a83b105bbcc71e01 +size 7402 diff --git a/Content/Fonts/Font_good_times_rg_Raymond_Larabie_Font.uasset b/Content/Fonts/Font_good_times_rg_Raymond_Larabie_Font.uasset new file mode 100644 index 0000000..0165afa --- /dev/null +++ b/Content/Fonts/Font_good_times_rg_Raymond_Larabie_Font.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:18c5cf58aa5e5a5d8e57477750e9516f7ba40ffac949364cabb01a56a4c6a126 +size 7036 diff --git a/Content/Fonts/Font_good_timing_bd_Raymond_Larabie_Font_original.uasset b/Content/Fonts/Font_good_timing_bd_Raymond_Larabie_Font_original.uasset new file mode 100644 index 0000000..3326b28 --- /dev/null +++ b/Content/Fonts/Font_good_timing_bd_Raymond_Larabie_Font_original.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5cc15af5940879837bd0c33b2a50b7e6d7ea4e03c54da3de388dda101f425e55 +size 7130 diff --git a/Content/Fonts/Font_primer_print_Raymond_Larabie_Font.uasset b/Content/Fonts/Font_primer_print_Raymond_Larabie_Font.uasset new file mode 100644 index 0000000..f6cb0c9 --- /dev/null +++ b/Content/Fonts/Font_primer_print_Raymond_Larabie_Font.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0b018f17ce28f5de3be9564c385f08b54af766ad0fe1ce7dd9438808078d909f +size 7015 diff --git a/Content/Fonts/Font_primer_print_bold_Raymond_Larabie_Font.uasset b/Content/Fonts/Font_primer_print_bold_Raymond_Larabie_Font.uasset new file mode 100644 index 0000000..ede60eb --- /dev/null +++ b/Content/Fonts/Font_primer_print_bold_Raymond_Larabie_Font.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:78f49dfdbd643b1bba6111b5e4f48eb71338346baddae9deb55b089fa4c11c4d +size 6953 diff --git a/Content/Input/Actions/IA_FlyUpDown.uasset b/Content/Input/Actions/IA_FlyUpDown.uasset new file mode 100644 index 0000000..68823e1 Binary files /dev/null and b/Content/Input/Actions/IA_FlyUpDown.uasset differ diff --git a/Content/Input/Actions/IA_Interact.uasset b/Content/Input/Actions/IA_Interact.uasset new file mode 100644 index 0000000..7b8d0df Binary files /dev/null and b/Content/Input/Actions/IA_Interact.uasset differ diff --git a/Content/Input/Actions/IA_Jump.uasset b/Content/Input/Actions/IA_Jump.uasset new file mode 100644 index 0000000..78c440e Binary files /dev/null and b/Content/Input/Actions/IA_Jump.uasset differ diff --git a/Content/Input/Actions/IA_Look.uasset b/Content/Input/Actions/IA_Look.uasset new file mode 100644 index 0000000..3f2a0f2 Binary files /dev/null and b/Content/Input/Actions/IA_Look.uasset differ diff --git a/Content/Input/Actions/IA_Move.uasset b/Content/Input/Actions/IA_Move.uasset new file mode 100644 index 0000000..b0d4875 Binary files /dev/null and b/Content/Input/Actions/IA_Move.uasset differ diff --git a/Content/Input/Actions/IA_Run.uasset b/Content/Input/Actions/IA_Run.uasset new file mode 100644 index 0000000..3c79f7d Binary files /dev/null and b/Content/Input/Actions/IA_Run.uasset differ diff --git a/Content/Input/Actions/IA_TurnCameraMode.uasset b/Content/Input/Actions/IA_TurnCameraMode.uasset new file mode 100644 index 0000000..1f767f3 Binary files /dev/null and b/Content/Input/Actions/IA_TurnCameraMode.uasset differ diff --git a/Content/Input/IMC_CameraMode.uasset b/Content/Input/IMC_CameraMode.uasset new file mode 100644 index 0000000..2ebeb94 Binary files /dev/null and b/Content/Input/IMC_CameraMode.uasset differ diff --git a/Content/Input/IMC_Player.uasset b/Content/Input/IMC_Player.uasset new file mode 100644 index 0000000..6854026 Binary files /dev/null and b/Content/Input/IMC_Player.uasset differ diff --git a/Content/Models/GrayBoxes/Materials/M_Gray.uasset b/Content/Models/GrayBoxes/Materials/M_Gray.uasset new file mode 100644 index 0000000..a00de76 --- /dev/null +++ b/Content/Models/GrayBoxes/Materials/M_Gray.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:95b9efa07fc804a8c003ed60df522c3a3fa934d624bb5c64fce260edb58fa264 +size 93099 diff --git a/Lost_Edge.uproject b/Lost_Edge.uproject index c474c31..0f253f9 100644 --- a/Lost_Edge.uproject +++ b/Lost_Edge.uproject @@ -1,13 +1,16 @@ { "FileVersion": 3, - "EngineAssociation": "5.3", + "EngineAssociation": "{1596D39D-4A14-8FE8-BC5C-21A6B54321BE}", "Category": "", "Description": "", "Modules": [ { "Name": "Lost_Edge", "Type": "Runtime", - "LoadingPhase": "Default" + "LoadingPhase": "Default", + "AdditionalDependencies": [ + "Engine" + ] } ], "Plugins": [ diff --git a/Source/Lost_Edge/Private/APlayerBase.cpp b/Source/Lost_Edge/Private/APlayerBase.cpp index 918e6f5..845fa6e 100644 --- a/Source/Lost_Edge/Private/APlayerBase.cpp +++ b/Source/Lost_Edge/Private/APlayerBase.cpp @@ -3,11 +3,13 @@ #include "APlayerBase.h" +#include "Camera/CameraComponent.h" #include "CustomGameUserSettings.h" #include "EnhancedInputSubsystems.h" #include "GameFramework/CharacterMovementComponent.h" #include "Kismet/GameplayStatics.h" #include "Kismet/KismetMathLibrary.h" +#include "MainGameModeBase.h" APlayerBase::APlayerBase() { @@ -34,12 +36,6 @@ void APlayerBase::BeginPlay() camera->PostProcessSettings.MotionBlurAmount = gameSettings->bUseMotionBlur ? 1.0f : 0.0f; } - if(gameSettings->bShowFps) - world->Exec(world, TEXT("show stats")); - - mouseInvert = gameSettings->bMouseInverted; - mouseSensetivity = gameSettings->GetMouseSensetivity(); - if(inputMapping) { if(auto player = Cast(GetController())) @@ -47,7 +43,7 @@ void APlayerBase::BeginPlay() if(auto inputSubsystem = ULocalPlayer::GetSubsystem(player->GetLocalPlayer())) { inputSubsystem->ClearAllMappings(); - inputSubsystem->AddMappingContext(inputMapping, 0); + inputSubsystem->AddMappingContext(inputMapping.LoadSynchronous(), 0); } } } @@ -65,7 +61,17 @@ void APlayerBase::Tick(float DeltaTime) void APlayerBase::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent) { Super::SetupPlayerInputComponent(PlayerInputComponent); +} +void APlayerBase::SwitchToCameraPawn() +{ + if(auto gamemode_base = UGameplayStatics::GetGameMode(GetWorld())) + { + if(auto gamemode = Cast(gamemode_base)) + { + gamemode->SwitchCameraMode(); + } + } } void APlayerBase::MoveCamera(FVector2D value) @@ -73,11 +79,6 @@ void APlayerBase::MoveCamera(FVector2D value) if(cameraLocked) return; - if(mouseInvert) - value.Y *= -1; - - value *= mouseSensetivity; - AddControllerYawInput(value.X); AddControllerPitchInput(value.Y); } diff --git a/Source/Lost_Edge/Private/APlayerBase.h b/Source/Lost_Edge/Private/APlayerBase.h index d337945..d66c6cf 100644 --- a/Source/Lost_Edge/Private/APlayerBase.h +++ b/Source/Lost_Edge/Private/APlayerBase.h @@ -2,7 +2,6 @@ #pragma once -#include "Camera/CameraComponent.h" #include "CoreMinimal.h" #include "GameFramework/Character.h" #include "InputMappingContext.h" @@ -18,12 +17,14 @@ public: APlayerBase(); virtual void Tick(float DeltaTime) override; - virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override; protected: virtual void BeginPlay() override; + UFUNCTION(BlueprintCallable, Category = CameraMode) + void SwitchToCameraPawn(); + UFUNCTION(BlueprintCallable, Category = Character) void MoveCamera(FVector2D value); UFUNCTION(BlueprintCallable, Category = Character) @@ -33,7 +34,7 @@ protected: void SwitchRun(bool run); UPROPERTY(EditDefaultsOnly) - UInputMappingContext* inputMapping; + TSoftObjectPtr inputMapping; UPROPERTY(EditDefaultsOnly) float moveSpeed = 200; @@ -55,9 +56,6 @@ protected: // not visible :( //UPROPERTY(EditDefaultsOnly) //UCameraComponent* camera; - - bool mouseInvert = false; - float mouseSensetivity = 1.0f; UPROPERTY(EditAnywhere) bool cameraLocked = false; diff --git a/Source/Lost_Edge/Private/CameraModeBase.cpp b/Source/Lost_Edge/Private/CameraModeBase.cpp new file mode 100644 index 0000000..de81cfa --- /dev/null +++ b/Source/Lost_Edge/Private/CameraModeBase.cpp @@ -0,0 +1,85 @@ +// Oleg Petruny proprietary. + + +#include "CameraModeBase.h" + +#include "Camera/CameraComponent.h" +#include "CustomGameUserSettings.h" +#include "EnhancedInputSubsystems.h" +#include "GameFramework/Character.h" +#include "GameFramework/PawnMovementComponent.h" +#include "Kismet/GameplayStatics.h" +#include "MainGameModeBase.h" + +ACameraModeBase::ACameraModeBase() +{ + PrimaryActorTick.bCanEverTick = true; + +} + +void ACameraModeBase::BeginPlay() +{ + Super::BeginPlay(); + + auto world = GetWorld(); + + //GetMovementComponent()->speed + // GetCharacterMovement()->MaxWalkSpeed = moveSpeed; + + auto gameSettings = UCustomGameUserSettings::GetCustomGameUserSettings(); + + if(auto camera = FindComponentByClass()) + { + camera->PostProcessSettings.MotionBlurAmount = gameSettings->bUseMotionBlur ? 1.0f : 0.0f; + } + + if(inputMapping) + { + if(auto player = Cast(GetController())) + { + if(auto inputSubsystem = ULocalPlayer::GetSubsystem(player->GetLocalPlayer())) + { + inputSubsystem->ClearAllMappings(); + inputSubsystem->AddMappingContext(inputMapping.LoadSynchronous(), 0); + } + } + } + +} + +void ACameraModeBase::Tick(float DeltaTime) +{ + Super::Tick(DeltaTime); + + // stabilize move speed by fps + AddActorLocalOffset(ConsumeMovementInputVector() * DeltaTime); +} + +void ACameraModeBase::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent) +{ + Super::SetupPlayerInputComponent(PlayerInputComponent); +} + +void ACameraModeBase::SwitchToPlayerPawn() +{ + if(auto gamemode_base = UGameplayStatics::GetGameMode(GetWorld())) + { + if(auto gamemode = Cast(gamemode_base)) + { + gamemode->SwitchCameraMode(); + } + } +} + +void ACameraModeBase::ElevatePawn(float value) +{ + AddMovementInput(FVector::UpVector, value); +} + +void ACameraModeBase::SwitchRun(bool run) +{ + //if(run) + // GetMovement()->MaxWalkSpeed = moveSpeed * runSpeedMultiplier; + //else + // GetCharacterMovement()->MaxWalkSpeed = moveSpeed; +} \ No newline at end of file diff --git a/Source/Lost_Edge/Private/CameraModeBase.h b/Source/Lost_Edge/Private/CameraModeBase.h new file mode 100644 index 0000000..71d61da --- /dev/null +++ b/Source/Lost_Edge/Private/CameraModeBase.h @@ -0,0 +1,43 @@ +// Oleg Petruny proprietary. + +#pragma once + +#include "CoreMinimal.h" +#include "GameFramework/SpectatorPawn.h" +#include "InputMappingContext.h" + +#include "CameraModeBase.generated.h" + +UCLASS() +class ACameraModeBase : public ASpectatorPawn +{ + GENERATED_BODY() + +public: + ACameraModeBase(); + + virtual void Tick(float DeltaTime) override; + virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override; + +protected: + virtual void BeginPlay() override; + + UFUNCTION(BlueprintCallable, Category = CameraMode) + void SwitchToPlayerPawn(); + + UFUNCTION(BlueprintCallable, Category = Pawn) + void ElevatePawn(float value); + UFUNCTION(BlueprintCallable, Category = Pawn) + void SwitchRun(bool run); + + UPROPERTY(EditDefaultsOnly) + TSoftObjectPtr inputMapping; + + UPROPERTY(EditDefaultsOnly) + float moveSpeed = 200; + UPROPERTY(EditDefaultsOnly) + float runSpeedMultiplier = 4; + +private: + +}; diff --git a/Source/Lost_Edge/Private/CustomGameInstanceBase.cpp b/Source/Lost_Edge/Private/CustomGameInstanceBase.cpp new file mode 100644 index 0000000..034485c --- /dev/null +++ b/Source/Lost_Edge/Private/CustomGameInstanceBase.cpp @@ -0,0 +1,43 @@ +// Oleg Petruny proprietary. + + +#include "CustomGameInstanceBase.h" + +#include "CustomGameUserSettings.h" +#include "EnhancedInputLibrary.h" + +void UCustomGameInstanceBase::Init() +{ + //Super::Init(); + + ApplyMouseSettings(); +} + +void UCustomGameInstanceBase::ApplyMouseSettings() +{ + if(auto gameSettings = UCustomGameUserSettings::GetCustomGameUserSettings()) + { + for(auto context_it = defaultInputContexts.begin(); context_it != defaultInputContexts.end(); ++context_it) + { + auto& mappings = (*context_it).LoadSynchronous()->GetMappings(); + for(auto mapping_it = mappings.begin(); mapping_it != mappings.end(); ++mapping_it) + { + if((*mapping_it).Key == EKeys::Mouse2D) + { + for(auto modifiers_it = (*mapping_it).Modifiers.begin(); modifiers_it != (*mapping_it).Modifiers.end(); ++modifiers_it) + { + if(auto negate_modifier = Cast(*modifiers_it)) + { + negate_modifier->bY = !gameSettings->bMouseInverted; + } + if(auto scalar_modifier = Cast(*modifiers_it)) + { + scalar_modifier->Scalar = FVector{ gameSettings->GetMouseSensetivity() }; + } + } + } + } + UEnhancedInputLibrary::RequestRebuildControlMappingsUsingContext((*context_it).LoadSynchronous()); + } + } +} \ No newline at end of file diff --git a/Source/Lost_Edge/Private/CustomGameInstanceBase.h b/Source/Lost_Edge/Private/CustomGameInstanceBase.h new file mode 100644 index 0000000..6884b4f --- /dev/null +++ b/Source/Lost_Edge/Private/CustomGameInstanceBase.h @@ -0,0 +1,25 @@ +// Oleg Petruny proprietary. + +#pragma once + +#include "CoreMinimal.h" +#include "Engine/GameInstance.h" +#include "InputMappingContext.h" + +#include "CustomGameInstanceBase.generated.h" + +UCLASS() +class UCustomGameInstanceBase : public UGameInstance +{ + GENERATED_BODY() + +public: + virtual void Init() override; + + UFUNCTION(BlueprintCallable, Category = Settings) + void ApplyMouseSettings(); + +protected: + UPROPERTY(EditDefaultsOnly) + TArray> defaultInputContexts; +}; diff --git a/Source/Lost_Edge/Private/CustomGameUserSettings.cpp b/Source/Lost_Edge/Private/CustomGameUserSettings.cpp index f0e5d74..7f31e74 100644 --- a/Source/Lost_Edge/Private/CustomGameUserSettings.cpp +++ b/Source/Lost_Edge/Private/CustomGameUserSettings.cpp @@ -1,7 +1,11 @@ // Oleg Petruny proprietary. + #include "CustomGameUserSettings.h" +#include "CustomGameInstanceBase.h" +#include "Kismet/GameplayStatics.h" + UCustomGameUserSettings::UCustomGameUserSettings(const FObjectInitializer& ObjectInitializer) :Super(ObjectInitializer) { bUseMotionBlur = false; diff --git a/Source/Lost_Edge/Private/CustomGameUserSettings.h b/Source/Lost_Edge/Private/CustomGameUserSettings.h index a65fb5f..6400696 100644 --- a/Source/Lost_Edge/Private/CustomGameUserSettings.h +++ b/Source/Lost_Edge/Private/CustomGameUserSettings.h @@ -7,9 +7,6 @@ #include "CustomGameUserSettings.generated.h" -/** - * - */ UCLASS() class UCustomGameUserSettings : public UGameUserSettings { @@ -28,17 +25,17 @@ public: UFUNCTION(BlueprintCallable, Category = Settings) float GetMouseSensetivity() const; - UPROPERTY(config) + UPROPERTY(Config, BlueprintReadWrite) bool bUseMotionBlur; - UPROPERTY(config) + UPROPERTY(Config, BlueprintReadWrite) bool bShowFps; - UPROPERTY(config) + UPROPERTY(Config, BlueprintReadWrite) bool bMouseInverted; protected: - UPROPERTY(config) + UPROPERTY(Config) float fMouseSensetivity; }; diff --git a/Source/Lost_Edge/Private/MainGameModeBase.cpp b/Source/Lost_Edge/Private/MainGameModeBase.cpp new file mode 100644 index 0000000..cdd4fbf --- /dev/null +++ b/Source/Lost_Edge/Private/MainGameModeBase.cpp @@ -0,0 +1,41 @@ +// Oleg Petruny proprietary. + + +#include "MainGameModeBase.h" + +#include "Engine/World.h" +#include "GameFramework/SpectatorPawn.h" +#include "Kismet/GameplayStatics.h" + +void AMainGameModeBase::SwitchCameraMode() +{ + if(!_player_pawn) + { + if(auto controller = UGameplayStatics::GetPlayerController(GetWorld(), 0)) + { + if(auto pawn = controller->GetPawn()) + { + auto spawnLoc = pawn->GetActorLocation(); + auto spawnRot = pawn->GetActorRotation(); + if(auto cameraPawn = GetWorld()->SpawnActor(SpectatorClass, spawnLoc, spawnRot)) + { + _player_pawn = pawn; + controller->Possess(cameraPawn); + cameraPawn->BeginPlay(); + } + } + } + } + else + { + if(auto controller = UGameplayStatics::GetPlayerController(GetWorld(), 0)) + { + if(auto pawn = controller->GetPawn()) + { + controller->Possess(_player_pawn); + pawn->Destroy(); + } + } + } + +} \ No newline at end of file diff --git a/Source/Lost_Edge/Private/MainGameModeBase.h b/Source/Lost_Edge/Private/MainGameModeBase.h new file mode 100644 index 0000000..caf2255 --- /dev/null +++ b/Source/Lost_Edge/Private/MainGameModeBase.h @@ -0,0 +1,23 @@ +// Oleg Petruny proprietary. + +#pragma once + +#include "CoreMinimal.h" +#include "GameFramework/GameModeBase.h" +#include "GameFramework/Pawn.h" + +#include "MainGameModeBase.generated.h" + +UCLASS() +class AMainGameModeBase : public AGameModeBase +{ + GENERATED_BODY() + +public: + void SwitchCameraMode(); + +protected: + +private: + APawn* _player_pawn = nullptr; +};