mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-15 10:35:11 -04:00
More simplification of LocalPlayer.
This commit is contained in:
parent
8376a3b881
commit
4d4dca6de7
@ -72,25 +72,18 @@ namespace ClassicalSharp {
|
|||||||
if( Window.Map == null || Window.Map.IsNotLoaded ) return;
|
if( Window.Map == null || Window.Map.IsNotLoaded ) return;
|
||||||
map = Window.Map;
|
map = Window.Map;
|
||||||
|
|
||||||
float xMoving, zMoving;
|
float xMoving = 0, zMoving = 0;
|
||||||
lastPos = Position = nextPos;
|
lastPos = Position = nextPos;
|
||||||
lastYaw = nextYaw;
|
lastYaw = nextYaw;
|
||||||
lastPitch = nextPitch;
|
lastPitch = nextPitch;
|
||||||
HandleInput( out xMoving, out zMoving );
|
HandleInput( ref xMoving, ref zMoving );
|
||||||
UpdateState( xMoving, zMoving );
|
UpdateVelocityYState();
|
||||||
PhysicsTick( xMoving, zMoving );
|
PhysicsTick( xMoving, zMoving );
|
||||||
nextPos = Position;
|
nextPos = Position;
|
||||||
Position = lastPos;
|
Position = lastPos;
|
||||||
UpdateAnimState( lastPos, nextPos, delta );
|
UpdateAnimState( lastPos, nextPos, delta );
|
||||||
if( renderer != null ) {
|
if( renderer != null ) {
|
||||||
Bitmap bmp;
|
CheckSkin();
|
||||||
Window.AsyncDownloader.TryGetImage( "skin_" + SkinName, out bmp );
|
|
||||||
if( bmp != null ) {
|
|
||||||
Window.Graphics.DeleteTexture( renderer.TextureId );
|
|
||||||
renderer.TextureId = Window.Graphics.LoadTexture( bmp );
|
|
||||||
SkinType = Utils.GetSkinType( bmp );
|
|
||||||
bmp.Dispose();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -104,9 +97,7 @@ namespace ClassicalSharp {
|
|||||||
renderer.Render( deltaTime );
|
renderer.Render( deltaTime );
|
||||||
}
|
}
|
||||||
|
|
||||||
void HandleInput( out float xMoving, out float zMoving ) {
|
void HandleInput( ref float xMoving, ref float zMoving ) {
|
||||||
xMoving = 0;
|
|
||||||
zMoving = 0;
|
|
||||||
if( Window.ScreenLockedInput ) {
|
if( Window.ScreenLockedInput ) {
|
||||||
jumping = speeding = flyingUp = flyingDown = false;
|
jumping = speeding = flyingUp = flyingDown = false;
|
||||||
} else {
|
} else {
|
||||||
@ -122,7 +113,7 @@ namespace ClassicalSharp {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void UpdateState( float xMoving, float zMoving ) {
|
void UpdateVelocityYState() {
|
||||||
if( flying || noClip ) {
|
if( flying || noClip ) {
|
||||||
Velocity.Y = 0; // eliminate the effect of gravity
|
Velocity.Y = 0; // eliminate the effect of gravity
|
||||||
float vel = noClip ? 0.24f : 0.06f;
|
float vel = noClip ? 0.24f : 0.06f;
|
||||||
|
@ -64,14 +64,7 @@ namespace ClassicalSharp {
|
|||||||
List<State> states = new List<State>();
|
List<State> states = new List<State>();
|
||||||
State newState, oldState;
|
State newState, oldState;
|
||||||
public override void Tick( double delta ) {
|
public override void Tick( double delta ) {
|
||||||
Bitmap bmp;
|
CheckSkin();
|
||||||
Window.AsyncDownloader.TryGetImage( "skin_" + SkinName, out bmp );
|
|
||||||
if( bmp != null ) {
|
|
||||||
Window.Graphics.DeleteTexture( renderer.TextureId );
|
|
||||||
renderer.TextureId = Window.Graphics.LoadTexture( bmp );
|
|
||||||
SkinType = Utils.GetSkinType( bmp );
|
|
||||||
bmp.Dispose();
|
|
||||||
}
|
|
||||||
tickCount++;
|
tickCount++;
|
||||||
UpdateCurrentState();
|
UpdateCurrentState();
|
||||||
UpdateAnimState( oldState.pos, newState.pos, delta );
|
UpdateAnimState( oldState.pos, newState.pos, delta );
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Drawing;
|
||||||
using OpenTK;
|
using OpenTK;
|
||||||
using ClassicalSharp.Model;
|
using ClassicalSharp.Model;
|
||||||
using ClassicalSharp.Renderers;
|
using ClassicalSharp.Renderers;
|
||||||
@ -106,6 +107,17 @@ namespace ClassicalSharp {
|
|||||||
leftArmZRot = -idleZRot;
|
leftArmZRot = -idleZRot;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void CheckSkin() {
|
||||||
|
Bitmap bmp;
|
||||||
|
Window.AsyncDownloader.TryGetImage( "skin_" + SkinName, out bmp );
|
||||||
|
if( bmp != null ) {
|
||||||
|
Window.Graphics.DeleteTexture( renderer.TextureId );
|
||||||
|
renderer.TextureId = Window.Graphics.LoadTexture( bmp );
|
||||||
|
SkinType = Utils.GetSkinType( bmp );
|
||||||
|
bmp.Dispose();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void SetModel( string modelName ) {
|
public void SetModel( string modelName ) {
|
||||||
ModelName = modelName;
|
ModelName = modelName;
|
||||||
Model = Window.ModelCache.GetModel( ModelName );
|
Model = Window.ModelCache.GetModel( ModelName );
|
||||||
|
Loading…
x
Reference in New Issue
Block a user