Esempio n. 1
0
        public static HashSet <SRMod> FindAllModsWithData(PediaDataBuffer data)
        {
            var mods = new HashSet <SRMod>();

            data.unlockedIds.ForEach((x) => mods.Add(ModdedIDRegistry.ModForID(x)));
            data.completedTuts.ForEach((x) => mods.Add(ModdedIDRegistry.ModForID(x)));
            data.popupQueue.ForEach((x) => mods.Add(ModdedIDRegistry.ModForID(x)));

            mods.Remove(null);
            return(mods);
        }
Esempio n. 2
0
        public static bool IsModdedIdentifier(AmmoIdentifier id)
        {
            switch (id.AmmoType)
            {
            case AmmoType.PLAYER:
                return(ModdedIDRegistry.IsModdedID((PlayerState.AmmoMode)(int) id.longIdentifier));

            case AmmoType.LANDPLOT:
                return(ModdedIDRegistry.IsModdedID((SiloStorage.StorageType)(int) id.longIdentifier));
            }
            return(id.AmmoType.IsCustom());
        }
Esempio n. 3
0
            public void AddAndRemoveWhereCustom <T>(List <T> original)
            {
                var buffer = new List <T>();

                buffer.AddRange(original.Where((x) => x.GetType().IsEnum? ModdedIDRegistry.IsModdedID(x):SaveRegistry.IsCustom(x)));
                foreach (var v in buffer)
                {
                    original.Remove(v);
                }

                addBacks.Add(() => original.AddRange(buffer));
            }
Esempio n. 4
0
 public void Push(VanillaWorldData data)
 {
     foreach (var v in econSaturations)
     {
         if (ModdedIDRegistry.IsValidID(v.Key))
         {
             data.econSaturations[v.Key] = v.Value;
         }
     }
     data.pendingOfferRancherIds.AddRange(pendingOfferRancherIds.Where(ExchangeOfferRegistry.IsCustom));
     data.lastOfferRancherIds.AddRange(lastOfferRancherIds.Where(ExchangeOfferRegistry.IsCustom));
 }
Esempio n. 5
0
 public void Pull(VanillaWorldData data, SRMod mod)
 {
     foreach (var v in data.econSaturations)
     {
         if (ModdedIDRegistry.ModForID(v.Key) == mod)
         {
             econSaturations.Add(v.Key, v.Value);
         }
     }
     pendingOfferRancherIds.AddRange(data.pendingOfferRancherIds.Where((x) => ExchangeOfferRegistry.GetModForID(x) == mod));
     lastOfferRancherIds.AddRange(data.lastOfferRancherIds.Where((x) => ExchangeOfferRegistry.GetModForID(x) == mod));
 }
Esempio n. 6
0
        internal static SRMod GetModForIdentifier(AmmoIdentifier id)
        {
            switch (id.AmmoType)
            {
            case AmmoType.PLAYER:
                return(ModdedIDRegistry.ModForID((PlayerState.AmmoMode)(int) id.longIdentifier));

            case AmmoType.LANDPLOT:
                return(ModdedIDRegistry.ModForID((SiloStorage.StorageType)(int) id.longIdentifier));
            }
            return(id.AmmoType.IsCustom() ? SRModLoader.GetMod(id.custommodid) : null);
        }
Esempio n. 7
0
        static PartialExchangeData()
        {
            RegisterPartialData(() => new PartialExchangeData());
            EnumTranslator.RegisterEnumFixer <PartialExchangeData>((translator, mode, data) =>
            {
                translator.FixEnumValues(mode, data.requests);
                translator.FixEnumValues(mode, data.rewards);
            });
            EnumTranslator.RegisterEnumFixer <ItemEntryV03>((translator, mode, data) =>
            {
                data.id             = translator.TranslateEnum(mode, data.id);
                data.nonIdentReward = translator.TranslateEnum(mode, data.nonIdentReward);
            });

            EnumTranslator.RegisterEnumFixer <RequestedItemEntryV03>((translator, mode, data) =>
            {
                data.id             = translator.TranslateEnum(mode, data.id);
                data.nonIdentReward = translator.TranslateEnum(mode, data.nonIdentReward);
            });

            EnumTranslator.RegisterEnumFixer <ExchangeOfferV04>((translator, mode, data) =>
            {
                translator.FixEnumValues(mode, data.requests);
                translator.FixEnumValues(mode, data.rewards);
            });


            CustomChecker.RegisterCustomChecker <ExchangeOfferV04>((data) =>
            {
                if (ExchangeOfferRegistry.IsCustom(data))
                {
                    return(CustomChecker.CustomLevel.FULL);
                }
                if (data.requests.Any(x => ModdedIDRegistry.IsModdedID(x.id) || ModdedIDRegistry.IsModdedID(x.nonIdentReward)))
                {
                    return(CustomChecker.CustomLevel.PARTIAL);
                }
                if (data.rewards.Any(x => ModdedIDRegistry.IsModdedID(x.id) || ModdedIDRegistry.IsModdedID(x.nonIdentReward)))
                {
                    return(CustomChecker.CustomLevel.PARTIAL);
                }
                return(CustomChecker.CustomLevel.VANILLA);
            });
        }
