Beispiel #1
0
 private void FixedUpdate()
 {
     if (this.m_ParameterWriter != null)
     {
         int   num;
         float num2;
         this.CheckSendRate();
         if (this.CheckAnimStateChanged(out num, out num2))
         {
             AnimationMessage msg = new AnimationMessage {
                 netId          = base.netId,
                 stateHash      = num,
                 normalizedTime = num2
             };
             this.m_ParameterWriter.SeekZero();
             this.WriteParameters(this.m_ParameterWriter, false);
             msg.parameters = this.m_ParameterWriter.ToArray();
             if (base.hasAuthority || (ClientScene.readyConnection != null))
             {
                 ClientScene.readyConnection.Send(40, msg);
             }
             else if (base.isServer && !base.localPlayerAuthority)
             {
                 NetworkServer.SendToReady(base.gameObject, 40, msg);
             }
         }
     }
 }
Beispiel #2
0
        void FixedUpdate()
        {
            if (!sendMessagesAllowed)
            {
                return;
            }

            if (m_ParameterWriter == null)
            {
                m_ParameterWriter = new NetworkWriter();
            }

            CheckSendRate();

            int   stateHash;
            float normalizedTime;

            if (!CheckAnimStateChanged(out stateHash, out normalizedTime))
            {
                return;
            }

            var animMsg = new AnimationMessage();

            animMsg.netId          = netId;
            animMsg.stateHash      = stateHash;
            animMsg.normalizedTime = normalizedTime;

            m_ParameterWriter.SeekZero();
            WriteParameters(m_ParameterWriter, false);
            animMsg.parameters = m_ParameterWriter.ToArray();

            SendMessage(MsgType.Animation, animMsg);
        }
        private void FixedUpdate()
        {
            if (this.m_ParameterWriter == null)
            {
                return;
            }
            this.CheckSendRate();
            int   stateHash;
            float normalizedTime;

            if (!this.CheckAnimStateChanged(out stateHash, out normalizedTime))
            {
                return;
            }
            AnimationMessage animationMessage = new AnimationMessage();

            animationMessage.netId          = this.netId;
            animationMessage.stateHash      = stateHash;
            animationMessage.normalizedTime = normalizedTime;
            this.m_ParameterWriter.SeekZero();
            this.WriteParameters(this.m_ParameterWriter, false);
            animationMessage.parameters = this.m_ParameterWriter.ToArray();
            if (this.hasAuthority || ClientScene.readyConnection != null)
            {
                ClientScene.readyConnection.Send((short)40, (MessageBase)animationMessage);
            }
            else
            {
                if (!this.isServer || this.localPlayerAuthority)
                {
                    return;
                }
                NetworkServer.SendToReady(this.gameObject, (short)40, (MessageBase)animationMessage);
            }
        }
Beispiel #4
0
 private void FixedUpdate()
 {
     if (m_ParameterWriter == null)
     {
         return;
     }
     CheckSendRate();
     if (CheckAnimStateChanged(out int stateHash, out float normalizedTime))
     {
         AnimationMessage animationMessage = new AnimationMessage();
         animationMessage.netId          = base.netId;
         animationMessage.stateHash      = stateHash;
         animationMessage.normalizedTime = normalizedTime;
         m_ParameterWriter.SeekZero();
         WriteParameters(m_ParameterWriter, autoSend: false);
         animationMessage.parameters = m_ParameterWriter.ToArray();
         if (base.hasAuthority || ClientScene.readyConnection != null)
         {
             ClientScene.readyConnection.Send(40, animationMessage);
         }
         else if (base.isServer && !base.localPlayerAuthority)
         {
             NetworkServer.SendToReady(base.gameObject, 40, animationMessage);
         }
     }
 }
 public virtual Task <Message> SendAnimationAsync(AnimationMessage message,
                                                  CancellationToken cancellationToken = default)
 {
     return(Client.SendAnimationAsync(message.ChatId, message.InputOnlineFile, message.Duration, message.Width,
                                      message.Height, message.Thumb, message.Caption, message.ParseMode,
                                      message.DisableNotification, message.ReplyToMessageId, message.ReplyMarkup, cancellationToken));
 }
        // ------------------ server message handlers -------------------

        static internal void OnAnimationServerMessage(NetworkMessage netMsg)
        {
            AnimationMessage msg = new AnimationMessage();

            netMsg.ReadMessage(msg);
            if (LogFilter.logDev)
            {
                Debug.Log("OnAnimationMessage for netId=" + msg.netId + " conn=" + netMsg.conn);
            }

            GameObject go = NetworkServer.FindLocalObject(msg.netId);

            if (go == null)
            {
                return;
            }
            NetworkAnimator animSync = go.GetComponent <NetworkAnimator>();

            if (animSync != null)
            {
                NetworkReader reader = new NetworkReader(msg.parameters);
                animSync.HandleAnimMsg(msg, reader);

                NetworkServer.SendToReady(go, (short)MsgType.Animation, msg);
            }
        }
