package shootergame.entity; import shootergame.Main; import shootergame.display.Camera; import shootergame.entity.player.EntityPlayer; import shootergame.init.Layers; import shootergame.init.Textures; import shootergame.util.gl.GlHelpers; import shootergame.util.math.vec.Vec2d; import shootergame.world.chunk.Chunk; import shootergame.world.layer.Layer; import shootergame.world.layer.layergen.LayerGenRememberPlayerPos; public class EntityGrapplingHook extends EntityVertical { private int layerId; private double height; private Entity entity; public EntityGrapplingHook(Vec2d pos, int layerId, Entity entity) { super(pos, Textures.ENTITY_GRAPPLING_HOOK, new Vec2d(1, 16)); this.layerId = layerId; this.height = -16; this.entity = entity; if(entity instanceof EntityPlayer) { EntityPlayer ep = (EntityPlayer)entity; ep.in_animation = true; } } @Override public void tick(Chunk chunk, Layer layer) { super.tick(chunk, layer); if(entity instanceof EntityHeight) { EntityHeight ea = (EntityHeight)entity; if(height >= -8) { double h = ea.getHeight(); ea.setHeight(h + 0.02); if(entity instanceof EntityPlayer) { EntityPlayer ep = (EntityPlayer)entity; ep.moving = true; } if(h >= 8) { ea.setHeight(0); Main.world.setLayer(Layers.getLayer(layerId)); if(entity instanceof EntityPlayer) { EntityPlayer ep = (EntityPlayer)entity; ep.in_animation = false; ep.moving = false; } if(layer.layergen instanceof LayerGenRememberPlayerPos) { LayerGenRememberPlayerPos lgrpp = (LayerGenRememberPlayerPos)layer.layergen; entity.pos = lgrpp.getPlayerPos(); } kill(); return; } } else { height += 0.05; } } } @Override public void render(Vec2d pos, Camera camera) { GlHelpers.pushMatrix(); GlHelpers.translate3(0, 0, height); super.render(pos, camera); GlHelpers.popMatrix(); } }