You've already forked LuckyWorld
Optimizing gameinstance
This commit is contained in:
@ -9,6 +9,8 @@
|
||||
#include "GameFramework/GameUserSettings.h"
|
||||
#include "Kismet/KismetMathLibrary.h"
|
||||
#include "FunctionLibraries/LuckyRobotsFunctionLibrary.h"
|
||||
#include "VaRestSubsystem.h"
|
||||
#include "Subsystems/SubsystemBlueprintLibrary.h"
|
||||
|
||||
void ULuckyRobotsGameInstance::DoSendMessage(const FString& SendValue)
|
||||
{
|
||||
@ -284,6 +286,64 @@ TArray<FSelectableItemData> ULuckyRobotsGameInstance::GetSelectableItemList(EIte
|
||||
return SelectableItemList;
|
||||
}
|
||||
|
||||
void ULuckyRobotsGameInstance::GetMessageParse(FString Json)
|
||||
{
|
||||
auto VaRestSubsystem = CastChecked<UVaRestSubsystem>(USubsystemBlueprintLibrary::GetEngineSubsystem(UVaRestSubsystem::StaticClass()), ECastCheckedType::NullChecked);
|
||||
if (VaRestSubsystem)
|
||||
{
|
||||
UVaRestJsonObject* VaRestJsonObject = VaRestSubsystem->ConstructVaRestJsonObject();
|
||||
if (VaRestJsonObject)
|
||||
{
|
||||
if (VaRestJsonObject->DecodeJson(Json, true))
|
||||
{
|
||||
TArray<UVaRestJsonValue*> VaRestJsonValueList = VaRestJsonObject->GetArrayField("LuckyCode");
|
||||
if (VaRestJsonValueList.Num() > 0)
|
||||
{
|
||||
LuckyCodeList.Empty();
|
||||
for (auto VaRestJsonValue : VaRestJsonValueList)
|
||||
{
|
||||
if (VaRestJsonValue)
|
||||
{
|
||||
UVaRestJsonObject* TempObject = VaRestJsonValue->AsObject();
|
||||
if (TempObject)
|
||||
{
|
||||
FLuckyCode TempLuckyCode;
|
||||
TempLuckyCode.ID = FCString::Atoi(*(TempObject->GetStringField("ID")));
|
||||
TempLuckyCode.Code = TempObject->GetStringField("code");
|
||||
TempLuckyCode.Time = FCString::Atof(*(TempObject->GetStringField("time")));
|
||||
TempLuckyCode.bCallback = (TempObject->GetStringField("callback") == "on");
|
||||
LuckyCodeList.Add(TempLuckyCode);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
UVaRestJsonValue* VaRestJsonValue = VaRestJsonObject->GetField("LuckyCapture");
|
||||
if (VaRestJsonValue)
|
||||
{
|
||||
UVaRestJsonObject* TempObject = VaRestJsonValue->AsObject();
|
||||
if (TempObject)
|
||||
{
|
||||
bIsCapture = (TempObject->GetStringField("capture") == "on");
|
||||
bIsCaptureHand = (TempObject->GetStringField("is_capture_hand") == "on");
|
||||
bIsCaptureHead = (TempObject->GetStringField("is_capture_head") == "on");
|
||||
bScenarioCapture = (TempObject->GetStringField("scenario_capture") == "on");
|
||||
TargetPosition = FTransform();
|
||||
SetCurrentFileName(TempObject->GetStringField("file_name"));
|
||||
SetCurrentFolderName(TempObject->GetStringField("folder_name"));
|
||||
SetCurrentCaptureNumber(FCString::Atoi(*TempObject->GetStringField("capture_name")));
|
||||
SetCurrentIsInfiniteCapture(TempObject->GetStringField("infinite_capture") == "on");
|
||||
SetCurrentWritesPerSec(FCString::Atoi(*TempObject->GetStringField("per_second")));
|
||||
SetCurrentIsRandomPeople(TempObject->GetStringField("random_people") == "on");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ULuckyRobotsGameInstance::SetCurrentFolderName(const FString& FolderName)
|
||||
{
|
||||
CurrentCaptureSettingsData.FolderName = FText::FromString(FolderName);
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include "SocketIOClientComponent.h"
|
||||
#include "FunctionLibraries/LuckyRobotsFunctionLibrary.h"
|
||||
#include "Core/LuckyRobotsGameInstance.h"
|
||||
#include "SIOJLibrary.h"
|
||||
|
||||
ALuckyRobotsGameState::ALuckyRobotsGameState()
|
||||
{
|
||||
@ -41,6 +42,7 @@ void ALuckyRobotsGameState::DoSocketOnGenericEvent(FString EventName, USIOJsonVa
|
||||
{
|
||||
if (ULuckyRobotsGameInstance* GameInstance = ULuckyRobotsFunctionLibrary::GetLuckyRobotsGameInstance(this))
|
||||
{
|
||||
GameInstance->DoGetDispatch(EventName, EventData);
|
||||
GameInstance->OnMessageDispatched.Broadcast(EventName);
|
||||
GameInstance->GetMessageParse(USIOJLibrary::Conv_SIOJsonValueToString(EventData));
|
||||
}
|
||||
}
|
||||
|
@ -7,6 +7,9 @@
|
||||
#include "SharedDef.h"
|
||||
#include "LuckyRobotsGameInstance.generated.h"
|
||||
|
||||
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnMessageDispatched, const FString&, Message);
|
||||
DECLARE_DYNAMIC_MULTICAST_DELEGATE(FOnRandomMeshesUpdated);
|
||||
|
||||
class USIOJsonValue;
|
||||
class UGameUserWidget;
|
||||
/**
|
||||
@ -128,6 +131,13 @@ public:
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
||||
TArray<FLuckyCode> LuckyCodeList;
|
||||
|
||||
public:
|
||||
UPROPERTY(BlueprintCallable, BlueprintAssignable, Category = "Event")
|
||||
FOnMessageDispatched OnMessageDispatched;
|
||||
|
||||
UPROPERTY(BlueprintCallable, BlueprintAssignable, Category = "Event")
|
||||
FOnRandomMeshesUpdated OnRandomMeshesUpdated;
|
||||
|
||||
public:
|
||||
UFUNCTION(BlueprintCallable)
|
||||
void DoSendMessage(const FString& SendValue);
|
||||
@ -190,6 +200,9 @@ public:
|
||||
UFUNCTION(BlueprintPure, Category = "Selectable Items")
|
||||
TArray<FSelectableItemData> GetSelectableItemList(EItemCategory ItemCategory);
|
||||
|
||||
UFUNCTION(BlueprintCallable)
|
||||
void GetMessageParse(FString Json);
|
||||
|
||||
public:
|
||||
UFUNCTION(BlueprintCallable)
|
||||
void SetCurrentFolderName(const FString& FolderName);
|
||||
@ -295,7 +308,4 @@ public:
|
||||
UFUNCTION(BlueprintPure)
|
||||
int32 GetWidgetTotalHit() const;
|
||||
|
||||
public:
|
||||
UFUNCTION(BlueprintImplementableEvent)
|
||||
void DoGetDispatch(const FString& EventName, USIOJsonValue* EventData);
|
||||
};
|
||||
|
Reference in New Issue
Block a user