예제 #1
0
        /// <summary>
        /// Remove the Replica instantly from the manager, without notifying the clients.
        /// </summary>
        /// <param name="replica">The Replica to remove</param>
        /// <remarks>Won't do anything if this replica was removed already</remarks>
        public void RemoveReplica(Replica replica)
        {
            if (replica.Id == ReplicaId.Invalid)
            {
                return; // Replica already removed
            }
            _replicasInConstruction.Remove(replica.Id);
            _networkScene.RemoveReplica(replica);

            if (replica.Id != ReplicaId.Invalid)
            {
                FreeLocalReplicaId(replica.Id);
                replica.Id = ReplicaId.Invalid;
            }
        }
예제 #2
0
        /// <summary>
        /// Removes the Replica instantly from this manager, destroys the GameObject and sends a destroy message to the clients on the next update.
        /// </summary>
        /// <param name="replica">The Replica to remove</param>
        public void DestroyReplica(Replica replica)
        {
            if (replica.Id == ReplicaId.Invalid)
            {
                return; // Replica already destroyed
            }
            // We don't need to send a destroy message if the replica is not yet fully constructed on the server
            bool alreadyConstructed = !_replicasInConstruction.Remove(replica.Id);

            if (!alreadyConstructed)
            {
                _networkScene.RemoveReplica(replica);
                replica.Id = ReplicaId.Invalid;
                UnityEngine.Object.Destroy(replica.gameObject);
                return;
            }

            _replicasInDestruction.Add(replica);
        }
예제 #3
0
 public static void WriteReplicaId(this IBitWriter bs, Replica replica)
 {
     Assert.IsNotNull(replica);
     bs.WriteUShort(replica.Id.Data);
 }
예제 #4
0
 public void RemoveReplica(Replica replica)
 {
     networkScene.RemoveReplica(replica);
 }