some changes

This commit is contained in:
C
2022-06-29 14:10:51 +05:00
parent 841f2cf867
commit e359a6b55f
59 changed files with 144 additions and 4 deletions
@@ -11,6 +11,7 @@ void UResComGameInstance::Init()
{
Super::Init();
apartmentManager = NewObject<UResComApartmentManager>(this);
statisticsManager = NewObject<UResComStatistics>(this);
}
//void UResComGameInstance::SetApartmentManager(UResComApartmentManager* manager)
@@ -23,9 +24,10 @@ UResComApartmentManager* UResComGameInstance::GetApartmentManager() const
return apartmentManager;
}
UResComStatistics* UResComGameInstance::GetStatisticsManager() const
{
return statisticsManager;
}
@@ -0,0 +1,36 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "ResComStatistics.h"
void UResComStatistics::NewState(FString state)
{
if (prevState.duration != 0.0f)
{
prevState.duration = GetWorld()->GetTimeSeconds() - prevState.duration;
stateHistory.Add(prevState);
}
prevState.state = state;
prevState.duration = GetWorld()->GetTimeSeconds();
}
FString UResComStatistics::GetStateHistoryString()
{
FString strTmp("");
for (auto& state : stateHistory)
{
strTmp += "->" + state.state;
}
return strTmp;
}
void UResComStatistics::StartVR()
{
timeLastStartVR = GetWorld()->GetTimeSeconds();
}
void UResComStatistics::EndVR()
{
timeVR += GetWorld()->GetTimeSeconds() - timeLastStartVR;
}
@@ -2,6 +2,7 @@
#pragma once
#include "ResComStatistics.h"
#include "ResComApartmentManager.h"
#include "Engine/LatentActionManager.h"
#include "Interfaces/IHttpRequest.h"
@@ -27,6 +28,7 @@ class FORTIS_TAKTIKA_API UResComGameInstance : public UGameInstance
GENERATED_BODY()
private:
UResComApartmentManager* apartmentManager;
UResComStatistics* statisticsManager;
//FString HttpData;
//FHttpDelegate& Callback;
protected:
@@ -38,6 +40,9 @@ public:
UFUNCTION(BlueprintCallable, Category = "ApartmentManager")
UResComApartmentManager* GetApartmentManager() const;
UFUNCTION(BlueprintCallable, Category = "StatisticsManager")
UResComStatistics* GetStatisticsManager() const;
//UFUNCTION(BlueprintCallable)
@@ -0,0 +1,67 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "UObject/NoExportTypes.h"
#include "ResComStatistics.generated.h"
/**
*
*/
USTRUCT(BlueprintType)
struct FStateAndTime
{
GENERATED_BODY()
UPROPERTY(EditAnywhere, BlueprintReadWrite)
FString state;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
float duration = 0.0f;
FStateAndTime() {};
FStateAndTime(FString s, float t) : state(s), duration(t) {};
};
USTRUCT(BlueprintType)
struct FUserStatistics
{
GENERATED_BODY()
UPROPERTY(EditAnywhere, BlueprintReadWrite)
float timeSession = 0.0f;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
float timeVR = 0.0f;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
TArray<FStateAndTime> stateHistory;
};
UCLASS(BlueprintType)
class FORTIS_TAKTIKA_API UResComStatistics : public UObject
{
GENERATED_BODY()
protected:
float timeSession = 0.0f;
float timeVR = 0.0f;
TArray<FStateAndTime> stateHistory;
// start variables
float timeLastStartVR = 0.0f;
FStateAndTime prevState;
public:
UFUNCTION(BlueprintCallable, Category = "states")
void NewState(FString state);
UFUNCTION(BlueprintCallable, Category = "states")
FString GetStateHistoryString();
UFUNCTION(BlueprintCallable, Category = "VR")
void StartVR();
UFUNCTION(BlueprintCallable, Category = "VR")
void EndVR();
};