diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..f67c4b9 Binary files /dev/null and b/.DS_Store differ diff --git a/Config/DefaultEngine.ini b/Config/DefaultEngine.ini index d71e54f..9715479 100644 --- a/Config/DefaultEngine.ini +++ b/Config/DefaultEngine.ini @@ -1,7 +1,7 @@ [/Script/EngineSettings.GameMapsSettings] -EditorStartupMap=/Engine/Maps/Templates/OpenWorld.OpenWorld +EditorStartupMap=/Game/Maps/M_Menu.M_Menu LocalMapOptions= TransitionMap=None bUseSplitscreen=False @@ -9,8 +9,8 @@ TwoPlayerSplitscreenLayout=Horizontal ThreePlayerSplitscreenLayout=FavorTop FourPlayerSplitscreenLayout=Grid bOffsetPlayerGamepadIds=False -GameInstanceClass=/Script/Engine.GameInstance -GameDefaultMap=/Engine/Maps/Templates/OpenWorld.OpenWorld +GameInstanceClass=/Script/PointBlank.ShipsGameInstance +GameDefaultMap=/Game/Maps/M_Menu.M_Menu ServerDefaultMap=/Engine/Maps/Entry.Entry GlobalDefaultGameMode=/Script/Engine.GameModeBase GlobalDefaultServerGameMode=None diff --git a/Content/Maps/M_Menu.umap b/Content/Maps/M_Menu.umap index da4acf4..05bc34f 100644 Binary files a/Content/Maps/M_Menu.umap and b/Content/Maps/M_Menu.umap differ diff --git a/PointBlank.uproject b/PointBlank.uproject index 1b8d216..1759625 100644 --- a/PointBlank.uproject +++ b/PointBlank.uproject @@ -7,7 +7,10 @@ { "Name": "PointBlank", "Type": "Runtime", - "LoadingPhase": "Default" + "LoadingPhase": "Default", + "AdditionalDependencies": [ + "Engine" + ] } ], "Plugins": [ diff --git a/Source/.DS_Store b/Source/.DS_Store new file mode 100644 index 0000000..4e6956e Binary files /dev/null and b/Source/.DS_Store differ diff --git a/Source/PointBlank/.DS_Store b/Source/PointBlank/.DS_Store new file mode 100644 index 0000000..a58de1c Binary files /dev/null and b/Source/PointBlank/.DS_Store differ diff --git a/Source/PointBlank/PointBlank.Build.cs b/Source/PointBlank/PointBlank.Build.cs index 7b9d50e..4c80b8e 100644 --- a/Source/PointBlank/PointBlank.Build.cs +++ b/Source/PointBlank/PointBlank.Build.cs @@ -8,7 +8,7 @@ public class PointBlank : ModuleRules { PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs; - PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore" }); + PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "WebSockets" }); PrivateDependencyModuleNames.AddRange(new string[] { }); diff --git a/Source/PointBlank/ShipsGameInstance.cpp b/Source/PointBlank/ShipsGameInstance.cpp new file mode 100644 index 0000000..7d673b6 --- /dev/null +++ b/Source/PointBlank/ShipsGameInstance.cpp @@ -0,0 +1,56 @@ +// Fill out your copyright notice in the Description page of Project Settings. + + +#include "ShipsGameInstance.h" +#include "WebSocketsModule.h" +#include "Engine/GameEngine.h" + +void UShipsGameInstance::Init() +{ + Super::Init(); + + if (!FModuleManager::Get().IsModuleLoaded("WebSockets")) + { + FModuleManager::Get().LoadModule("WebSockets"); + } + + WebSocket = FWebSocketsModule::Get().CreateWebSocket("ws://localhost:8080/ws"); + + WebSocket->OnConnected().AddLambda([]() + { + GEngine->AddOnScreenDebugMessage(-1, 15.0f, FColor::Green, "Connected to the server"); + }); + + WebSocket->OnConnectionError().AddLambda([](const FString& Error) + { + GEngine->AddOnScreenDebugMessage(-1, 15.0f, FColor::Red, Error); + }); + + WebSocket->OnClosed().AddLambda([](int32 StatusCode, const FString& Reason, bool bWasClean) + { + GEngine->AddOnScreenDebugMessage(-1, 15.0f, FColor::Yellow, "Connection was closed"); + }); + + WebSocket->OnMessage().AddLambda([](const FString & MessageString) + { + UE_LOG(LogTemp,Warning, TEXT("Received Message:")); + }); + + + GEngine->AddOnScreenDebugMessage(-1, 15.0f, FColor::Green, "init is happening"); + + + WebSocket->Connect(); + +} + +void UShipsGameInstance::Shutdown() +{ + if (WebSocket->IsConnected()) + { + WebSocket->Close(); + } + + Super::Shutdown(); +} + diff --git a/Source/PointBlank/ShipsGameInstance.h b/Source/PointBlank/ShipsGameInstance.h new file mode 100644 index 0000000..af19d61 --- /dev/null +++ b/Source/PointBlank/ShipsGameInstance.h @@ -0,0 +1,25 @@ +// Fill out your copyright notice in the Description page of Project Settings. + +#pragma once + +#include "CoreMinimal.h" +#include "Engine/GameInstance.h" +#include "IWebSocket.h" +#include "ShipsGameInstance.generated.h" + + +/** + * + */ +UCLASS() +class POINTBLANK_API UShipsGameInstance : public UGameInstance +{ + GENERATED_BODY() + +public: + virtual void Init() override; + virtual void Shutdown() override; + + TSharedPtr WebSocket; + +};