removed r3

This commit is contained in:
2025-10-02 00:38:45 +02:00
parent f9fae63e01
commit fe7dea3c7c
7 changed files with 66 additions and 47 deletions

View File

@@ -3,8 +3,8 @@ using System.Collections.Generic;
using System.Runtime.CompilerServices;
using System.Threading;
using Cysharp.Threading.Tasks;
using R3;
using RebootKit.Engine.Console;
using RebootKit.Engine.Extensions;
using RebootKit.Engine.Foundation;
using RebootKit.Engine.Input;
using RebootKit.Engine.Network;
@@ -32,10 +32,10 @@ namespace RebootKit.Engine.Main {
internal static EngineConfigAsset EngineConfig;
static DisposableBag s_DisposableBag;
static DisposableBag s_ServicesBag;
static AsyncOperationHandle<SceneInstance> s_MainMenuSceneHandle;
internal static GameObject SystemGameObject;
internal static AppLoopManager LoopManager;
internal static NetworkSystem Network;
internal static byte NetworkProtocolVersion {
@@ -62,14 +62,16 @@ namespace RebootKit.Engine.Main {
EngineConfig = configAsset;
s_Logger.Info("Initializing");
s_ServicesBag = new DisposableBag();
s_DisposableBag = new DisposableBag();
s_Logger.Info("Registering core services");
Console = CreateService<ConsoleService>();
Console = new ConsoleService();
Input = new InputService(EngineConfig.inputConfig);
s_ServicesBag.Add(Input);
World = CreateService<WorldService>();
World = new WorldService();
SystemGameObject = new GameObject("__RebootReality__");
Object.DontDestroyOnLoad(SystemGameObject);
LoopManager = SystemGameObject.AddComponent<AppLoopManager>();
#if RR_STEAM
await SteamManager.InitializeAsync(cancellationToken);
@@ -83,9 +85,7 @@ namespace RebootKit.Engine.Main {
// @NOTE: This method is called after the main scene is loaded.
internal static async UniTask RunAsync(CancellationToken cancellationToken) {
Observable.EveryUpdate()
.Subscribe(_ => Tick())
.AddTo(ref s_DisposableBag);
LoopManager.Add(Tick);
await OpenMainMenuAsync(cancellationToken);
@@ -116,9 +116,14 @@ namespace RebootKit.Engine.Main {
#if RR_STEAM
SteamManager.Shutdown();
#endif
s_ServicesBag.Dispose();
s_DisposableBag.Dispose();
World.Dispose();
Input.Dispose();
Console.Dispose();
LoopManager = null;
if (SystemGameObject.OrNull() != null) {
Object.Destroy(SystemGameObject);
}
}
// Assets API
@@ -140,8 +145,7 @@ namespace RebootKit.Engine.Main {
throw new ArgumentException("World config name cannot be null or empty", nameof(name));
}
WorldConfigAsset worldConfig =
s_WorldConfigsAssets.Find(asset => asset.Config.name.Equals(name, StringComparison.Ordinal));
WorldConfigAsset worldConfig = s_WorldConfigsAssets.Find(asset => asset.Config.name.Equals(name, StringComparison.Ordinal));
if (worldConfig is null) {
throw new KeyNotFoundException($"World config '{name}' not found");
}
@@ -271,26 +275,6 @@ namespace RebootKit.Engine.Main {
}
}
//
// @MARK: Service API
// Services seems to be useless in the current architecture. Consider removing this API in the future.
//
public static TService CreateService<TService>(ServiceAsset<TService> asset) where TService : class, IService {
if (asset is null) {
throw new ArgumentNullException($"Null asset of type {typeof(TService)}");
}
TService service = asset.Create();
s_ServicesBag.Add(service);
return service;
}
public static TService CreateService<TService>() where TService : class, IService {
TService service = Activator.CreateInstance<TService>();
s_ServicesBag.Add(service);
return service;
}
//
// @MARK: Logging API
//
@@ -425,9 +409,8 @@ namespace RebootKit.Engine.Main {
throw new NotSupportedException("Cannot send chat message. Not connected to a server.");
}
static void Tick() {
float deltaTime = Time.deltaTime;
Network.Tick(deltaTime);
static void Tick(float dt) {
Network.Tick(dt);
}
internal static void OnServerStarted() {