initial add

This commit is contained in:
2026-04-10 17:53:31 -05:00
commit ebd36e4ef3
196 changed files with 51603 additions and 0 deletions

View File

@@ -0,0 +1,2 @@
[*.cs]
csharp_new_line_before_open_brace = none

View File

@@ -0,0 +1,77 @@
using Godot;
public partial class PlayerAirborn : State {
private Player player;
public override void _Ready() {
player = GetNode<Player>("../..");
}
public override void Enter() {
GD.Print("airborn");
player.StateLabel?.Text = Name;
player.InParachute = false;
player.AnimStateMachine?.Travel("Airborne");
}
public override void PhysicsUpdate(double delta) {
var floatDelta = (float)delta;
if (player.IsOnFloor()) {
EmitSignal(SignalName.Transitioned, this, "PlayerGrounded");
}
if (player.MoveDir.X != 0) {
player.Velocity = new(
Mathf.MoveToward(player.Velocity.X, player.MoveDir.X * player.Speed, player.Acceleration),
player.Velocity.Y);
}
else {
player.Velocity = new(
Mathf.MoveToward(player.Velocity.X, 0.0f, player.AirFriction),
player.Velocity.Y);
}
if (player.Velocity.Y >= 0) {
player.Velocity = new(
player.Velocity.X,
player.Velocity.Y + player.Gravity * floatDelta * player.FallMod);
}
else {
player.Velocity = new(
player.Velocity.X,
player.Velocity.Y + player.Gravity * floatDelta);
}
var wcl = player.WallCastLow != null && player.WallCastLow.IsColliding();
var wcm = player.WallCastMid != null && player.WallCastLow.IsColliding();
var wct = player.WallCastTop != null && player.WallCastTop.IsColliding();
if (wcl && wcm && wct) {
EmitSignal(SignalName.Transitioned, this, "PlayerWallGrab");
}
if (Input.IsActionJustPressed("jump") && player.CanCoyoteJump) {
player.Velocity = new(player.Velocity.X, player.Jump);
}
LedgeLogic();
player.LastVelocityY = player.Velocity.Y;
}
private void LedgeLogic() {
if (player.IsOnFloor() || player.Velocity.Y <= -30 || player.MoveDir == Vector2.Zero) {
return;
}
if (!player.WallCastMid.IsColliding() || player.WallCastTop.IsColliding()) {
return;
}
var desiredPos = player.WallCastMid.GetCollisionPoint().Snapped(new Vector2(4, 4)) + new Vector2(-2 * player.MoveDir.X, -1);
var posTween = CreateTween().SetTrans(Tween.TransitionType.Sine);
posTween.TweenProperty(player, "global_position", desiredPos, 0.05);
player.LastVelocityY = 0.0f;
player.Velocity = new (0.0f, player.LedgeJump);
}
}

View File

@@ -0,0 +1 @@
uid://desj0bmav00ec

View File

