Ejemplo n.º 1
0
        public void ClientRead(ServerNetObject type, Lidgren.Network.NetBuffer msg, float sendingTime)
        {
            SetState(msg.ReadBoolean(), true);
            Stuck = msg.ReadRangedSingle(0.0f, 100.0f, 8);

            predictedState = null;
        }
Ejemplo n.º 2
0
        public void ServerRead(ClientNetObject type, Lidgren.Network.NetBuffer msg, Client c)
        {
            bool  isActive = msg.ReadBoolean();
            bool  directionalPing = useDirectionalPing;
            float zoomT = zoom, pingDirectionT = 0.0f;

            if (isActive)
            {
                zoomT           = msg.ReadRangedSingle(0.0f, 1.0f, 8);
                directionalPing = msg.ReadBoolean();
                if (directionalPing)
                {
                    pingDirectionT = msg.ReadRangedSingle(0.0f, 1.0f, 8);
                }
            }

            if (!item.CanClientAccess(c))
            {
                return;
            }

            IsActive = isActive;

            //TODO: cleanup
#if CLIENT
            activeTickBox.Selected = IsActive;
#endif
            if (isActive)
            {
                zoom = MathHelper.Lerp(MinZoom, MaxZoom, zoomT);
                useDirectionalPing = directionalPing;
                if (useDirectionalPing)
                {
                    float pingAngle = MathHelper.Lerp(0.0f, MathHelper.TwoPi, pingDirectionT);
                    pingDirection = new Vector2((float)Math.Cos(pingAngle), (float)Math.Sin(pingAngle));
                }
#if CLIENT
                zoomSlider.BarScroll        = zoomT;
                directionalTickBox.Selected = useDirectionalPing;
                directionalSlider.BarScroll = pingDirectionT;
#endif
            }
#if SERVER
            item.CreateServerEvent(this);
#endif
        }
Ejemplo n.º 3
0
        public void ClientRead(ServerNetObject type, Lidgren.Network.NetBuffer msg, float sendingTime)
        {
            long msgStartPos = msg.Position;

            bool  isActive        = msg.ReadBoolean();
            float zoomT           = 1.0f;
            bool  directionalPing = useDirectionalPing;
            float directionT      = 0.0f;

            if (isActive)
            {
                zoomT           = msg.ReadRangedSingle(0.0f, 1.0f, 8);
                directionalPing = msg.ReadBoolean();
                if (directionalPing)
                {
                    directionT = msg.ReadRangedSingle(0.0f, 1.0f, 8);
                }
            }

            if (correctionTimer > 0.0f)
            {
                int msgLength = (int)(msg.Position - msgStartPos);
                msg.Position = msgStartPos;
                StartDelayedCorrection(type, msg.ExtractBits(msgLength), sendingTime);
                return;
            }

            IsActive = isActive;
            if (isActive)
            {
                activeTickBox.Selected = true;
                zoomSlider.BarScroll   = zoomT;
                zoom = MathHelper.Lerp(MinZoom, MaxZoom, zoomT);
                if (directionalPing)
                {
                    directionalSlider.BarScroll = directionT;
                    float pingAngle = MathHelper.Lerp(0.0f, MathHelper.TwoPi, directionalSlider.BarScroll);
                    pingDirection = new Vector2((float)Math.Cos(pingAngle), (float)Math.Sin(pingAngle));
                }
                useDirectionalPing = directionalTickBox.Selected = directionalPing;
            }
            else
            {
                passiveTickBox.Selected = true;
            }
        }
Ejemplo n.º 4
0
        public override void ClientRead(ServerNetObject type, Lidgren.Network.NetBuffer msg, float sendingTime)
        {
            base.ClientRead(type, msg, sendingTime);

            SetState(msg.ReadBoolean(), isNetworkMessage: true, sendNetworkMessage: false);
            Stuck = msg.ReadRangedSingle(0.0f, 100.0f, 8);

            PredictedState = null;
        }