Space Plunder
Loading...
Searching...
No Matches
UStoredData Class Reference

#include <StoredData.h>

Inheritance diagram for UStoredData:

Public Member Functions

void SaveData (UPackage *Package, const FString &SlotName)
 

Static Public Member Functions

static UStoredDataFindDataAsset (const FString &SlotName, const UWorld *const World)
 

Public Attributes

FVector2D PitchAim = FVector2D::ZeroVector
 
FVector4 YawAim = FVector4(0, 0, 0, 0)
 
FVector4 RollAim = FVector4(0, 0, 0, 0)
 
FVector2D PitchHip = FVector2D::ZeroVector
 
FVector4 YawHip = FVector4(0, 0, 0, 0)
 
FVector4 RollHip = FVector4(0, 0, 0, 0)
 
FVector2D KickAim = FVector2D::ZeroVector
 
FVector2D KickAimR = FVector2D::ZeroVector
 
FVector2D KickAimUp = FVector2D::ZeroVector
 
FVector2D KickHip = FVector2D::ZeroVector
 
FVector2D KickHipR = FVector2D::ZeroVector
 
FVector2D KickHipUp = FVector2D::ZeroVector
 
FRotator SmoothRot = FRotator::ZeroRotator
 
FVector SmoothLoc = FVector::ZeroVector
 
FRotator MultiRot = FRotator(1.f, 1.f, 1.f)
 
FVector MultiLoc = FVector(1.f, 1.f, 1.f)
 
bool bSmoothRoll = false
 
FVector2D Noise2DTarget = FVector2D::ZeroVector
 
FVector2D Noise2DAccel = FVector2D::ZeroVector
 
FVector2D Noise2DZero = FVector2D::ZeroVector
 
float NoiseAimScalar = 1.f
 
float Pushback = 0.f
 
float PushbackZero = 0.f
 
float PushbackAccel = 0.f
 
FProgression PitchProgress
 
FProgression ZProgress
 
float ProgressAimAlpha = 0.f
 
float PlaybackOffset = 0.f
 
float PlayRate = 1.f
 

Private Member Functions

FString GetPackagePath (const FString &SlotName) const
 

Member Function Documentation

◆ FindDataAsset()

UStoredData * UStoredData::FindDataAsset ( const FString & SlotName,
const UWorld *const World )
static

Tries to load data asset

If DataAsset is null, there're 2 possible scenarios: 1) Data asset just doesn't exist, in this case a new data asset will be created in PRAS folder 2) Data asset exists, but it hasn't been assigned yet p.s will be exeucted in editor only

not a valid state

Quit game with error message

if loaded package is null, then new data asset will be created

13{
18
19
20 UE_LOG(LogRecoilAnimation, Warning, TEXT("%s data asset is NULL!"), *SlotName)
21
22 if(!World->IsPlayInEditor())
23 {
24
25 return nullptr;
26 }
27
28 const auto PluginSettings = GetMutableDefault<UPluginSettings>();
29
30 if(!PluginSettings)
31 {
32 UE_LOG(LogRecoilAnimation, Error, TEXT("Plugin Settings Are NULL"))
33 return nullptr;
34 }
35
36 const FString PackagePath = PluginSettings->DataSavePath + SlotName;
37
38 auto QuitSession = [&]() -> void
39 {
40
41 FMessageDialog::Open(EAppMsgType::Ok,
42 FText::FromString(
43 SlotName + TEXT(" data asset hasn't been assigned yet!")));
44 World->GetFirstPlayerController()->ConsoleCommand("quit");
45 };
46
47 if(LoadPackage(nullptr, *PackagePath, LOAD_None))
48 {
49 QuitSession();
50 return nullptr;
51 }
52
53 if(PluginSettings->bCreateDataAssetIfNull)
54 {
55
56 UPackage* Package = CreatePackage(*PackagePath);
57 UE_LOG(LogRecoilAnimation, Warning, TEXT("%s data asset doesn't exist! Creating new data asset..."), *SlotName)
58
59 UStoredData* Loaded = NewObject<UStoredData>(Package, FName(*SlotName), RF_Public | RF_Standalone);
60 Loaded->SaveData(Package, SlotName);
61
62 return Loaded;
63 }
64
65 QuitSession();
66 return nullptr;
67}
Definition StoredData.h:26
void SaveData(UPackage *Package, const FString &SlotName)
Definition StoredData.cpp:69

◆ GetPackagePath()

FString UStoredData::GetPackagePath ( const FString & SlotName) const
private

Current data asset's location

103{
104
105 auto String = GetPathName();
106 if(String.RemoveFromEnd(FString(".") + SlotName))
107 {
108 return String;
109 }
110
111 const auto PluginSettings = GetMutableDefault<UPluginSettings>();
112
113 if(!PluginSettings)
114 {
115 UE_LOG(LogRecoilAnimation, Error, TEXT("Plugin Settings Are NULL"))
116 return FString("None");
117 }
118
119 return PluginSettings->DataSavePath + SlotName;
120}

◆ SaveData()

void UStoredData::SaveData ( UPackage * Package,
const FString & SlotName )

Saves recoil animation data by creating a data asset

This creates or finds (if exists) package using the given path

