package NET.worlds.scape; public class Event implements Cloneable { public static final Class eventSuperclass = new Object().getClass(); public int time; public Object source; public WObject target; public WObject receiver; public Event(int time, Object source, WObject target) { this.time = time; this.source = source; this.target = target; } @Override public Object clone() { try { return super.clone(); } catch (CloneNotSupportedException var2) { System.out.println("Clone of Object not supported!"); return null; } } public boolean isA(Class c) { for (Class t = this.getClass(); t != eventSuperclass; t = t.getSuperclass()) { if (t == c) { return true; } } return false; } public boolean deliver(Object o) { return o instanceof Handler && ((Handler)o).handle(this); } @Override public String toString() { String result = "Event at " + this.time; String sname = null; if (this.source instanceof SuperRoot) { sname = ((SuperRoot)this.source).getName(); } else if (this.source != null) { sname = this.source.toString(); } if (sname != null) { result = result + " from " + sname; } String tname = null; if (this.target != null) { this.target.getName(); } if (tname != null) { result = result + " to " + tname; } String rname = null; if (this.receiver != null) { this.receiver.getName(); } if (rname != null) { result = result + " handled by " + rname; } return result; } }