Ejemplo n.º 1
0
        public GhostManager(Player player, Level level)
            : base(Vector2.Zero)
        {
            Player = player;

            Tag = Tags.HUD;

            // 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);
            });
        }
Ejemplo n.º 2
0
        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;
        }