Added Weapons to Save System

This commit is contained in:
Rafal Swierczek 2024-02-02 03:46:50 +00:00
parent ca6dc22109
commit 2364873041
8 changed files with 81 additions and 27 deletions

View File

@ -8,14 +8,13 @@
</component> </component>
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="8acc2658-cb31-4c49-857f-282cfee74640" name="Changes" comment=""> <list default="true" id="8acc2658-cb31-4c49-857f-282cfee74640" name="Changes" comment="">
<change afterPath="$PROJECT_DIR$/Content/BountySystem/ApartmentBounty/BP_Elevator.uasset" afterDir="false" /> <change beforePath="$PROJECT_DIR$/.idea/.idea.EndlessVendetta/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/.idea.EndlessVendetta/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Content/FirstPerson/Blueprints/BP_FirstPersonCharacter.uasset" beforeDir="false" afterPath="$PROJECT_DIR$/Content/FirstPerson/Blueprints/BP_FirstPersonCharacter.uasset" afterDir="false" /> <change beforePath="$PROJECT_DIR$/Content/FirstPerson/Blueprints/BP_FirstPersonCharacter.uasset" beforeDir="false" afterPath="$PROJECT_DIR$/Content/FirstPerson/Blueprints/BP_FirstPersonCharacter.uasset" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Content/Levels/Apartment_hit.umap" beforeDir="false" afterPath="$PROJECT_DIR$/Content/Levels/Apartment_hit.umap" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Content/Levels/MainMenuLevel.umap" beforeDir="false" afterPath="$PROJECT_DIR$/Content/Levels/MainMenuLevel.umap" afterDir="false" /> <change beforePath="$PROJECT_DIR$/Content/Levels/MainMenuLevel.umap" beforeDir="false" afterPath="$PROJECT_DIR$/Content/Levels/MainMenuLevel.umap" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Content/StarterContent/Architecture/Floor_400x400.uasset" beforeDir="false" afterPath="$PROJECT_DIR$/Content/StarterContent/Architecture/Floor_400x400.uasset" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Content/StarterContent/Audio/Collapse01.uasset" beforeDir="false" afterPath="$PROJECT_DIR$/Content/StarterContent/Audio/Collapse01.uasset" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Content/StarterContent/Blueprints/Blueprint_CeilingLight.uasset" beforeDir="false" afterPath="$PROJECT_DIR$/Content/StarterContent/Blueprints/Blueprint_CeilingLight.uasset" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Content/StarterContent/HDRI/HDRI_Epic_Courtyard_Daylight.uasset" beforeDir="false" afterPath="$PROJECT_DIR$/Content/StarterContent/HDRI/HDRI_Epic_Courtyard_Daylight.uasset" afterDir="false" /> <change beforePath="$PROJECT_DIR$/Content/StarterContent/HDRI/HDRI_Epic_Courtyard_Daylight.uasset" beforeDir="false" afterPath="$PROJECT_DIR$/Content/StarterContent/HDRI/HDRI_Epic_Courtyard_Daylight.uasset" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Content/StarterContent/Particles/P_Ambient_Dust.uasset" beforeDir="false" afterPath="$PROJECT_DIR$/Content/StarterContent/Particles/P_Ambient_Dust.uasset" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Source/EndlessVendetta/EndlessVendettaCharacter.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/Source/EndlessVendetta/EndlessVendettaCharacter.cpp" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Source/EndlessVendetta/MainSaveGameClass.h" beforeDir="false" afterPath="$PROJECT_DIR$/Source/EndlessVendetta/MainSaveGameClass.h" afterDir="false" />
</list> </list>
<option name="SHOW_DIALOG" value="false" /> <option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" /> <option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -59,7 +58,7 @@
] ]
} }
}</component> }</component>
<component name="RunManager"> <component name="RunManager" selected="C++ Project.EndlessVendetta">
<configuration name="EndlessVendetta" type="CppProject" factoryName="C++ Project"> <configuration name="EndlessVendetta" type="CppProject" factoryName="C++ Project">
<configuration_1> <configuration_1>
<option name="CONFIGURATION" value="DebugGame Editor" /> <option name="CONFIGURATION" value="DebugGame Editor" />
@ -139,13 +138,23 @@
<workItem from="1706626387819" duration="5432000" /> <workItem from="1706626387819" duration="5432000" />
<workItem from="1706711852868" duration="19944000" /> <workItem from="1706711852868" duration="19944000" />
<workItem from="1706799696925" duration="11011000" /> <workItem from="1706799696925" duration="11011000" />
<workItem from="1706838825990" duration="646000" /> <workItem from="1706838825990" duration="4397000" />
</task> </task>
<servers /> <servers />
</component> </component>
<component name="TypeScriptGeneratedFilesManager"> <component name="TypeScriptGeneratedFilesManager">
<option name="version" value="3" /> <option name="version" value="3" />
</component> </component>
<component name="UnitTestsCoverage.Settings">
<option name="coveragePercentColumnWidth" value="150" />
<option name="sortOrder" value="DESCENDING" />
<option name="sortedColumn" value="1" />
<option name="symbolColumnWidth" value="346" />
<coverage-tree-state>
<expand />
<select />
</coverage-tree-state>
</component>
<component name="VcsManagerConfiguration"> <component name="VcsManagerConfiguration">
<option name="CLEAR_INITIAL_COMMIT_MESSAGE" value="true" /> <option name="CLEAR_INITIAL_COMMIT_MESSAGE" value="true" />
</component> </component>

