public void ServerDataReceived(AnimatorUpdate au)
        {
            if (!_isActive)
            {
                return;
            }

            //If also server, client host, then do nothing. Animations already ran on server.
            if (base.isServer)
            {
                return;
            }

            //If has authority.
            if (base.hasAuthority)
            {
                //No need to sync to self if client authoritative.
                if (_clientAuthoritative)
                {
                    return;
                }
                //Not client authoritative, but also don't sync to owner.
                else if (!_clientAuthoritative && !_synchronizeToOwner)
                {
                    return;
                }
            }

            ApplyParametersUpdated(au.Data);
        }
Esempio n. 2
0
        public static void SendToObserver(NetworkConnection conn, AnimatorUpdate data)
        {
            List <AnimatorUpdate> datas;

            //If doesn't have datas for connection yet then make new datas.
            if (!_observerReliableAnimatorUpdate.TryGetValue(conn, out datas))
            {
                datas = new List <AnimatorUpdate>();
                _observerReliableAnimatorUpdate[conn] = datas;
            }

            datas.Add(data);
        }
Esempio n. 3
0
        public static AnimatorUpdate ReadAnimatorUpdate(this NetworkReader reader)
        {
            AnimatorUpdate au = new AnimatorUpdate();

            //Component index.
            au.ComponentIndex = reader.ReadByte();

            //Network identity.
            byte netIdCompression = reader.ReadByte();

            if (netIdCompression == 1)
            {
                au.NetworkIdentity = reader.ReadByte();
            }
            else if (netIdCompression == 2)
            {
                au.NetworkIdentity = reader.ReadUInt16();
            }
            else
            {
                au.NetworkIdentity = reader.ReadUInt32();
            }

            //Animation data.
            byte dataLengthCompression = reader.ReadByte();
            int  dataLength;

            if (dataLengthCompression == 1)
            {
                dataLength = reader.ReadByte();
            }
            else if (dataLengthCompression == 2)
            {
                dataLength = reader.ReadUInt16();
            }
            else
            {
                dataLength = reader.ReadInt32();
            }

            if (dataLength > 0)
            {
                au.Data = reader.ReadBytes(dataLength);
            }
            else
            {
                au.Data = new byte[0];
            }

            return(au);
        }
        public void ClientDataReceived(AnimatorUpdate au)
        {
            if (!_isActive)
            {
                return;
            }
            if (!_clientAuthoritative)
            {
                return;
            }

            ApplyParametersUpdated(au.Data);
            //Add to parameters to send to clients.
            _updatesFromClients.Add(au);
        }
Esempio n. 5
0
        public static void WriteAnimatorUpdate(this NetworkWriter writer, AnimatorUpdate au)
        {
            //Component index.
            writer.WriteByte(au.ComponentIndex);

            //Write compressed network identity.
            //byte.
            if (au.NetworkIdentity <= byte.MaxValue)
            {
                writer.WriteByte(1);
                writer.WriteByte((byte)au.NetworkIdentity);
            }
            //ushort.
            else if (au.NetworkIdentity <= ushort.MaxValue)
            {
                writer.WriteByte(2);
                writer.WriteUInt16((ushort)au.NetworkIdentity);
            }
            //Full value.
            else
            {
                writer.WriteByte(4);
                writer.WriteUInt32(au.NetworkIdentity);
            }

            //Animation data.
            //Compress data length.
            if (au.Data.Length <= byte.MaxValue)
            {
                writer.WriteByte(1);
                writer.WriteByte((byte)au.Data.Length);
            }
            else if (au.Data.Length <= ushort.MaxValue)
            {
                writer.WriteByte(2);
                writer.WriteUInt16((ushort)au.Data.Length);
            }
            else
            {
                writer.WriteByte(4);
                writer.WriteInt32(au.Data.Length);
            }
            if (au.Data.Length > 0)
            {
                writer.WriteBytes(au.Data, 0, au.Data.Length);
            }
        }
Esempio n. 6
0
 public static void SendToAll(AnimatorUpdate data)
 {
     _toAllReliableAnimatorUpdate.Add(data);
 }
Esempio n. 7
0
 public static void SendToServer(AnimatorUpdate data)
 {
     _toServerReliableAnimatorUpdate.Add(data);
 }