Beispiel #7
0
 internal void HandleAnimMsg(AnimationMessage msg, NetworkReader reader)
 {
     if (!base.hasAuthority)
     {
         if (msg.stateHash != 0)
         {
             this.m_Animator.Play(msg.stateHash, 0, msg.normalizedTime);
         }
         this.ReadParameters(reader, false);
     }
 }
Beispiel #8
0
        internal void HandleAnimMsg(AnimationMessage msg, NetworkReader reader)
        {
            if (hasAuthority)
            {
                return;
            }

            // usually transitions will be triggered by parameters, if not, play anims directly.
            // NOTE: this plays "animations", not transitions, so any transitions will be skipped.
            // NOTE: there is no API to play a transition(?)
            if (msg.stateHash != 0)
            {
                m_Animator.Play(msg.stateHash, 0, msg.normalizedTime);
            }

            ReadParameters(reader, false);
        }
        // ------------------ client message handlers -------------------

        static internal void OnAnimationClientMessage(NetworkMessage netMsg)
        {
            AnimationMessage msg = new AnimationMessage();

            netMsg.ReadMessage(msg);

            GameObject go = ClientScene.FindLocalObject(msg.netId);

            if (go == null)
            {
                return;
            }
            var animSync = go.GetComponent <NetworkAnimator>();

            if (animSync != null)
            {
                var reader = new NetworkReader(msg.parameters);
                animSync.HandleAnimMsg(msg, reader);
            }
        }
        void FixedUpdate()
        {
            // check for authority
            if (m_ParameterWriter == null)
            {
                return;
            }

            CheckSendRate();

            int   stateHash;
            float normalizedTime;

            if (!CheckAnimStateChanged(out stateHash, out normalizedTime))
            {
                return;
            }

            var animMsg = new AnimationMessage();

            animMsg.netId          = netId;
            animMsg.stateHash      = stateHash;
            animMsg.normalizedTime = normalizedTime;

            m_ParameterWriter.SeekZero();
            WriteParameters(m_ParameterWriter, false);
            animMsg.parameters = m_ParameterWriter.ToArray();

            if (hasAuthority || ClientScene.readyConnection != null)
            {
                ClientScene.readyConnection.Send(MsgType.Animation, animMsg);
                return;
            }

            // for server-based objects
            if (isServer && !localPlayerAuthority)
            {
                NetworkServer.SendToReady(gameObject, MsgType.Animation, animMsg);
            }
        }
 private void FixedUpdate()
 {
     if (this.sendMessagesAllowed)
     {
         if (this.m_ParameterWriter == null)
         {
             this.m_ParameterWriter = new NetworkWriter();
         }
         this.CheckSendRate();
         int   stateHash;
         float normalizedTime;
         if (this.CheckAnimStateChanged(out stateHash, out normalizedTime))
         {
             AnimationMessage animationMessage = new AnimationMessage();
             animationMessage.netId          = base.netId;
             animationMessage.stateHash      = stateHash;
             animationMessage.normalizedTime = normalizedTime;
             this.m_ParameterWriter.SeekZero();
             this.WriteParameters(this.m_ParameterWriter, false);
             animationMessage.parameters = this.m_ParameterWriter.ToArray();
             this.SendMessage(40, animationMessage);
         }
     }
 }
Beispiel #12
0
 public void NotifyAnimation(AnimationMessage message, GameObject obj, params object[] opData)
 {
     animationController.OnNotification(message, obj, opData);
 }