Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

move Netspeak Unreal SDK into Agones Unreal SDK #1739

Merged
merged 7 commits into from
Aug 7, 2020
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 15 additions & 14 deletions sdks/unreal/Agones/Agones.uplugin
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
{
"CanContainContent": false,
"Category": "Agones",
"CreatedBy": "",
"CreatedByURL": "",
"Description": "Agones SDK for Unreal, wrapping the Agones REST API.",
"DocsURL": "https://agones.dev/site/docs/guides/client-sdks/rest/",
"FileVersion": 3,
"Version": 1,
"VersionName": "0.2",
"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/",
"Installed": false,
"IsBetaVersion": false,
"IsExperimentalVersion": false,
"MarketplaceURL": "",
"SupportURL": "https://github.com/googleforgames/agones/issues",
"CanContainContent": false,
"IsBetaVersion": true,
"Installed": true,
"Modules": [
{
"LoadingPhase": "PreLoadingScreen",
"Name": "Agones",
"Type": "Runtime",
"LoadingPhase": "Default"
"Type": "Runtime"
}
]
],
"SupportURL": "https://github.com/googleforgames/agones",
"Version": 2,
"VersionName": "2.0.0"
}
150 changes: 113 additions & 37 deletions sdks/unreal/Agones/README.md
Original file line number Diff line number Diff line change
@@ -1,49 +1,125 @@
# Agones UE4 Plugin
# Agones Unreal SDK

