12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- package me.hammerle.supersnuvi.entity.components.ai;
- import me.hammerle.supersnuvi.entity.Entity;
- public class FollowHeroController extends Controller
- {
- private final float motion;
- private boolean jump;
-
- public FollowHeroController(Entity ent, float motion)
- {
- super(ent);
- this.motion = motion;
- this.jump = false;
- }
- /*@Override
- public void tick()
- {
- if(ent.getHealth().isDead())
- {
- return;
- }
- Entity hero = ent.getLevel().getHero();
- if(hero.squaredDistance(ent) <= 409600)
- {
- if(jump)
- {
- jump = false;
- SoundUtils.playSound(SoundUtils.Sound.LONDONER_JUMP);
- ent.getMovement().jump();
- }
- float distance = ent.signedDistanceX(hero);
- if(distance < 0)
- {
- ent.setMotionX(motion * ent.getMovementPenalty().getFactor());
- }
- else if(distance > 0)
- {
- ent.setMotionX(-motion * ent.getMovementPenalty().getFactor());
- }
- }
- }
- @Override
- public void onCollideWithEntity(Entity ent, Face face)
- {
- if(this.ent.signedDistanceX(ent) == 0)
- {
- if(ent.getX() - this.ent.getX() > 0)
- {
- ent.setMotionX(6.0f);
- }
- else
- {
- ent.setMotionX(-6.0f);
- }
- ent.getHealth().addHealth(-0.05);
- if(ent.getMovement().useCollisionBox())
- {
- jump = true;
- }
- }
- }
- @Override
- public void onCollideWithTile(Location loc, Face face)
- {
- if((face == Face.LEFT || face == Face.RIGHT) &&
- Math.abs(ent.getPreviousMotionX() - ent.getMotionX()) > 0.001 &&
- Math.abs(ent.signedDistanceX(ent.getLevel().getHero())) > 0.001)
- {
- jump = true;
- }
- }*/
- }
|