package ReviveManager import PlayerData constant TIMER_PERIOD = 0.1 interface ReviveListener function onAllDead() public ReviveListener waitForListener public enum ReviveMode TIMED CIRCLE WAIT_FOR_ALL public ReviveMode revMode = ReviveMode.TIMED class RevivePod PlayerData owner real time boolean wait construct(PlayerData owner, real time, boolean wait) this.owner = owner this.time = time this.wait = wait RevivePod array pods int waitForCount = 0 public function changeRevMode(ReviveMode rMode) waitForCount = 0 for i = 0 to 11 pods[i].time = 0 pods[i].wait = false revMode = rMode update() public function manageRevive(Escaper e) if isBuilderPlayer(e.owner) manageTimedRevive(e, TIMER_PERIOD) switch revMode case TIMED manageTimedRevive(e, 2.75) case CIRCLE // TODO case WAIT_FOR_ALL manageWaitForRevive(e) function manageTimedRevive(Escaper e, real time) let id = e.owner.getId() if pods[id] == null pods[id] = new RevivePod(pData[id], time, false) public function forceRevive(Escaper e) let pod = pods[e.owner.getId()] if pod != null if pod.owner.escaper != null and not pod.owner.escaper.alive pod.owner.escaper.revive() destroy pod pods[e.owner.getId()] = null function manageWaitForRevive(Escaper e) let id = e.owner.getId() if pods[id] == null pods[id] = new RevivePod(pData[id], 0, true) if waitForListener != null waitForCount++ function checkSharedRevive() if waitForCount >= escaperPlayers.size() waitForCount = 0 waitForListener.onAllDead() waitForListener = null for i = 0 to 11 pods[i].wait = false function update() if revMode == ReviveMode.WAIT_FOR_ALL checkSharedRevive() for i = 0 to 11 let pod = pods[i] if pod != null if not pod.wait pod.time -= TIMER_PERIOD if pod.time <= 0 if pod.owner.escaper != null and not pod.owner.escaper.alive pod.owner.escaper.revive() destroy pod pods[i] = null init CreateTimer().startPeriodic(TIMER_PERIOD, () -> update())