Esempio n. 8
0
        public static HashSet <SRMod> FindAllModsWithData(PlayerV14 player)
        {
            var mods = new HashSet <SRMod>();

            player.upgrades.ForEach((x) => mods.Add(ModdedIDRegistry.ModForID(x)));
            player.availUpgrades.ForEach((x) => mods.Add(ModdedIDRegistry.ModForID(x)));
            foreach (var x in player.upgradeLocks)
            {
                mods.Add(ModdedIDRegistry.ModForID(x.Key));
            }

            foreach (var x in player.progress)
            {
                mods.Add(ModdedIDRegistry.ModForID(x.Key));
            }
            foreach (var x in player.delayedProgress)
            {
                mods.Add(ModdedIDRegistry.ModForID(x.Key));
            }

            player.blueprints.ForEach((x) => mods.Add(ModdedIDRegistry.ModForID(x)));
            player.availBlueprints.ForEach((x) => mods.Add(ModdedIDRegistry.ModForID(x)));
            foreach (var x in player.blueprintLocks)
            {
                mods.Add(ModdedIDRegistry.ModForID(x.Key));
            }

            foreach (var x in player.gadgets)
            {
                mods.Add(ModdedIDRegistry.ModForID(x.Key));
            }

            foreach (var x in player.craftMatCounts)
            {
                mods.Add(ModdedIDRegistry.ModForID(x.Key));
            }

            player.mail.ForEach((x) => mods.Add(MailRegistry.GetModForMail(x.messageKey)));

            player.unlockedZoneMaps.ForEach((x) => mods.Add(ModdedIDRegistry.ModForID(x)));

            mods.Remove(null);
            return(mods);
        }
Esempio n. 9
0
        public void Push(PlayerV14 player)
        {
            player.upgrades.AddRange(upgrades.Where((x) => ModdedIDRegistry.IsValidID(x)));
            player.availUpgrades.AddRange(availUpgrades.Where((x) => ModdedIDRegistry.IsValidID(x)));
            AddRange(player.upgradeLocks, upgradeLocks.Where((x) => ModdedIDRegistry.IsValidID(x.Key)));

            AddRange(player.progress, progress.Where((x) => ModdedIDRegistry.IsValidID(x.Key)));
            AddRange(player.delayedProgress, delayedProgress.Where((x) => ModdedIDRegistry.IsValidID(x.Key)));

            player.blueprints.AddRange(blueprints.Where((x) => ModdedIDRegistry.IsValidID(x)));
            player.availBlueprints.AddRange(availBlueprints.Where((x) => ModdedIDRegistry.IsValidID(x)));
            AddRange(player.blueprintLocks, blueprintLocks.Where((x) => ModdedIDRegistry.IsValidID(x.Key)));

            AddRange(player.gadgets, gadgets.Where((x) => ModdedIDRegistry.IsValidID(x.Key)));

            AddRange(player.craftMatCounts, craftMatCounts.Where((x) => ModdedIDRegistry.IsValidID(x.Key)));
            player.unlockedZoneMaps.AddRange(unlockedZoneMaps.Where((x) => ModdedIDRegistry.IsValidID(unlockedZoneMaps)));
            player.mail.AddRange(mail.Where((x) => MailRegistry.GetModForMail(x.messageKey) != null));
        }
