diff options
| author | Fuwn <[email protected]> | 2026-02-12 22:33:32 -0800 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2026-02-12 22:33:32 -0800 |
| commit | c7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9 (patch) | |
| tree | df9f48bf128a6c0186a8e91857d6ff30fe0e9f18 /NET/worlds/scape/Event.java | |
| download | worldsplayer-c7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9.tar.xz worldsplayer-c7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9.zip | |
Initial commit
Diffstat (limited to 'NET/worlds/scape/Event.java')
| -rw-r--r-- | NET/worlds/scape/Event.java | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/NET/worlds/scape/Event.java b/NET/worlds/scape/Event.java new file mode 100644 index 0000000..69c9c6a --- /dev/null +++ b/NET/worlds/scape/Event.java @@ -0,0 +1,74 @@ +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; + } +} |