Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified Content/G2I_Game/Core/Controllers/BP_PlayerController.uasset
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified Content/G2I_Game/Core/Input/IMC_Characters.uasset
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
26 changes: 26 additions & 0 deletions Source/G2I/Private/Characters/G2ICharacterDaughter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@
#include "G2I.h"
#include "G2IFlightComponent.h"
#include "Engine/LocalPlayer.h"
#include "Game/G2IPlayerState.h"
#include "Components/Camera/G2IThirdPersonCameraComponent.h"
#include "Components/G2ICharacterMovementComponent.h"
#include "Components/G2IInteractionComponent.h"
#include "Components/G2ICharacterCollisionComponent.h"
#include "Components/Camera/G2ICameraControllerComponent.h"
#include "Components/Camera/G2IFixedCamerasComponent.h"
#include "Components/G2IInventoryComponent.h"
#include <InputActionValue.h>

AG2ICharacterDaughter::AG2ICharacterDaughter(const FObjectInitializer& ObjectInitializer)
: ACharacter(ObjectInitializer.SetDefaultSubobjectClass<UG2ICharacterMovementComponent>(
Expand Down Expand Up @@ -69,3 +71,27 @@ FUnPossessedDelegate& AG2ICharacterDaughter::GetUnPossessedDelegate()
{
return OnUnPossessedDelegate;
}

void AG2ICharacterDaughter::SaveData_Implementation(UG2IGameplaySaveGame* SaveGameRef)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Либо проверить SaveGameRef на nullptr
Либо передавать в функцию ссылку, а не указатель

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GameInstance не будет вызывать эти функции, если SaveGame == nullptr.
но могу поменять на ссылку

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Лучше проверку всё же сделать, или на ссылку поменять

{
if (IsPlayerControlled())
{
SaveGameRef->PlayersSaveData.CurrentCharacter = GetClass();
}

SaveGameRef->PlayersSaveData.CharactersTransform.Add(GetClass(), GetTransform());
}

void AG2ICharacterDaughter::LoadData_Implementation(const UG2IGameplaySaveGame* SaveGameRef)
{
if (IsPlayerControlled() && !this->IsA(SaveGameRef->PlayersSaveData.CurrentCharacter))
{
if (auto* G2IPlayerState = Cast<AG2IPlayerState>(GetPlayerState()))
{
G2IPlayerState->SelectNextCharacter();
}
}

if (auto* KeyTransform = SaveGameRef->PlayersSaveData.CharactersTransform.Find(GetClass()))
SetActorTransform(*KeyTransform);
}
27 changes: 26 additions & 1 deletion Source/G2I/Private/Characters/G2ICharacterEngineer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "Components/SteamGlove/G2ISteamGloveComponent.h"
#include "Components/Camera/G2ICameraControllerComponent.h"
#include "Components/Camera/G2IFixedCamerasComponent.h"
#include "Game/G2IPlayerState.h"
#include "GameFramework/Controller.h"
#include "Engine/World.h"
#include "G2I.h"
Expand Down Expand Up @@ -59,4 +60,28 @@ FPossessedDelegate& AG2ICharacterEngineer::GetPossessedDelegate()
FUnPossessedDelegate& AG2ICharacterEngineer::GetUnPossessedDelegate()
{
return OnUnPossessedDelegate;
}
}

void AG2ICharacterEngineer::SaveData_Implementation(UG2IGameplaySaveGame* SaveGameRef)
{
if (IsPlayerControlled())
{
SaveGameRef->PlayersSaveData.CurrentCharacter = GetClass();
}

SaveGameRef->PlayersSaveData.CharactersTransform.Add(GetClass(), GetTransform());
}

void AG2ICharacterEngineer::LoadData_Implementation(const UG2IGameplaySaveGame* SaveGameRef)
{
if (IsPlayerControlled() && !this->IsA(SaveGameRef->PlayersSaveData.CurrentCharacter))
{
if (auto* G2IPlayerState = Cast<AG2IPlayerState>(GetPlayerState()))
{
G2IPlayerState->SelectNextCharacter();
}
}

if (auto* KeyTransform = SaveGameRef->PlayersSaveData.CharactersTransform.Find(GetClass()))
SetActorTransform(*KeyTransform);
}
56 changes: 44 additions & 12 deletions Source/G2I/Private/Controls/G2IPlayerController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "G2ISteamMovementInputInterface.h"
#include "G2ISteamShotInputInterface.h"
#include "G2IUIManager.h"
#include "G2ISavingGameplayManager.h"
#include "Kismet/KismetSystemLibrary.h"

void AG2IPlayerController::SetupInputComponent()
Expand Down Expand Up @@ -77,6 +78,10 @@ void AG2IPlayerController::SetupInputComponent()
EnhancedInputComponent->BindAction(PauseAction, ETriggerEvent::Started,this, &ThisClass::CallPause);

EnhancedInputComponent->BindAction(GlovePunchAction, ETriggerEvent::Started, this, &ThisClass::GlovePunchActivation);
#if WITH_EDITOR
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Думаю, может issue сделать
Чтобы для дебажных кнопок был отдельный input maping context?
Для лучшей читаемости
Что думаешь?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

кстати можно!
но не будет ли эта таска отложена на потом и по итогу никогда не сделана тк не хватит на нее времени?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Конечно, будет)

