private static void RegisterActor_Postfix(long actorId, GameObject gameObj, Dictionary <long, ActorModel> p_actors)
        {
            Identifiable.Id id = Identifiable.GetId(gameObj);
            if (!IdentifiableRegistry.IsIdentifiableRegistered(id))
            {
                return;
            }

            IDRegistry.RegisterActor(actorId);
        }
Пример #2
0
 private static bool IsGuuIdentifiable(Identifiable.Id id) => IdentifiableRegistry.IsIdentifiableRegistered(id);
Пример #3
0
 private static bool IsGuuIdentifiable <V>(KeyValuePair <Identifiable.Id, V> pair) => IdentifiableRegistry.IsIdentifiableRegistered(pair.Key);
Пример #4
0
        //! Patch: SavedGame.Save
        internal static void Save(GameV12 original)
        {
            GuuCore.LOGGER.Log("Attempting to save modded save file");
            gameState = new GameV12();

            //& Strip Summary
            if (IdentifiableRegistry.IsIdentifiableRegistered(original.summary.iconId))
            {
                gameState.summary.iconId = original.summary.iconId;
                original.summary.iconId  = FALLBACK_ICON;
            }

            //# Strip Game Mode

            //& Strip World
            StripByMatch(original.world.lastOfferRancherIds, gameState.world.lastOfferRancherIds, IsGuuID);
            StripByMatch(original.world.pendingOfferRancherIds, gameState.world.pendingOfferRancherIds, IsGuuID);
            //# Strip Weather

            StripByMatch(original.world.offers, gameState.world.offers, pair => IsGuuID(pair.Value.rancherId) || IsGuuID(pair.Value.offerId) || ExchangeRegistry.IsOfferTypeRegistered(pair.Key));
            foreach (ExchangeDirector.OfferType type in original.world.offers.Keys)
            {
                ExchangeOfferV04 ori = original.world.offers[type];
                ExchangeOfferV04 mod = new ExchangeOfferV04();

                StripByMatch(ori.requests, mod.requests, request => IsGuuIdentifiable(request.id) || ExchangeRegistry.IsNonIdenRegistered(request.nonIdentReward));
                StripByMatch(ori.rewards, mod.rewards, reward => IsGuuIdentifiable(reward.id) || ExchangeRegistry.IsNonIdenRegistered(reward.nonIdentReward));

                gameState.world.offers.Add(type, mod);
            }

            StripByMatch(original.world.econSaturations, gameState.world.econSaturations, IsGuuIdentifiable);
            StripByMatch(original.world.teleportNodeActivations, gameState.world.teleportNodeActivations, IsGuuID);
            StripByMatch(original.world.liquidSourceUnits, gameState.world.liquidSourceUnits, IsGuuID);

            StripByMatch(original.world.gordos, gameState.world.gordos, IsGuuID);
            foreach (KeyValuePair <string, GordoV01> gordo in original.world.gordos.Where(pair => pair.Value.fashions.Exists(IsGuuIdentifiable)))
            {
                gameState.world.gordos.Add(gordo.Key, new GordoV01());
                StripByMatch(gordo.Value.fashions, gameState.world.gordos[gordo.Key].fashions, IsGuuIdentifiable);
            }

            StripByMatch(original.world.placedGadgets, gameState.world.placedGadgets, IsGuuID);
            foreach (string id in original.world.placedGadgets.Keys)
            {
                PlacedGadgetV08 ori = original.world.placedGadgets[id];
                PlacedGadgetV08 mod = new PlacedGadgetV08();

                if (IsGuuGadget(ori.gadgetId))
                {
                    mod.gadgetId = ori.gadgetId;
                    ori.gadgetId = Gadget.Id.NONE;
                }

                foreach (AmmoDataV02 ammo in ori.ammo)
                {
                    AmmoDataV02 mAmmo = new AmmoDataV02();

                    if (IsGuuIdentifiable(ammo.id))
                    {
                        mAmmo.id = ammo.id;
                        ammo.id  = Identifiable.Id.NONE;
                    }

                    //# Strip Emotion Data
                }

                if (IsGuuIdentifiable(ori.baitTypeId))
                {
                    mod.baitTypeId = ori.baitTypeId;
                    ori.baitTypeId = Identifiable.Id.NONE;
                }

                if (IsGuuIdentifiable(ori.gordoTypeId))
                {
                    mod.gordoTypeId = ori.gordoTypeId;
                    ori.gordoTypeId = Identifiable.Id.NONE;
                }

                StripByMatch(ori.fashions, mod.fashions, IsGuuIdentifiable);

                if (ori.drone != null)
                {
                    mod.drone = new DroneGadgetV01
                    {
                        drone = new DroneV05()
                    };

                    AmmoDataV02 ammo  = ori.drone.drone.ammo;
                    AmmoDataV02 mAmmo = mod.drone.drone.ammo;

                    if (IsGuuIdentifiable(ammo.id))
                    {
                        mAmmo.id = ammo.id;
                        ammo.id  = Identifiable.Id.NONE;
                    }

                    //# Strip Emotion Data

                    StripByMatch(ori.drone.drone.fashions, mod.drone.drone.fashions, IsGuuIdentifiable);
                }

                gameState.world.placedGadgets.Add(id, mod);
            }

            StripByMatch(original.world.treasurePods, gameState.world.treasurePods, IsGuuID);
            foreach (KeyValuePair <string, TreasurePodV01> pod in original.world.treasurePods.Where(pair => pair.Value.spawnQueue.Exists(IsGuuIdentifiable)))
            {
                gameState.world.treasurePods.Add(pod.Key, new TreasurePodV01());
                StripByMatch(pod.Value.spawnQueue, gameState.world.treasurePods[pod.Key].spawnQueue, IsGuuIdentifiable);
            }

            StripByMatch(original.world.switches, gameState.world.switches, IsGuuID);
            StripByMatch(original.world.puzzleSlotsFilled, gameState.world.puzzleSlotsFilled, IsGuuID);
            StripByMatch(original.world.occupiedPhaseSites, gameState.world.occupiedPhaseSites, IsGuuID);
            StripByMatch(original.world.quicksilverEnergyGenerators, gameState.world.quicksilverEnergyGenerators, IsGuuID);
            StripByMatch(original.world.oasisStates, gameState.world.oasisStates, IsGuuID);
            StripByMatch(original.world.activeGingerPatches, gameState.world.activeGingerPatches, IsGuuID);
            StripByMatch(original.world.echoNoteGordos, gameState.world.echoNoteGordos, IsGuuID);

            //? Slimeulation
            StripByMatch(original.world.glitch.teleporters, gameState.world.glitch.teleporters, IsGuuID);
            StripByMatch(original.world.glitch.nodes, gameState.world.glitch.nodes, IsGuuID);
            StripByMatch(original.world.glitch.impostoDirectors, gameState.world.glitch.impostoDirectors, IsGuuID);
            StripByMatch(original.world.glitch.impostos, gameState.world.glitch.impostos, IsGuuID);
            StripByMatch(original.world.glitch.slimes, gameState.world.glitch.slimes, IsGuuID);
            StripByMatch(original.world.glitch.storage, gameState.world.glitch.storage, IsGuuID);
            StripByMatch(original.world.glitch.storage, gameState.world.glitch.storage, pair => IsGuuIdentifiable(pair.Value.id));

            //& Strip Player
            //# Strip Game Mode

            if (IsGuuIdentifiable(original.player.gameIconId))
            {
                gameState.player.gameIconId = original.player.gameIconId;
                original.player.gameIconId  = FALLBACK_ICON;
            }

            StripByMatch(original.player.upgrades, gameState.player.upgrades, IsGuuUpgrade);

            StripByMatch(original.player.ammo, gameState.player.ammo, pair => AmmoRegistry.IsAmmoModeRegistered(pair.Key));
            foreach (KeyValuePair <PlayerState.AmmoMode, List <AmmoDataV02> > ammoList in original.player.ammo)
            {
                List <AmmoDataV02> moddedList = new List <AmmoDataV02>();
                foreach (AmmoDataV02 ammo in ammoList.Value)
                {
                    AmmoDataV02 data = new AmmoDataV02();

                    if (IsGuuIdentifiable(ammo.id))
                    {
                        data.id = ammo.id;
                        ammo.id = Identifiable.Id.NONE;
                    }

                    //# Strip Emotions

                    moddedList.Add(data);
                }

                if (moddedList.Count > 0)
                {
                    gameState.player.ammo[ammoList.Key] = moddedList;
                }
            }

            foreach (MailV02 mail in original.player.mail)
            {
                MailV02 mod = new MailV02
                {
                    messageKey = string.Empty,
                    mailType   = MailDirector.Type.UPGRADE
                };

                if (MailRegistry.IsTypeRegistered(mail.mailType))
                {
                    mod.mailType  = mail.mailType;
                    mail.mailType = MailDirector.Type.PERSONAL;
                }

                if (MailRegistry.IsMailRegistered(mail.messageKey))
                {
                    mod.messageKey = mail.messageKey;
                    if (mod.mailType == MailDirector.Type.UPGRADE)
                    {
                        mod.mailType = mail.mailType;
                    }
                    mail.mailType = MailDirector.Type.UPGRADE;
                }

                gameState.player.mail.Add(mod);
            }

            StripByMatch(original.player.availUpgrades, gameState.player.availUpgrades, IsGuuUpgrade);
            StripByMatch(original.player.upgradeLocks, gameState.player.upgradeLocks, IsGuuUpgrade);
            StripByMatch(original.player.progress, gameState.player.progress, pair => ProgressRegistry.IsTypeRegistered(pair.Key));
            StripByMatch(original.player.delayedProgress, gameState.player.delayedProgress, pair => ProgressRegistry.IsTrackerRegistered(pair.Key));
            StripByMatch(original.player.blueprints, gameState.player.blueprints, IsGuuGadget);
            StripByMatch(original.player.availBlueprints, gameState.player.availBlueprints, IsGuuGadget);
            StripByMatch(original.player.blueprintLocks, gameState.player.blueprintLocks, IsGuuGadget);
            StripByMatch(original.player.gadgets, gameState.player.gadgets, IsGuuGadget);
            StripByMatch(original.player.craftMatCounts, gameState.player.craftMatCounts, IsGuuIdentifiable);

            //# Strip Region Set ID && Player Pos
            //# Strip Unlocked Zone

            //? Decorizer
            StripByMatch(original.player.decorizer.contents, gameState.player.decorizer.contents, IsGuuIdentifiable);
            StripByMatch(original.player.decorizer.settings, gameState.player.decorizer.settings, IsGuuID);
            StripByMatch(original.player.decorizer.settings, gameState.player.decorizer.settings, pair => IsGuuIdentifiable(pair.Value.selected));

            //& Strip Ranch
            //# Strip Plots

            StripByMatch(original.ranch.accessDoorStates, gameState.ranch.accessDoorStates, IsGuuID);
            StripByMatch(original.ranch.palettes, gameState.ranch.palettes, pair => ChromaPackRegistry.IsTypeRegistered(pair.Key) || ChromaPackRegistry.IsPaletteRegistered(pair.Value));
            StripByMatch(original.ranch.ranchFastForward, gameState.ranch.ranchFastForward, IsGuuID);

            //& Strip Actors
            StripByMatch(original.actors, gameState.actors, actor => IsGuuID(actor.actorId));
            foreach (ActorDataV09 actor in original.actors)
            {
                ActorDataV09 newActor = new ActorDataV09();
                // ReSharper disable once ReplaceWithSingleAssignment.False
                bool hasData = false;

                //# Strip Emotions

                if (actor.fashions.Exists(IsGuuIdentifiable))
                {
                    hasData = true;
                    StripByMatch(actor.fashions, newActor.fashions, IsGuuIdentifiable);
                }

                //# Strip Region Set && Position

                if (hasData)
                {
                    gameState.actors.Add(newActor);
                }
            }

            //& Strip Pedia
            //# Strip Unlocked IDs
            //# Strip Completed Tuts
            //# Strip Popup Queue

            //& Strip Achievements
            //# Strip Float Stats
            //# Strip Double Stats
            //# Strip Int Stats

            //# Strip ID Stats by Key
            foreach (KeyValuePair <AchievementsDirector.GameIdDictStat, Dictionary <Identifiable.Id, int> > idDictStat in original.achieve.gameIdDictStatDict.Where(pair => pair.Value.Count(pair2 => IsGuuIdentifiable(pair2.Key)) > 0))
            {
                gameState.achieve.gameIdDictStatDict[idDictStat.Key] = new Dictionary <Identifiable.Id, int>();
                StripByMatch(idDictStat.Value, gameState.achieve.gameIdDictStatDict[idDictStat.Key], IsGuuIdentifiable);
            }

            //& Strip Holidays
            StripByMatch(original.holiday.eventGordos, gameState.holiday.eventGordos, IsGuuID);
            StripByMatch(original.holiday.eventEchoNoteGordos, gameState.holiday.eventEchoNoteGordos, IsGuuID);

            //& Strip Appearances
            StripByMatch(original.appearances.unlocks, gameState.appearances.unlocks, IsGuuIdentifiable);
            //# Strip Unlocks based on Appearance Sets

            StripByMatch(original.appearances.selections, gameState.appearances.selections, IsGuuIdentifiable);
            //# Strip Selections based on Appearance Sets

            //& Strip Instruments
            //# Strip Unlocks
            //# Strip Selection

            // TODO: Strip content from the original
        }