Esempio n. 1
0
        public static void PushModdedData(GameV09 game)
        {
            foreach (var mod in data.segments)
            {
                Debug.Log($"Splicing data from mod {mod.modid} which {mod.identifiableData.Count} pieces of identifiable data");
                foreach (var customData in mod.identifiableData)
                {
                    switch (customData.dataID.Type)
                    {
                    case IdentifierType.ACTOR:
                        game.actors.Add((VanillaActorData)customData.data);
                        break;

                    case IdentifierType.GADGET:
                        game.world.placedGadgets[customData.dataID.stringID] = (VanillaGadgetData)customData.data;
                        break;

                    default:
                        throw new NotImplementedException();
                    }
                }

                mod.playerData.Push(game.player);
                mod.pediaData.Push(game.pedia);

                foreach (var ammo in mod.customAmmo)
                {
                    AmmoDataUtils.SpliceAmmoData(AmmoIdentifier.ResolveToData(ammo.Key, game), ammo.Value);
                }
            }

            ExtendedData.Pull(data);
            PersistentAmmoManager.Pull(data);
        }
Esempio n. 2
0
        public static void PushAllModdedData(ModdedSaveData data, Game game)
        {
            ExtendedData.Pull(data);
            PushAllSegmentData(data, game);


            PersistentAmmoManager.Pull(data);
            PushAllPartialData(data, game);
        }
Esempio n. 3
0
        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);
        }
Esempio n. 4
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);
        }
Esempio n. 5
0
 static void ClearAllNonData()
 {
     ExtendedData.Clear();
     PersistentAmmoManager.Clear();
 }