示例#1
0
        public static void Update(bool updateVel = false)
        {
            if (Engine.Scene is Level level)
            {
                Player player = level.Tracker.GetEntity <Player>();
                if (player != null)
                {
                    string        pos   = GetAdjustedPos(player, out string exactPos);
                    string        speed = GetAdjustedSpeed(player.Speed, out string exactSpeed);
                    Vector2Double diff  = player.GetMoreExactPosition(false) - LastPos;
                    if (!Frozen && updateVel)
                    {
                        LastDiff = diff;
                    }
                    else
                    {
                        diff = LastDiff;
                    }

                    if (TasSettings.SpeedUnit == SpeedUnit.PixelPerSecond)
                    {
                        diff *= FramesPerRealSecond;
                    }

                    string velocity = GetAdjustedVelocity(diff, out string exactVelocity);

                    string polarVel = $"Fly:   {diff.Length():F2}, {diff.Angle():F5}°";

                    string analog = string.Empty;
                    if (Manager.Running && Manager.Controller.Previous is { } inputFrame&& inputFrame.HasActions(Actions.Feather))
                    {
                        Vector2 angleVector2 = inputFrame.AngleVector2;
                        analog =
                            $"Analog: {angleVector2.X:F5}, {angleVector2.Y:F5}, {GetAngle(new Vector2(angleVector2.X, -angleVector2.Y)):F5}°";
                    }

                    string retainedSpeed = GetAdjustedRetainedSpeed(player, out string exactRetainedSpeed);

                    string liftBoost = GetAdjustedLiftBoost(player, out string exactLiftBoost);

                    string miscStats = $"Stamina: {player.Stamina:0} "
                                       + (WallJumpCheck(player, 1) ? "Wall-R " : string.Empty)
                                       + (WallJumpCheck(player, -1) ? "Wall-L " : string.Empty)
                                       + PlayerStates.GetStateName(player.StateMachine.State);

                    int dashCooldown = DashCooldownTimer(player).ToFloorFrames();

                    PlayerSeeker playerSeeker = level.Tracker.GetEntity <PlayerSeeker>();
                    if (playerSeeker != null)
                    {
                        pos   = GetAdjustedPos(playerSeeker, out exactPos);
                        speed = GetAdjustedSpeed(PlayerSeekerSpeed(playerSeeker), out exactSpeed);
                        diff  = playerSeeker.GetMoreExactPosition(false) - LastPlayerSeekerPos;
                        if (!Frozen && updateVel)
                        {
                            LastPlayerSeekerDiff = diff;
                        }
                        else
                        {
                            diff = LastPlayerSeekerDiff;
                        }

                        if (TasSettings.SpeedUnit == SpeedUnit.PixelPerSecond)
                        {
                            diff *= FramesPerRealSecond;
                        }

                        velocity = GetAdjustedVelocity(diff, out exactVelocity);

                        polarVel     = $"Chase: {diff.Length():F2}, {diff.Angle():F5}°";
                        dashCooldown = PlayerSeekerDashTimer(playerSeeker).ToCeilingFrames();
                    }

                    string statuses = GetStatuses(level, player, dashCooldown);

                    string   timers = string.Empty;
                    Follower firstRedBerryFollower = player.Leader.Followers.Find(follower => follower.Entity is Strawberry {
                        Golden: false
                    });
        public static void Update(bool updateVel = false)
        {
            if (Engine.Scene is Level level)
            {
                Player player      = level.Tracker.GetEntity <Player>();
                long   chapterTime = level.Session.Time;
                if (player != null)
                {
                    StringBuilder stringBuilder = new();
                    string        pos           = GetAdjustedPos(player.Position, player.PositionRemainder);
                    string        speed         = GetAdjustedSpeed(player.Speed);
                    Vector2Double diff          = (player.GetMoreExactPosition() - LastPos) * FramesPerSecond;
                    string        velocity      = GetAdjustedVelocity(diff);
                    if (!Frozen && updateVel)
                    {
                        LastVel = velocity;
                    }
                    else
                    {
                        velocity = LastVel;
                    }

                    string polarVel = $"Fly:   {diff.Length():F2}, {diff.Angle():F5}°";

                    string analog = string.Empty;
                    if (Manager.Running && Manager.Controller.Previous is { } inputFrame&& inputFrame.HasActions(Actions.Feather))
                    {
                        Vector2 angleVector2 = inputFrame.AngleVector2;
                        analog =
                            $"Analog: {angleVector2.X:F5}, {angleVector2.Y:F5}, {Manager.GetAngle(new Vector2(angleVector2.X, -angleVector2.Y)):F5}°";
                    }

                    string retainedSpeed = string.Empty;
                    if (PlayerRetainedSpeedTimer(player) is float retainedSpeedTimer and > 0f)
                    {
                        retainedSpeed = $"Retained: {PlayerRetainedSpeed(player):F2} ({retainedSpeedTimer.ToCeilingFrames()})";
                    }

                    string liftBoost = string.Empty;
                    if (PlayerLiftBoost(player) is var liftBoostVector2 && liftBoostVector2 != Vector2.Zero)
                    {
                        liftBoost =
                            $"LiftBoost: {liftBoostVector2.X:F2}, {liftBoostVector2.Y:F2} ({ActorLiftSpeedTimer(player).ToCeilingFrames()})";
                    }

                    string miscStats = $"Stamina: {player.Stamina:0} "
                                       + (WallJumpCheck(player, 1) ? "Wall-R " : string.Empty)
                                       + (WallJumpCheck(player, -1) ? "Wall-L " : string.Empty)
                                       + PlayerStates.GetStateName(player.StateMachine.State);

                    int dashCooldown = DashCooldownTimer(player).ToFloorFrames();

                    PlayerSeeker playerSeeker = level.Tracker.GetEntity <PlayerSeeker>();
                    if (playerSeeker != null)
                    {
                        pos      = GetAdjustedPos(playerSeeker.Position, playerSeeker.PositionRemainder);
                        speed    = GetAdjustedSpeed(PlayerSeekerSpeed(playerSeeker));
                        diff     = (playerSeeker.GetMoreExactPosition() - LastPlayerSeekerPos) * FramesPerSecond;
                        velocity = GetAdjustedVelocity(diff);
                        if (!Frozen && updateVel)
                        {
                            LastPlayerSeekerVel = velocity;
                        }
                        else
                        {
                            velocity = LastPlayerSeekerVel;
                        }

                        polarVel     = $"Chase: {diff.Length():F2}, {diff.Angle():F5}°";
                        dashCooldown = PlayerSeekerDashTimer(playerSeeker).ToCeilingFrames();
                    }

                    string statuses = (dashCooldown <= 0 && player.Dashes > 0 ? "CanDash " : string.Empty)
                                      + (player.LoseShards ? "Ground " : string.Empty)
                                      + (!player.LoseShards && JumpGraceTimer(player).ToFloorFrames() is int coyote and > 0
                                          ? $"Coyote({coyote}) "
                                          : string.Empty);

                    string noControlFrames = transitionFrames > 0 ? $"({transitionFrames})" : string.Empty;
                    float  unpauseTimer    = LevelUnpauseTimer?.Invoke(level) ?? 0f;
                    if (unpauseTimer > 0f)
                    {
                        noControlFrames = $"({unpauseTimer.ToCeilingFrames()})";
                    }

                    statuses = (Engine.FreezeTimer > 0f ? $"Frozen({Engine.FreezeTimer.ToCeilingFrames()}) " : string.Empty)
                               + (player.InControl && !level.Transitioning && unpauseTimer <= 0f ? statuses : $"NoControl{noControlFrames} ")
                               + (player.Dead ? "Dead " : string.Empty)
                               + (level.InCutscene ? "Cutscene " : string.Empty)
                               + (AdditionalStatusInfo ?? string.Empty);

                    if (player.Holding == null &&
                        level.Tracker.GetComponents <Holdable>().Any(holdable => ((Holdable)holdable).Check(player)))
                    {
                        statuses += "Grab ";
                    }

                    string   timers = string.Empty;
                    Follower firstRedBerryFollower = player.Leader.Followers.Find(follower => follower.Entity is Strawberry {
                        Golden: false
                    });