working on steam multiplayer
This commit is contained in:
@@ -8,6 +8,8 @@ using RebootKit.Engine.Services.Console;
|
||||
using RebootKit.Engine.Services.Crosshair;
|
||||
using RebootKit.Engine.Services.GameMode;
|
||||
using RebootKit.Engine.Services.Simulation;
|
||||
using UnityEngine;
|
||||
using Logger = RebootKit.Engine.Foundation.Logger;
|
||||
|
||||
namespace RebootReality.jelycho.Main {
|
||||
public static class JelychoConsoleCommands {
|
||||
@@ -61,9 +63,33 @@ namespace RebootReality.jelycho.Main {
|
||||
RR.Console.WriteToOutput($" {worldConfigAsset.Config.name}");
|
||||
}
|
||||
}
|
||||
|
||||
[RCCMD("connect", "Connects to a server with given Steam ID. Usage: connect <steam_id>")]
|
||||
public static void ConnectToServer(string[] args) {
|
||||
RR.Console.WriteToOutput("Connecting to server...");
|
||||
|
||||
if (args.Length != 1) {
|
||||
RR.Console.WriteToOutput($"Usage: {args[0]} <steam_id>");
|
||||
return;
|
||||
}
|
||||
|
||||
RR.ConnectToLobby();
|
||||
}
|
||||
|
||||
[RCCMD("disconnect", "Disconnects from the current server")]
|
||||
public static void DisconnectFromServer(string[] args) {
|
||||
if (args.Length != 1) {
|
||||
RR.Console.WriteToOutput($"Usage: {args[0]}");
|
||||
return;
|
||||
}
|
||||
|
||||
RR.Disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
public class JelychoGame : IGame {
|
||||
static readonly Logger s_Logger = new Logger(nameof(JelychoGame));
|
||||
|
||||
[Serializable]
|
||||
public class Config {
|
||||
public string mainMenuWorld = "main_menu";
|
||||
@@ -82,6 +108,8 @@ namespace RebootReality.jelycho.Main {
|
||||
}
|
||||
|
||||
public async UniTask InitAsync(CancellationToken cancellationToken) {
|
||||
Screen.SetResolution(1600, 900, FullScreenMode.Windowed);
|
||||
|
||||
RR.CreateService<CrosshairService>();
|
||||
await UniTask.Yield();
|
||||
}
|
||||
@@ -103,9 +131,19 @@ namespace RebootReality.jelycho.Main {
|
||||
}
|
||||
|
||||
public void NewGame() {
|
||||
NewGameAsync().Forget();
|
||||
}
|
||||
|
||||
async UniTask NewGameAsync() {
|
||||
RR.HostServer();
|
||||
await UniTask.WaitForSeconds(0.5f);
|
||||
|
||||
s_Logger.Info("Starting new game");
|
||||
s_Logger.Info($"Is connected: {RR.IsClient()}");
|
||||
s_Logger.Info($"Is host: {RR.IsHost()}");
|
||||
|
||||
GameModeAsset gameModeAsset = RR.GetGameMode(m_Config.standardGameMode);
|
||||
WorldConfigAsset worldConfigAsset = RR.GetWorldConfigAsset(m_Config.mainGameplayWorld);
|
||||
|
||||
RR.StartGameMode(gameModeAsset, worldConfigAsset.Config);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user