コード例 #1
0
ファイル: SaveHandler.cs プロジェクト: veesusmikelheir/SRML
        public static void PullModdedData(ModdedSaveData data, Game game)
        {
            data.Clear();


            PullFullData(data, game);
            PullTertiaryData(data, game);
            PullAmmoData(data, game);
            PullPartialData(data, game);

            ExtendedData.Push(data);
            PersistentAmmoManager.SyncAll();
            PersistentAmmoManager.Push(data);
        }
コード例 #2
0
        public static void PullModdedData(GameV09 game)
        {
            data.segments.Clear();
            data.ammoDataEntries.Clear();
            foreach (var actor in game.actors.Where((x) => SaveRegistry.IsCustom(x)))
            {
                var segment = data.GetSegmentForMod(SaveRegistry.ModForData(actor));
                segment.identifiableData.Add(new IdentifiedData()
                {
                    data   = actor,
                    dataID = new DataIdentifier()
                    {
                        longID = actor.actorId, stringID = "", Type = IdentifierType.ACTOR
                    }
                });
            }

            foreach (var gadget in game.world.placedGadgets.Where((x) => SaveRegistry.IsCustom(x.Value)))
            {
                var segment = data.GetSegmentForMod(SaveRegistry.ModForData(gadget.Value));
                segment.identifiableData.Add(new IdentifiedData()
                {
                    data   = gadget.Value,
                    dataID = new DataIdentifier()
                    {
                        longID = 0, stringID = gadget.Key, Type = IdentifierType.GADGET
                    }
                });
            }

            foreach (var mod in ModPlayerData.FindAllModsWithData(game.player))
            {
                var segment = data.GetSegmentForMod(mod);

                segment.playerData.Pull(game.player, mod);
            }

            PediaDataBuffer buf = new PediaDataBuffer(game.pedia);

            foreach (var mod in ModPediaData.FindAllModsWithData(buf))
            {
                var segment = data.GetSegmentForMod(mod);
                segment.pediaData.Pull(buf, mod);
            }

            foreach (var ammo in AmmoDataUtils.GetAllAmmoData(game).Where((x) => AmmoDataUtils.HasCustomData(x)))
            {
                var modsInThis = new HashSet <SRMod>(ammo.Select((x) => SaveRegistry.IsCustom(x.id) ? SaveRegistry.ModForID(x.id) : null));
                modsInThis.Remove(null);
                foreach (var mod in modsInThis)
                {
                    if (mod == null)
                    {
                        continue;
                    }
                    if (AmmoIdentifier.TryGetIdentifier(ammo, game, out var identifier))
                    {
                        var segment = data.GetSegmentForMod(mod);
                        segment.customAmmo[identifier] =
                            AmmoDataUtils.RipOutWhere(ammo, (x) => SaveRegistry.ModForID(x.id) == mod, false);
                    }
                    else
                    {
                        throw new Exception("OH GOD ITS HAPPENING");
                    }
                }
            }

            ExtendedData.Push(data);
            PersistentAmmoManager.SyncAll();
            PersistentAmmoManager.Push(data);
        }