core/src/mysko/pilzhere/gameboygame/entities/Player.java
// used to detect if in air. 0 = in air.
used to detect if in air.
used to detect if in air .
@Override
	public float reportRayFixture(Fixture fixture, Vector2 point, Vector2 normal, float fraction) {
		if (!super.getScreen().b2dWorld.isLocked()) {
			if (rayDig) {
				if (fixture.getFilterData().categoryBits == CollisionContactListener.BLOCK_COL) {
					Object tempObj = fixture.getBody().getUserData();
					((Block) tempObj).currentHp = ((Block) tempObj).currentHp - 1;
					((Block) tempObj).damageBlock();
					if (((Block) tempObj).currentHp <= 0) {
						super.getScreen().b2dWorld.destroyBody(fixture.getBody());
						if (((Block) tempObj).containsResource) {
							((Block) tempObj).spawnResource();
						}
						super.getScreen().blocks.removeValue((Entity) tempObj, true);
						sfxDestroy.play(0.75f);
						for (Entity entity : super.getScreen().blocks) {
							((Block) entity).checkForNeighbours();
							((Block) entity)
									.updateSprite(AssetsManager.MANAGER.get(AssetsManager.ATLAS01, Texture.class));
						}
					} else {
						sfxDig.play(1f);
					}
				} else if (fixture.getFilterData().categoryBits == CollisionContactListener.TERRAIN_COL) {
					sfxDenied.play(1f);
				} else if (fixture.getFilterData().categoryBits == CollisionContactListener.ENEMY_COL) {
					Object tempObj = fixture.getBody().getUserData();
					if (tempObj instanceof Spider) {
						((Spider) tempObj).onHit();
						sfxEnemyHit.play(1f);
					} else if (tempObj instanceof Rat) {
						((Rat) tempObj).onHit();
						sfxEnemyHit.play(1f);
					} else if (tempObj instanceof Ant) {
						((Ant) tempObj).onHit();
						sfxEnemyHit.play(1f);
					}
				}
			} else if (rayGroundedLeft) {
				tempFractLeft = fraction; 
				if (fixture.getFilterData().categoryBits == CollisionContactListener.TERRAIN_COL
						|| fixture.getFilterData().categoryBits == CollisionContactListener.BLOCK_COL) {
					groundedLeft = true;
				} else {
					groundedLeft = false;
				}
			} else if (rayGroundedRight) {
				tempFractRight = fraction; 
				if (fixture.getFilterData().categoryBits == CollisionContactListener.TERRAIN_COL
						|| fixture.getFilterData().categoryBits == CollisionContactListener.BLOCK_COL) {
					groundedRight = true;
				} else {
					groundedRight = false;
				}
			} else if (rayPlaceTool) { 
				if (fixture.getFilterData().categoryBits == CollisionContactListener.TERRAIN_COL
						|| fixture.getFilterData().categoryBits == CollisionContactListener.BLOCK_COL) {
					ladderPos.set(new Vector2(fixture.getBody().getPosition().x - 10,
							fixture.getBody().getPosition().y + 10));
					placeTool = true;
				}
			} else if (rayPlaceToolCimbing) {  while climbing
				if (fixture.getFilterData().categoryBits == CollisionContactListener.LADDER_COL) {
					tempLadder = (Ladder) fixture.getBody().getUserData();
					placeTool = true;
				}
			} else if (rayLadderAlreadyPlaced) {  while climbing
				if (fixture.getFilterData().categoryBits == CollisionContactListener.LADDER_COL) {
					placeTool = false;
				}
			}
		}
		return 0;
	}
