summaryrefslogtreecommitdiff
path: root/NET/worlds/scape/WObjectHighlighter.java
diff options
context:
space:
mode:
Diffstat (limited to 'NET/worlds/scape/WObjectHighlighter.java')
-rw-r--r--NET/worlds/scape/WObjectHighlighter.java52
1 files changed, 52 insertions, 0 deletions
diff --git a/NET/worlds/scape/WObjectHighlighter.java b/NET/worlds/scape/WObjectHighlighter.java
new file mode 100644
index 0000000..8a94f02
--- /dev/null
+++ b/NET/worlds/scape/WObjectHighlighter.java
@@ -0,0 +1,52 @@
+package NET.worlds.scape;
+
+import NET.worlds.console.Main;
+import NET.worlds.console.MainCallback;
+
+class WObjectHighlighter implements MainCallback {
+ private WObject target;
+ private Room room;
+ private boolean newState;
+ private boolean registered;
+
+ public WObjectHighlighter(WObject target) {
+ this.target = target;
+ this.start();
+ }
+
+ @Override
+ public synchronized void mainCallback() {
+ if (this.newState != this.target.getHighlit()) {
+ this.target.setHighlit(this.newState);
+ if (this.newState) {
+ this.room = this.target.getRoom();
+ if (this.room != null) {
+ this.room.highlightTarget = this.target;
+ }
+ } else if (this.room != null) {
+ this.room.highlightTarget = null;
+ this.room = null;
+ }
+ }
+
+ Main.unregister(this);
+ this.registered = false;
+ }
+
+ public synchronized void start() {
+ this.newState = true;
+ this.registerMe();
+ }
+
+ public synchronized void stop() {
+ this.newState = false;
+ this.registerMe();
+ }
+
+ private synchronized void registerMe() {
+ if (!this.registered) {
+ Main.register(this);
+ this.registered = true;
+ }
+ }
+}