示例#1
0
 private void World_OnAdd(StatefulObject obj)
 {
     if (obj.ID == currentOwnedObject && !obj.GetComponent <IInputController>().Enabled)
     {
         obj.GetComponent <IInputController>().SetEnabled(true);
     }
 }
示例#2
0
        public void Add(StatefulObject o, int id)
        {
            o.ID = id;
            statefulObjects[id] = o;

            OnAdd?.Invoke(o);
        }
示例#3
0
        public void Add(StatefulObject o)
        {
            int id = statefulObjects.Count + 1;

            o.ID = id;
            statefulObjects[id] = o;

            OnAdd?.Invoke(o);
        }
示例#4
0
        public void Add(StatefulObject o, int id, bool silent = false)
        {
            o.ID = id;
            statefulObjects[id] = o;

            o.Ownable.OnAuthorityChanged += Ownable_OnAuthorityChanged;

            if (!silent)
            {
                OnAdd?.Invoke(o);
            }
        }
示例#5
0
        private void StatefulWorld_OnAdd(StatefulObject obj)
        {
            if (arbiter)
            {
                IdentifiableObject o = obj.GetComponent <IdentifiableObject>();

                // Only the arbiter is permitted to relinquish an object's authority;
                // non-arbiter remotes will hang on to authority until they receive confirmation
                // from the arbiter that the object has relinquished.
                o.GetComponent <StatefulObject>().Ownable.CanRelinquishAuthority = true;
                objectsToSpawn.Add(obj.ID, o);
            }
        }
示例#6
0
        public void AssignOwnership(StatefulObject statefulObject, int peerId)
        {
            if (role == Role.Server)
            {
                NetDataWriter writer = new NetDataWriter();
                writer.Put((byte)PacketType.Ownership);
                writer.Put(statefulObject.ID);

                NetPeer peer = netManager.ConnectedPeerList.Where(x => x.Id == peerId - 1).First();
                peer.Send(writer, DeliveryMethod.ReliableUnordered);
            }
            else
            {
                NetDebug.LogError("Attempting to assign ownership with a non-server peer.");
            }
        }
示例#7
0
        public void Add(StatefulObject o, bool silent = false)
        {
            int id = statefulObjects.Count + 1;

            Add(o, id);
        }
示例#8
0
        public void Add(StatefulObject o)
        {
            int id = statefulObjects.Count + 1;

            Add(o, id);
        }