@ Override public float reportRayFixture ( Fixture fixture , Vector2 point , Vector2 normal , float fraction ) { if ( ! super . getScreen ( ) . b2dWorld . isLocked ( ) ) { if ( rayDig ) { if ( fixture . getFilterData ( ) . categoryBits == CollisionContactListener . BLOCK_COL ) { Object tempObj = fixture . getBody ( ) . getUserData ( ) ; ( ( Block ) tempObj ) . currentHp = ( ( Block ) tempObj ) . currentHp - 1 ; ( ( Block ) tempObj ) . damageBlock ( ) ; if ( ( ( Block ) tempObj ) . currentHp <= 0 ) { super . getScreen ( ) . b2dWorld . destroyBody ( fixture . getBody ( ) ) ; if ( ( ( Block ) tempObj ) . containsResource ) { ( ( Block ) tempObj ) . spawnResource ( ) ; } super . getScreen ( ) . blocks . removeValue ( ( Entity ) tempObj , true ) ; sfxDestroy . play ( 0.75f ) ; for ( Entity entity : super . getScreen ( ) . blocks ) { ( ( Block ) entity ) . checkForNeighbours ( ) ; ( ( Block ) entity ) . updateSprite ( AssetsManager . MANAGER . get ( AssetsManager . ATLAS01 , Texture . class ) ) ; } } else { sfxDig . play ( 1f ) ; } } else if ( fixture . getFilterData ( ) . categoryBits == CollisionContactListener . TERRAIN_COL ) { sfxDenied . play ( 1f ) ; } else if ( fixture . getFilterData ( ) . categoryBits == CollisionContactListener . ENEMY_COL ) { Object tempObj = fixture . getBody ( ) . getUserData ( ) ; if ( tempObj instanceof Spider ) { ( ( Spider ) tempObj ) . onHit ( ) ; sfxEnemyHit . play ( 1f ) ; } else if ( tempObj instanceof Rat ) { ( ( Rat ) tempObj ) . onHit ( ) ; sfxEnemyHit . play ( 1f ) ; } else if ( tempObj instanceof Ant ) { ( ( Ant ) tempObj ) . onHit ( ) ; sfxEnemyHit . play ( 1f ) ; } } } else if ( rayGroundedLeft ) { tempFractLeft = fraction ; if ( fixture . getFilterData ( ) . categoryBits == CollisionContactListener . TERRAIN_COL || fixture . getFilterData ( ) . categoryBits == CollisionContactListener . BLOCK_COL ) { groundedLeft = true ; } else { groundedLeft = false ; } } else if ( rayGroundedRight ) { tempFractRight = fraction ; if ( fixture . getFilterData ( ) . categoryBits == CollisionContactListener . TERRAIN_COL || fixture . getFilterData ( ) . categoryBits == CollisionContactListener . BLOCK_COL ) { groundedRight = true ; } else { groundedRight = false ; } } else if ( rayPlaceTool ) { if ( fixture . getFilterData ( ) . categoryBits == CollisionContactListener . TERRAIN_COL || fixture . getFilterData ( ) . categoryBits == CollisionContactListener . BLOCK_COL ) { ladderPos . set ( new Vector2 ( fixture . getBody ( ) . getPosition ( ) . x - 10 , fixture . getBody ( ) . getPosition ( ) . y + 10 ) ) ; placeTool = true ; } } else if ( rayPlaceToolCimbing ) { if ( fixture . getFilterData ( ) . categoryBits == CollisionContactListener . LADDER_COL ) { tempLadder = ( Ladder ) fixture . getBody ( ) . getUserData ( ) ; placeTool = true ; } } else if ( rayLadderAlreadyPlaced ) { if ( fixture . getFilterData ( ) . categoryBits == CollisionContactListener . LADDER_COL ) { placeTool = false ; } } } return 0 ; }
used to detect if in air.
used to detect if in air .
// All enemies should be of class Enemy but I'm lazy. // if 0 = in air // if 0 = in air // LADDER // super.getScreen().tools.add(new Ladder(super.getScreen(), // fixture.getBody().getPosition().x - 10, fixture.getBody().getPosition().y + // 10)); // LADDER while climbing // ladderPos.set(new Vector2(fixture.getBody().getPosition().x - 10, // fixture.getBody().getPosition().y + 10)); // super.getScreen().tools.add(new Ladder(super.getScreen(), // fixture.getBody().getPosition().x - 10, fixture.getBody().getPosition().y + // 10)); // LADDER while climbing // ladderPos.set(new Vector2(fixture.getBody().getPosition().x - 10, // fixture.getBody().getPosition().y + 10)); // super.getScreen().tools.add(new Ladder(super.getScreen(), // fixture.getBody().getPosition().x - 10, fixture.getBody().getPosition().y + // 10));