EnhancedInputComponent->BindAction(SaveAction, ETriggerEvent::Triggered, this, &ThisClass::SaveGameplay);
EnhancedInputComponent->BindAction(LoadAction, ETriggerEvent::Triggered, this, &ThisClass::LoadGameplay);
#endif
}
else
{
Expand Down Expand Up @@ -389,27 +394,18 @@ void AG2IPlayerController::Fly(int Direction)
{
IG2IFlightInterface::Execute_Fly(FlightComponent, MovementComponent, Direction);
}
else
{
UE_LOG(LogG2I, Log, TEXT("Pawn doesn't have component with fly interface in %s"), *GetName());
UE_LOG(LogG2I, Log, TEXT("Pawn doesn't have component with movement interface in %s"), *GetName());
}
}

void AG2IPlayerController::Jump(const FInputActionValue& Value)
{
if (!FlightComponent)
{
UE_LOG(LogG2I, Log, TEXT("Pawn doesn't have component with fly interface in %s"), *GetName());
}
else
if (FlightComponent)
{
return;
}

if (!ensure(MovementComponent))
{
UE_LOG(LogG2I, Warning, TEXT("Pawn doesn't have component with movement interface in %s"), *GetName());
UE_LOG(LogG2I, Warning, TEXT("Pawn doesn't have movement component in %s"), *GetName());
return;
}

Expand Down Expand Up @@ -567,4 +563,40 @@ void AG2IPlayerController::ToggleFollowAIBehindPlayer(const FInputActionValue& V
void AG2IPlayerController::GlovePunchActivation(const FInputActionInstance& Instance)
{
IG2IGlovePunchInterface::Execute_GlovePunchActivation(GlovePunchComponent);
}
}

#if WITH_EDITOR
void AG2IPlayerController::SaveGameplay(const FInputActionValue& Value)
{
if (auto* GameInstance = GetGameInstance())
{

if (UG2ISavingGameplayManager* SavingGameplayManager = GameInstance->GetSubsystem<UG2ISavingGameplayManager>())
{
SavingGameplayManager->SaveAllDataAndGameplay(true);
}
else
{
UE_LOG(LogG2I, Warning, TEXT("Couldn't get SavingGameplayManager subsystem from GameInstance in %s."), *GetName());
return;
}
}
}

void AG2IPlayerController::LoadGameplay(const FInputActionValue& Value)
{
if (auto* GameInstance = GetGameInstance())
{
if (UG2ISavingGameplayManager* SavingGameplayManager = GameInstance->GetSubsystem<UG2ISavingGameplayManager>())
{
SavingGameplayManager->LoadGameplay(false);
SavingGameplayManager->LoadAllData();
}
else
{
UE_LOG(LogG2I, Warning, TEXT("Couldn't get SavingGameplayManager subsystem from GameInstance in %s."), *GetName());
return;
}
}
}
#endif
1 change: 1 addition & 0 deletions Source/G2I/Private/Game/G2IGameInstance.cpp
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
#include "G2IGameInstance.h"
#include "G2I.h"
Loading