package com.ezardlabs.lostsector.objects.warframes.abilities.frost;

import com.ezardlabs.dethsquare.Collider;
import com.ezardlabs.dethsquare.GameObject;
import com.ezardlabs.dethsquare.Script;
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.Game.DamageType;
import com.ezardlabs.lostsector.objects.enemies.Enemy;

public class Freeze extends Script {

	@Override
	public void start() {
		TextureAtlas ta = TextureAtlas.load("data/warframes/frost/abilities/freeze");
		gameObject.renderer.setTextureAtlas(ta, 100, 100);
		gameObject.animator.setAnimations(
				Animations.load("data/warframes/frost/abilities/freeze", ta, new Validator("move", "shatter")));
		gameObject.animator.play("move");
	}

	@Override
	public void update() {
		transform.translate(15f * transform.scale.x, 0);
	}

	@Override
	public void onTriggerEnter(Collider other) {
		if (other.gameObject.getTag() != null) {
			if (other.gameObject.getTag().equals("enemy")) {
				//noinspection ConstantConditions
				other.gameObject.getComponentOfType(Enemy.class).applyDamage(1, DamageType.COLD, transform.position);
				gameObject.removeComponent(Collider.class);
				Network.destroy(gameObject);
			} else if (other.gameObject.getTag().equals("solid") && other.gameObject.name != null &&
					!other.gameObject.name.equals("Snowglobe")) {
				gameObject.animator.play("shatter");
				gameObject.removeComponent(Freeze.class);
				GameObject.destroy(gameObject, 400);
			}
		}
	}
}

@@ -148,16 +148,56 @@
 Object;%0A
+import com.ezardlabs.dethsquare.Layers;%0A
 import c
@@ -228,16 +228,16 @@
 Script;%0A
-
 import c
@@ -929,16 +929,51 @@
 move%22);%0A
+%09%09gameObject.renderer.setDepth(5);%0A
 %09%7D%0A%0A%09@Ov
@@ -1145,67 +1145,37 @@
 .get
-Tag() != null) %7B%0A%09%09%09if (other.gameObject.getTag().equals(%22e
+Layer() == Layers.getLayer(%22E
 nemy
@@ -1183,17 +1183,16 @@
 )) %7B%0A%09%09%09
-%09
 //noinsp
@@ -1217,17 +1217,16 @@
 ditions%0A
-%09
 %09%09%09other
@@ -1322,17 +1322,16 @@
 ition);%0A
-%09
 %09%09%09gameO
@@ -1372,17 +1372,16 @@
 ss);%0A%09%09%09
-%09
 Network.
@@ -1401,17 +1401,16 @@
 bject);%0A
-%09
 %09%09%7D else
@@ -1438,23 +1438,37 @@
 .get
-Tag().equals(%22s
+Layer() == Layers.getLayer(%22S
 olid
@@ -1510,17 +1510,16 @@
  &&%0A%09%09%09%09
-%09
 !other.g
@@ -1555,25 +1555,24 @@
 obe%22)) %7B%0A%09%09%09
-%09
 gameObject.a
@@ -1596,17 +1596,16 @@
 tter%22);%0A
-%09
 %09%09%09gameO
@@ -1644,17 +1644,16 @@
 ss);%0A%09%09%09
-%09
 GameObje
@@ -1685,13 +1685,8 @@
 0);%0A
-%09%09%09%7D%0A
 %09%09%7D%0A

Set depth and change collision logic from tag-checking to layer-checking