Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
14 changes: 9 additions & 5 deletions Assets/Examples/LobbiesServers/Scripts/UI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,15 @@ private BackendClient TEMPBackendClient()
return new BackendClient(config.BackendEndpoint);
}

private string TEMPRegion()
{
return "atl";
}

private string TEMPGameVersion()
{
// var config = new Configuration();
// return config.GameVersion;
return "default";
var config = new Configuration();
return config.GameVersion;
}

private void Start()
Expand Down Expand Up @@ -69,14 +73,14 @@ public async void OnClick_Find()

var response = await TEMPBackendClient().Lobbies.FindOrCreate(new Backend.Model.Lobbies.FindOrCreateRequest(
varVersion: TEMPGameVersion(),
regions: new List<string> { "local" },
regions: new List<string> { TEMPRegion() },
tags: new Dictionary<string, string>
{
// ["gameMode"] = gameMode,
},
players: new List<object> { new() },
createConfig: new Backend.Model.Lobbies.FindOrCreateRequestCreateConfig(
region: "local",
region: TEMPRegion(),
tags: new Dictionary<string, string> { },
maxPlayers: 32,
maxPlayersDirect: 32
Expand Down
4 changes: 2 additions & 2 deletions Assets/Rivet/Editor/Native/librivet_toolchain_ffi.dylib
Git LFS file not shown
Git LFS file not shown
35 changes: 34 additions & 1 deletion Assets/Rivet/Editor/PluginSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using UnityEngine;
using UnityEditor;
using Rivet.Editor.UI;
using Rivet.UI.Screens;

namespace Rivet.Editor
{
Expand Down Expand Up @@ -70,6 +71,38 @@ private static void SaveSettings()
}

// MARK: Settings
[SerializeField]
private EnvironmentType environmentType = EnvironmentType.Local;

public static EnvironmentType EnvironmentType
{
get { return Settings != null ? Settings.environmentType : EnvironmentType.Local; }
set
{
if (Settings != null)
{
Settings.environmentType = value;
SaveSettings();
}
}
}

[SerializeField]
private string? remoteEnvironmentId;

public static string? RemoteEnvironmentId
{
get { return Settings?.remoteEnvironmentId; }
set
{
if (Settings != null)
{
Settings.remoteEnvironmentId = value;
SaveSettings();
}
}
}

[SerializeField]
private bool enableDebugLogs = false;

Expand All @@ -78,7 +111,7 @@ public static bool EnableDebugLogs
get { return Settings != null && Settings.enableDebugLogs; }
}


// TODO: Remove this with cleaner impl
[SerializeField]
private int tempBackendLocalPort = 6420;

Expand Down
3 changes: 2 additions & 1 deletion Assets/Rivet/Editor/Task.cs
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,8 @@ private Result<JObject> RunTask(string name, JObject input, JObject runConfig)
public static string GetRivetCLIPath()
{
// TODO: Update this path as needed
return "/Users/nathan/rivet/cli/target/debug/rivet-cli";
// return "/Users/nathan/rivet/cli/target/debug/rivet-cli";
return "/Users/nathan/rivet/cli/target/debug/rivet";
}

// private static Result<JObject> RunRivetCLI(params string[] args)
Expand Down
11 changes: 0 additions & 11 deletions Assets/Rivet/Editor/UI/Screens/LoginController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,20 +55,13 @@ private async Task CheckLoginState()
{
_pluginWindow.SetScreen(Editor.UI.Screen.Main);
}
else
{
SetLoginButtonEnabled(true);
}

break;
}
}

private async Task SignIn()
{
// Disable the button sign in button
SetLoginButtonEnabled(false);

// Get link token
var getLinkResult = await new RivetTask(
"start_device_link",
Expand All @@ -92,7 +85,6 @@ private async Task SignIn()

break;
case ResultErr<JObject> err:
SetLoginButtonEnabled(true);
return;
default:
throw new System.Exception("unreachable");
Expand All @@ -114,12 +106,9 @@ private async Task SignIn()
_pluginWindow.SetScreen(Editor.UI.Screen.Main);
break;
case ResultErr<JObject> err:
SetLoginButtonEnabled(true);
return;

}
}

