2024-04-23 15:54:17 -07:00
|
|
|
#pragma once
|
2024-04-12 19:05:09 -07:00
|
|
|
#include "GameFramework/GameState.h"
|
2024-04-13 02:32:52 -07:00
|
|
|
|
2024-04-12 19:05:09 -07:00
|
|
|
#include "GasaCommon.h"
|
2024-04-22 22:10:02 -07:00
|
|
|
#include "Engine/Engine.h"
|
|
|
|
#include "Networking/GasaNetLibrary.h"
|
2024-04-12 19:05:09 -07:00
|
|
|
|
|
|
|
#include "GasaGameState.generated.h"
|
|
|
|
|
2024-04-22 22:10:02 -07:00
|
|
|
UCLASS( Blueprintable )
|
2024-04-12 19:05:09 -07:00
|
|
|
class GASA_API AGasaGameState : public AGameState
|
|
|
|
{
|
|
|
|
GENERATED_BODY()
|
|
|
|
public:
|
|
|
|
#pragma region Cog
|
2024-04-22 22:10:02 -07:00
|
|
|
// To make sure it doesn't get garbage collected.
|
|
|
|
UPROPERTY()
|
|
|
|
TObjectPtr<UObject> CogWindowManagerRef;
|
|
|
|
|
2024-04-12 19:05:09 -07:00
|
|
|
#if ENABLE_COG
|
2024-04-12 19:37:31 -07:00
|
|
|
TObjectPtr<UCogWindowManager> CogWindowManager;
|
2024-04-22 22:10:02 -07:00
|
|
|
#endif
|
|
|
|
// ENABLE_COG
|
2024-04-12 19:05:09 -07:00
|
|
|
#pragma endregion Cog
|
|
|
|
|
|
|
|
AGasaGameState();
|
2024-04-22 22:10:02 -07:00
|
|
|
|
|
|
|
#pragma region GameFramework
|
2024-04-23 15:54:17 -07:00
|
|
|
UPROPERTY(BlueprintAssignable)
|
|
|
|
FOnPawnReadySig Event_OnPlayerPawnReady;
|
|
|
|
|
2024-04-22 22:10:02 -07:00
|
|
|
UFUNCTION()
|
|
|
|
void OnGameFrameworkInitialized();
|
|
|
|
|
|
|
|
UFUNCTION(BlueprintCallable, BlueprintImplementableEvent, meta=(DisplayName = "Game Framework Initialized"))
|
|
|
|
void BP_OnGameFrameworkInitialized();
|
2024-04-23 15:54:17 -07:00
|
|
|
|
|
|
|
UFUNCTION()
|
|
|
|
void NotifyPlayerPawnReady(APawn* Pawn)
|
|
|
|
{
|
|
|
|
if (Event_OnPlayerPawnReady.IsBound())
|
|
|
|
Event_OnPlayerPawnReady.Broadcast(Pawn);
|
|
|
|
}
|
2024-04-22 22:10:02 -07:00
|
|
|
#pragma endregion GameFramework
|
|
|
|
|
|
|
|
#pragma region Networking
|
|
|
|
UPROPERTY(Replicated, BlueprintReadOnly)
|
|
|
|
AGasaPlayerState* ListenServerHost;
|
|
|
|
|
|
|
|
UPROPERTY(ReplicatedUsing = "Client_OnRep_OnlinePlayers", BlueprintReadOnly)
|
2024-04-23 15:54:17 -07:00
|
|
|
TArray<AGasaPlayerState*> OnlinePlayers;
|
2024-04-22 22:10:02 -07:00
|
|
|
|
|
|
|
UFUNCTION()
|
|
|
|
void Client_OnRep_OnlinePlayers();
|
|
|
|
#pragma endregion Networking
|
|
|
|
|
|
|
|
#pragma region Seamless Travel
|
|
|
|
UPROPERTY(BlueprintAssignable)
|
|
|
|
FOnTravelSig Event_OnSeamlessTravelStart;
|
|
|
|
|
|
|
|
UPROPERTY(BlueprintAssignable, meta=(DisplayName="Event: On Seamless Travel End"))
|
|
|
|
FOnTravelSig BP_Event_OnSeamlessTravelEnd;
|
|
|
|
|
|
|
|
FOnTravelDelegate Event_OnSeamlessTravelEnd;
|
|
|
|
|
|
|
|
UFUNCTION(NetMulticast, Reliable)
|
|
|
|
void Multicast_R_NotifySeamlessTravelEnd();
|
|
|
|
#pragma endregion Seamless Travel
|
|
|
|
|
|
|
|
#pragma region NetSlime
|
|
|
|
// NetSlime interface is generated by GasaGen/GasaGen_NetSlime.cpp
|
|
|
|
FORCEINLINE ENetworkMode GetNetworkMode() const { return Gasa::GetNetworkMode( this ); }
|
|
|
|
FORCEINLINE bool IsClient() const { return Gasa::IsClient( this ); }
|
|
|
|
FORCEINLINE bool IsListenServer() const { return Gasa::IsListenServer( this ); }
|
|
|
|
FORCEINLINE bool IsNetOwner() const { return Gasa::IsNetOwner( this ); }
|
|
|
|
FORCEINLINE bool IsServer() const { return Gasa::IsServer( this ); }
|
|
|
|
FORCEINLINE bool IsSimulatedProxy() const { return Gasa::IsSimulatedProxy( this ); }
|
|
|
|
FORCEINLINE void NetLog(
|
|
|
|
FString Message,
|
|
|
|
EGasaVerbosity Verbosity = EGasaVerbosity::Log,
|
|
|
|
FLogCategoryBase& Category = LogGasaNet,
|
|
|
|
bool DumpStack = false,
|
|
|
|
int32 Line = __builtin_LINE(),
|
|
|
|
ANSICHAR const* File = __builtin_FILE(),
|
|
|
|
ANSICHAR const* Func = __builtin_FUNCTION()
|
|
|
|
)
|
|
|
|
{
|
|
|
|
Gasa::NetLog( this, Message, Verbosity, Category, DumpStack, Line, File, Func );
|
|
|
|
}
|
|
|
|
#pragma endregion NetSlime
|
2024-04-12 19:05:09 -07:00
|
|
|
|
|
|
|
#pragma region GameState
|
2024-04-22 22:10:02 -07:00
|
|
|
void HandleBeginPlay() override;
|
|
|
|
#pragma endregion GameState
|
|
|
|
|
|
|
|
#pragma region GameStateBase
|
|
|
|
void SeamlessTravelTransitionCheckpoint(bool bToTransitionMap) override;
|
|
|
|
#pragma endregion GameStateBase
|
|
|
|
|
|
|
|
#pragma region Actor
|
2024-04-12 19:05:09 -07:00
|
|
|
void BeginPlay() override;
|
2024-04-22 22:10:02 -07:00
|
|
|
void PostInitializeComponents() override;
|
|
|
|
void Tick( float DeltaSeconds ) override;
|
|
|
|
#pragma endregion Actor
|
2024-04-12 19:05:09 -07:00
|
|
|
|
2024-04-22 22:10:02 -07:00
|
|
|
#pragma region UObject
|
|
|
|
void GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const override;
|
|
|
|
#pragma endregion UObject
|
2024-04-12 23:31:49 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
namespace Gasa
|
|
|
|
{
|
2024-04-22 22:10:02 -07:00
|
|
|
inline AGasaGameState* GetGameState( UObject* Context )
|
2024-04-13 02:32:52 -07:00
|
|
|
{
|
2024-04-22 22:10:02 -07:00
|
|
|
UWorld* World = GEngine->GetWorldFromContextObject( Context, EGetWorldErrorMode::LogAndReturnNull );
|
|
|
|
if ( World == nullptr )
|
2024-04-13 02:32:52 -07:00
|
|
|
{
|
2024-04-22 22:10:02 -07:00
|
|
|
Log( "World is null... are you running in a proper context?", ELogV::Error );
|
2024-04-13 02:32:52 -07:00
|
|
|
return nullptr;
|
|
|
|
}
|
2024-04-22 22:10:02 -07:00
|
|
|
return Cast<AGasaGameState>( World->GetGameState() );
|
2024-04-12 23:31:49 -07:00
|
|
|
}
|
|
|
|
}
|