mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-13 01:26:50 -04:00
Various simplifications.
This commit is contained in:
parent
dc2b67d538
commit
bae3b3d32e
@ -187,11 +187,8 @@ namespace ClassicalSharp {
|
|||||||
Velocity.Y -= 0.08f;
|
Velocity.Y -= 0.08f;
|
||||||
|
|
||||||
if( BlockUnderFeet == Block.Ice ) {
|
if( BlockUnderFeet == Block.Ice ) {
|
||||||
// Limit velocity while travelling on ice.
|
Utils.Clamp( ref Velocity.X, -0.25f, 0.25f );
|
||||||
if( Velocity.X > 0.25f ) Velocity.X = 0.25f;
|
Utils.Clamp( ref Velocity.Z, -0.25f, 0.25f );
|
||||||
if( Velocity.X < -0.25f ) Velocity.X = -0.25f;
|
|
||||||
if( Velocity.Z > 0.25f ) Velocity.Z = 0.25f;
|
|
||||||
if( Velocity.Z < -0.25f ) Velocity.Z = -0.25f;
|
|
||||||
} else if( onGround || flying ) {
|
} else if( onGround || flying ) {
|
||||||
// Apply air resistance or ground friction
|
// Apply air resistance or ground friction
|
||||||
Velocity.X *= 0.6f;
|
Velocity.X *= 0.6f;
|
||||||
@ -209,7 +206,8 @@ namespace ClassicalSharp {
|
|||||||
|
|
||||||
bool jumping, speeding, flying, noClip, flyingDown, flyingUp;
|
bool jumping, speeding, flying, noClip, flyingDown, flyingUp;
|
||||||
public void ParseHackFlags( string name, string motd ) {
|
public void ParseHackFlags( string name, string motd ) {
|
||||||
if( name.Contains( "-hax" ) || motd.Contains( "-hax" ) ) {
|
string joined = name + motd;
|
||||||
|
if( joined.Contains( "-hax" ) ) {
|
||||||
CanFly = CanNoclip = CanSpeed = CanRespawn = false;
|
CanFly = CanNoclip = CanSpeed = CanRespawn = false;
|
||||||
Window.CanUseThirdPersonCamera = false;
|
Window.CanUseThirdPersonCamera = false;
|
||||||
Window.SetCamera( false );
|
Window.SetCamera( false );
|
||||||
@ -219,32 +217,32 @@ namespace ClassicalSharp {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Determine if specific hacks are or are not allowed.
|
// Determine if specific hacks are or are not allowed.
|
||||||
if( name.Contains( "+fly" ) || motd.Contains( "+fly" ) ) {
|
if( joined.Contains( "+fly" ) ) {
|
||||||
CanFly = true;
|
CanFly = true;
|
||||||
} else if( name.Contains( "-fly" ) || motd.Contains( "-fly" ) ) {
|
} else if( joined.Contains( "-fly" ) ) {
|
||||||
CanFly = false;
|
CanFly = false;
|
||||||
}
|
}
|
||||||
if( name.Contains( "+noclip" ) || motd.Contains( "+noclip" ) ) {
|
if( joined.Contains( "+noclip" ) ) {
|
||||||
CanNoclip = true;
|
CanNoclip = true;
|
||||||
} else if( name.Contains( "-noclip" ) || motd.Contains( "-noclip" ) ) {
|
} else if( joined.Contains( "-noclip" ) ) {
|
||||||
CanNoclip = false;
|
CanNoclip = false;
|
||||||
}
|
}
|
||||||
if( name.Contains( "+speed" ) || motd.Contains( "+speed" ) ) {
|
if( joined.Contains( "+speed" ) ) {
|
||||||
CanSpeed = true;
|
CanSpeed = true;
|
||||||
} else if( name.Contains( "-speed" ) || motd.Contains( "-speed" ) ) {
|
} else if( joined.Contains( "-speed" ) ) {
|
||||||
CanSpeed = false;
|
CanSpeed = false;
|
||||||
}
|
}
|
||||||
if( name.Contains( "+respawn" ) || motd.Contains( "+respawn" ) ) {
|
if( joined.Contains( "+respawn" ) ) {
|
||||||
CanRespawn = true;
|
CanRespawn = true;
|
||||||
} else if( name.Contains( "-respawn" ) || motd.Contains( "-respawn" ) ) {
|
} else if( joined.Contains( "-respawn" ) ) {
|
||||||
CanRespawn = false;
|
CanRespawn = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Operator override.
|
// Operator override.
|
||||||
if( UserType == 0x64 ) {
|
if( UserType == 0x64 ) {
|
||||||
if( name.Contains( "+ophax" ) || motd.Contains( "+ophax" ) ) {
|
if( joined.Contains( "+ophax" ) ) {
|
||||||
CanFly = CanNoclip = CanSpeed = CanRespawn = true;
|
CanFly = CanNoclip = CanSpeed = CanRespawn = true;
|
||||||
} else if( name.Contains( "-ophax" ) || motd.Contains( "-ophax" ) ) {
|
} else if( joined.Contains( "-ophax" ) ) {
|
||||||
CanFly = CanNoclip = CanSpeed = CanRespawn = false;
|
CanFly = CanNoclip = CanSpeed = CanRespawn = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -43,22 +43,19 @@ namespace ClassicalSharp {
|
|||||||
|
|
||||||
/// <summary> Gets the block just underneath the player's feet position. </summary>
|
/// <summary> Gets the block just underneath the player's feet position. </summary>
|
||||||
public Block BlockUnderFeet {
|
public Block BlockUnderFeet {
|
||||||
get {
|
get { return GetBlock( new Vector3( Position.X, Position.Y - 0.01f, Position.Z ) ); }
|
||||||
if( map == null || map.IsNotLoaded ) return Block.Air;
|
|
||||||
Vector3I blockCoords = Vector3I.Floor( Position.X, Position.Y - 0.01f, Position.Z );
|
|
||||||
if( !map.IsValidPos( blockCoords ) ) return Block.Air;
|
|
||||||
return (Block)map.GetBlock( blockCoords );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary> Gets the block at player's eye position. </summary>
|
/// <summary> Gets the block at player's eye position. </summary>
|
||||||
public Block BlockAtHead {
|
public Block BlockAtHead {
|
||||||
get {
|
get { return GetBlock( EyePosition ); }
|
||||||
if( map == null || map.IsNotLoaded ) return Block.Air;
|
|
||||||
Vector3I blockCoords = Vector3I.Floor( EyePosition );
|
|
||||||
if( !map.IsValidPos( blockCoords ) ) return Block.Air;
|
|
||||||
return (Block)map.GetBlock( blockCoords );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Block GetBlock( Vector3 coords ) {
|
||||||
|
if( map == null || map.IsNotLoaded ) return Block.Air;
|
||||||
|
Vector3I blockCoords = Vector3I.Floor( coords );
|
||||||
|
return map.IsValidPos( blockCoords ) ?
|
||||||
|
(Block)map.GetBlock( blockCoords ) : Block.Air;
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract void Tick( double delta );
|
public abstract void Tick( double delta );
|
||||||
|
@ -76,7 +76,7 @@ namespace ClassicalSharp {
|
|||||||
Orientation.X += delta.X * sensitivity;
|
Orientation.X += delta.X * sensitivity;
|
||||||
Orientation.Y += delta.Y * sensitivity;
|
Orientation.Y += delta.Y * sensitivity;
|
||||||
|
|
||||||
Clamp( ref Orientation.Y, halfPi + 0.01f, threeHalfPi - 0.01f );
|
Utils.Clamp( ref Orientation.Y, halfPi + 0.01f, threeHalfPi - 0.01f );
|
||||||
LocationUpdate update = LocationUpdate.MakeOri(
|
LocationUpdate update = LocationUpdate.MakeOri(
|
||||||
(float)Utils.RadiansToDegrees( Orientation.X ),
|
(float)Utils.RadiansToDegrees( Orientation.X ),
|
||||||
(float)Utils.RadiansToDegrees( Orientation.Y - Math.PI )
|
(float)Utils.RadiansToDegrees( Orientation.Y - Math.PI )
|
||||||
@ -91,11 +91,6 @@ namespace ClassicalSharp {
|
|||||||
CentreMousePosition();
|
CentreMousePosition();
|
||||||
UpdateMouseRotation();
|
UpdateMouseRotation();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void Clamp( ref float value, float min, float max ) {
|
|
||||||
if( value < min ) value = min;
|
|
||||||
if( value > max ) value = max;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ThirdPersonCamera : PerspectiveCamera {
|
public class ThirdPersonCamera : PerspectiveCamera {
|
||||||
|
@ -22,6 +22,11 @@ namespace ClassicalSharp {
|
|||||||
|
|
||||||
public static string AppName = "ClassicalSharp 0.5";
|
public static string AppName = "ClassicalSharp 0.5";
|
||||||
|
|
||||||
|
public static void Clamp( ref float value, float min, float max ) {
|
||||||
|
if( value < min ) value = min;
|
||||||
|
if( value > max ) value = max;
|
||||||
|
}
|
||||||
|
|
||||||
public static int NextPowerOf2( int value ) {
|
public static int NextPowerOf2( int value ) {
|
||||||
int next = 1;
|
int next = 1;
|
||||||
while( value > next ) {
|
while( value > next ) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user