@@ -0,0 +1,83 @@
using Godot;
public partial class PlayerGrounded : State {
private Player player;
private Node3D modelRoot;
public override void _Ready() {
player = GetNode<Player>("../..");
modelRoot = GetNode<Node3D>("../../ModelContainer/SubViewportContainer/SubViewport/blockbench_export");
}
public override void Enter() {
player.StateLabel?.Text = Name;
player.ResetCoyoteTimer();
player.InParachute = false;
player.AnimStateMachine?.Travel("Grounded");
var fall_speed = Mathf.Abs(player.LastVelocityY);
fall_speed *= 0.0025f;
if (modelRoot != null) {
modelRoot.Scale = new (
modelRoot.Scale.X + fall_speed,
modelRoot.Scale.Y - fall_speed,
modelRoot.Scale.Z + fall_speed);
var fallTween = GetTree().CreateTween();
fallTween.TweenProperty(
modelRoot,
"scale",
new Vector3(1.0f, 1.0f, 1.0f),
0.2);
}
// if (player.SprintStateMachine) {
// if (move_dir < 0) {
// player.SprintStateMachine.travel("sprint_left");
// }
// else if (move_dir > 0) {
// player.SprintStateMachine.travel("sprint_right");
// }
// }
}
public override void PhysicsUpdate(double delta) {
if (!player.IsOnFloor()) {
EmitSignal(SignalName.Transitioned, this, "PlayerAirborne");
}
if (player.MoveDir.X != 0) {
if (Input.IsActionPressed("slow_walk")) {
player.Velocity = new (
Mathf.MoveToward(player.Velocity.X, player.MoveDir.X * player.Speed * player.SlowMod, player.Acceleration),
player.Velocity.Y);
player.GroundedStateMachine?.Travel("Walk");
}
else {
player.Velocity = new (
Mathf.MoveToward(player.Velocity.X, player.MoveDir.X * player.Speed, player.Acceleration),
player.Velocity.Y);
player.GroundedStateMachine?.Travel("Sprint");
if (player.MoveDir.X < 0) {
player.SprintStateMachine?.Travel("sprint_left");
}
else if (player.MoveDir.X > 0) {
player.SprintStateMachine?.Travel("sprint_right");
}
}
}
else {
player.Velocity = new (
Mathf.MoveToward(player.Velocity.X, 0.0f, player.Friction),
player.Velocity.Y);
player.GroundedStateMachine?.Travel("Idle");
}
if (Input.IsActionJustPressed("jump") && player.IsOnFloor()) {
player.Velocity = new (player.Velocity.X, player.Jump);
EmitSignal(SignalName.Transitioned, this, "PlayerAirborne");
}
}
}

View File

@@ -0,0 +1 @@
uid://dv3sve5vfcn55

View File

@@ -0,0 +1,61 @@
using Godot;
public partial class PlayerWallGrab : State {
private Player player;
private float wallDirection;
public override void _Ready() {
player = GetNode<Player>("../..");
}
public override void Enter() {
player.StateLabel?.Text = Name;
player.InParachute = false;
Vector2 desiredPos = new (
(player.WallCastLow.GetCollisionPoint().Snapped(new Vector2(4, 4)) + new Vector2(-2 * player.MoveDir.X, 0)).X,
player.GlobalPosition.Y);
var posTween = CreateTween().SetTrans(Tween.TransitionType.Sine);
posTween.TweenProperty(player, "global_position", desiredPos, 0.05);
wallDirection = player.MoveDir.X;
}
public override void PhysicsUpdate(double delta) {
var floatDelta = (float)delta;
player.Velocity = new (0.0f, player.Velocity.Y);
if (player.MoveDir.X != 0.0) {
if (!player.WallCastLow.IsColliding() ||
!player.WallCastMid.IsColliding() ||
!player.WallCastTop.IsColliding()) {
EmitSignal(SignalName.Transitioned, this, "PlayerAirborne");
}
}
if (player.MoveDir.Y != 0) {
player.Velocity = new (
player.Velocity.X,
Mathf.MoveToward(player.Velocity.Y, player.MoveDir.Y * player.WallSpeed, player.Acceleration));
}
else {
player.Velocity = new (
player.Velocity.X,
Mathf.MoveToward(player.Velocity.Y, 0.0f, floatDelta * player.WallFriction));
}
if (Input.IsActionJustPressed("jump")) {
player.WallCastTop?.Enabled = false;
player.WallCastMid?.Enabled = false;
player.WallCastLow?.Enabled = false;
player.WallCastDelayTimer.Start();
EmitSignal(SignalName.Transitioned, this, "PlayerAirborne");
player.Velocity = new (player.Velocity.X, player.Jump * 0.85f);
if (wallDirection > 0) {
player.Velocity = new (-player.WallJump, player.Velocity.Y);
}
else {
player.Velocity = new (player.WallJump, player.Velocity.Y);
}
}
}
}

View File

@@ -0,0 +1 @@
uid://dn3js76wk06we