/// <summary> /// Register new distributed object to this root /// </summary> /// <param name="newObject">New distributed object to be registered</param> public void RegisterObject(DistributedObject newObject) { if (registeredObjects.Contains(newObject)) { return; } registeredObjects.Add(newObject); MessagesManager.RegisterObject(newObject); NewDistributedObjectRegistered?.Invoke(newObject); }
/// <summary> /// Unregister distributed object from this root /// </summary> /// <param name="objectToUnregister">Distributed object to be unregistered</param> public void UnregisterObject(DistributedObject objectToUnregister) { if (!registeredObjects.Contains(objectToUnregister)) { return; } MessagesManager.UnregisterObject(objectToUnregister); registeredObjects.Remove(objectToUnregister); DistributedObjectUnregistered?.Invoke(objectToUnregister); }
/// <summary> /// Locate distributed object in the hierarchy parent objects /// </summary> private DistributedObject LocateParentObject() { var node = transform; while (node != null && parentObject == null) { parentObject = node.GetComponent <DistributedObject>(); node = node.parent; } return(parentObject); }
/// <summary> /// Constructor /// </summary> /// <param name="prefabId">Instantiated object prefab id in the NetworkingConfig</param> /// <param name="distributedObject">Reference to instantiated distributed object component</param> public InstantiatedObjectData(int prefabId, DistributedObject distributedObject) { PrefabId = prefabId; DistributedObject = distributedObject; }