Esempio n. 10
0
        public static HashSet <SRMod> FindAllModsWithData(VanillaWorldData data)
        {
            var set = new HashSet <SRMod>();

            foreach (var v in data.econSaturations)
            {
                set.Add(ModdedIDRegistry.ModForID(v.Key));
            }

            foreach (var v in data.lastOfferRancherIds.Select(ExchangeOfferRegistry.GetModForID))
            {
                set.Add(v);
            }
            foreach (var v in data.pendingOfferRancherIds.Select(ExchangeOfferRegistry.GetModForID))
            {
                set.Add(v);
            }
            set.Remove(null);
            return(set);
        }
Esempio n. 11
0
        public void Pull(PlayerV14 player, SRMod ourMod)
        {
            upgrades.AddRange(player.upgrades.Where((x) => ModdedIDRegistry.ModForID(x) == ourMod));
            availUpgrades.AddRange(player.availUpgrades.Where((x) => ModdedIDRegistry.ModForID(x) == ourMod));
            AddRange(upgradeLocks, player.upgradeLocks.Where((x) => ModdedIDRegistry.ModForID(x.Key) == ourMod));

            AddRange(progress, player.progress.Where((x) => ModdedIDRegistry.ModForID(x.Key) == ourMod));
            AddRange(delayedProgress, player.delayedProgress.Where((x) => ModdedIDRegistry.ModForID(x.Key) == ourMod));

            blueprints.AddRange(player.blueprints.Where((x) => ModdedIDRegistry.ModForID(x) == ourMod));
            availBlueprints.AddRange(player.availBlueprints.Where((x) => ModdedIDRegistry.ModForID(x) == ourMod));
            AddRange(blueprintLocks, player.blueprintLocks.Where((x) => ModdedIDRegistry.ModForID(x.Key) == ourMod));

            AddRange(gadgets, player.gadgets.Where((x) => ModdedIDRegistry.ModForID(x.Key) == ourMod));

            AddRange(craftMatCounts, player.craftMatCounts.Where((x) => ModdedIDRegistry.ModForID(x.Key) == ourMod));

            unlockedZoneMaps.AddRange(player.unlockedZoneMaps.Where((x) => ModdedIDRegistry.ModForID(x) == ourMod));

            mail.AddRange(player.mail.Where((x) => MailRegistry.GetModForMail(x.messageKey) == ourMod));
        }
Esempio n. 12
0
 static LandPlotUpgradeRegistry()
 {
     ModdedIDRegistry.RegisterIDRegistry(moddedUpgrades);
     EnumPatcher.RegisterAlternate(typeof(LandPlot.Upgrade), (obj, name) => CreateLandPlotUpgrade(obj, name));
     PurchasableUIRegistry.RegisterManipulator((LandPlotUI ui, ref Purchasable[] purchasables) =>
     {
         List <Purchasable> purchasables1 = purchasables.ToList();
         Purchasable Demolish             = purchasables1.FirstOrDefault(match => match.nameKey == DemolishKey);
         if (Demolish == null)
         {
             return;
         }
         purchasables1.Remove(Demolish);
         Purchasable ClearCrop = purchasables1.FirstOrDefault(match => match.nameKey == ClearCropKey);
         if (ClearCrop != null)
         {
             purchasables1.Remove(ClearCrop);
             purchasables1.Add(ClearCrop);
         }
         purchasables1.Add(Demolish);
         purchasables = purchasables1.ToArray();
     });
 }
Esempio n. 13
0
 static T GiveNoneIfModded <T>(T a)
 {
     return(ModdedIDRegistry.IsModdedID(a) ? (T)(object)0 : a);
 }
Esempio n. 14
0
 static T GiveBackIfModded <T>(T a)
 {
     return(ModdedIDRegistry.IsModdedID(a) ? a : (T)(object)0);
 }
Esempio n. 15
0
 static GadgetRegistry()
 {
     ModdedIDRegistry.RegisterIDRegistry(moddedGadgets);
 }
Esempio n. 16
0
 static IdentifiableRegistry()
 {
     ModdedIDRegistry.RegisterIDRegistry(moddedIdentifiables);
 }
Esempio n. 17
0
 static PediaRegistry()
 {
     ModdedIDRegistry.RegisterIDRegistry(moddedIds);
 }
