| 
						
						
							
								
							
						
						
					 | 
					 | 
					@ -18,22 +18,49 @@ import mightypork.util.math.Easing; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 */ | 
					 | 
					 | 
					 | 
					 */ | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					public class Player implements IonBundled, MapObserver, Updateable { | 
					 | 
					 | 
					 | 
					public class Player implements IonBundled, MapObserver, Updateable { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						 | 
					 | 
					 | 
					 | 
						 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
						private final double walktime = 0.3; // possibly make changeable for speed potion
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
						 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						private final WorldPos position = new WorldPos(); | 
					 | 
					 | 
					 | 
						private final WorldPos position = new WorldPos(); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						private final VectAnimated walkOffset = new VectAnimated(Vect.ZERO, Easing.LINEAR); | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						private final WorldPos target = new WorldPos(); | 
					 | 
					 | 
					 | 
						private final WorldPos target = new WorldPos(); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						private Runnable targetListener; | 
					 | 
					 | 
					 | 
						private Runnable moveListenerCustom; | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
						private Runnable moveListener = new Runnable() { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
							 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
							@Override | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
							public void run() | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
							{ | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
								if (moveListenerCustom != null) moveListenerCustom.run(); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
								 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
								if (!target.equals(position)) { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
									 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
									int x = (target.x - position.x); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
									int y = (target.y - position.y); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
									 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
									if (Math.abs(x) >= Math.abs(y)) y = 0; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
									if (Math.abs(y) > Math.abs(x)) x = 0; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
									 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
									if (x > 0) x = 1; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
									if (x < 0) x = -1; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
									 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
									if (y > 0) y = 1; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
									if (y < 0) y = -1; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
									 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
									position.walk(x, y, walktime); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
									 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
								} | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
							} | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
						}; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						 | 
					 | 
					 | 
					 | 
						 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						 | 
					 | 
					 | 
					 | 
						 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						public Player() | 
					 | 
					 | 
					 | 
						public Player() | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						{ | 
					 | 
					 | 
					 | 
						{ | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							walkOffset.setDefaultDuration(0.25); | 
					 | 
					 | 
					 | 
							position.setMoveListener(moveListener); | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						} | 
					 | 
					 | 
					 | 
						} | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						 | 
					 | 
					 | 
					 | 
						 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						 | 
					 | 
					 | 
					 | 
						 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						public Player(int x, int y, int floor) | 
					 | 
					 | 
					 | 
						public Player(int x, int y, int floor) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						{ | 
					 | 
					 | 
					 | 
						{ | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							this.position.setTo(x, y, floor); | 
					 | 
					 | 
					 | 
							position.setTo(x, y, floor); | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							this.target.setTo(position); | 
					 | 
					 | 
					 | 
							target.setTo(position); | 
				
			
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						} | 
					 | 
					 | 
					 | 
						} | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						 | 
					 | 
					 | 
					 | 
						 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						 | 
					 | 
					 | 
					 | 
						 | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
					 | 
					@ -60,19 +87,12 @@ public class Player implements IonBundled, MapObserver, Updateable { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						 | 
					 | 
					 | 
					 | 
						 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						 | 
					 | 
					 | 
					 | 
						 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						@Override | 
					 | 
					 | 
					 | 
						@Override | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						public WorldPos getLogicalPosition() | 
					 | 
					 | 
					 | 
						public WorldPos getPosition() | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						{ | 
					 | 
					 | 
					 | 
						{ | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							return position; | 
					 | 
					 | 
					 | 
							return position; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						} | 
					 | 
					 | 
					 | 
						} | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						 | 
					 | 
					 | 
					 | 
						 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						 | 
					 | 
					 | 
					 | 
						 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						@Override | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						public Vect getVisualOffset() | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						{ | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							return walkOffset; | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						} | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						 | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						 | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						@Override | 
					 | 
					 | 
					 | 
						@Override | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						public int getViewRange() | 
					 | 
					 | 
					 | 
						public int getViewRange() | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						{ | 
					 | 
					 | 
					 | 
						{ | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					 | 
					@ -84,49 +104,24 @@ public class Player implements IonBundled, MapObserver, Updateable { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						{ | 
					 | 
					 | 
					 | 
						{ | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							position.setTo(pos); | 
					 | 
					 | 
					 | 
							position.setTo(pos); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							target.setTo(pos); | 
					 | 
					 | 
					 | 
							target.setTo(pos); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							walkOffset.reset(); | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						} | 
					 | 
					 | 
					 | 
						} | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						 | 
					 | 
					 | 
					 | 
						 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						 | 
					 | 
					 | 
					 | 
						 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						public void walk(int offsetX, int offsetY) | 
					 | 
					 | 
					 | 
						public void walk(int offsetX, int offsetY) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						{ | 
					 | 
					 | 
					 | 
						{ | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							this.target.setTo(position.x + offsetX, position.y + offsetY, this.position.floor); | 
					 | 
					 | 
					 | 
							target.setTo(position.x + offsetX, position.y + offsetY, this.position.floor); | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						} | 
					 | 
					 | 
					 | 
						} | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						 | 
					 | 
					 | 
					 | 
						 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						 | 
					 | 
					 | 
					 | 
						 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						@Override | 
					 | 
					 | 
					 | 
						@Override | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						public void update(double delta) | 
					 | 
					 | 
					 | 
						public void update(double delta) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						{ | 
					 | 
					 | 
					 | 
						{ | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							if (!walkOffset.isFinished()) { | 
					 | 
					 | 
					 | 
							position.update(delta); | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
								walkOffset.update(delta); | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
								if (walkOffset.isFinished()) { | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
									position.add(walkOffset.xi(), walkOffset.yi(), position.floor); | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
									walkOffset.reset(); | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
									targetListener.run(); | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
								} | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							} | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							 | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							if (walkOffset.isFinished() && !target.equals(position)) { | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
								 | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
								int x = (target.x - position.x); | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
								int y = (target.y - position.y); | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
								 | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
								if (Math.abs(x) >= Math.abs(y)) y = 0; | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
								if (Math.abs(y) > Math.abs(x)) x = 0; | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
								 | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
								if (x > 0) x = 1; | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
								if (x < 0) x = -1; | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
								 | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
								if (y > 0) y = 1; | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
								if (y < 0) y = -1; | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
								 | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
								walkOffset.animate(x, y, 0); | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							} | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						} | 
					 | 
					 | 
					 | 
						} | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						 | 
					 | 
					 | 
					 | 
						 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						 | 
					 | 
					 | 
					 | 
						 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						public void setTargetListener(Runnable r) | 
					 | 
					 | 
					 | 
						public void setMoveListener(Runnable r) | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						{ | 
					 | 
					 | 
					 | 
						{ | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							this.targetListener = r; | 
					 | 
					 | 
					 | 
							this.moveListenerCustom = r; | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						} | 
					 | 
					 | 
					 | 
						} | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					} | 
					 | 
					 | 
					 | 
					} | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
					 | 
					 | 
					
  |