using Godot; using gobbos_logic; public partial class Player : CharacterBody2D, IPlayer { [Signal] public delegate void BlinkTimerTimeoutEventHandler(); [Signal] public delegate void WallCastDelayTimeoutEventHandler(); // Constants const double COYOTE_JUMP_WINDOW = 0.15; // private readonly Vector2 TILE_SIZE = new(8, 8); [Export] public AnimationPlayer Blinkplayer { get; set; } private double timeSinceLeavingGround = 0.0; public bool CanCoyoteJump => timeSinceLeavingGround < COYOTE_JUMP_WINDOW; public void ResetCoyoteTimer() { timeSinceLeavingGround = 0.0; } public float Acceleration { get; set; } = 4.0f; public float Friction { get; set; } = 4.0f; public float AirFriction { get; set; } = 0.1f; public float WallFriction { get; set; } = 1200.0f; public int Speed { get; set; } = 40; public int WallSpeed { get; set; } = 15; public float SlowMod { get; set; } = 0.5f; public int Gravity { get; set; } = 250; public int Jump { get; set; } = -95; public int WallJump { get; set; } = 55; public int LedgeJump { get; set; } = -70; public float FallMod { get; set; } = 1.5f; public float ParachuteMod { get; set; } = 0.2f; public bool OnLedge { get; set; } = false; public bool InParachute { get; set; } = false; public bool CanParachute { get; set; } = false; public Vector2 AnimDir { get; set; } = Vector2.Zero; public Vector2 LastDir { get; set; } = Vector2.Zero; public Vector2 MoveDir { get; set; } = Vector2.Zero; public Label StateLabel { get; set; } public RayCast2D WallCastTop { get; set; } public RayCast2D WallCastMid { get; set; } public RayCast2D WallCastLow { get; set; } public AnimationNodeStateMachinePlayback AnimStateMachine { get; set; } public AnimationNodeStateMachinePlayback GroundedStateMachine { get; set; } public AnimationNodeStateMachinePlayback AirborneStateMachine { get; set; } public AnimationNodeStateMachinePlayback SprintStateMachine { get; set; } public float LastVelocityY { get; set; } = 0.0f; public float WallCastLength { get; set; } = 3.8f; public Timer WallCastDelayTimer { get; set; } private RayCast2D cameraOffsetCast; private RayCast2D cameraDownCast; private Node2D modelContainer; private Timer blinkTimer; public AnimationTree animTree; private StateMachine stateMachine; public override void _Ready() { modelContainer = GetNode("ModelContainer"); blinkTimer = GetNode("BlinkTimer"); animTree = GetNode("AnimationTree"); cameraOffsetCast = GetNode("CameraOffsetCast"); cameraDownCast = GetNode("CameraOffsetCast/CameraDownCast"); stateMachine = GetNode("StateMachine"); animTree.Set("parameters/Airborne/Standard/blend_position", 1.0f); animTree.Set("parameters/Airborne/Parachute/blend_position", 1.0f); WallCastTop = GetNode("WallCastTop"); WallCastMid = GetNode("WallCastMid"); WallCastLow = GetNode("WallCastLow"); WallCastDelayTimer = GetNode("WallCastDelay"); WallCastDelayTimer.Timeout += OnWallCastDelayTimeout; AnimStateMachine = (AnimationNodeStateMachinePlayback)animTree.Get("parameters/playback"); GroundedStateMachine = (AnimationNodeStateMachinePlayback)animTree.Get("parameters/Grounded/playback"); AirborneStateMachine = (AnimationNodeStateMachinePlayback)animTree.Get("parameters/Airborne/playback"); SprintStateMachine = (AnimationNodeStateMachinePlayback)animTree.Get("parameters/Grounded/Sprint/playback"); StateLabel = GetNode