Example #1
0
        public override void TickDefered()
        {
            ReckoningCore.Tick(false);
            ReckoningCore.Move();
            ReckoningCore.Quantize();

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

            var events = Core.TriggeredEvents;
            var mask   = GameContext.MaskAllExceptOne(Player.ClientId);

            if (events.HasFlag(CoreEvents.GROUND_JUMP))
            {
                GameContext.CreateSound(Position, Sound.PLAYER_JUMP, mask);
            }

            if (events.HasFlag(CoreEvents.HOOK_ATTACH_PLAYER))
            {
                GameContext.CreateSound(Position, Sound.HOOK_ATTACH_PLAYER, GameContext.MaskAll());
            }

            if (events.HasFlag(CoreEvents.HOOK_ATTACH_GROUND))
            {
                GameContext.CreateSound(Position, Sound.HOOK_ATTACH_GROUND, mask);
            }

            if (events.HasFlag(CoreEvents.HOOK_HIT_NOHOOK))
            {
                GameContext.CreateSound(Position, Sound.HOOK_NOATTACH, mask);
            }

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

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

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

                if (ReckoningTick + Server.TickSpeed * 3 < Server.Tick || !predicted.Compare(current))
                {
                    ReckoningTick = Server.Tick;
                    Core.FillTo(SendCore);
                    Core.FillTo(ReckoningCore);
                }
            }
        }
Example #2
0
        public virtual void Read(SnapObj_Character character)
        {
            Position = new Vector2(character.PosX, character.PosY);
            Velocity = new Vector2(character.VelX / 256.0f, character.VelY / 256.0f);

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

            Jumped    = character.Jumped;
            Direction = character.Direction;
            Angle     = character.Angle;
        }
Example #3
0
        public virtual void Write(SnapObj_Character character)
        {
            character.PosX = Math.RoundToInt(Position.x);
            character.PosY = Math.RoundToInt(Position.y);

            character.VelX = Math.RoundToInt(Velocity.x * 256.0f);
            character.VelY = Math.RoundToInt(Velocity.y * 256.0f);

            character.HookState = HookState;
            character.HookTick  = HookTick;

            character.HookX = Math.RoundToInt(HookPosition.x);
            character.HookY = Math.RoundToInt(HookPosition.y);

            character.HookDx = Math.RoundToInt(HookDirection.x * 256.0f);
            character.HookDy = Math.RoundToInt(HookDirection.y * 256.0f);

            character.HookedPlayer = HookedPlayer;
            character.Jumped       = Jumped;
            character.Direction    = Direction;
            character.Angle        = Angle;
        }
Example #4
0
 public CharacterCore()
 {
     QuantizeCore = new SnapObj_Character();
     Input        = new SnapObj_PlayerInput();
 }