Optimize gamemode and gamestate code

This commit is contained in:
martinluckyrobots
2025-04-01 11:04:11 +08:00
parent c35cf74b49
commit 8e1c017515
18 changed files with 234 additions and 18 deletions

View File

@ -13,5 +13,7 @@ UCLASS()
class LUCKYROBOTS_API ALobbyGameMode : public AGameModeBase
{
GENERATED_BODY()
protected:
virtual void BeginPlay() override;
};

View File

@ -7,6 +7,7 @@
#include "SharedDef.h"
#include "LuckyRobotsFunctionLibrary.generated.h"
class ULuckyRobotsGameInstance;
/**
*
*/
@ -15,9 +16,15 @@ class LUCKYROBOTS_API ULuckyRobotsFunctionLibrary : public UBlueprintFunctionLib
{
GENERATED_BODY()
public:
UFUNCTION(BlueprintPure, meta = (WorldContext = "WorldContextObject"))
static ULuckyRobotsGameInstance* GetLuckyRobotsGameInstance(const UObject* WorldContextObject);
UFUNCTION(BlueprintPure, meta = (WorldContext = "WorldContextObject"))
static TArray<FRobotData> GetActiveRobotDataList(const UObject* WorldContextObject);
UFUNCTION(BlueprintPure, meta = (WorldContext = "WorldContextObject"))
static TArray<FLevelData> GetActiveLevelDataList(const UObject* WorldContextObject);
UFUNCTION(BlueprintCallable, meta = (WorldContext = "WorldContextObject"))
static void UpdateQualitySettings(const UObject* WorldContextObject);
};

View File

@ -7,6 +7,7 @@
#include "SharedDef.h"
#include "LuckyRobotsGameInstance.generated.h"
class USIOJsonValue;
/**
*
*/
@ -24,13 +25,15 @@ public:
public:
UPROPERTY(EditAnywhere, BlueprintReadWrite)
ERobotsName CurrentSelectRobot;
ERobotsName CurrentSelectRobot = ERobotsName::None;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
ELevelEnum CurrentSelectLevel;
ELevelEnum CurrentSelectLevel = ELevelEnum::None;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
EQualityEnum CurrentSelectQuality;
EQualityEnum CurrentSelectQuality = EQualityEnum::Epic;
public:
UFUNCTION(BlueprintImplementableEvent)
void DoGetDispatch(const FString& EventName, USIOJsonValue* EventData);
};

View File

@ -13,7 +13,9 @@ UCLASS()
class LUCKYROBOTS_API ALuckyRobotsGameMode : public AGameModeBase
{
GENERATED_BODY()
public:
protected:
virtual void BeginPlay() override;
virtual UClass* GetDefaultPawnClassForController_Implementation(AController* InController) override;
};

View File

@ -6,6 +6,8 @@
#include "GameFramework/GameStateBase.h"
#include "LuckyRobotsGameState.generated.h"
class USocketIOClientComponent;
class USIOJsonValue;
/**
*
*/
@ -13,5 +15,21 @@ UCLASS()
class LUCKYROBOTS_API ALuckyRobotsGameState : public AGameStateBase
{
GENERATED_BODY()
protected:
ALuckyRobotsGameState();
virtual void BeginPlay() override;
public:
UPROPERTY(Category = Character, VisibleAnywhere, BlueprintReadOnly, meta = (AllowPrivateAccess = "true"))
USocketIOClientComponent* SocketIOClientComponent;
public:
UFUNCTION(BlueprintCallable)
void DoSendMessage(FString SendValue);
UFUNCTION(BlueprintCallable)
void DoSocketOnConnect(FString SocketId, FString SessionId, bool IsReconnection);
UFUNCTION(BlueprintCallable)
void DoSocketOnGenericEvent(FString EventName, USIOJsonValue* EventData);
};

View File

@ -64,10 +64,18 @@ enum class ELevelEnum : uint8
UENUM(BlueprintType)
enum class EQualityEnum : uint8
{
Epic UMETA(DisplayName = "Epic"),
High UMETA(DisplayName = "High"),
Low UMETA(DisplayName = "Low"),
Middle UMETA(DisplayName = "Middle"),
Low UMETA(DisplayName = "Low")
High UMETA(DisplayName = "High"),
Epic UMETA(DisplayName = "Epic")
};
UENUM(BlueprintType)
enum class EGoalType : uint8
{
GrabAndPull UMETA(DisplayName = "Grab and Pull"),
GrabAndRotate UMETA(DisplayName = "Grab and Rotate"),
};
USTRUCT(BlueprintType)
@ -123,4 +131,92 @@ public:
UPROPERTY(EditAnywhere, BlueprintReadWrite)
TArray<ERobotsCategories> RobotTypeList;
};
};
USTRUCT(BlueprintType)
struct FGoalsTaskData : public FTableRowBase
{
GENERATED_BODY()
public:
UPROPERTY(EditAnywhere, BlueprintReadWrite)
EGoalType GoalType;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
bool bIsStart;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
FTransform TargetLocation;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
AActor* TargetActor;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
bool bIsComplate;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
FVector DropOffLocation;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
FString ObjectName;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
bool bActive;
};
USTRUCT(BlueprintType)
struct FCaptureSettingsData : public FTableRowBase
{
GENERATED_BODY()
public:
UPROPERTY(EditAnywhere, BlueprintReadWrite)
FText FolderName;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
FText FileName;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
FText WritesPerSec;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
bool IsScenario;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
TArray<FGoalsTaskData> TaskList;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
bool bLight;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
bool bMaterials;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
bool bRobotPosition;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
bool bPets;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
FText NumberOfPets;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
bool bPeople;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
FText NumberOfPeople;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
bool bObjects;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
FText NumberOfObjects;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
TArray<UStaticMeshComponent*> RandomMeshes;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
bool bInfiniteCapture;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
FText NumberOfCaptures;
};