Beispiel #1
0
        public GhostInputReplayer(Game game, GhostData data)
            : base(game)
        {
            Data = data;

            On.Celeste.Input.Initialize += HookInput;
            HookInput(null);
        }
Beispiel #2
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);
            });
        }
Beispiel #3
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;
        }
Beispiel #4
0
        public Ghost(Player player, GhostData data)
            : base(player.Position)
        {
            Player = player;
            Data   = data;

            Depth = 1;

            Sprite           = new PlayerSprite(player.Sprite.Mode);
            Sprite.HairCount = player.Sprite.HairCount;
            Add(Hair         = new PlayerHair(Sprite));
            Add(Sprite);

            Hair.Color = Player.NormalHairColor;

            Name = new GhostName(this, Data?.Name ?? "");
        }
Beispiel #5
0
        public static List <GhostData> ReadAllGhosts(Session session, List <GhostData> list = null)
        {
            if (list == null)
            {
                list = new List <GhostData>();
            }

            foreach (string filePath in GetAllGhostFilePaths(session))
            {
                GhostData ghost = new GhostData(filePath).Read();
                if (ghost == null)
                {
                    continue;
                }
                list.Add(ghost);
            }

            return(list);
        }
Beispiel #6
0
 public static void ForAllGhosts(Session session, Func <int, GhostData, bool> cb)
 {
     if (cb == null)
     {
         return;
     }
     string[] filePaths = GetAllGhostFilePaths(session);
     for (int i = 0; i < filePaths.Length; i++)
     {
         GhostData ghost = new GhostData(filePaths[i]).Read();
         if (ghost == null)
         {
             continue;
         }
         if (!cb(i, ghost))
         {
             break;
         }
     }
 }
Beispiel #7
0
        public Ghost(Player player, GhostData data)
            : base(player.Position)
        {
            Player = player;
            Data   = data;

            Depth = 1;
            // Tag = Tags.PauseUpdate;

            PlayerSpriteMode playerSpriteMode = player.Sprite.Mode;

            if (GhostModule.ModuleSettings.ReversedPlayerSpriteMode)
            {
                if (playerSpriteMode == PlayerSpriteMode.MadelineAsBadeline)
                {
                    if (player.Inventory.Backpack)
                    {
                        playerSpriteMode = PlayerSpriteMode.MadelineNoBackpack;
                    }
                    else
                    {
                        playerSpriteMode = PlayerSpriteMode.Madeline;
                    }
                }
                else
                {
                    playerSpriteMode = PlayerSpriteMode.MadelineAsBadeline;
                }
            }
            Sprite           = new PlayerSprite(playerSpriteMode);
            Sprite.HairCount = player.Sprite.HairCount;
            Add(Hair         = new PlayerHair(Sprite));
            Add(Sprite);

            Hair.Color = Player.NormalHairColor;

            Name = new GhostName(this, Data?.Name ?? "");
        }