package com.ezardlabs.lostsector.objects.environment;

import com.ezardlabs.dethsquare.Animator;
import com.ezardlabs.dethsquare.Collider;
import com.ezardlabs.dethsquare.Component;
import com.ezardlabs.dethsquare.TextureAtlas;
import com.ezardlabs.dethsquare.animation.Animations;
import com.ezardlabs.dethsquare.animation.Animations.Validator;
import com.ezardlabs.dethsquare.multiplayer.Network;
import com.ezardlabs.lostsector.objects.warframes.Warframe;

public class Locker extends Component {
	private final boolean locked;
	private final TextureAtlas ta;
	private boolean unlocking = false;

	public Locker(boolean locked, TextureAtlas ta) {
		this.locked = locked;
		this.ta = ta;
	}

	@Override
	public void start() {
		super.start();
		gameObject.renderer.setTextureAtlas(ta, 100, 200);
		if (locked) {
			gameObject.renderer.setSprite(ta.getSprite("lockred"));
		} else {
			gameObject.animator.addAnimations(
					Animations.load("animations/environment/corpus/locker", ta, new Validator("lock", "unlock")));
			gameObject.animator.play("lock");
		}
	}

	@Override
	public void onTriggerEnter(Collider other) {
		if (!locked && !unlocking && Network.isHost() && other.gameObject.getTag() != null &&
				other.gameObject.getTag().equals("player")) {
			unlocking = true;
			//noinspection ConstantConditions
			gameObject.getComponent(Animator.class).play("unlock");
			Warframe w = other.gameObject.getComponentOfType(Warframe.class);
			//noinspection ConstantConditions
			w.addHealth(20);
			w.addEnergy(25);
		}
	}
}
@@ -52,50 +52,8 @@
 t;%0A%0A
-import com.ezardlabs.dethsquare.Animator;%0A
 impo
@@ -394,68 +394,223 @@
 cts.
-warframes.Warframe;%0A%0Apublic class Locker extends Component %7B
+DropTable;%0A%0Aimport static java.util.Arrays.asList;%0A%0Apublic class Locker extends Component %7B%0A%09private static final DropTable dropTable = new DropTable(asList(%22pickup_health%22, %22pickup_energy%22), asList(0.5f,%0A%09%09%090.5f));
 %0A%09pr
@@ -1396,78 +1396,28 @@
 %0A%09%09%09
-//noinspection ConstantConditions%0A%09%09%09gameObject.getComponent(A
+gameObject.a
 nimator.
 clas
@@ -1416,15 +1416,8 @@
 tor.
-class).
 play
@@ -1435,150 +1435,121 @@
 %0A%09%09%09
-Warframe w = other.gameObject.getComponentOfType(Warframe.class);%0A%09%09%09//noinspection ConstantConditions%0A%09%09%09w.addHealth(20);%0A%09%09%09w.addEnergy(25);
+String drop = dropTable.getDrop();%0A%09%09%09if (drop != null) %7B%0A%09%09%09%09Network.instantiate(drop, transform.position);%0A%09%09%09%7D
 %0A%09%09%7D

Modify locker to drop health/energy pickups