Beispiel #1
0
        public void TestSerialization()
        {
            var item = new SnapshotCharacter()
            {
                Tick = 94128,
                X    = 111,
                Y    = 222,
                VelX = 333,
                VelY = 444,

                Angle     = 555,
                Direction = 666,

                Jumped       = 777,
                HookedPlayer = 888,
                HookState    = HookState.RetractStart,
                HookTick     = 999,

                HookX           = 1111,
                HookY           = 2222,
                HookDx          = 3333,
                HookDy          = 4444,
                Health          = 5555,
                Armor           = 6666,
                AmmoCount       = 7777,
                Weapon          = Weapon.Ninja,
                Emote           = Emote.Pain,
                AttackTick      = 8888,
                TriggeredEvents = CoreEvents.HookAttachGround | CoreEvents.AirJump,
            };

            var actual   = item.ToArray();
            var expected = new int[]
            {
                94128,
                111,
                222,
                333,
                444,
                555,
                666,
                777,
                888,
                1,
                999,
                1111,
                2222,
                3333,
                4444,
                5555,
                6666,
                7777,
                5,
                1,
                8888,
                10,
            };

            CollectionAssert.AreEqual(expected, actual);
        }
Beispiel #2
0
        public override void LateTick()
        {
            ReckoningCore.Tick(null);
            ReckoningCore.Move();
            ReckoningCore.Quantize();

            Core.Move();
            Core.Quantize();
            Position = Core.Position;

            if (Player.Team == Team.Spectators)
            {
                Position = new Vector2(Input.TargetX, Input.TargetY);
            }

            {
                var predicted = new SnapshotCharacter();
                var current   = new SnapshotCharacter();

                ReckoningCore.Write(predicted);
                Core.Write(current);

                if (ReckoningTick + Server.TickSpeed * 3 < Server.Tick || !current.Equals(predicted))
                {
                    ReckoningTick = Server.Tick;
                    SendCore.Fill(Core);
                    ReckoningCore.Fill(Core);
                }
            }
        }
Beispiel #3
0
        public override void Read(SnapshotCharacter core)
        {
            Position = new Vector2(core.X, core.Y);
            Velocity = new Vector2(core.VelX / 256.0f, core.VelY / 256.0f);

            HookState     = core.HookState;
            HookTick      = core.HookTick;
            HookPosition  = new Vector2(core.HookX, core.HookY);
            HookDirection = new Vector2(core.HookDx / 256.0f, core.HookDy / 256.0f);
            HookedPlayer  = core.HookedPlayer;

            Jumped    = core.Jumped;
            Direction = core.Direction;
            Angle     = core.Angle;
        }
Beispiel #4
0
 public abstract void Read(SnapshotCharacter core);
Beispiel #5
0
 public CharacterCore()
 {
     QuantizeCore = new SnapshotCharacter();
 }