DI updates

This commit is contained in:
2025-03-17 18:43:45 +01:00
parent 569b1d00b3
commit f80fd22a00
18 changed files with 42 additions and 53 deletions

View File

@@ -1,16 +1,16 @@
using UnityEngine;
namespace RebootKit.Engine.Services.Console {
[CreateAssetMenu(fileName = RConsts.AssetMenu + "cvar")]
[CreateAssetMenu(menuName = RConsts.AssetMenu + "cvar", fileName = "cvar")]
public class CVarAsset : ScriptableObject {
[SerializeField]
private CVar _cvar;
public CVar Create(string name = null) {
CVar cvar = new CVar(_cvar);
public CVar Create(string cvarName = null) {
CVar cvar = new(_cvar);
if (name != null) {
cvar.Name = name;
if (cvarName != null) {
cvar.Name = cvarName;
}
return cvar;

View File

@@ -46,7 +46,7 @@ namespace RebootKit.Engine.Services.Console {
_config = config;
}
public async UniTask OnInit(CancellationToken cancellationToken) {
public async UniTask OnWakeUp(CancellationToken cancellationToken) {
_logger.Info("Waking up");
_ui = UnityEngine.Object.Instantiate(_config.ConsoleUIPrefab);

View File

@@ -2,6 +2,7 @@
using Cysharp.Threading.Tasks;
using RebootKit.Engine.Foundation;
using RebootKit.Engine.Services.Console;
using UnityEngine.Assertions;
namespace RebootKit.Engine.Services.Game {
public class GameService : IService {
@@ -11,7 +12,7 @@ namespace RebootKit.Engine.Services.Game {
private GameMode _gameMode;
private bool _running;
public async UniTask OnInit(CancellationToken cancellationToken) {
public async UniTask OnWakeUp(CancellationToken cancellationToken) {
await UniTask.Yield(cancellationToken);
}
@@ -21,6 +22,8 @@ namespace RebootKit.Engine.Services.Game {
}
public async UniTask Start(GameModeAsset asset, CancellationToken cancellationToken) {
Assert.IsNotNull(asset);
_gameMode = asset.Create();
await _gameMode.Start(cancellationToken);

View File

@@ -21,10 +21,6 @@ namespace RebootKit.Engine.Services.Input {
public void Dispose() {
}
public async UniTask OnInit(CancellationToken cancellationToken) {
await UniTask.Yield(cancellationToken);
}
public void EnableControls() {
_config.InputAsset.Enable();
}

View File

@@ -13,10 +13,6 @@ namespace RebootKit.Engine.Services.Simulation {
private WorldConfig _config;
private List<Actor> _actors = new();
public async UniTask OnInit(CancellationToken cancellationToken) {
await UniTask.Yield(cancellationToken);
}
public void Dispose() {
KillAllActors();
}

View File

@@ -4,7 +4,7 @@ using RebootKit.Engine.Foundation;
namespace RebootKit.Engine.Services {
public class UpdateLoopService : IService {
public async UniTask OnInit(CancellationToken cancellationToken) {
public async UniTask OnWakeUp(CancellationToken cancellationToken) {
await UniTask.Yield(cancellationToken);
}