reanimator
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user