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

import com.ezardlabs.dethsquare.Collider;
import com.ezardlabs.dethsquare.GameObject;
import com.ezardlabs.dethsquare.Layers;
import com.ezardlabs.dethsquare.Script;
import com.ezardlabs.dethsquare.TextureAtlas;
import com.ezardlabs.dethsquare.Time;
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");
		gameObject.renderer.setDepth(5);
	}

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

	@Override
	public void onTriggerEnter(Collider other) {
		if (other.gameObject.getLayer() == Layers.getLayer("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.getLayer() == Layers.getLayer("Solid") && other.gameObject.name != null &&
				!other.gameObject.name.equals("Snowglobe")) {
			gameObject.animator.play("shatter");
			gameObject.removeComponent(Freeze.class);
			transform.position.x = other.transform.position.x - gameObject.collider.getBounds().width();
			GameObject.destroy(gameObject, 400);
		}
	}
}

@@ -1245,45 +1245,22 @@
 %0A%09%09%09
-//noinspection ConstantConditions%0A%09%09%09
+Enemy enemy = 
 othe
@@ -1303,16 +1303,70 @@
 y.class)
+;%0A%09%09%09if (enemy != null && !enemy.isDead()) %7B%0A%09%09%09%09enemy
 .applyDa
@@ -1411,16 +1411,17 @@
 ition);%0A
+%09
 %09%09%09gameO
@@ -1462,16 +1462,17 @@
 ss);%0A%09%09%09
+%09
 Network.
@@ -1492,16 +1492,21 @@
 bject);%0A
+%09%09%09%7D%0A
 %09%09%7D else

Fix projectile hitting dead enemies