...
This commit is contained in:
@@ -49,10 +49,6 @@ namespace RebootKit.Engine.Main {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!configAsset.initializeOnLoad) {
|
||||
return;
|
||||
}
|
||||
|
||||
s_logger.Info("Initializing RR");
|
||||
await RR.InitAsync(configAsset, cancellationToken);
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
using System;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using RebootKit.Engine.Services.Simulation;
|
||||
using Unity.Collections;
|
||||
using Unity.Netcode;
|
||||
using UnityEngine;
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using RebootKit.Engine.Services.Simulation;
|
||||
using RebootKit.Engine.Simulation;
|
||||
using Unity.Collections;
|
||||
using Unity.Netcode;
|
||||
|
||||
@@ -3,11 +3,9 @@ using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using R3;
|
||||
using RebootKit.Engine.Console;
|
||||
using RebootKit.Engine.Foundation;
|
||||
using RebootKit.Engine.Input;
|
||||
using RebootKit.Engine.Services.Console;
|
||||
using RebootKit.Engine.Services.Input;
|
||||
using RebootKit.Engine.Services.Simulation;
|
||||
using RebootKit.Engine.Simulation;
|
||||
using RebootKit.Engine.Steam;
|
||||
using Unity.Netcode;
|
||||
@@ -65,9 +63,10 @@ namespace RebootKit.Engine.Main {
|
||||
s_disposableBag = new DisposableBag();
|
||||
|
||||
s_Logger.Info("Registering core services");
|
||||
Console = CreateService(EngineConfig.coreServices.consoleService);
|
||||
Input = CreateService(EngineConfig.coreServices.inputService);
|
||||
World = CreateService(EngineConfig.coreServices.worldService);
|
||||
Console = CreateService<ConsoleService>();
|
||||
Input = new InputService(EngineConfig.inputConfig);
|
||||
s_servicesBag.Add(Input);
|
||||
World = CreateService<WorldService>();
|
||||
|
||||
await InitializeAssetsAsync(cancellationToken);
|
||||
|
||||
@@ -217,6 +216,20 @@ namespace RebootKit.Engine.Main {
|
||||
s_Logger.Info($"Spawning actor from asset reference: {assetReference.RuntimeKey}");
|
||||
NetworkSystemInstance.Actors.SpawnActor(assetReference, position, rotation);
|
||||
}
|
||||
|
||||
public static Actor FindSpawnedActor(ulong actorID) {
|
||||
if (NetworkSystemInstance is null) {
|
||||
s_Logger.Error("NetworkSystemInstance is not initialized. Cannot find actor.");
|
||||
return null;
|
||||
}
|
||||
|
||||
Actor actor = NetworkSystemInstance.Actors.FindActorByID(actorID);
|
||||
if (actor is null) {
|
||||
s_Logger.Error($"Actor with ID {actorID} not found");
|
||||
}
|
||||
|
||||
return actor;
|
||||
}
|
||||
|
||||
// Service API
|
||||
public static TService CreateService<TService>(ServiceAsset<TService> asset) where TService : class, IService {
|
||||
@@ -235,7 +248,7 @@ namespace RebootKit.Engine.Main {
|
||||
return service;
|
||||
}
|
||||
|
||||
// Logging API
|
||||
// Logging API
|
||||
public static void Log(string message) {
|
||||
Debug.Log(message);
|
||||
Console?.WriteToOutput(message);
|
||||
@@ -396,7 +409,10 @@ namespace RebootKit.Engine.Main {
|
||||
}
|
||||
|
||||
if (NetworkSystemInstance is not null) {
|
||||
NetworkSystemInstance.NetworkObject.Despawn();
|
||||
if (NetworkSystemInstance.NetworkObject is not null && NetworkSystemInstance.NetworkObject.IsSpawned) {
|
||||
NetworkSystemInstance.NetworkObject.Despawn();
|
||||
}
|
||||
|
||||
NetworkSystemInstance = null;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user