View File

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:f147d5f0aa2007afc8217367dae73fc3253c6769d2eef3aa85ca322865f9ebe8 oid sha256:2c7bbe0e841e41f594ccb33dfaa31a8d80c43cf21a86cddb92bf0c665b214cec
size 458476 size 457638

View File

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:fca5db6a6d4564927237fbb2b9912ac9d1a54605ef884b185ab519358657fba4 oid sha256:215612d6840204435d8e381bb7fef7ae045f523adc98458ea1af9923b8a398ab
size 299618 size 299666

View File

@ -0,0 +1,5 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:String x:Key="/Default/Environment/Highlighting/HighlightingSourceSnapshotLocation/@EntryValue">C:\Users\Rafal\AppData\Local\JetBrains\Rider2023.3\resharper-host\temp\Rider\vAny\CoverageData\_EndlessVendetta.-1253833435\Snapshot\snapshot.utdcvr</s:String>
<s:String x:Key="/Default/Environment/UnitTesting/UnitTestSessionStore/Sessions/=aba8233e_002D1c76_002D499a_002Db1de_002D7423eeed41c5/@EntryIndexedValue">&lt;SessionState ContinuousTestingMode="0" IsActive="True" Name="All tests from Solution" xmlns="urn:schemas-jetbrains-com:jetbrains-ut-session"&gt;&#xD;
&lt;Solution /&gt;&#xD;
&lt;/SessionState&gt;</s:String></wpf:ResourceDictionary>

View File

