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); }
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); } } }
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; }
public abstract void Read(SnapshotCharacter core);
public CharacterCore() { QuantizeCore = new SnapshotCharacter(); }