Skip to content

Commit

Permalink
Merge pull request #88 from selimnahimi/patch
Browse files Browse the repository at this point in the history
Several patches
  • Loading branch information
selimnahimi authored Sep 8, 2023
2 parents f5159a4 + 6f2bba7 commit 60d1cd3
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 27 deletions.
1 change: 1 addition & 0 deletions code/pawn/PawnController.Climbing.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ void UpdateClimbing()
{
TimeSinceClimbing = 0f;
CurrentClimbAmount = 0;
StopClimbing();
return;
}

Expand Down
55 changes: 36 additions & 19 deletions code/pawn/PawnController.Util.cs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,16 @@ bool IsDashing()

bool ShouldDash()
{
return Grounded && !Input.Down( "forward" ) && (Input.Down( "left" ) || Input.Down( "right" ));
if ( !Grounded )
return false;

if ( Input.Down( "forward" ) )
return false;

if ( !Input.Down( "left" ) && !Input.Down( "right" ) )
return false;

return true;
}

void HandleNoclipping()
Expand Down Expand Up @@ -217,16 +226,25 @@ void AdjustSharpTurn( Vector3 moveVector )

void InitiateJump()
{
if ( CanJump() )
{
Jumping = true;
Entity.Velocity = ApplyJump( Entity.Velocity, "jump" );
}
Jumping = true;
Entity.Velocity = ApplyJump( Entity.Velocity, "jump" );
}

bool CanJump()
{
return Grounded && !IsVaulting();
if ( !Grounded )
return false;

if ( IsVaulting() )
return false;

if ( IsDashing() )
return false;

if ( IsWallRunning() )
return false;

return true;
}

Entity CheckForGround()
Expand All @@ -245,12 +263,12 @@ Entity CheckForGround()
return trace.Entity;
}

Vector3 ApplyFriction( Vector3 input, float frictionAmount )
Vector3 ApplyFriction( Vector3 velocity, float frictionAmount )
{
float StopSpeed = 100.0f;

var speed = input.Length;
if ( speed < 0.1f ) return input;
var speed = velocity.Length;
if ( speed < 0.1f ) return velocity;

// Bleed off some speed, but if we have less than the bleed
// threshold, bleed the threshold amount.
Expand All @@ -262,12 +280,12 @@ Vector3 ApplyFriction( Vector3 input, float frictionAmount )
// scale the velocity
float newspeed = speed - drop;
if ( newspeed < 0 ) newspeed = 0;
if ( newspeed == speed ) return input;
if ( newspeed == speed ) return velocity;

newspeed /= speed;
input *= newspeed;
velocity *= newspeed;

return input;
return velocity;
}

void DoMovement( Vector3 moveVector )
Expand All @@ -276,21 +294,20 @@ void DoMovement( Vector3 moveVector )
Entity.Velocity = ApplyFriction( Entity.Velocity, Friction );
}

Vector3 Accelerate( Vector3 input, Vector3 wishdir, float wishspeed, float speedLimit, float acceleration )
Vector3 Accelerate( Vector3 velocity, Vector3 wishdir, float wishspeed, float speedLimit, float acceleration )
{
if ( speedLimit > 0 && wishspeed > speedLimit )
wishspeed = speedLimit;

input = input.LerpTo( wishdir * wishspeed, Time.Delta * 45f * acceleration );
velocity = velocity.LerpTo( wishdir * wishspeed, Time.Delta * 45f * acceleration );

return input;
return velocity;
}

Vector3 ApplyJump( Vector3 input, string jumpType )
Vector3 ApplyJump( Vector3 velocity, string jumpType )
{
AddEvent( jumpType );

return input + Vector3.Up * JumpSpeed;
return velocity.WithZ(0) + Vector3.Up * JumpSpeed;
}

void UpdateMoveHelper( Entity groundEntity )
Expand Down
12 changes: 6 additions & 6 deletions code/pawn/PawnController.Wallrunning.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,14 +87,14 @@ bool TryWallrunning( )

var traceWall = CheckForWall();

if ( CanWallrun( traceWall ) && previousWallrunNormal != traceWall.traceResult.Normal )
{
InitiateWallrun( traceWall );
if ( previousWallrunNormal.AlmostEqual(traceWall.traceResult.Normal, 0.1f) )
return false;

return true;
}
if ( !CanWallrun( traceWall ) )
return false;

return false;
InitiateWallrun( traceWall );
return true;
}

void InitiateWallrun( WallRunTrace traceWall )
Expand Down
3 changes: 1 addition & 2 deletions code/pawn/PawnController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ public partial class PawnController : EntityComponent<Pawn>
private bool debugMode => false;
private bool parkouredSinceJumping = false;
private bool wallrunSinceJumping = false;
// private WallRunSide previousWallrunSide = WallRunSide.None;
private Vector3 previousWallrunNormal = Vector3.Zero;
private bool parkouredBeforeLanding = false;

Expand Down Expand Up @@ -133,7 +132,7 @@ public void Simulate( IClient cl )
InitiateJumpOffWall();
}

if ( !IsWallRunning() && !IsDashing() )
if ( CanJump() )
{
InitiateJump();
}
Expand Down

0 comments on commit 60d1cd3

Please sign in to comment.