package com.ezardlabs.lostsector.objects.environment;

import com.ezardlabs.dethsquare.Script;
import com.ezardlabs.lostsector.objects.Player;

public class Door extends Script {

	@Override
	public void start() {
	}

	@Override
	public void update() {
		if (Player.player.collider.bounds.bottom > gameObject.collider.bounds.top &&
				Player.player.collider.bounds.top < gameObject.collider.bounds.bottom &&
				Math.abs(transform.position.x + 100 - Player.player.transform.position.x) < 600) {
			gameObject.animator.play("open");
			gameObject.setTag(null);
		} else {
			gameObject.animator.play("close");
			gameObject.setTag("solid");
		}
	}
}

@@ -84,219 +84,929 @@
 are.
-Script;%0Aimport com.ezardlabs.lostsector.objects.Player;%0A%0Apublic class Door extends Script %7B%0A%0A%09@Override%0A%09public void start() %7B%0A%09%7D%0A%0A%09@Override%0A%09public void update() %7B%0A%09%09if (Player.player.collider.bounds.bottom 
+Collider;%0Aimport com.ezardlabs.dethsquare.GameObject;%0Aimport com.ezardlabs.dethsquare.Script;%0A%0Aimport java.util.concurrent.ConcurrentHashMap;%0Aimport java.util.concurrent.ConcurrentHashMap.KeySetView;%0A%0Apublic class Door extends Script %7B%0A%0A%09@Override%0A%09public void start() %7B%0A%09%09GameObject.instantiate(new GameObject(%22DoorDetection%22, new Collider(1200, 500, true),%0A%09%09%09%09new DoorDetection(this)), transform.position.offset(-500, 0));%0A%09%7D%0A%0A%09private void open() %7B%0A%09%09gameObject.animator.play(%22open%22);%0A%09%09gameObject.setTag(null);%0A%09%7D%0A%0A%09private void close() %7B%0A%09%09gameObject.animator.play(%22close%22);%0A%09%09gameObject.setTag(%22solid%22);%0A%09%7D%0A%0A%09private class DoorDetection extends Script %7B%0A%09%09private final Door door;%0A%09%09private KeySetView%3CCollider, Boolean%3E colliders = ConcurrentHashMap.newKeySet();%0A%0A%09%09private DoorDetection(Door door) %7B%0A%09%09%09this.door = door;%0A%09%09%7D%0A%0A%09%09@Override%0A%09%09public void update() %7B%0A%09%09%09colliders.stream()%0A%09%09%09%09%09 .filter(collider -
 %3E 
+!
 game
@@ -1032,32 +1032,56 @@
 nds.
-top &&%0A%09%09%09%09Player.player
+contains(collider.bounds) &&%0A%09%09%09%09%09%09%09 !gameObject
 .col
@@ -1097,25 +1097,19 @@
 nds.
-top %3C gameObject.
+intersects(
 coll
@@ -1123,223 +1123,278 @@
 unds
-.bottom &&%0A%09%09%09%09Math.abs(transform.position.x + 100 - Player.player.transform.position.x) %3C 600) %7B%0A%09%09%09gameObject.animator.play(%22
+))%0A%09%09%09%09%09 .forEach(collider -%3E colliders.remove(collider));%0A%09%09%09if (colliders.size() %3E 0) %7B%0A%09%09%09%09door.
 open
-%22
+(
 );%0A%09%09%09
-gameObject.setTag(null);%0A%09%09%7D else %7B%0A%09%09%09gameObject.animator.play(%22close%22);%0A%09%09%09
+%7D else %7B%0A%09%09%09%09door.close();%0A%09%09%09%7D%0A%09%09%7D%0A%0A%09%09@Override%0A%09%09public void onTriggerEnter(Collider other) %7B%0A%09%09%09if (other.gameObject.getTag().equals(%22player%22) %7C%7C%0A%09%09%09%09%09other.
 game
@@ -1400,32 +1400,74 @@
 eObject.
-s
+g
 etTag(
-%22s
+).equals(%22enemy%22)) %7B%0A%09%09%09%09c
 ol
+l
 id
-%22);
+ers.add(other);%0A%09%09%09%7D
 %0A%09%09%7D%0A%09%7D%0A

Change door open/close detection to use trigger colliders