Esempio n. 18
0
 static PersonalUpgradeRegistry()
 {
     ModdedIDRegistry.RegisterIDRegistry(moddedUpgrades);
 }
Esempio n. 19
0
 public void Pull(PediaDataBuffer data, SRMod ourMod)
 {
     unlockedIds.AddRange(data.unlockedIds.Where((x) => ModdedIDRegistry.ModForID(x) == ourMod).Select((x) => Enum.GetName(typeof(PediaDirector.Id), x)));
     completedTuts.AddRange(data.completedTuts.Where((x) => ModdedIDRegistry.ModForID(x) == ourMod).Select((x) => Enum.GetName(typeof(TutorialDirector.Id), x)));
     popupQueue.AddRange(data.popupQueue.Where((x) => ModdedIDRegistry.ModForID(x) == ourMod).Select((x) => Enum.GetName(typeof(TutorialDirector.Id), x)));
 }
Esempio n. 20
0
        public static void Prefix(GameV12 __instance, ref RemovalData __state)
        {
            __state = new RemovalData();

            __state.AddAndRemoveWhereCustom(__instance.actors);
            __state.AddAndRemoveWhere(__instance.world.placedGadgets, (x) => SaveRegistry.IsCustom(x.Value) || ModdedStringRegistry.IsModdedString(x.Key));
            __state.AddAndRemoveWhere(__instance.ranch.plots, (x) => SaveRegistry.IsCustom(x) || ModdedStringRegistry.IsModdedString(x.id));
            __state.AddAndRemoveWhere(__instance.world.gordos, x => SaveRegistry.IsCustom(x.Value) || ModdedStringRegistry.IsModdedString(x.Key));
            __state.AddAndRemoveWhere(__instance.world.treasurePods, x => SaveRegistry.IsCustom(x.Value) || ModdedStringRegistry.IsModdedString(x.Key));
            __state.AddAndRemoveWhere(__instance.world.offers, x => SaveRegistry.IsCustom(x.Value) || ModdedIDRegistry.IsModdedID(x.Key) || ExchangeOfferRegistry.IsCustom(x.Value));
            __state.AddAndRemoveWhere(__instance.world.econSaturations, (x) => ModdedIDRegistry.IsModdedID(x.Key));
            __state.AddAndRemoveWhere(__instance.world.lastOfferRancherIds, ExchangeOfferRegistry.IsCustom);
            __state.AddAndRemoveWhere(__instance.world.pendingOfferRancherIds, ExchangeOfferRegistry.IsCustom);

            __state.AddAndRemoveWhereCustom(__instance.player.upgrades);
            __state.AddAndRemoveWhereCustom(__instance.player.availUpgrades);
            __state.AddAndRemoveWhere(__instance.player.upgradeLocks,
                                      (x) => ModdedIDRegistry.IsModdedID(x.Key));

            __state.AddAndRemoveWhereCustom(__instance.player.blueprints);
            __state.AddAndRemoveWhereCustom(__instance.player.availBlueprints);
            __state.AddAndRemoveWhere(__instance.player.blueprintLocks, (x) => ModdedIDRegistry.IsModdedID(x.Key));

            __state.AddAndRemoveWhere(__instance.player.progress, (x) => ModdedIDRegistry.IsModdedID(x.Key));
            __state.AddAndRemoveWhere(__instance.player.delayedProgress, (x) => ModdedIDRegistry.IsModdedID(x.Key));

            __state.AddAndRemoveWhere(__instance.player.gadgets, (x) => ModdedIDRegistry.IsModdedID(x.Key));

            __state.AddAndRemoveWhere(__instance.player.craftMatCounts, (x) => ModdedIDRegistry.IsModdedID(x.Key));

            __state.AddAndRemoveWhereCustom(__instance.player.unlockedZoneMaps);

            __state.AddAndRemoveWhere(__instance.player.mail, (x) => MailRegistry.GetModForMail(x.messageKey) != null);

            __state.AddAndRemoveWhere(__instance.pedia.unlockedIds, (x) => ModdedIDRegistry.IsModdedID(Enum.Parse(typeof(PediaDirector.Id), x)));
            __state.AddAndRemoveWhere(__instance.pedia.completedTuts, (x) => ModdedIDRegistry.IsModdedID(Enum.Parse(typeof(TutorialDirector.Id), x)));
            __state.AddAndRemoveWhere(__instance.pedia.popupQueue, (x) => ModdedIDRegistry.IsModdedID(Enum.Parse(typeof(TutorialDirector.Id), x)));



            foreach (var data in AmmoDataUtils.GetAllAmmoData(__instance))
            {
                if (AmmoIdentifier.TryGetIdentifier(data, __instance, out var id) && AmmoIdentifier.IsModdedIdentifier(id))
                {
                    __state.addBacks.Add(AmmoDataUtils.RemoveAmmoDataWithAddBack(data, __instance));
                }
                else
                {
                    var moddedData = AmmoDataUtils.RipOutModdedData(data);

                    __state.addBacks.Add(() =>
                    {
                        AmmoDataUtils.SpliceAmmoData(data, moddedData);
                    });
                }
            }

            void RemovePartial(object actor, RemovalData data)
            {
                if (CustomChecker.GetCustomLevel(actor) == CustomChecker.CustomLevel.PARTIAL)
                {
                    var partial = PartialData.GetPartialData(actor.GetType(), true);
                    partial.Pull(actor);
                    data.addBacks.Add(() =>
                    {
                        partial.Push(actor);
                    });
                }
            }

            foreach (var actor in __instance.actors)
            {
                RemovePartial(actor, __state);
            }

            foreach (var actor in __instance.ranch.plots)
            {
                RemovePartial(actor, __state);
            }

            foreach (var actor in __instance.world.placedGadgets)
            {
                RemovePartial(actor.Value, __state);
            }

            foreach (var actor in __instance.world.gordos)
            {
                RemovePartial(actor.Value, __state);
            }

            foreach (var actor in __instance.world.treasurePods)
            {
                RemovePartial(actor.Value, __state);
            }

            foreach (var offer in __instance.world.offers)
            {
                RemovePartial(offer.Value, __state);
            }

            var partialAppearance = new PartialAppearancesData();

            partialAppearance.Pull(__instance.appearances);
            __state.addBacks.Add(() => partialAppearance.Push(__instance.appearances));
        }