For installation and usage instructions, see
[Unreal Engine Game Server Client Plugin](https://agones.dev/site/docs/guides/client-sdks/unreal/).
Agones is a multilayer dedicated game server scaling and orchestration platform that can run anywhere Kubernetes can run.

If you'd like to contribute to the plugin, see
[CONTRIBUTING.md](/CONTRIBUTING.md)
This is a SDK inspired by the REST API to the Agones sidecars that allows engineers to talk to the sidecar from either C++ or Blueprints.

## Developer Information
## Getting Started
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These user docs should really live in: https://agones.dev/site/docs/guides/client-sdks/unreal/

There is a guide on how to document upcoming features so that they can be hidden until the next release here:
https://agones.dev/site/docs/contribute/#documentation-for-upcoming-features


### Directory Structure
The Agones Unreal SDK can either be used from C++ or from Blueprints.

The plugin consists of a single [UE4
Module](https://docs.unrealengine.com/en-US/Programming/BuildTools/UnrealBuildTool/ModuleFiles/index.html),
also named [Agones](Source/Agones). The structure of this
module is based on the common *Public*/*Private* module layout found in many of
UE4's own internal modules where:
### Getting the Code

- *Public* contains all public C++ header files. These files can be included by
game code and must not include files in *Private*.
- *Private* contains private C++ header and all C++ source files.
Easiest way to get this code is to clone the repository and drop the entire plugin folder into your own `Plugins` folder. This runs the plugin as a Project plugin rather than an engine plugin.

For more information on directory structure, see:
We could however turn this into a marketplace plugin that can be retrived from the marketplace directly into the UE4 editor.

- *PublicIncludePaths* in [Modules](https://docs.unrealengine.com/en-US/Programming/BuildTools/UnrealBuildTool/ModuleFiles/index.html)
- [UE4 Marketplace Guidelines - Code Plugins](https://www.unrealengine.com/en-US/marketplace-guidelines#26)
- [UE4 engine source code](https://github.com/EpicGames/UnrealEngine/tree/release/Engine/Source)
(requires acceptance of [UE4 EULA](https://www.unrealengine.com/en-US/ue4-on-github))
### Health Calls
#### Using C++
- Add Plugin (in your own `.uplugin` file)
```
"Plugins": [
{
"Enabled": true,
"Name": "Agones"
}
],
```
- Add Plugin (in your own `*.Build.cs`)
```
PublicDependencyModuleNames.AddRange(
new[]
{
"Agones",
});
```
- Add component in header
```c++
#include "AgonesComponent.h"

### IWYU
UPROPERTY(EditAnywhere, BlueprintReadWrite)
UAgonesComponent* AgonesSDK;
```
- Initialize component in GameMode
```c++
#include "AgonesComponent.h"
#include "Classes.h"

Code should follow the [Include What You
Use](https://docs.unrealengine.com/en-US/Programming/BuildTools/UnrealBuildTool/IWYU/index.html)
dependency model. From [General Tips](https://docs.unrealengine.com/en-US/Programming/BuildTools/UnrealBuildTool/IWYU/#generaltips):
ATestGameMode::ATestGameMode()
{
AgonesSDK = CreateDefaultSubobject<UAgonesComponent>(TEXT("AgonesSDK"));
}
```

> 1. Include `CoreMinimal.h` at the top of each header file.
> 1. To verify that all of your source files include all of their required
> dependencies, compile your game project in non-unity mode with PCH files
> disabled.
> 1. If you need to access `UEngine` or `GEngine`, which are defined in
> `Runtime\Engine\Classes\Engine\Engine.h`, you can `#include
> Engine/Engine.h` (distinguishing from the monolithic header file, which is
> located at `Runtime\Engine\Public\Engine.h`).
> 1. If you use a class that the compiler doesn't recognize, and don't know
> what you need to include may be missing the header file. This is
> especially the case if you are converting from non-IWYU code that compiled
> correctly. You can look up the class in the API Documentation, and find
> the necessary modules and header files at the bottom of the page.
- Use the Agones component to call PlayerReady
```c++
void APlatformGameSession::PostLogin(APlayerController* NewPlayer)
{
// Empty brances are for callbacks on success and errror.
AgonesSDK->PlayerConnect("netspeak-player", {}, {});
}
```

#### Using Blueprints
- Add Component to your Blueprint GameMode
![component](/docs/img/01_bp_component.PNG)
- This will automatically call `/health` every 10 seconds and once `/gameserver` calls are succesful it will call `/ready`.

- Accessing other functionality of Agones can be done via adding a node in Blueprints.
![actions](/docs/img/02_bp_actions.PNG)


## SDK Functionality

Additional methods have been added for ease of use (both of which are enabled by default):

- Connect
- will call `/gameserver` till a succesful response is returned and then call `/ready`.
- disabled by setting `bDisableAutoConnect` to `true`.
- An event is broadcast with the `GameServer` data once the `/gameserver` call succeeds.
- Health
- calls `/health` endpoint on supplied rate
- enabled by default with 10 second rate
- disabled by default by setting `HealthRateSeconds` to `0`.

Both of the above are automatically kicked off in the `BeginPlay` of the component.

This Agones SDK wraps the REST API and supports the following actions:

Stable
- Lifecycle
- Ready
- Health
- Reserve
- Allocate
- Shutdown
- Configuration
- GameServer
- Metadata
- SetAnnotation
- SetLabel

Alpha
- Player Tracking
- GetConnectedPlayers
- GetPlayerCapacity
- GetPlayerCount
- IsPlayerConnected
- PlayerConnect
- PlayerDisconnect
- SetPlayerCapacity

Unimplemented
- WatchGameServer

Current the only missing functionality is the `WatchGameServer` functionality. We welcome collaborators to help implement this, if people need it before we get around to implementing it ourselves.

## Unreal Hooks

Within the Unreal [GameMode](https://docs.unrealengine.com/en-US/API/Runtime/Engine/GameFramework/AGameMode/index.html) and [GameSession](https://docs.unrealengine.com/en-US/API/Runtime/Engine/GameFramework/AGameSession/index.html) exist a number of useful existing
funtions that can be used to fit in with making calls out to Agones.

A few examples are:
- `RegisterServer` to call `SetLabel`, `SetPlayerCapacity`
- `PostLogin` to call `PlayerConnect`
- `NotifyLogout` to call `PlayerDisconnect`
Binary file modified sdks/unreal/Agones/Resources/Icon128.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
46 changes: 15 additions & 31 deletions sdks/unreal/Agones/Source/Agones/Agones.Build.cs
Original file line number Diff line number Diff line change
@@ -1,43 +1,27 @@
// Copyright 2019 Google LLC 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;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All files will need to have the Google LLC Apache licence at the top please, before we can accept them.


public class Agones : ModuleRules
{
public Agones(ReadOnlyTargetRules Target) : base(Target)
public Agones(ReadOnlyTargetRules target) : base(target)
{
PCHUsage = ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs;

PublicIncludePaths.AddRange(
new string[] {
});

PublicDependencyModuleNames.AddRange(
new string[]
{
"Core",
"Http",
});

PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs;
PublicIncludePaths.AddRange(new string[] {});
PrivateIncludePaths.AddRange(new string[] {});
PublicDependencyModuleNames.AddRange(new[]
{
"Core",
"Http",
"Json",
"JsonUtilities"
});
PrivateDependencyModuleNames.AddRange(
new string[]
new[]
{
"CoreUObject",
"Json",
"JsonUtilities",
"Engine",
"Slate",
"SlateCore"
});
DynamicallyLoadedModuleNames.AddRange(new string[]{ });
}
}
Loading