something
This commit is contained in:
@@ -28,7 +28,7 @@ namespace RebootKit.Engine.Main {
|
||||
}
|
||||
|
||||
public static class RR {
|
||||
static readonly Logger s_logger = new("RR");
|
||||
static readonly Logger s_Logger = new Logger("RR");
|
||||
|
||||
[ConfigVar("con.write_log", 1, "Enables writing game log to console output")]
|
||||
static ConfigVar s_writeLogToConsole;
|
||||
@@ -48,6 +48,8 @@ namespace RebootKit.Engine.Main {
|
||||
public static WorldService World => s_worldService;
|
||||
public static GameModesService GameModes => s_gameModesService;
|
||||
|
||||
public static Camera MainCamera { get; internal set; }
|
||||
|
||||
static IGame s_game;
|
||||
|
||||
public static async UniTask InitAsync(EngineConfigAsset configAsset, CancellationToken cancellationToken) {
|
||||
@@ -56,11 +58,11 @@ namespace RebootKit.Engine.Main {
|
||||
|
||||
s_engineConfigAsset = configAsset;
|
||||
|
||||
s_logger.Info("Initializing");
|
||||
s_Logger.Info("Initializing");
|
||||
s_servicesBag = new DisposableBag();
|
||||
s_disposableBag = new DisposableBag();
|
||||
|
||||
s_logger.Debug("Registering core services");
|
||||
s_Logger.Debug("Registering core services");
|
||||
s_consoleService = CreateService(s_engineConfigAsset.coreServices.consoleService);
|
||||
s_inputService = CreateService(s_engineConfigAsset.coreServices.inputService);
|
||||
s_worldService = CreateService(s_engineConfigAsset.coreServices.worldService);
|
||||
@@ -68,14 +70,14 @@ namespace RebootKit.Engine.Main {
|
||||
|
||||
await InitializeAssetsAsync(cancellationToken);
|
||||
|
||||
s_logger.Debug("Creating game");
|
||||
s_Logger.Debug("Creating game");
|
||||
s_game = s_engineConfigAsset.gameAsset.CreateGame();
|
||||
|
||||
await s_game.InitAsync(cancellationToken);
|
||||
}
|
||||
|
||||
public static void Shutdown() {
|
||||
s_logger.Info("Shutting down");
|
||||
s_Logger.Info("Shutting down");
|
||||
s_servicesBag.Dispose();
|
||||
s_disposableBag.Dispose();
|
||||
}
|
||||
@@ -85,11 +87,11 @@ namespace RebootKit.Engine.Main {
|
||||
|
||||
#if UNITY_EDITOR
|
||||
string scriptContent = UnityEditor.EditorPrefs.GetString("RebootKitEditor.OnGameRunScriptContent", "");
|
||||
s_logger.Info($"Executing script: {scriptContent}");
|
||||
s_Logger.Info($"Executing script: {scriptContent}");
|
||||
|
||||
if (!string.IsNullOrEmpty(scriptContent)) {
|
||||
foreach (string cmd in scriptContent.Split('\n')) {
|
||||
s_logger.Info($"Executing command: {cmd}");
|
||||
s_Logger.Info($"Executing command: {cmd}");
|
||||
Console.Execute(cmd);
|
||||
}
|
||||
}
|
||||
@@ -97,8 +99,8 @@ namespace RebootKit.Engine.Main {
|
||||
}
|
||||
|
||||
// Assets API
|
||||
static readonly List<GameModeAsset> s_gameModesAssets = new();
|
||||
static readonly List<WorldConfigAsset> s_worldConfigsAssets = new();
|
||||
static readonly List<GameModeAsset> s_gameModesAssets = new List<GameModeAsset>();
|
||||
static readonly List<WorldConfigAsset> s_worldConfigsAssets = new List<WorldConfigAsset>();
|
||||
|
||||
public static IReadOnlyList<GameModeAsset> GameModesAssets => s_gameModesAssets;
|
||||
public static IReadOnlyList<WorldConfigAsset> WorldConfigsAssets => s_worldConfigsAssets;
|
||||
@@ -107,10 +109,10 @@ namespace RebootKit.Engine.Main {
|
||||
s_gameModesAssets.Clear();
|
||||
s_worldConfigsAssets.Clear();
|
||||
|
||||
s_logger.Info("Loading game assets");
|
||||
s_Logger.Info("Loading game assets");
|
||||
|
||||
await Addressables.LoadAssetsAsync<GameModeAsset>("game_mode", asset => { s_gameModesAssets.Add(asset); }).ToUniTask(cancellationToken: cancellationToken);
|
||||
s_logger.Info($"Loaded {s_gameModesAssets.Count} game modes");
|
||||
s_Logger.Info($"Loaded {s_gameModesAssets.Count} game modes");
|
||||
|
||||
await Addressables.LoadAssetsAsync<WorldConfigAsset>("world", asset => { s_worldConfigsAssets.Add(asset); }).ToUniTask(cancellationToken: cancellationToken);
|
||||
}
|
||||
@@ -121,7 +123,7 @@ namespace RebootKit.Engine.Main {
|
||||
throw new ArgumentNullException(nameof(gameMode));
|
||||
}
|
||||
|
||||
s_logger.Info($"Starting game mode: {gameMode.name} in world: {world.name}");
|
||||
s_Logger.Info($"Starting game mode: {gameMode.name} in world: {world.name}");
|
||||
s_gameModesService.Start(gameMode, world);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user