@ -14,6 +14,7 @@
#include "GameFramework/MovementComponent.h" #include "GameFramework/MovementComponent.h"
#include "Inventory/InventoryComponent.h" #include "Inventory/InventoryComponent.h"
#include "EndlessVendettaGameMode.h" #include "EndlessVendettaGameMode.h"
#include "EVGameInstance.h"
#include "DialogueSystem/AC_Dialogue.h" #include "DialogueSystem/AC_Dialogue.h"
@ -51,6 +52,10 @@ void AEndlessVendettaCharacter::BeginPlay()
// Call the base class // Call the base class
Super::BeginPlay(); Super::BeginPlay();
UEVGameInstance* GI = Cast<UEVGameInstance>(GetWorld()->GetGameInstance());
PrimaryWeaponClass = GI->MainSaveGameInstanceRef->PrimaryWeaponClassSave;
SecondaryWeaponClass = GI->MainSaveGameInstanceRef->SecondaryWeaponClassSave;
// Set the fp skeletal mesh for the vault it plugin to use // Set the fp skeletal mesh for the vault it plugin to use
TArray<UActorComponent*> MeshActComps = GetComponentsByClass(USkeletalMeshComponent::StaticClass()); TArray<UActorComponent*> MeshActComps = GetComponentsByClass(USkeletalMeshComponent::StaticClass());
for (auto MeshActorComponent : MeshActComps) for (auto MeshActorComponent : MeshActComps)
@ -372,24 +377,42 @@ void AEndlessVendettaCharacter::EquipPrimary()
if (GadgetManager->IsValidReconGadget() && GadgetManager->IsReconEquipped() && !GadgetManager->TryToUnequipRecon()) return; if (GadgetManager->IsValidReconGadget() && GadgetManager->IsReconEquipped() && !GadgetManager->TryToUnequipRecon()) return;
if (GadgetManager->IsValidCombatGadget() && GadgetManager->IsCombatEquipped() && !GadgetManager->TryToUnequipCombat()) return; if (GadgetManager->IsValidCombatGadget() && GadgetManager->IsCombatEquipped() && !GadgetManager->TryToUnequipCombat()) return;
if (!IsValid(PrimaryWeapon))
{
bHasRifle = true; bHasRifle = true;
// if(!bIsPrimaryWeaponCreated) if (!bIsPrimaryWeaponCreated)
// { {
// //Creating a new actor object called PrimaryWeapon that is based off primaryweaponClass PrimaryWeaponActor = GetWorld()->SpawnActor<AActor>(PrimaryWeaponClass, spawnParams);
// //Changing PrimaryWeaponActor to ABaseWeaponClass type instead of actor and storing it into PrimaryWeapon which is a ABaseClass Object PrimaryWeaponActor->AttachToComponent(Mesh1P, AttachmentRules, FName("GripPoint"));
// //We do this because we need to check if PrimaryWeapon is equipped and we want primaryweapon to be ABaseWeapon type and not a generic AActor PrimaryWeapon = Cast<ABaseWeaponClass>(PrimaryWeaponActor);
// PrimaryWeaponActor = GetWorld()->SpawnActor<AActor>(PrimaryWeaponClass, spawnParams); PrimaryWeapon->SetActorHiddenInGame(false);
// PrimaryWeaponActor->AttachToComponent(Mesh1P, AttachmentRules, FName("GripPoint")); bIsPrimaryWeaponCreated = true;
// PrimaryWeapon = Cast<ABaseWeaponClass>(PrimaryWeaponActor); }
// PrimaryWeapon->SetActorHiddenInGame(false); //UE_LOG(LogTemp, Warning, TEXT("Primary Weapon Is Hidden: %hhd"), SecondaryWeapon->IsHidden());
// bIsPrimaryWeaponCreated = true; GLog->Log("Primary Weapon Equipped");
// } }
if (!IsValid(PrimaryWeaponActor)) return; if (!IsValid(PrimaryWeaponActor)) return;
Cast<AEndlessVendettaGameMode>(GetWorld()->GetAuthGameMode())->SendEvent("Equip", "Pri"); Cast<AEndlessVendettaGameMode>(GetWorld()->GetAuthGameMode())->SendEvent("Equip", "Pri");
PrimaryWeaponActor->AttachToComponent(Mesh1P, AttachmentRules, FName("GripPoint")); PrimaryWeaponActor->AttachToComponent(Mesh1P, AttachmentRules, FName("GripPoint"));
PrimaryWeapon = Cast<ABaseWeaponClass>(PrimaryWeaponActor); PrimaryWeapon = Cast<ABaseWeaponClass>(PrimaryWeaponActor);
PrimaryWeapon->SetActorHiddenInGame(false); PrimaryWeapon->SetActorHiddenInGame(false);
GetWorldTimerManager().ClearTimer(PrimaryWeapon->reloadTimerHandle); GetWorldTimerManager().ClearTimer(PrimaryWeapon->reloadTimerHandle);
// bHasRifle = true;
// // if(!bIsPrimaryWeaponCreated)
// // {
// // //Creating a new actor object called PrimaryWeapon that is based off primaryweaponClass
// // //Changing PrimaryWeaponActor to ABaseWeaponClass type instead of actor and storing it into PrimaryWeapon which is a ABaseClass Object
// // //We do this because we need to check if PrimaryWeapon is equipped and we want primaryweapon to be ABaseWeapon type and not a generic AActor
// // PrimaryWeaponActor = GetWorld()->SpawnActor<AActor>(PrimaryWeaponClass, spawnParams);
// // PrimaryWeaponActor->AttachToComponent(Mesh1P, AttachmentRules, FName("GripPoint"));
// // PrimaryWeapon = Cast<ABaseWeaponClass>(PrimaryWeaponActor);
// // PrimaryWeapon->SetActorHiddenInGame(false);
// // bIsPrimaryWeaponCreated = true;
// // }
} }
void AEndlessVendettaCharacter::EquipSecondary() void AEndlessVendettaCharacter::EquipSecondary()
@ -456,6 +479,11 @@ void AEndlessVendettaCharacter::WeaponSwitcher(AActor* Outhit)
} }
bIsWeaponPickedUp = true; bIsWeaponPickedUp = true;
PrimaryWeaponClass = Outhit->GetClass(); PrimaryWeaponClass = Outhit->GetClass();
UEVGameInstance* GI = Cast<UEVGameInstance>(GetGameInstance());
GI->MainSaveGameInstanceRef->PrimaryWeaponClassSave = Outhit->GetClass();
UGameplayStatics::SaveGameToSlot(GI->MainSaveGameInstanceRef, "MainSave", 0);
Outhit->Destroy(); Outhit->Destroy();
EquipPrimary(); EquipPrimary();
} }
@ -467,6 +495,11 @@ void AEndlessVendettaCharacter::WeaponSwitcher(AActor* Outhit)
} }
bIsWeaponPickedUp = true; bIsWeaponPickedUp = true;
SecondaryWeaponClass = Outhit->GetClass(); SecondaryWeaponClass = Outhit->GetClass();
UEVGameInstance* GI = Cast<UEVGameInstance>(GetGameInstance());
GI->MainSaveGameInstanceRef->SecondaryWeaponClassSave = Outhit->GetClass();
UGameplayStatics::SaveGameToSlot(GI->MainSaveGameInstanceRef, "MainSave", 0);
Outhit->Destroy(); Outhit->Destroy();
EquipSecondary(); EquipSecondary();
} }

View File

@ -4,6 +4,7 @@
#include "CoreMinimal.h" #include "CoreMinimal.h"
#include "GameFramework/SaveGame.h" #include "GameFramework/SaveGame.h"
#include "WeaponSystem/BaseWeaponClass.h"
#include "MainSaveGameClass.generated.h" #include "MainSaveGameClass.generated.h"
/** /**
@ -21,4 +22,10 @@ public:
UPROPERTY() UPROPERTY()
int LastMainBountyIndexInOpenWorld; int LastMainBountyIndexInOpenWorld;
UPROPERTY()
TSubclassOf<ABaseWeaponClass> PrimaryWeaponClassSave;
UPROPERTY()
TSubclassOf<ABaseWeaponClass> SecondaryWeaponClassSave;
}; };