Esempio n. 21
0
 public static List <VanillaAmmoData> RipOutModdedData(List <VanillaAmmoData> original)
 {
     return(RipOutWhere(original, (x) => ModdedIDRegistry.IsModdedID(x.id)));
 }
Esempio n. 22
0
 static ChromaRegistry()
 {
     ModdedIDRegistry.RegisterIDRegistry(moddedPalettes);
     ModdedIDRegistry.RegisterIDRegistry(moddedPaletteTypes);
 }
 static SpawnResourceRegistry()
 {
     ModdedIDRegistry.RegisterIDRegistry(moddedSpawnResources);
     EnumPatcher.RegisterAlternate(typeof(SpawnResource.Id), (obj, name) => CreateSpawnResourceId(obj, name));
 }
Esempio n. 24
0
 public void Push(PediaV03 data)
 {
     data.unlockedIds.AddRange(unlockedIds.Where((x) => Enum.IsDefined(typeof(PediaDirector.Id), x) && ModdedIDRegistry.IsValidID(Enum.Parse(typeof(PediaDirector.Id), x))));
     data.completedTuts.AddRange(completedTuts.Where((x) => Enum.IsDefined(typeof(TutorialDirector.Id), x) && ModdedIDRegistry.IsValidID(Enum.Parse(typeof(TutorialDirector.Id), x))));
     data.popupQueue.AddRange(popupQueue.Where((x) => Enum.IsDefined(typeof(TutorialDirector.Id), x) && ModdedIDRegistry.IsValidID(Enum.Parse(typeof(TutorialDirector.Id), x))));
 }
Esempio n. 25
0
 public static bool HasCustomData(List <VanillaAmmoData> ammo)
 {
     return(ammo.Any((x) => ModdedIDRegistry.IsModdedID(x.id)));
 }
Esempio n. 26
0
 static LandPlotUpgradeRegistry()
 {
     ModdedIDRegistry.RegisterIDRegistry(moddedUpgrades);
     EnumPatcher.RegisterAlternate(typeof(LandPlot.Upgrade), (obj, name) => CreateLandPlotUpgrade(obj, name));
 }
Esempio n. 27
0
 static LandPlotRegistry()
 {
     ModdedIDRegistry.RegisterIDRegistry(landplots);
 }