This commit is contained in:
2025-07-11 14:40:42 +02:00
parent c39b87ed44
commit 0da6f275c0
42 changed files with 756 additions and 226 deletions

View File

@@ -8,7 +8,6 @@ using UnityEngine.AddressableAssets;
using Logger = RebootKit.Engine.Foundation.Logger;
namespace RebootKit.Engine.Simulation {
// @TODO:
// - Actors States might be packed into chunks to reduce the number of RPCs sent.
public class ActorsManager : NetworkBehaviour {
@@ -270,6 +269,7 @@ namespace RebootKit.Engine.Simulation {
return;
}
actor.Manager = this;
actor.SourceActorPath = assetReference.AssetGUID;
actor.ActorID = UniqueID.NewULongFromGuid();
actor.Data = actor.InternalCreateActorData();
@@ -307,6 +307,7 @@ namespace RebootKit.Engine.Simulation {
return;
}
actor.Manager = this;
actor.SourceActorPath = guid;
actor.ActorID = actorID;
actor.Data = actor.InternalCreateActorData();
@@ -334,5 +335,39 @@ namespace RebootKit.Engine.Simulation {
Destroy(actor.gameObject);
}
public bool IsActorHidden(ulong actorID) {
Actor actor = FindActorByID(actorID);
if (actor is null) {
s_Logger.Error($"Actor with ID {actorID} not found.");
return false;
}
return !actor.gameObject.activeSelf;
}
public void SetActorHidden(ulong actorID, bool hidden) {
if (!IsServer) {
s_Logger.Error("Only the server can set actor visibility.");
return;
}
SetActorHiddenRpc(actorID, hidden, RpcTarget.Everyone);
}
[Rpc(SendTo.SpecifiedInParams)]
void SetActorHiddenRpc(ulong actorID, bool hidden, RpcParams rpcParams) {
Actor actor = FindActorByID(actorID);
if (actor is null) {
s_Logger.Error($"Actor with ID {actorID} not found.");
return;
}
if (hidden) {
actor.gameObject.SetActive(false);
} else {
actor.gameObject.SetActive(true);
}
}
}
}