void SetLoginButtonEnabled(bool enabled) => _root.Q(name: "SignIn").SetEnabled(enabled);
}
}
10 changes: 4 additions & 6 deletions Assets/Rivet/Editor/UI/Screens/MainController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,19 +55,17 @@ public class MainController
private SettingsController _settingsController;

// MARK: Environment
private EnvironmentType _environmentType = EnvironmentType.Local;
public EnvironmentType EnvironmentType {
get { return _environmentType; }
get { return PluginSettings.EnvironmentType; }
set {
_environmentType = value;
PluginSettings.EnvironmentType = value;
SharedSettings.UpdateFromPlugin();
}
}
private string? _remoteEnvironmentId;
public string? RemoteEnvironmentId {
get { return _remoteEnvironmentId; }
get { return PluginSettings.RemoteEnvironmentId; }
set {
_remoteEnvironmentId = value;
PluginSettings.RemoteEnvironmentId = value;
SharedSettings.UpdateFromPlugin();
}
}
Expand Down
9 changes: 5 additions & 4 deletions Assets/Rivet/Editor/UI/Tabs/DeployController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ private void OnBuildAndDeploy()
// Run deploy with CLI using TaskPopupWindow
var task = TaskPopupWindow.RunTask("Build & Deploy", "deploy", new JObject
{
["cwd"] = serverPath != null ? Path.GetDirectoryName(serverPath) : Builder.ProjectRoot(),
["cwd"] = Builder.ProjectRoot(),
["environment_id"] = environmentId,
["game_server"] = deployGameServer,
["backend"] = deployBackend,
Expand All @@ -124,10 +124,11 @@ private void OnBuildAndDeploy()
{
if (output is ResultOk<JObject> ok)
{
var version = ok.Data["version"]?.ToString();
if (!string.IsNullOrEmpty(version))
var gameServerObj = ok.Data["game_server"];
if (gameServerObj != null && gameServerObj.Type == JTokenType.Object)
{
RivetPlugin.Singleton.GameVersion = ok.Data["version"].ToString();
var version = gameServerObj["version_name"]?.ToString();
RivetPlugin.Singleton.GameVersion = version;
SharedSettings.UpdateFromPlugin();
Debug.Log($"New game version: {RivetPlugin.Singleton.GameVersion}");
}
Expand Down
4 changes: 2 additions & 2 deletions Assets/Rivet/Editor/UI/TaskPopup/TaskPopupWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ private async void InitializeAndStartTask()
try
{
var output = await _task.RunAsync();
OnTaskCompleted(output);
EditorApplication.delayCall += () => OnTaskCompleted(output);
}
catch (Exception ex)
{
Expand All @@ -136,7 +136,6 @@ private void UpdateUI()

private void OnTaskCompleted(Result<JObject> output)
{
OnTaskOutput.Invoke(output);
switch (output)
{
case ResultOk<JObject> ok:
Expand All @@ -146,6 +145,7 @@ private void OnTaskCompleted(Result<JObject> output)
AddLogLine(err.Message, LogType.STDERR);
break;
}
OnTaskOutput.Invoke(output);

UpdateUI();
}
Expand Down
5 changes: 4 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ WORKDIR /app
ARG BUILD_PATH=./Builds/Release/DedicatedServer/Linux_x86_64/
ARG BINARY_NAME=DedicatedServer

# Pass BINARY_NAME to env so we can use it in the entrypoint
ENV BINARY_NAME=${BINARY_NAME}

# Install necessary libraries for Unity
RUN apt-get update && apt-get install -y \
ca-certificates \
Expand All @@ -17,4 +20,4 @@ COPY ${BUILD_PATH} /app
RUN ls /app && chmod +x /app/${BINARY_NAME}

USER rivet
ENTRYPOINT ["/app/${BINARY_NAME}", "-server", "-batchmode", "-nographics"]
ENTRYPOINT "/app/${BINARY_NAME}" "-server" "-batchmode" "-nographics"
13 changes: 10 additions & 3 deletions backend.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
{
"runtime": {
"cors": {
"origins": [
"http://localhost:8080"
]
}
},
"registries": {
"default": {
"local": {
Expand Down Expand Up @@ -27,12 +34,12 @@
"ports": {
"game": {
"protocol": "udp",
"serverPort": 7777
"internalPort": 7777
}
},
"resources": {
"cpu": 1000,
"memory": 1000
"cpu": 250,
"memory": 250
}
}
}
Expand Down