package NET.worlds.scape; import NET.worlds.console.Main; import NET.worlds.console.MainCallback; import NET.worlds.core.Std; import java.util.Enumeration; public class HighJump extends InventoryAction implements MainCallback { int start; SmoothDriver sd; public HighJump(String id, String name) { super(id, name); } public HighJump(String id, String name, int qty) { super(id, name, qty); } public HighJump(HighJump in) { super(in); } @Override public InventoryItem cloneItem() { return new HighJump(this); } private SmoothDriver findSD(Pilot p) { Enumeration e = p.getHandlers(); while (e.hasMoreElements()) { Object o = e.nextElement(); if (o instanceof SmoothDriver) { return (SmoothDriver)o; } } return null; } @Override public boolean doAction() { if (this.itemQuantity_ > 0) { Pilot p = Pilot.getActive(); if (p == null) { return false; } else { this.sd = this.findSD(p); if (this.sd == null) { return false; } else { if (this.sd != null) { Main.register(this); this.start = Std.getRealTime(); this.itemQuantity_--; } return true; } } } else { return false; } } @Override public void mainCallback() { int now = Std.getFastTime(); if (now > this.start + 6000) { Main.unregister(this); this.sd.setEyeHeight(150.0F); } else { float t = 1.0F - (float)Math.pow(1.0F - (now - this.start) / 3000.0F, 4.0); this.sd.setEyeHeight(150.0F + 150.0F * t); } } }