Fix water/lava physics being more difficult than classicube. (Thanks venom983)

This commit is contained in:
UnknownShadow200 2015-12-12 18:17:05 +11:00
parent f5fd0c9853
commit 4e080a63c1
2 changed files with 23 additions and 7 deletions

View file

@ -45,6 +45,7 @@
<DefineConstants>TRACE;</DefineConstants> <DefineConstants>TRACE;</DefineConstants>
<BaseIntermediateOutputPath>obj\</BaseIntermediateOutputPath> <BaseIntermediateOutputPath>obj\</BaseIntermediateOutputPath>
<StartAction>Project</StartAction> <StartAction>Project</StartAction>
<StartArguments>wwwf 4f34 127.0.0.1 25564</StartArguments>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug_D3D' "> <PropertyGroup Condition=" '$(Configuration)' == 'Debug_D3D' ">
<PlatformTarget>AnyCPU</PlatformTarget> <PlatformTarget>AnyCPU</PlatformTarget>

View file

@ -134,6 +134,7 @@ namespace ClassicalSharp {
} }
bool useLiquidGravity = false; // used by BlockDefinitions. bool useLiquidGravity = false; // used by BlockDefinitions.
bool canLiquidJump = true;
void UpdateVelocityYState() { void UpdateVelocityYState() {
if( flying || noClip ) { if( flying || noClip ) {
Velocity.Y = 0; // eliminate the effect of gravity Velocity.Y = 0; // eliminate the effect of gravity
@ -149,25 +150,39 @@ namespace ClassicalSharp {
if( jumping ) { if( jumping ) {
if( TouchesAnyWater() || TouchesAnyLava() ) { if( TouchesAnyWater() || TouchesAnyLava() ) {
BoundingBox bounds = CollisionBounds; BoundingBox bounds = CollisionBounds;
bounds.Min.Y += 1; bounds.Max.Y = bounds.Min.Y;
bool feetInWater = TouchesAny( bounds, StandardLiquid );
bool pastJumpPoint = feetInWater && (Position.Y % 1 >= 0.4);
bool isSolid = TouchesAny( bounds, if( !pastJumpPoint ) {
b => info.CollideType[b] != BlockCollideType.WalkThrough || b == (byte)Block.Rope ); canLiquidJump = true;
bool pastJumpPoint = Position.Y % 1 >= 0.4;
if( isSolid || !pastJumpPoint )
Velocity.Y += speeding ? 0.08f : 0.04f; Velocity.Y += speeding ? 0.08f : 0.04f;
else if( (collideX || collideZ) && !isSolid && pastJumpPoint ) } else if( pastJumpPoint ) {
Velocity.Y += 0.10f; // either A) jump bob in water B) climb up solid on side
if( canLiquidJump || (collideX || collideZ) )
Velocity.Y += 0.10f;
canLiquidJump = false;
}
} else if( useLiquidGravity ) { } else if( useLiquidGravity ) {
Velocity.Y += speeding ? 0.08f : 0.04f; Velocity.Y += speeding ? 0.08f : 0.04f;
canLiquidJump = false;
} else if( TouchesAnyRope() ) { } else if( TouchesAnyRope() ) {
Velocity.Y += speeding ? 0.15f : 0.10f; Velocity.Y += speeding ? 0.15f : 0.10f;
canLiquidJump = false;
} else if( onGround ) { } else if( onGround ) {
Velocity.Y = speeding ? jumpVel * 2 : jumpVel; Velocity.Y = speeding ? jumpVel * 2 : jumpVel;
canLiquidJump = false;
} }
} else {
canLiquidJump = false;
} }
} }
bool StandardLiquid( byte block ) {
return block == (byte)Block.Water || block == (byte)Block.StillWater ||
block == (byte)Block.Lava || block == (byte)Block.StillLava;
}
static Vector3 waterDrag = new Vector3( 0.8f, 0.8f, 0.8f ), static Vector3 waterDrag = new Vector3( 0.8f, 0.8f, 0.8f ),
lavaDrag = new Vector3( 0.5f, 0.5f, 0.5f ), lavaDrag = new Vector3( 0.5f, 0.5f, 0.5f ),
ropeDrag = new Vector3( 0.5f, 0.85f, 0.5f ), ropeDrag = new Vector3( 0.5f, 0.85f, 0.5f ),