示例#1
0
 public static int[] XYMax(
     this PartialData src)
 => new int[]
 {
     src.Select(x => x.X).Max(),
     src.Select(x => x.Y).Max()
 };
 public PartialOutput(PartialData data)
 {
     _type          = data.Type;
     _directoryName = data.DirectoryName;
     _jsonFileName  = data.JsonFileName;
     _jsonTagKey    = data.JsonTagKey;
 }
示例#3
0
 static PartialAppearancesData()
 {
     PartialData.RegisterPartialData <AppearancesV01>(typeof(PartialAppearancesData));
     EnumTranslator.RegisterEnumFixer <PartialAppearancesData>((x, y, z) =>
     {
         EnumTranslator.FixEnumValues(x, y, z.unlocksCustom);
         EnumTranslator.FixEnumValues(x, y, z.unlocksPartial);
         EnumTranslator.FixEnumValues(x, y, z.selections);
     });
 }
        static PartialLandPlotData()
        {
            EnumTranslator.RegisterEnumFixer <PartialLandPlotData>((translator, mode, data) =>
            {
                translator.FixEnumValues(mode, data.upgrades);
                while (data.upgrades.InternalList.Contains(global::LandPlot.Upgrade.NONE))
                {
                    data.upgrades.InternalList.Remove(global::LandPlot.Upgrade.NONE);
                }
                data.attachedId = translator.TranslateEnum(mode, data.attachedId);
            });

            PartialData.RegisterPartialData(() => new PartialLandPlotData());
        }
示例#5
0
 public PartialSession(PartialData data)
 {
     Id                        = data.Id;
     _chatId                   = data.ChatId;
     _name                     = data.Name;
     _batchCount               = data.BatchCount;
     _dataSource               = new PartialSource(data.DataSource);
     _isRandomOrder            = data.IsRandomOrder;
     _dataOutput               = new PartialOutput(data.DataOutput);
     _options                  = data.Options;
     _canAddOptions            = data.CanAddOptions;
     _autoOrderOptions         = data.AutoOrderOptions;
     _canSelectMultipleOptions = data.CanSelectMultipleOptions;
 }
示例#6
0
 public static byte[,] UpdateWith(
     this byte[,] src, PartialData datas)
 {
     foreach (var data in datas)
     {
         if (data.Y >= 0 &&
             data.Y < src.GetLength(0) &&
             data.X >= 0 &&
             data.X < src.GetLength(1))
         {
             src[data.Y, data.X] = data.Data;
         }
     }
     return(src);
 }
示例#7
0
        static PartialGordoData()
        {
            EnumTranslator.RegisterEnumFixer <PartialGordoData>((translator, mode, data) =>
            {
                translator.FixEnumValues(mode, data.fashions);
            });

            CustomChecker.RegisterCustomChecker <GordoV01>((x) =>
            {
                if (x.fashions.Any(ModdedIDRegistry.IsModdedID))
                {
                    return(CustomChecker.CustomLevel.PARTIAL);
                }
                return(CustomChecker.CustomLevel.NONE);
            });
            PartialData.RegisterPartialData(() => new PartialGordoData());
        }
        static PartialTreasurePodData()
        {
            CustomChecker.RegisterCustomChecker <TreasurePodV01>(x =>
            {
                if (x.spawnQueue.Any(ModdedIDRegistry.IsModdedID))
                {
                    return(CustomChecker.CustomLevel.PARTIAL);
                }
                return(CustomChecker.CustomLevel.NONE);
            });

            EnumTranslator.RegisterEnumFixer <PartialTreasurePodData>((translator, mode, data) =>
            {
                translator.FixEnumValues(mode, data.spawnQueue);
            });

            PartialData.RegisterPartialData(() => new PartialTreasurePodData());
        }
示例#9
0
 public PartialSource(PartialData data)
 {
     Type           = data.Type;
     _directoryName = data.DirectoryName;
 }
示例#10
0
 private void LoadPartialPawnData([NotNull] PartialData <PawnKindItem> data)
 {
     Data.LoadPawnPartial(data.Data);
     _pawnWorker.NotifyGlobalDataChanged();
 }
示例#11
0
 private void LoadPartialTraitData([NotNull] PartialData <TraitItem> data)
 {
     Data.ProcessTraitPartial(data.Data);
     _traitWorker.NotifyGlobalDataChanged();
 }