Getting the full path to the file

Finally saving just created package

70{
71
72 const FString PackagePath = GetPackagePath(SlotName);
73
74 if(!Package)
75 {
76 Package = CreatePackage(*PackagePath);
77 }
78
79 FAssetRegistryModule::AssetCreated(this);
80
81
82 const FString FilePath = FPackageName::LongPackageNameToFilename(Package->GetPathName(),
83 FPackageName::GetAssetPackageExtension());
84
85
86 FSavePackageArgs SavePackageArgs;
87
88 SavePackageArgs.TopLevelFlags = EObjectFlags::RF_Public | EObjectFlags::RF_Standalone;
89 SavePackageArgs.Error = GError;
90 SavePackageArgs.bForceByteSwapping = true;
91 SavePackageArgs.bWarnOfLongFilename = true;
92 SavePackageArgs.SaveFlags = SAVE_NoError;
93
94 const bool bSuccess = UPackage::SavePackage(Package, this, *FilePath, SavePackageArgs);
95
96 Package->SetDirtyFlag(true);
97
98 UE_LOG(LogRecoilAnimation, Warning, TEXT("Saved Package: %s, location: %s"),
99 bSuccess ? TEXT("SUCCESS") : TEXT("ERROR"), *FilePath)
100}
FString GetPackagePath(const FString &SlotName) const
Definition StoredData.cpp:102

Member Data Documentation

◆ bSmoothRoll

bool UStoredData::bSmoothRoll = false

Enables smoothing for Roll target values

◆ KickAim

FVector2D UStoredData::KickAim = FVector2D::ZeroVector

Target values for Kickback when aiming X - min Y - max

◆ KickAimR

FVector2D UStoredData::KickAimR = FVector2D::ZeroVector

Target values for Kickback Right when aiming X - min Y - max

◆ KickAimUp

FVector2D UStoredData::KickAimUp = FVector2D::ZeroVector

Target values for Kickback Up when aiming X - min Y - max

◆ KickHip

FVector2D UStoredData::KickHip = FVector2D::ZeroVector

Target values for Kickback when not aiming X - min Y - max

◆ KickHipR

FVector2D UStoredData::KickHipR = FVector2D::ZeroVector

Target values for Kickback Right when not aiming X - min Y - max

◆ KickHipUp

FVector2D UStoredData::KickHipUp = FVector2D::ZeroVector

Target values for Kickback Up when not aiming X - min Y - max

◆ MultiLoc

FVector UStoredData::MultiLoc = FVector(1.f, 1.f, 1.f)

Multiplier for each translation axis while in Semi/Auto state

◆ MultiRot

FRotator UStoredData::MultiRot = FRotator(1.f, 1.f, 1.f)

Multiplier for each rotation axis while in Semi/Auto state

◆ Noise2DAccel

FVector2D UStoredData::Noise2DAccel = FVector2D::ZeroVector

◆ Noise2DTarget

FVector2D UStoredData::Noise2DTarget = FVector2D::ZeroVector

◆ Noise2DZero

FVector2D UStoredData::Noise2DZero = FVector2D::ZeroVector

◆ NoiseAimScalar

float UStoredData::NoiseAimScalar = 1.f

◆ PitchAim

FVector2D UStoredData::PitchAim = FVector2D::ZeroVector

Target values for Pitch when aiming X - min Y - max

◆ PitchHip

FVector2D UStoredData::PitchHip = FVector2D::ZeroVector

Target values for Pitch when not aiming X - min Y - max

◆ PitchProgress

FProgression UStoredData::PitchProgress

◆ PlaybackOffset

float UStoredData::PlaybackOffset = 0.f

Playback position used for getting start value during Semi-Auto transition

◆ PlayRate

float UStoredData::PlayRate = 1.f

◆ ProgressAimAlpha

float UStoredData::ProgressAimAlpha = 0.f

◆ Pushback

float UStoredData::Pushback = 0.f

◆ PushbackAccel

float UStoredData::PushbackAccel = 0.f

◆ PushbackZero

float UStoredData::PushbackZero = 0.f

◆ RollAim

FVector4 UStoredData::RollAim = FVector4(0, 0, 0, 0)

Target values for Roll when aiming X - min min Y - min max Z - max min W - max max

◆ RollHip

FVector4 UStoredData::RollHip = FVector4(0, 0, 0, 0)

Target values for Roll when not aiming X - min min Y - min max Z - max min W - max max

◆ SmoothLoc

FVector UStoredData::SmoothLoc = FVector::ZeroVector

Smooth amount in Auto mode. 0 means no smoothing

◆ SmoothRot

FRotator UStoredData::SmoothRot = FRotator::ZeroRotator

Smooth amount in Auto mode. 0 means no smoothing

◆ YawAim

FVector4 UStoredData::YawAim = FVector4(0, 0, 0, 0)

Target values for Yaw when aiming X - min min Y - min max Z - max min W - max max

◆ YawHip

FVector4 UStoredData::YawHip = FVector4(0, 0, 0, 0)

Target values for Yaw when not aiming X - min min Y - min max Z - max min W - max max

◆ ZProgress

FProgression UStoredData::ZProgress

The documentation for this class was generated from the following files: