package com.deftwun.zombiecopter.systems;

import com.badlogic.ashley.core.Entity;
import com.badlogic.ashley.core.Family;
import com.badlogic.ashley.systems.IteratingSystem;
import com.badlogic.gdx.utils.Logger;
import com.deftwun.zombiecopter.ComponentMappers;
import com.deftwun.zombiecopter.App;
import com.deftwun.zombiecopter.components.HealthComponent;
import com.deftwun.zombiecopter.components.PhysicsComponent;
import com.deftwun.zombiecopter.components.TimeToLiveComponent;

public class LifetimeSystem extends IteratingSystem{
	private Logger logger = new Logger("LifeTimeSystem",Logger.INFO);
	
	@SuppressWarnings("unchecked")
	public LifetimeSystem() {
		super(Family.all(PhysicsComponent.class)
				    .one(HealthComponent.class,TimeToLiveComponent.class).get());
		logger.debug("initializing");
	}		

	@Override
	protected void processEntity(Entity entity, float deltaTime) {
		
		ComponentMappers mappers = App.engine.mappers;
		TimeToLiveComponent timeToLive = mappers.timeToLive.get(entity);
	
		//Time to live (expiration)
		if (timeToLive != null){
			timeToLive.time += deltaTime;
			if (timeToLive.time >= timeToLive.timeLimit){
				logger.debug("Entity #" + entity.getId() + " has expired: Time to live exceeded");
				App.engine.removeEntity(entity);
			}
		}
	}
}

@@ -53,120 +53,93 @@
 com.
-badlogic.ashley.core.Entity;%0D%0Aimport com.badlogic.ashley.core.Family;%0D%0Aimport com.badlogic.ashley.systems.Iterat
+artemis.Aspect;%0D%0Aimport com.artemis.Entity;%0D%0Aimport com.artemis.systems.EntityProcess
 ingS
@@ -217,32 +217,19 @@
 ecopter.
-ComponentMappers
+App
 ;%0D%0Aimpor
@@ -247,35 +247,48 @@
 un.zombiecopter.
-App
+ComponentMappers
 ;%0D%0Aimport com.de
@@ -504,14 +504,21 @@
 nds 
-Iterat
+EntityProcess
 ingS
@@ -522,16 +522,17 @@
 ngSystem
+ 
 %7B%0D%0A%09priv
@@ -670,14 +670,14 @@
 per(
-Family
+Aspect
 .all
@@ -767,14 +767,8 @@
 ass)
-.get()
 );%0D%0A
@@ -843,22 +843,16 @@
  process
-Entity
 (Entity 
@@ -861,25 +861,8 @@
 tity
-, float deltaTime
 ) %7B%0D
@@ -1072,17 +1072,19 @@
  += 
+world.
 delta
-Time
 ;%0D%0A%09

Migrate LifetimeSystem.java