reanimator

This commit is contained in:
2025-08-08 23:37:33 +02:00
parent 369f7099ad
commit 2d06552025
10 changed files with 268 additions and 2 deletions

View File

@@ -188,6 +188,35 @@ namespace RebootKit.Engine.Simulation {
actor.ActorID = actorID;
}
}
public Actor SpawnLocalOnlyActor(AssetReferenceGameObject assetReference, Vector3 position, Quaternion rotation) {
if (!assetReference.RuntimeKeyIsValid()) {
s_Logger.Error("Trying to spawn an actor with an invalid asset reference.");
return null;
}
if (!TryGenerateNextActorID(out ushort actorID)) {
s_Logger.Error("Cannot spawn actor: Failed to generate next actor ID.");
return null;
}
GameObject actorObject = assetReference.InstantiateAsync(position, rotation).WaitForCompletion();
Actor actor = actorObject.GetComponent<Actor>();
if (actor is null) {
s_Logger.Error($"GameObject {actorObject.name} does not have an Actor component.");
Object.Destroy(actorObject);
return null;
}
actor.Manager = this;
actor.IsLocalOnly = true;
actor.SourceActorPath = assetReference.AssetGUID;
actor.ActorID = actorID;
actor.Data = actor.InternalCreateActorData();
// m_SpawnedActors.Add(actor);
return actor;
}
//
// @MARK: Common API