package uk.co.rossbinden.transferencevoid.system

import com.badlogic.ashley.core.Entity
import com.badlogic.ashley.systems.IteratingSystem
import uk.co.rossbinden.transferencevoid.TransferenceVoid
import uk.co.rossbinden.transferencevoid.component.*
import uk.co.rossbinden.transferencevoid.screen.EndScreen

class TimerSystem: IteratingSystem(TIMER_FAMILY) {
    override fun processEntity(entity: Entity, deltaTime: Float) {
        TIMER.get(entity).timeRemaining -= deltaTime
        if (!TERMINAL_FAMILY.matches(entity)) {
            if (TIMER.get(entity).timeRemaining <= -4f) {
                TransferenceVoid.screen = EndScreen(DATA.get(engine.getEntitiesFor(GOAL_FAMILY).first()).data)
            }
        }
    }
}