public override void Removed(Scene scene) { base.Removed(scene); // Remove any dead ghosts (heh) for (int i = Ghosts.Count - 1; i > -1; --i) { Ghost ghost = Ghosts[i]; if (ghost.Player != Player) { ghost.RemoveSelf(); } } Ghosts.Clear(); }
public void Step(Level level) { if (!Settings.Enabled) { return; } string target = level.Session.Level; Logger.Log("ghost", $"Stepping into {level.Session.Area.GetSID()} {target}"); Player player = level.Tracker.GetEntity <Player>(); // Write the ghost, even if we haven't gotten an IL PB. // Maybe we left the level prematurely earlier? if (GhostRecorder?.Data != null) { GhostRecorder.Data.Target = target; GhostRecorder.Data.Write(); } // Remove any dead ghosts (heh) for (int i = Ghosts.Count - 1; i > -1; --i) { Ghost ghost = Ghosts[i]; if (ghost.Player != player) { ghost.RemoveSelf(); } } Ghosts.Clear(); // Read and add all ghosts. GhostData.ForAllGhosts(level.Session, (i, ghostData) => { Ghost ghost = new Ghost(player, ghostData); level.Add(ghost); Ghosts.Add(ghost); return(true); }); if (GhostRecorder != null) { GhostRecorder.RemoveSelf(); } level.Add(GhostRecorder = new GhostRecorder(player)); GhostRecorder.Data = new GhostData(level.Session); GhostRecorder.Data.Name = Settings.Name; }