Esempio n. 1
0
 public void Add(string scene, IGameStateMod mod)
 {
     if (!gameState.TryGetValue(scene, out var sceneMods))
     {
         gameState.Add(scene, sceneMods = new List <IGameStateMod>());
     }
     sceneMods.Add(mod);
 }
Esempio n. 2
0
        public static Savegame ReadNew(BinaryReader r)
        {
            Savegame sg = new Savegame();

            sg.version       = ZZVersion.ReadNew(r);
            sg.name          = r.ReadZString();
            sg.secondsPlayed = r.ReadInt32();
            sg.progress      = r.ReadInt32();
            if (r.ReadUInt32() != LocationBlockSize)
            {
                throw new InvalidDataException("Invalid size of savegame location block");
            }
            sg.sceneId = r.ReadInt32();
            sg.entryId = r.ReadInt32();

            var sceneCount = r.ReadUInt32();

            sg.gameState.EnsureCapacity((int)sceneCount);
            for (uint i = 0; i < sceneCount; i++)
            {
                var sceneName = r.ReadZString();
                var modCount  = r.ReadInt32();
                var mods      = new List <IGameStateMod>(modCount);
                for (int j = 0; j < modCount; j++)
                {
                    mods.Add(IGameStateMod.ReadNew(r));
                }
                sg.gameState[sceneName] = mods;
            }

            var itemCount = r.ReadUInt32();

            sg.inventory.EnsureCapacity((int)itemCount);
            for (uint i = 0; i < itemCount; i++)
            {
                sg.inventory.Add(InventoryCard.ReadNew(r));
            }

            sg.pixiesHolding = r.ReadUInt32();
            sg.pixiesCatched = r.ReadUInt32();

            if (r.ReadInt32() != GlobalVar.Count)
            {
                throw new InvalidDataException("Invalid global variable count");
            }
            for (int i = 0; i < sg.globalVars.Length; i++)
            {
                sg.globalVars[i] = GlobalVar.ReadNew(r);
            }

            sg.switchGameMinMoves = r.ReadUInt32();
            return(sg);
        }
Esempio n. 3
0
 private void HandleGSModForThisScene(IGameStateMod gsMod) => savegame.Add($"sc_{scene.dataset.sceneId}", gsMod);