示例#12
0
 private void LoadPartialEventData([NotNull] PartialData <EventPartial> data)
 {
     Data.LoadEventPartial(data.Data);
     _eventWorker.NotifyGlobalDataChanged();
 }
示例#13
0
 private void LoadPartialItemData([NotNull] PartialData <ItemPartial> data)
 {
     Data.LoadItemPartial(data.Data);
     _itemWorker.NotifyGlobalDataChanged();
 }
示例#14
0
        private static void PullPartialData(ModdedSaveData data, Game game)
        {
            void Check <T>(T v, Action
                           <T, PartialData> onSuccess)
            {
                var level = CustomChecker.GetCustomLevel(v);

                if (level == CustomChecker.CustomLevel.PARTIAL)
                {
                    var partialdata = PartialData.GetPartialData(v.GetType(), true);
                    partialdata.Pull(v);

                    onSuccess(v, partialdata);
                }
            }

            foreach (var g in game.actors)
            {
                Check(g, (v, partialdata) =>
                      data.partialData.Add(new DataIdentifier()
                {
                    longID = v.actorId, Type = IdentifierType.ACTOR
                }, partialdata));
            }

            foreach (var g in game.world.placedGadgets)
            {
                var currentString = g.Key;
                Check(g.Value, (v, partialdata) =>
                {
                    data.partialData.Add(new DataIdentifier()
                    {
                        stringID = currentString, Type = IdentifierType.GADGET
                    },
                                         partialdata);
                });
            }

            foreach (var g in game.ranch.plots)
            {
                var currentString = g.id;
                Check(g, (v, partialdata) =>
                      data.partialData.Add(new DataIdentifier()
                {
                    stringID = currentString, Type = IdentifierType.LANDPLOT
                }, partialdata));
            }

            foreach (var g in game.world.gordos)
            {
                Check(g.Value, (v, partialData) => data.partialData.Add(new DataIdentifier()
                {
                    Type = IdentifierType.GORDO, stringID = g.Key
                }, partialData));
            }

            foreach (var t in game.world.treasurePods)
            {
                Check(t.Value, (v, partialData) => data.partialData.Add(new DataIdentifier()
                {
                    Type = IdentifierType.TREASUREPOD, stringID = t.Key
                }, partialData));
            }

            foreach (var t in game.world.offers)
            {
                var cur = t.Key;
                Check(t.Value, (v, partialData) => data.partialData.Add(new DataIdentifier()
                {
                    Type = IdentifierType.EXCHANGEOFFER, longID = (int)cur
                }, partialData));
            }

            data.appearancesData.Pull(game.appearances);
        }
示例#15
0
        public void ReadData(BinaryReader reader)
        {
            ammoDataEntries.Clear();

            int count = reader.ReadInt32();

            for (int i = 0; i < count; i++)
            {
                var newEntry = new IdentifiableAmmoData();
                newEntry.Read(reader);

                ammoDataEntries.Add(newEntry);
            }

            segments.Clear();
            count = reader.ReadInt32();
            for (int i = 0; i < count; i++)
            {
                long start = reader.BaseStream.Position;
                var  mod   = new ModDataSegment();
                try
                {
                    mod.Read(reader);
                    segments.Add(mod);
                }
                catch (Exception e)
                {
                    Debug.Log($"Encountered exception {e}\nskipping loading {mod.modid} skipping {mod.byteLength} bytes in the stream");
                    reader.BaseStream.Seek(start + mod.byteLength, SeekOrigin.Begin);
                }
            }

            if (version >= 1)
            {
                enumTranslator = new EnumTranslator();
                enumTranslator.Read(reader);
                if (version >= 2)
                {
                    partialData.Clear();
                    count = reader.ReadInt32();
                    for (int i = 0; i < count; i++)
                    {
                        var id       = DataIdentifier.Read(reader);
                        var dataType = DataIdentifier.IdentifierTypeToData[id.Type];
                        if (PartialData.TryGetPartialData(dataType, out var data))
                        {
                            data.Read(reader);
                            partialData[id] = data;
                        }
                        else
                        {
                            Debug.LogError("No partial data for data identifier type " + id.Type);
                        }
                    }
                    if (version >= 3)
                    {
                        try
                        {
                            appearancesData.Read(reader);
                        }
                        catch (Exception e)
                        {
                            throw;
                        }
                    }
                }
            }
        }
示例#16
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));
        }