Update Game Instance to Start Game from Lobby
This commit is contained in:
parent
46d076c844
commit
8ac4588aed
@ -6,10 +6,12 @@
|
|||||||
[/Script/EngineSettings.GameMapsSettings]
|
[/Script/EngineSettings.GameMapsSettings]
|
||||||
EditorStartupMap=/Game/FirstPerson/Maps/FirstPersonMap.FirstPersonMap
|
EditorStartupMap=/Game/FirstPerson/Maps/FirstPersonMap.FirstPersonMap
|
||||||
LocalMapOptions=
|
LocalMapOptions=
|
||||||
TransitionMap=
|
TransitionMap=None
|
||||||
bUseSplitscreen=True
|
bUseSplitscreen=True
|
||||||
TwoPlayerSplitscreenLayout=Horizontal
|
TwoPlayerSplitscreenLayout=Horizontal
|
||||||
ThreePlayerSplitscreenLayout=FavorTop
|
ThreePlayerSplitscreenLayout=FavorTop
|
||||||
|
FourPlayerSplitscreenLayout=Grid
|
||||||
|
bOffsetPlayerGamepadIds=False
|
||||||
GameInstanceClass=/Script/CorruptedMemory.CMGameInstance
|
GameInstanceClass=/Script/CorruptedMemory.CMGameInstance
|
||||||
GameDefaultMap=/Game/Levels/ClientEntry.ClientEntry
|
GameDefaultMap=/Game/Levels/ClientEntry.ClientEntry
|
||||||
ServerDefaultMap=/Game/FirstPerson/Maps/FirstPersonMap.FirstPersonMap
|
ServerDefaultMap=/Game/FirstPerson/Maps/FirstPersonMap.FirstPersonMap
|
||||||
|
@ -14,7 +14,7 @@ Build=IfProjectHasCode
|
|||||||
BuildConfiguration=PPBC_Development
|
BuildConfiguration=PPBC_Development
|
||||||
BuildTarget=CorruptedMemory
|
BuildTarget=CorruptedMemory
|
||||||
LaunchOnTarget=
|
LaunchOnTarget=
|
||||||
StagingDirectory=(Path="C:/Users/Phro/Downloads/TestLobbies")
|
StagingDirectory=(Path="C:/Users/Phro/Downloads/ServerArm64")
|
||||||
FullRebuild=False
|
FullRebuild=False
|
||||||
ForDistribution=False
|
ForDistribution=False
|
||||||
IncludeDebugFiles=False
|
IncludeDebugFiles=False
|
||||||
@ -100,12 +100,13 @@ bSkipMovies=False
|
|||||||
+IniSectionDenylist=HordeStorageServers
|
+IniSectionDenylist=HordeStorageServers
|
||||||
+IniSectionDenylist=StorageServers
|
+IniSectionDenylist=StorageServers
|
||||||
+MapsToCook=(FilePath="/Game/FirstPerson/Maps/FirstPersonMap")
|
+MapsToCook=(FilePath="/Game/FirstPerson/Maps/FirstPersonMap")
|
||||||
|
+MapsToCook=(FilePath="/Game/Levels/ClientEntry")
|
||||||
+DirectoriesToAlwaysCook=(Path="/Interchange/Functions")
|
+DirectoriesToAlwaysCook=(Path="/Interchange/Functions")
|
||||||
+DirectoriesToAlwaysCook=(Path="/Interchange/gltf")
|
+DirectoriesToAlwaysCook=(Path="/Interchange/gltf")
|
||||||
+DirectoriesToAlwaysCook=(Path="/Interchange/Materials")
|
+DirectoriesToAlwaysCook=(Path="/Interchange/Materials")
|
||||||
+DirectoriesToAlwaysCook=(Path="/Interchange/Pipelines")
|
+DirectoriesToAlwaysCook=(Path="/Interchange/Pipelines")
|
||||||
+DirectoriesToAlwaysCook=(Path="/Interchange/Utilities")
|
+DirectoriesToAlwaysCook=(Path="/Interchange/Utilities")
|
||||||
PerPlatformBuildConfig=(("LinuxArm64", PPBC_Development))
|
PerPlatformBuildConfig=(("LinuxArm64", PPBC_Shipping))
|
||||||
PerPlatformTargetFlavorName=()
|
PerPlatformTargetFlavorName=()
|
||||||
PerPlatformBuildTarget=(("LinuxArm64", "CorruptedMemoryServer"))
|
PerPlatformBuildTarget=(("LinuxArm64", "CorruptedMemoryServer"))
|
||||||
|
|
||||||
|
BIN
CorruptedMemory/Content/FirstPerson/Maps/FirstPersonMap.umap
(Stored with Git LFS)
BIN
CorruptedMemory/Content/FirstPerson/Maps/FirstPersonMap.umap
(Stored with Git LFS)
Binary file not shown.
@ -1,3 +1,3 @@
|
|||||||
version https://git-lfs.github.com/spec/v1
|
version https://git-lfs.github.com/spec/v1
|
||||||
oid sha256:44980cb55dcf0f576a61c7cb15800fc9b3fbe722500af8f796855a2a7befe79b
|
oid sha256:89d525aa3d9c4633b4dfe12cf01e928844cbb8a21dcd92f7b008adecd7521828
|
||||||
size 120991
|
size 140796
|
||||||
|
BIN
CorruptedMemory/Content/Server/BP_LobbyServer.uasset
(Stored with Git LFS)
BIN
CorruptedMemory/Content/Server/BP_LobbyServer.uasset
(Stored with Git LFS)
Binary file not shown.
@ -1,3 +1,3 @@
|
|||||||
version https://git-lfs.github.com/spec/v1
|
version https://git-lfs.github.com/spec/v1
|
||||||
oid sha256:46876bb5c3c4d8cdb567cadf0b3034ac0d3df3fa804507323949398b9097432a
|
oid sha256:626aeae1e79975c59fdf35d793d2a62fbbb0bb0ed9f61829d0523238dc831158
|
||||||
size 1016257
|
size 1198885
|
||||||
|
Binary file not shown.
@ -51,11 +51,6 @@ void UCMGameInstance::CreateLobby(const int MaxPlayers)
|
|||||||
|
|
||||||
void UCMGameInstance::JoinLobby(const FString LobbyID)
|
void UCMGameInstance::JoinLobby(const FString LobbyID)
|
||||||
{
|
{
|
||||||
// if (APlayerController* PC = GetWorld()->GetFirstPlayerController())
|
|
||||||
// {
|
|
||||||
// PC->ConsoleCommand("open " + ServerFQDN + ":" + FString::FromInt(Port));
|
|
||||||
// }
|
|
||||||
|
|
||||||
const auto Request = FHttpModule::Get().CreateRequest();
|
const auto Request = FHttpModule::Get().CreateRequest();
|
||||||
Request->SetURL(LobbyAPI + "/join");
|
Request->SetURL(LobbyAPI + "/join");
|
||||||
Request->SetVerb("POST");
|
Request->SetVerb("POST");
|
||||||
@ -100,7 +95,7 @@ void UCMGameInstance::GetPlayerLobbyList()
|
|||||||
void UCMGameInstance::GetServerLobbyList()
|
void UCMGameInstance::GetServerLobbyList()
|
||||||
{
|
{
|
||||||
const auto Request = FHttpModule::Get().CreateRequest();
|
const auto Request = FHttpModule::Get().CreateRequest();
|
||||||
Request->SetURL(LobbyAPI + "/lobbies" + JoinedLobbyID);
|
Request->SetURL(LobbyAPI + "/lobbies");
|
||||||
Request->SetVerb("GET");
|
Request->SetVerb("GET");
|
||||||
Request->SetHeader("Authorization", "Bearer " + JwtToken);
|
Request->SetHeader("Authorization", "Bearer " + JwtToken);
|
||||||
Request->SetHeader("Accept", "application/json");
|
Request->SetHeader("Accept", "application/json");
|
||||||
@ -108,6 +103,31 @@ void UCMGameInstance::GetServerLobbyList()
|
|||||||
Request->ProcessRequest();
|
Request->ProcessRequest();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void UCMGameInstance::ReadyUp()
|
||||||
|
{
|
||||||
|
const TSharedPtr<FJsonObject> ReadyUp = MakeShareable(new FJsonObject);
|
||||||
|
ReadyUp->SetStringField("lobbyID", JoinedLobbyID);
|
||||||
|
ReadyUp->SetStringField("username", AccountUsername);
|
||||||
|
Socket->Emit(TEXT("ready"), ReadyUp);
|
||||||
|
}
|
||||||
|
|
||||||
|
void UCMGameInstance::UnReady()
|
||||||
|
{
|
||||||
|
const TSharedPtr<FJsonObject> UnReady = MakeShareable(new FJsonObject);
|
||||||
|
UnReady->SetStringField("lobbyID", JoinedLobbyID);
|
||||||
|
UnReady->SetStringField("username", AccountUsername);
|
||||||
|
Socket->Emit(TEXT("unready"), UnReady);
|
||||||
|
}
|
||||||
|
|
||||||
|
void UCMGameInstance::StartGame()
|
||||||
|
{
|
||||||
|
Socket->Emit(TEXT("start"), JoinedLobbyID);
|
||||||
|
if (APlayerController* PC = GetWorld()->GetFirstPlayerController())
|
||||||
|
{
|
||||||
|
PC->ConsoleCommand("open " + ServerFQDN + ":" + FString::FromInt(ServerPort));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void UCMGameInstance::Init()
|
void UCMGameInstance::Init()
|
||||||
{
|
{
|
||||||
Super::Init();
|
Super::Init();
|
||||||
@ -148,7 +168,6 @@ void UCMGameInstance::Init()
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
Socket->OnEvent("join", [this](const FString& Event, const TSharedPtr<FJsonValue>& Message)
|
Socket->OnEvent("join", [this](const FString& Event, const TSharedPtr<FJsonValue>& Message)
|
||||||
{
|
{
|
||||||
const auto JsonReader = TJsonReaderFactory<>::Create(USIOJConvert::ToJsonString(Message));
|
const auto JsonReader = TJsonReaderFactory<>::Create(USIOJConvert::ToJsonString(Message));
|
||||||
@ -178,8 +197,37 @@ void UCMGameInstance::Init()
|
|||||||
if (GetWorld()->GetName() != "ClientEntry")
|
if (GetWorld()->GetName() != "ClientEntry")
|
||||||
{
|
{
|
||||||
UGameplayStatics::OpenLevel(GetWorld(), "ClientEntry");
|
UGameplayStatics::OpenLevel(GetWorld(), "ClientEntry");
|
||||||
|
}
|
||||||
OnServerClose.Broadcast(JsonMessage);
|
OnServerClose.Broadcast(JsonMessage);
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Socket->OnEvent("ready", [this](const FString& Event, const TSharedPtr<FJsonValue>& Message)
|
||||||
|
{
|
||||||
|
const auto JsonReader = TJsonReaderFactory<>::Create(USIOJConvert::ToJsonString(Message));
|
||||||
|
if (TSharedPtr<FJsonObject> JsonObject; FJsonSerializer::Deserialize(JsonReader, JsonObject))
|
||||||
|
{
|
||||||
|
const auto JsonUsername = JsonObject->GetStringField("username");
|
||||||
|
OnPlayerReady.Broadcast(JsonUsername);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Socket->OnEvent("unready", [this](const FString& Event, const TSharedPtr<FJsonValue>& Message)
|
||||||
|
{
|
||||||
|
const auto JsonReader = TJsonReaderFactory<>::Create(USIOJConvert::ToJsonString(Message));
|
||||||
|
if (TSharedPtr<FJsonObject> JsonObject; FJsonSerializer::Deserialize(JsonReader, JsonObject))
|
||||||
|
{
|
||||||
|
const auto JsonUsername = JsonObject->GetStringField("username");
|
||||||
|
OnPlayerUnReady.Broadcast(JsonUsername);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Socket->OnEvent("start", [this](const FString& Event, const TSharedPtr<FJsonValue>& Message)
|
||||||
|
{
|
||||||
|
if (GetWorld()->GetName() != "ClientEntry") return;
|
||||||
|
if (APlayerController* PC = GetWorld()->GetFirstPlayerController())
|
||||||
|
{
|
||||||
|
PC->ConsoleCommand("open " + ServerFQDN + ":" + FString::FromInt(ServerPort));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -324,7 +372,8 @@ void UCMGameInstance::OnRequestToGetLobbyPlayersComplete(FHttpRequestPtr Request
|
|||||||
{
|
{
|
||||||
const auto JsonUsername = Player->AsObject()->GetStringField("user");
|
const auto JsonUsername = Player->AsObject()->GetStringField("user");
|
||||||
const auto JsonIsOwner = Player->AsObject()->GetBoolField("isOwner");
|
const auto JsonIsOwner = Player->AsObject()->GetBoolField("isOwner");
|
||||||
PlayersInLobby.Add(FPlayerInLobby(JsonUsername, JsonIsOwner));
|
const auto JsonIsReady = Player->AsObject()->GetBoolField("isReady");
|
||||||
|
PlayersInLobby.Add(FPlayerInLobby(JsonUsername, JsonIsOwner, JsonIsReady));
|
||||||
}
|
}
|
||||||
OnGetPlayersInLobbyComplete.Broadcast(true);
|
OnGetPlayersInLobbyComplete.Broadcast(true);
|
||||||
}
|
}
|
||||||
|
@ -36,6 +36,10 @@ public:
|
|||||||
|
|
||||||
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnPlayerLeave, const FString, PlayerName);
|
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnPlayerLeave, const FString, PlayerName);
|
||||||
|
|
||||||
|
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnPlayerReady, const FString, PlayerName);
|
||||||
|
|
||||||
|
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnPlayerUnReady, const FString, PlayerName);
|
||||||
|
|
||||||
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnServerClose, const FString, Message);
|
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnServerClose, const FString, Message);
|
||||||
|
|
||||||
UPROPERTY(BlueprintAssignable, Category = "Account")
|
UPROPERTY(BlueprintAssignable, Category = "Account")
|
||||||
@ -59,6 +63,10 @@ public:
|
|||||||
UPROPERTY(BlueprintAssignable, Category = "Lobby")
|
UPROPERTY(BlueprintAssignable, Category = "Lobby")
|
||||||
FOnPlayerLeave OnPlayerLeave;
|
FOnPlayerLeave OnPlayerLeave;
|
||||||
UPROPERTY(BlueprintAssignable, Category = "Lobby")
|
UPROPERTY(BlueprintAssignable, Category = "Lobby")
|
||||||
|
FOnPlayerReady OnPlayerReady;
|
||||||
|
UPROPERTY(BlueprintAssignable, Category = "Lobby")
|
||||||
|
FOnPlayerUnReady OnPlayerUnReady;
|
||||||
|
UPROPERTY(BlueprintAssignable, Category = "Lobby")
|
||||||
FOnServerClose OnServerClose;
|
FOnServerClose OnServerClose;
|
||||||
|
|
||||||
UPROPERTY(BlueprintReadOnly, Category = "Account")
|
UPROPERTY(BlueprintReadOnly, Category = "Account")
|
||||||
@ -93,6 +101,12 @@ public:
|
|||||||
void GetPlayerLobbyList();
|
void GetPlayerLobbyList();
|
||||||
UFUNCTION(BlueprintCallable, Category = "Lobby")
|
UFUNCTION(BlueprintCallable, Category = "Lobby")
|
||||||
void GetServerLobbyList();
|
void GetServerLobbyList();
|
||||||
|
UFUNCTION(BlueprintCallable, Category = "Lobby")
|
||||||
|
void ReadyUp();
|
||||||
|
UFUNCTION(BlueprintCallable, Category = "Lobby")
|
||||||
|
void UnReady();
|
||||||
|
UFUNCTION(BlueprintCallable, Category = "Lobby")
|
||||||
|
void StartGame();
|
||||||
|
|
||||||
|
|
||||||
virtual void Init() override;
|
virtual void Init() override;
|
||||||
|
@ -14,16 +14,22 @@ struct FPlayerInLobby
|
|||||||
UPROPERTY(VisibleAnywhere, BlueprintReadOnly)
|
UPROPERTY(VisibleAnywhere, BlueprintReadOnly)
|
||||||
bool bIsOwner;
|
bool bIsOwner;
|
||||||
|
|
||||||
FPlayerInLobby(FString Username, const bool bIsOwner)
|
UPROPERTY(VisibleAnywhere, BlueprintReadOnly)
|
||||||
|
bool bIsReady;
|
||||||
|
|
||||||
|
|
||||||
|
FPlayerInLobby(FString Username, const bool bIsOwner, const bool bIsReady)
|
||||||
{
|
{
|
||||||
this->Username = Username;
|
this->Username = Username;
|
||||||
this->bIsOwner = bIsOwner;
|
this->bIsOwner = bIsOwner;
|
||||||
|
this->bIsReady = bIsReady;
|
||||||
}
|
}
|
||||||
|
|
||||||
FPlayerInLobby()
|
FPlayerInLobby()
|
||||||
{
|
{
|
||||||
this->Username = "";
|
this->Username = "";
|
||||||
this->bIsOwner = false;
|
this->bIsOwner = false;
|
||||||
|
this->bIsReady = false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user