working on steam multiplayer

This commit is contained in:
2025-06-24 14:45:26 +02:00
parent 3f62560279
commit 40d07041fa
41 changed files with 13770 additions and 55 deletions

View File

@@ -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);
}
}

View File

@@ -1,10 +1,11 @@
using RebootKit.Engine.Main;
using TriInspector;
using UnityEngine;
namespace RebootReality.jelycho.Main {
[CreateAssetMenu(menuName = GameConsts.k_AddComponentMenu + "Jelycho Game")]
public class JelychoGameAsset : GameAsset {
[SerializeField] JelychoGame.Config m_Config;
[SerializeField, InlineProperty, HideLabel] JelychoGame.Config m_Config;
public override IGame CreateGame() {
return new JelychoGame(m_Config);