summaryrefslogtreecommitdiff
path: root/NET/worlds/scape/Event.java
diff options
context:
space:
mode:
authorFuwn <[email protected]>2026-02-12 22:33:32 -0800
committerFuwn <[email protected]>2026-02-12 22:33:32 -0800
commitc7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9 (patch)
treedf9f48bf128a6c0186a8e91857d6ff30fe0e9f18 /NET/worlds/scape/Event.java
downloadworldsplayer-c7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9.tar.xz
worldsplayer-c7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9.zip
Initial commit
Diffstat (limited to 'NET/worlds/scape/Event.java')
-rw-r--r--NET/worlds/scape/Event.java74
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;
+ }
+}