From e0da9e35aac6affa9e64eaea7463561f1df888ab Mon Sep 17 00:00:00 2001 From: YannickLange Date: Wed, 13 Mar 2019 17:27:29 +0100 Subject: [PATCH 1/3] Unreal Engine 4 Plugin --- sdks/UEAgones/.gitignore | 2 + sdks/UEAgones/README.md | 0 sdks/UEAgones/Resources/Icon128.png | Bin 0 -> 9491 bytes sdks/UEAgones/Source/Agones/Agones.Build.cs | 41 +++++++ sdks/UEAgones/Source/Agones/Agones.cpp | 80 ++++++++++++ sdks/UEAgones/Source/Agones/AgonesHook.cpp | 115 ++++++++++++++++++ sdks/UEAgones/Source/Agones/AgonesHook.h | 63 ++++++++++ .../UEAgones/Source/Agones/AgonesSettings.cpp | 26 ++++ sdks/UEAgones/Source/Agones/Public/Agones.h | 34 ++++++ .../Source/Agones/Public/AgonesSettings.h | 46 +++++++ sdks/UEAgones/UEAgones.uplugin | 23 ++++ 11 files changed, 430 insertions(+) create mode 100644 sdks/UEAgones/.gitignore create mode 100644 sdks/UEAgones/README.md create mode 100644 sdks/UEAgones/Resources/Icon128.png create mode 100644 sdks/UEAgones/Source/Agones/Agones.Build.cs create mode 100644 sdks/UEAgones/Source/Agones/Agones.cpp create mode 100644 sdks/UEAgones/Source/Agones/AgonesHook.cpp create mode 100644 sdks/UEAgones/Source/Agones/AgonesHook.h create mode 100644 sdks/UEAgones/Source/Agones/AgonesSettings.cpp create mode 100644 sdks/UEAgones/Source/Agones/Public/Agones.h create mode 100644 sdks/UEAgones/Source/Agones/Public/AgonesSettings.h create mode 100644 sdks/UEAgones/UEAgones.uplugin diff --git a/sdks/UEAgones/.gitignore b/sdks/UEAgones/.gitignore new file mode 100644 index 0000000000..c4ed221d06 --- /dev/null +++ b/sdks/UEAgones/.gitignore @@ -0,0 +1,2 @@ +Binaries/ +Intermediate/ \ No newline at end of file diff --git a/sdks/UEAgones/README.md b/sdks/UEAgones/README.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/sdks/UEAgones/Resources/Icon128.png b/sdks/UEAgones/Resources/Icon128.png new file mode 100644 index 0000000000000000000000000000000000000000..f8ff97861698de9ba616d777f1681df29c6a525a GIT binary patch literal 9491 zcmeHtS5y>D@b4@L2nr}HAWD?DL;;Bk5`|?!a*h%uXON6UQAtY%$@wEmW?7PoAYow% zl9Q5li2_SbcfJ2}?(==Pk9W?@^r`Nu?yl;Z-_+D}tmZ3aa167F2SCc@LC?kYxJ0EkQZ-vzow@k0gx z?leLb<#gYg@8pm>oBX2b+w=E@!^Qa3vp9WwX2-yW5OguPpq}45EJKRaL0)N`_|e_l zB|lt5dSiNDg2gP~r-iVCxv4F}$tz~lGl<{E)y$P^7Wk477T2VZzfZ=oZIMBt&Pxqm zIpd$iERF-GUODIGt)Ax|nqG7SUhgdi?jrY;NW)of|6iU6!oL@hme&WN;EPHg$Dl+* zS)^FDZ;dvj417QMGU+n`KvnKjORxbj4w8`O1@whhwFRH(zu#Bx&GDe?j#6jN9h=&- zC`a$ZNmE+|mqvSsk+0^Y_PsiBo|8O6wC>f^v(C+OQ92Q;)mJ!8lJ} zI&k^K>+=&xXkqBWBa?OS`e&6kX279=uX^Tc&t7r2_-I0UJu;t_6&K!nv=1d=e(QAg zjmg(Os){UMW};5FAS7I>Z)TfHhUAFyA~kyJu}OI7YlGhY4?vor@>1t!{4>x#6IthX z*VhkJZg~VCdA0AGmKn=Zz7b6TI8B zw9NhXv-($lyUlKongnNx=lx8THj2PT?b+#2r0+M}TFv-#MH)~y{{V`F>vN{28&GI-_*s+6ZP?g2VVUyB!lt6v?dxf!PcHgn2OpQo69>`xz(GX zHNy(Y^?`=`+hUuBM!K*$~ItFM~7_a6YpKo2_tlCqo)p zg+t#i;(?<(V8>(eyW&<$&E!;er3va&66IM?TYVFkN&<<1H;clv$cAY?35NF_gFjd$ zlw|g<#LJ0}3WjZ+jlLEFDw)ewRz)mwJ3&bw70|JY{B+WCD+4s9jp3r8&&a|CDzN#G zom@ECq}bDnY&bvF13P^T%a_PfkCij)O6Y=twlFzZp z;p46DFcDGA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A!4P>%y36&yH1 zQlydxKWqPL%C*+4`YyDxgX4r{i#-5V4b8`6MLQoBKh2%7G0UokmN|Hct ze$@TlLK@4VO?=P3;ZZZAMPmn@^1&fW)Ii%+mMyh$WJT}tCQ+ay@5sw2GUL2E8=kkN;)n|Nrs-$^r~yHzYXL RUDN1@l7HKt{?9*;{{_i$*&F}> literal 0 HcmV?d00001 diff --git a/sdks/UEAgones/Source/Agones/Agones.Build.cs b/sdks/UEAgones/Source/Agones/Agones.Build.cs new file mode 100644 index 0000000000..11fc83634c --- /dev/null +++ b/sdks/UEAgones/Source/Agones/Agones.Build.cs @@ -0,0 +1,41 @@ +// Copyright 2018 Google Inc. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +using UnrealBuildTool; + +public class Agones : ModuleRules +{ + public Agones(ReadOnlyTargetRules Target) : base(Target) + { + PCHUsage = ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs; + + PublicIncludePaths.AddRange( + new string[] { + }); + + PublicDependencyModuleNames.AddRange( + new string[] + { + "Core", + }); + + PrivateDependencyModuleNames.AddRange( + new string[] + { + "CoreUObject", + "Engine", + "Http", + }); + } +} diff --git a/sdks/UEAgones/Source/Agones/Agones.cpp b/sdks/UEAgones/Source/Agones/Agones.cpp new file mode 100644 index 0000000000..8a0547e327 --- /dev/null +++ b/sdks/UEAgones/Source/Agones/Agones.cpp @@ -0,0 +1,80 @@ +// Copyright 2018 Google Inc. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "Agones.h" +#include "AgonesHook.h" + +#if WITH_EDITOR +#include "AgonesSettings.h" +#include "ISettingsModule.h" +#include "ISettingsSection.h" +#include "UObject/Class.h" +#include "UObject/WeakObjectPtr.h" +#endif + +#define LOCTEXT_NAMESPACE "AgonesModule" + +void FAgonesModule::StartupModule() +{ + FWorldDelegates::OnPostWorldInitialization.AddRaw(this, &FAgonesModule::OnWorldInitialized); + + +#if WITH_EDITOR + // register Agones settings + ISettingsModule* SettingsModule = FModuleManager::GetModulePtr("Settings"); + + if (SettingsModule != nullptr) + { + ISettingsSectionPtr SettingsSection = SettingsModule->RegisterSettings("Project", "Plugins", "Agones", + LOCTEXT("AgonesSettingsName", "Agones"), + LOCTEXT("AgonesSettingsDescription", "Configure the Agones plug-in."), + GetMutableDefault() + ); + } +#endif //WITH_EDITOR +} + +void FAgonesModule::ShutdownModule() +{ + FWorldDelegates::OnPostWorldInitialization.RemoveAll(this); + + if (HookPtr.IsValid()) + { + HookPtr->Shutdown(); + } + +#if WITH_EDITOR + // unregister Agones settings + ISettingsModule* SettingsModule = FModuleManager::GetModulePtr("Settings"); + + if (SettingsModule != nullptr) + { + SettingsModule->UnregisterSettings("Project", "Plugins", "Agones"); + } +#endif //WITH_EDITOR +} + +void FAgonesModule::OnWorldInitialized(UWorld* World, const UWorld::InitializationValues IVS) +{ + // Only start the agones hook if this is a dedicated server. + if (World != nullptr && World->GetNetMode() == ENetMode::NM_DedicatedServer) + { + HookPtr = MakeShareable(new FAgonesHook()); + HookPtr->Ready(); + } +} + +#undef LOCTEXT_NAMESPACE + +IMPLEMENT_MODULE(FAgonesModule, Agones) \ No newline at end of file diff --git a/sdks/UEAgones/Source/Agones/AgonesHook.cpp b/sdks/UEAgones/Source/Agones/AgonesHook.cpp new file mode 100644 index 0000000000..452258fc6a --- /dev/null +++ b/sdks/UEAgones/Source/Agones/AgonesHook.cpp @@ -0,0 +1,115 @@ +// Copyright 2018 Google Inc. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "AgonesHook.h" +#include "AgonesSettings.h" +#include "Runtime/Online/HTTP/Public/Http.h" + +#define LOCTEXT_NAMESPACE "AgonesHook" +DEFINE_LOG_CATEGORY(LogAgonesHook); + +FAgonesHook::FAgonesHook() + : FTickableGameObject() + , CurrentHealthTime(0.0f) + , Settings(nullptr) + , ReadySuffix(FString(TEXT("/ready"))) + , HealthSuffix(FString(TEXT("/health"))) + , ShutdownSuffix(FString(TEXT("/shutdown"))) +{ + Settings = GetDefault(); + check(Settings != nullptr); + + UE_LOG(LogAgonesHook, Log, TEXT("Initialized Agones Hook, Sidecar address: %s, Health Enabled: %s, Health Ping: %f, Debug: %s") + , *Settings->AgonesSidecarAddress + , (Settings->bHealthPingEnabled ? TEXT("True") : TEXT("False")) + , Settings->HealthPingSeconds + , (Settings->bDebugLogEnabled ? TEXT("True") : TEXT("False"))); +} + +FAgonesHook::~FAgonesHook() +{ + Settings = nullptr; +} + +void FAgonesHook::Tick(float DeltaTime) +{ + CurrentHealthTime += DeltaTime; + if (CurrentHealthTime >= Settings->HealthPingSeconds) + { + Health(); + CurrentHealthTime = 0.0f; + } +} + +bool FAgonesHook::IsTickable() const +{ + return Settings->bHealthPingEnabled; +} + +TStatId FAgonesHook::GetStatId() const +{ + RETURN_QUICK_DECLARE_CYCLE_STAT(FAgonesHook, STATGROUP_Tickables); +} + +bool FAgonesHook::IsTickableWhenPaused() const +{ + return true; +} + +static TSharedRef MakeRequest(const FString& URL) +{ + FHttpModule* http = &FHttpModule::Get(); + TSharedRef req = http->CreateRequest(); + req->SetURL(URL); + req->SetVerb("POST"); + req->SetHeader("Content-Type", "application/json"); + req->SetContentAsString("{}"); + return req; +} + +void FAgonesHook::Ready() +{ + SendRequest(Settings->AgonesSidecarAddress + ReadySuffix); +} + +void FAgonesHook::Health() +{ + SendRequest(Settings->AgonesSidecarAddress + HealthSuffix); +} + +void FAgonesHook::Shutdown() +{ + SendRequest(Settings->AgonesSidecarAddress + ShutdownSuffix); +} + + +bool FAgonesHook::SendRequest(const FString& URL) +{ + TSharedRef req = MakeRequest(URL); + bool bSuccess = req->ProcessRequest(); + if (Settings->bDebugLogEnabled) + { + if (bSuccess) + { + UE_LOG(LogAgonesHook, Log, TEXT("Send: %s"), *URL); + } + else + { + UE_LOG(LogAgonesHook, Error, TEXT("ERROR - failed sending: %s"), *URL); + } + } + return bSuccess; +} + +#undef LOCTEXT_NAMESPACE \ No newline at end of file diff --git a/sdks/UEAgones/Source/Agones/AgonesHook.h b/sdks/UEAgones/Source/Agones/AgonesHook.h new file mode 100644 index 0000000000..904a506a9b --- /dev/null +++ b/sdks/UEAgones/Source/Agones/AgonesHook.h @@ -0,0 +1,63 @@ +// Copyright 2018 Google Inc. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#pragma once + +#include "CoreMinimal.h" +#include "Tickable.h" + +DECLARE_LOG_CATEGORY_EXTERN(LogAgonesHook, Verbose, All); + +class FAgonesHook : public FTickableGameObject +{ +public: + + /** Default constructor */ + FAgonesHook(); + + /** Deconstructor */ + ~FAgonesHook(); + + // FTickableObjectBase interface + virtual void Tick(float DeltaTime) override; + virtual bool IsTickable() const override; + virtual TStatId GetStatId() const override; + // End FTickableObjectBase interface + + // FTickableGameObject interface + virtual bool IsTickableWhenPaused() const override; + // End FTickableGameObject interface + + /** Sends ready request to sidecar **/ + void Ready(); + /** Sends health ping request to sidecar **/ + void Health(); + /** Sends shutdown request to sidecar **/ + void Shutdown(); + +private: + + /** Helper function to send requests with default debug output */ + bool SendRequest(const FString& URL); + + /** Time since last health ping */ + float CurrentHealthTime; + + /** Agones settings */ + const class UAgonesSettings* Settings; + + const FString ReadySuffix; + const FString HealthSuffix; + const FString ShutdownSuffix; +}; \ No newline at end of file diff --git a/sdks/UEAgones/Source/Agones/AgonesSettings.cpp b/sdks/UEAgones/Source/Agones/AgonesSettings.cpp new file mode 100644 index 0000000000..838d8d4b71 --- /dev/null +++ b/sdks/UEAgones/Source/Agones/AgonesSettings.cpp @@ -0,0 +1,26 @@ +// Copyright 2019 Google Inc. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "AgonesSettings.h" + +UAgonesSettings::UAgonesSettings() + : Super() + , AgonesSidecarAddress("http://localhost:59358") + , bHealthPingEnabled(false) + , HealthPingSeconds(5.0f) + , bDebugLogEnabled(false) +{ +} + + \ No newline at end of file diff --git a/sdks/UEAgones/Source/Agones/Public/Agones.h b/sdks/UEAgones/Source/Agones/Public/Agones.h new file mode 100644 index 0000000000..44d0e2a974 --- /dev/null +++ b/sdks/UEAgones/Source/Agones/Public/Agones.h @@ -0,0 +1,34 @@ +// Copyright 2018 Google Inc. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#pragma once + +#include "CoreMinimal.h" +#include "ModuleManager.h" +#include "Engine/World.h" + +class FAgonesModule : public IModuleInterface +{ +public: + + /** IModuleInterface implementation */ + virtual void StartupModule() override; + virtual void ShutdownModule() override; + +private: + void OnWorldInitialized(UWorld* World, UWorld::InitializationValues IVS); + + /** Communicates with the Agones sidecar. */ + TSharedPtr HookPtr; +}; \ No newline at end of file diff --git a/sdks/UEAgones/Source/Agones/Public/AgonesSettings.h b/sdks/UEAgones/Source/Agones/Public/AgonesSettings.h new file mode 100644 index 0000000000..179e17e322 --- /dev/null +++ b/sdks/UEAgones/Source/Agones/Public/AgonesSettings.h @@ -0,0 +1,46 @@ +// Copyright 2018 Google Inc. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#pragma once + +#include "CoreMinimal.h" +#include "UObject/ObjectMacros.h" +#include "UObject/Object.h" +#include "AgonesSettings.generated.h" + +/** + * Implements the settings for Agones. + */ +UCLASS(config = Game) +class AGONES_API UAgonesSettings : public UObject +{ + GENERATED_BODY() + +public: + + /** Default constructor */ + UAgonesSettings(); + + UPROPERTY(EditAnywhere, config, Category = "Agones", meta = (DisplayName = "Agones Sidecar IP Address")) + FString AgonesSidecarAddress; + + UPROPERTY(EditAnywhere, config, Category = "Agones", meta = (DisplayName = "Health Ping Enabled")) + bool bHealthPingEnabled; + + UPROPERTY(EditAnywhere, config, Category = "Agones", meta = (DisplayName = "Health Ping Seconds")) + float HealthPingSeconds; + + UPROPERTY(EditAnywhere, config, Category = "Agones", meta = (DisplayName = "Debug Logging Enabled")) + bool bDebugLogEnabled; +}; diff --git a/sdks/UEAgones/UEAgones.uplugin b/sdks/UEAgones/UEAgones.uplugin new file mode 100644 index 0000000000..c53754d565 --- /dev/null +++ b/sdks/UEAgones/UEAgones.uplugin @@ -0,0 +1,23 @@ +{ + "FileVersion": 3, + "Version": 1, + "VersionName": "0.1", + "FriendlyName": "Agones", + "Description": "Unreal Engine Plugin for Agones Game Server Client", + "Category": "Google", + "CreatedBy": "Google Inc", + "CreatedByURL": "https://agones.dev", + "DocsURL": "https://agones.dev/site/docs/", + "MarketplaceURL": "", + "SupportURL": "https://github.com/GoogleCloudPlatform/agones/issues", + "CanContainContent": false, + "IsBetaVersion": true, + "Installed": true, + "Modules": [ + { + "Name": "Agones", + "Type": "Runtime", + "LoadingPhase": "Default" + } + ] +} From 5ec463e9686050aea50ba73900e381031c3e8165 Mon Sep 17 00:00:00 2001 From: YannickLange Date: Mon, 8 Apr 2019 12:57:38 +0200 Subject: [PATCH 2/3] Added docs and moved plugin to unreal folder. - Changed copyright to 2019 - Removed unused REAMDE.md --- sdks/UEAgones/README.md | 0 sdks/{UEAgones => unreal/Agones}/.gitignore | 0 .../Agones/Agones.uplugin} | 0 .../Agones}/Resources/Icon128.png | Bin .../Agones}/Source/Agones/Agones.Build.cs | 2 +- .../Agones}/Source/Agones/Agones.cpp | 2 +- .../Agones}/Source/Agones/AgonesHook.cpp | 4 +- .../Agones}/Source/Agones/AgonesHook.h | 2 +- .../Agones}/Source/Agones/AgonesSettings.cpp | 0 .../Agones}/Source/Agones/Public/Agones.h | 44 +++++++++--------- .../Source/Agones/Public/AgonesSettings.h | 2 +- .../en/docs/Guides/Client SDKs/unreal.md | 37 +++++++++++++++ 12 files changed, 65 insertions(+), 28 deletions(-) delete mode 100644 sdks/UEAgones/README.md rename sdks/{UEAgones => unreal/Agones}/.gitignore (100%) rename sdks/{UEAgones/UEAgones.uplugin => unreal/Agones/Agones.uplugin} (100%) rename sdks/{UEAgones => unreal/Agones}/Resources/Icon128.png (100%) rename sdks/{UEAgones => unreal/Agones}/Source/Agones/Agones.Build.cs (91%) rename sdks/{UEAgones => unreal/Agones}/Source/Agones/Agones.cpp (94%) rename sdks/{UEAgones => unreal/Agones}/Source/Agones/AgonesHook.cpp (93%) rename sdks/{UEAgones => unreal/Agones}/Source/Agones/AgonesHook.h (93%) rename sdks/{UEAgones => unreal/Agones}/Source/Agones/AgonesSettings.cpp (100%) rename sdks/{UEAgones => unreal/Agones}/Source/Agones/Public/Agones.h (92%) rename sdks/{UEAgones => unreal/Agones}/Source/Agones/Public/AgonesSettings.h (95%) create mode 100644 site/content/en/docs/Guides/Client SDKs/unreal.md diff --git a/sdks/UEAgones/README.md b/sdks/UEAgones/README.md deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/sdks/UEAgones/.gitignore b/sdks/unreal/Agones/.gitignore similarity index 100% rename from sdks/UEAgones/.gitignore rename to sdks/unreal/Agones/.gitignore diff --git a/sdks/UEAgones/UEAgones.uplugin b/sdks/unreal/Agones/Agones.uplugin similarity index 100% rename from sdks/UEAgones/UEAgones.uplugin rename to sdks/unreal/Agones/Agones.uplugin diff --git a/sdks/UEAgones/Resources/Icon128.png b/sdks/unreal/Agones/Resources/Icon128.png similarity index 100% rename from sdks/UEAgones/Resources/Icon128.png rename to sdks/unreal/Agones/Resources/Icon128.png diff --git a/sdks/UEAgones/Source/Agones/Agones.Build.cs b/sdks/unreal/Agones/Source/Agones/Agones.Build.cs similarity index 91% rename from sdks/UEAgones/Source/Agones/Agones.Build.cs rename to sdks/unreal/Agones/Source/Agones/Agones.Build.cs index 11fc83634c..c59446b946 100644 --- a/sdks/UEAgones/Source/Agones/Agones.Build.cs +++ b/sdks/unreal/Agones/Source/Agones/Agones.Build.cs @@ -1,4 +1,4 @@ -// Copyright 2018 Google Inc. All Rights Reserved. +// Copyright 2019 Google Inc. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/sdks/UEAgones/Source/Agones/Agones.cpp b/sdks/unreal/Agones/Source/Agones/Agones.cpp similarity index 94% rename from sdks/UEAgones/Source/Agones/Agones.cpp rename to sdks/unreal/Agones/Source/Agones/Agones.cpp index 8a0547e327..50e795dbc2 100644 --- a/sdks/UEAgones/Source/Agones/Agones.cpp +++ b/sdks/unreal/Agones/Source/Agones/Agones.cpp @@ -1,4 +1,4 @@ -// Copyright 2018 Google Inc. All Rights Reserved. +// Copyright 2019 Google Inc. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/sdks/UEAgones/Source/Agones/AgonesHook.cpp b/sdks/unreal/Agones/Source/Agones/AgonesHook.cpp similarity index 93% rename from sdks/UEAgones/Source/Agones/AgonesHook.cpp rename to sdks/unreal/Agones/Source/Agones/AgonesHook.cpp index 452258fc6a..1a96bceb41 100644 --- a/sdks/UEAgones/Source/Agones/AgonesHook.cpp +++ b/sdks/unreal/Agones/Source/Agones/AgonesHook.cpp @@ -1,4 +1,4 @@ -// Copyright 2018 Google Inc. All Rights Reserved. +// Copyright 2019 Google Inc. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -106,7 +106,7 @@ bool FAgonesHook::SendRequest(const FString& URL) } else { - UE_LOG(LogAgonesHook, Error, TEXT("ERROR - failed sending: %s"), *URL); + UE_LOG(LogAgonesHook, Error, TEXT("Failed sending: %s"), *URL); } } return bSuccess; diff --git a/sdks/UEAgones/Source/Agones/AgonesHook.h b/sdks/unreal/Agones/Source/Agones/AgonesHook.h similarity index 93% rename from sdks/UEAgones/Source/Agones/AgonesHook.h rename to sdks/unreal/Agones/Source/Agones/AgonesHook.h index 904a506a9b..7520951e6c 100644 --- a/sdks/UEAgones/Source/Agones/AgonesHook.h +++ b/sdks/unreal/Agones/Source/Agones/AgonesHook.h @@ -1,4 +1,4 @@ -// Copyright 2018 Google Inc. All Rights Reserved. +// Copyright 2019 Google Inc. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/sdks/UEAgones/Source/Agones/AgonesSettings.cpp b/sdks/unreal/Agones/Source/Agones/AgonesSettings.cpp similarity index 100% rename from sdks/UEAgones/Source/Agones/AgonesSettings.cpp rename to sdks/unreal/Agones/Source/Agones/AgonesSettings.cpp diff --git a/sdks/UEAgones/Source/Agones/Public/Agones.h b/sdks/unreal/Agones/Source/Agones/Public/Agones.h similarity index 92% rename from sdks/UEAgones/Source/Agones/Public/Agones.h rename to sdks/unreal/Agones/Source/Agones/Public/Agones.h index 44d0e2a974..12fbb4f0d0 100644 --- a/sdks/UEAgones/Source/Agones/Public/Agones.h +++ b/sdks/unreal/Agones/Source/Agones/Public/Agones.h @@ -1,4 +1,4 @@ -// Copyright 2018 Google Inc. All Rights Reserved. +// Copyright 2019 Google Inc. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -10,25 +10,25 @@ // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and -// limitations under the License. - -#pragma once - -#include "CoreMinimal.h" -#include "ModuleManager.h" -#include "Engine/World.h" - -class FAgonesModule : public IModuleInterface -{ -public: - - /** IModuleInterface implementation */ - virtual void StartupModule() override; - virtual void ShutdownModule() override; - -private: - void OnWorldInitialized(UWorld* World, UWorld::InitializationValues IVS); - - /** Communicates with the Agones sidecar. */ - TSharedPtr HookPtr; +// limitations under the License. + +#pragma once + +#include "CoreMinimal.h" +#include "ModuleManager.h" +#include "Engine/World.h" + +class FAgonesModule : public IModuleInterface +{ +public: + + /** IModuleInterface implementation */ + virtual void StartupModule() override; + virtual void ShutdownModule() override; + +private: + void OnWorldInitialized(UWorld* World, UWorld::InitializationValues IVS); + + /** Communicates with the Agones sidecar. */ + TSharedPtr HookPtr; }; \ No newline at end of file diff --git a/sdks/UEAgones/Source/Agones/Public/AgonesSettings.h b/sdks/unreal/Agones/Source/Agones/Public/AgonesSettings.h similarity index 95% rename from sdks/UEAgones/Source/Agones/Public/AgonesSettings.h rename to sdks/unreal/Agones/Source/Agones/Public/AgonesSettings.h index 179e17e322..f0fb3b7145 100644 --- a/sdks/UEAgones/Source/Agones/Public/AgonesSettings.h +++ b/sdks/unreal/Agones/Source/Agones/Public/AgonesSettings.h @@ -1,4 +1,4 @@ -// Copyright 2018 Google Inc. All Rights Reserved. +// Copyright 2019 Google Inc. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/site/content/en/docs/Guides/Client SDKs/unreal.md b/site/content/en/docs/Guides/Client SDKs/unreal.md new file mode 100644 index 0000000000..01a6869475 --- /dev/null +++ b/site/content/en/docs/Guides/Client SDKs/unreal.md @@ -0,0 +1,37 @@ +--- +title: "Unreal Engine Game Server Client Plugin" +linkTitle: "Unreal Engine" +date: 2019-01-02T10:17:50Z +weight: 10 +description: "This is the Unreal Engine 4 Agones Game Server Client Plugin. " +--- + +Check the [Client SDK Documentation]({{< relref "_index.md" >}}) for more details on each of the SDK functions and how to run the SDK locally. + +## Download + +Download the source from the [Releases Page](https://github.com/GoogleCloudPlatform/agones/releases) +or {{< ghlink href="sdks/unreal" >}}directly from Github{{< /ghlink >}}. + +## Usage + +The Unreal Engine plugin is specifically designed to be as simple as possible. No programming should be required to use the plugin within your Unreal Engine project. + +### From source + +At this moment we do not provide binaries for the plugin. This requires you to compile the plugin yourself. In order to do this you need to have a C++ Unreal Engine project. + +1. Create a `Plugins` directory in your Unreal Engine project root directory. +2. Copy {{< ghlink href="sdks/unreal" >}}the Agones plugin directory{{< /ghlink >}} into the Plugins directory. +3. Build the project. + +## Settings + +The settings for the Agones Plugin can be found in the Unreal Engine editor `Edit > Project Settings > Plugins > Agones` + +Available settings: +- Agones Sidecar IP. (default: `http://localhost:59358`) +- Health Ping Enabled. Whether the server sends a health ping to the Agones sidecar. (default: `true`) +- Health Ping Seconds. Interval of the server sending a health ping to the Agones sidecar. (default: `5`) +- Debug Logging Enabled. Debug logging for development of this Plugin. (default: `false`) + From b18773733c1584d7e7147ce3c8c15553dfd1e54c Mon Sep 17 00:00:00 2001 From: Mark Mandel Date: Mon, 15 Apr 2019 22:43:24 +0200 Subject: [PATCH 3/3] Update unreal.md date Co-Authored-By: YannickLange --- site/content/en/docs/Guides/Client SDKs/unreal.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/site/content/en/docs/Guides/Client SDKs/unreal.md b/site/content/en/docs/Guides/Client SDKs/unreal.md index 01a6869475..aaff26fefd 100644 --- a/site/content/en/docs/Guides/Client SDKs/unreal.md +++ b/site/content/en/docs/Guides/Client SDKs/unreal.md @@ -1,7 +1,8 @@ --- title: "Unreal Engine Game Server Client Plugin" linkTitle: "Unreal Engine" -date: 2019-01-02T10:17:50Z +date: 2019-06-13T10:17:50Z +publishDate: 2019-06-13 weight: 10 description: "This is the Unreal Engine 4 Agones Game Server Client Plugin. " ---