Beispiel #1
0
        public override void Process(PDAEntryProgress packet)
        {
            using (packetSender.Suppress <PDAEntryAdd>())
                using (packetSender.Suppress <PDAEntryProgress>())
                {
                    TechType             techType  = packet.TechType.ToUnity();
                    PDAScanner.EntryData entryData = PDAScanner.GetEntryData(techType);

                    PDAScanner.Entry entry;
                    if (PDAScanner.GetPartialEntryByKey(techType, out entry))
                    {
                        if (packet.Unlocked > entry.unlocked)
                        {
                            Log.Info("PDAEntryProgress Upldate Old:" + entry.unlocked + " New" + packet.Unlocked);
                            entry.unlocked = packet.Unlocked;
                        }
                    }
                    else
                    {
                        Log.Info("PDAEntryProgress New TechType:" + techType + " Unlocked:" + packet.Unlocked);
                        MethodInfo methodAdd = typeof(PDAScanner).GetMethod("Add", BindingFlags.NonPublic | BindingFlags.Static, null, new Type[] { typeof(TechType), typeof(int) }, null);
                        entry = (PDAScanner.Entry)methodAdd.Invoke(null, new object[] { techType, packet.Unlocked });
                    }
                }
        }
 public static void Postfix(ref PDAScanner.EntryData __result, TechType key)
 {
     if (__result != null && Settings.Instance.ScannerData.Required.ContainsKey(key))
     {
         __result.totalFragments = Settings.Instance.ScannerData.Required[key];
     }
 }
        public override void Process(PDAEntryAdd packet)
        {
            using (packetSender.Suppress <PDAEntryAdd>())
                using (packetSender.Suppress <PDAEntryProgress>())
                {
                    TechType             techType  = packet.TechType.ToUnity();
                    PDAScanner.EntryData entryData = PDAScanner.GetEntryData(techType);

                    if (!PDAScanner.GetPartialEntryByKey(techType, out PDAScanner.Entry entry))
                    {
                        entry = PDAScanner.Add(techType, packet.Unlocked);
                    }

                    if (entry != null)
                    {
                        entry.unlocked++;

                        if (entry.unlocked >= entryData.totalFragments)
                        {
                            PDAScanner.partial.Remove(entry);
                            PDAScanner.complete.Add(entry.techType);
                        }
                        else
                        {
                            int totalFragments = entryData.totalFragments;
                            if (totalFragments > 1)
                            {
                                float num2 = (float)entry.unlocked / (float)totalFragments;
                                float arg  = (float)Mathf.RoundToInt(num2 * 100f);
                                ErrorMessage.AddError(Language.main.GetFormat <string, float, int, int>("ScannerInstanceScanned", Language.main.Get(entry.techType.AsString(false)), arg, entry.unlocked, totalFragments));
                            }
                        }
                    }
                }
        }
 // Code here is adapted from Kylinator25's Alien Rifle unlock patch https://github.com/kylinator25/SubnauticaMods/blob/master/AlienRifle/PDAScannerUnlockPatch.cs
 public static bool Prefix(PDAScanner.EntryData entryData)
 {
     if (entryData.key == TechType.SpineEel)
     {
         if (!KnownTech.Contains(ReinforcedSuitsCore.ReinforcedStillSuit))
         {
             KnownTech.Add(ReinforcedSuitsCore.ReinforcedStillSuit);
             ErrorMessage.AddMessage("Added blueprint for reinforced still suit to database");
         }
         if (!KnownTech.Contains(ReinforcedSuitsCore.ReinforcedSuit2ID))
         {
             KnownTech.Add(ReinforcedSuitsCore.ReinforcedSuit2ID);
             ErrorMessage.AddMessage("Added blueprint for reinforced dive suit mark 2 to database");
         }
     }
     if (entryData.key == TechType.LavaLizard)
     {
         if (!KnownTech.Contains(ReinforcedSuitsCore.ReinforcedSuit3ID))
         {
             KnownTech.Add(ReinforcedSuitsCore.ReinforcedSuit3ID);
             ErrorMessage.AddMessage("Added blueprint for reinforced dive suit mark 3 to database");
         }
     }
     if (entryData.key == TechType.LavaLarva && Main.specialtyTanks)
     {
         if (!KnownTech.Contains(O2TanksCore.ChemosynthesisTankID))
         {
             KnownTech.Add(O2TanksCore.ChemosynthesisTankID);
             ErrorMessage.AddMessage("Added blueprint for chemosynthesis oxygen tank to database");
         }
     }
     return(true);
 }
Beispiel #5
0
        private void PatchTechDataEntry()
        {
            CraftDataHandler.SetTechData(TechType, GetBlueprintRecipe());


            if (GroupForPDA != TechGroup.Uncategorized)
            {
                List <TechCategory> categories = new List <TechCategory>();
                CraftData.GetBuilderCategories(GroupForPDA, categories);
                if (categories.Contains(CategoryForPDA))
                {
                    CraftDataHandler.AddToGroup(GroupForPDA, CategoryForPDA, TechType);
                }
                else
                {
                    Logger.Error($"Failed to add {TechType} to {GroupForPDA}/{CategoryForPDA} as it is not a registered combination.");
                }
            }

            if (EncyclopediaEntryData != null)
            {
                PDAEncyclopediaHandler.AddCustomEntry(EncyclopediaEntryData);
            }

            if (!UnlockedAtStart)
            {
                var unlockTech = RequiredForUnlock == TechType.None? this.TechType: RequiredForUnlock;

                KnownTechHandler.SetAnalysisTechEntry(unlockTech, new TechType[1] {
                    TechType
                }, DiscoverMessageResolved);

                if (CompoundTechsForUnlock != null && CompoundTechsForUnlock.Count > 0)
                {
                    KnownTechHandler.SetCompoundUnlock(this.TechType, CompoundTechsForUnlock);
                }

                if (AddScannerEntry)
                {
                    PDAScanner.EntryData entryData = new PDAScanner.EntryData()
                    {
                        key              = unlockTech,
                        blueprint        = TechType,
                        destroyAfterScan = DestroyFragmentOnScan,
                        isFragment       = true,
                        locked           = true,
                        scanTime         = TimeToScanFragment,
                        totalFragments   = FragmentsToScan
                    };

                    if (EncyclopediaEntryData != null)
                    {
                        entryData.encyclopedia = EncyclopediaEntryData.key;
                    }
                    PDAHandler.AddCustomScannerEntry(entryData);
                }
            }
        }
Beispiel #6
0
        /// <summary>
        /// Adds in a custom <see cref="PDAScanner.EntryData"/>. ***Cannot be used to Change the values of a techtype that has data already!***
        /// </summary>
        /// <param name="entryData">The <see cref="PDAScanner.EntryData"/> of the entry. Must be populated when passed in.</param>
        void IPDAHandler.AddCustomScannerEntry(PDAScanner.EntryData entryData)
        {
            if (PDAPatcher.CustomEntryData.ContainsKey(entryData.key))
            {
                Logger.Log($"{entryData.key} already has custom PDAScanner.EntryData. Replacing with latest.", LogLevel.Debug);
            }

            PDAPatcher.CustomEntryData[entryData.key] = entryData;
        }
        public static void Postfix()
        {
            if (Main.config.Hardcore)
            {
                Dictionary <TechType, PDAScanner.EntryData> map = PDAScanner.mapping;
                foreach (TechType techType in Enum.GetValues(typeof(TechType)))
                {
                    RecipeData data = Main.GetData(techType);
                    map.TryGetValue(techType, out PDAScanner.EntryData entryData);

                    if (data is null && entryData != null && !entryData.isFragment && entryData.blueprint == TechType.None)
                    {
                        entryData.blueprint = techType;
                        entryData.locked    = true;
                        continue;
                    }

                    if (data != null && entryData is null && (data.ingredientCount == 0 || techType == TechType.Titanium))
                    {
                        map[techType] = new PDAScanner.EntryData()
                        {
                            key              = techType,
                            blueprint        = techType,
                            destroyAfterScan = false,
                            isFragment       = false,
                            locked           = true,
                            scanTime         = 2f,
                            totalFragments   = 1
                        };
                        continue;
                    }

                    if (data != null && entryData != null && !entryData.isFragment && entryData.blueprint == TechType.None && (data.ingredientCount == 0 || techType == TechType.Titanium))
                    {
                        entryData.blueprint = techType;
                        entryData.locked    = true;
                        continue;
                    }

                    if (data is null && entryData is null)
                    {
                        map[techType] = new PDAScanner.EntryData()
                        {
                            key              = techType,
                            blueprint        = techType,
                            destroyAfterScan = false,
                            isFragment       = false,
                            locked           = true,
                            scanTime         = 2f,
                            totalFragments   = 1
                        };
                        continue;
                    }
                }
            }
        }
Beispiel #8
0
        public static bool Prefix(TechType techType, bool verbose)
        {
            if (Main.config.Hardcore)
            {
                PDAScanner.EntryData entryData = PDAScanner.GetEntryData(techType);
                return(!verbose || entryData == null || (entryData != null && PDAScanner.ContainsCompleteEntry(techType)));
            }

            return(true);
        }
Beispiel #9
0
 public static bool Prefix(PDAScanner.EntryData entryData)
 {
     if (entryData.key == TechType.PrecursorPrisonArtifact8)
     {
         if (!KnownTech.Contains(SwordPrefab.TechTypeID))
         {
             KnownTech.Add(SwordPrefab.TechTypeID);
             ErrorMessage.AddMessage("Added blueprint for Ancient Sword fabrication to database");
         }
     }
     return(true);
 }
Beispiel #10
0
 public static bool Prefix(PDAScanner.EntryData entryData)
 {
     if (entryData.key == TechType.PrecursorPrisonArtifact7)
     {
         if (!KnownTech.Contains(Main.techTypeID))
         {
             KnownTech.Add(Main.techTypeID);
             ErrorMessage.AddMessage("P.R.A.W.N Plasma Cannon Arm blueprint discovered!");
         }
     }
     return(true);
 }
Beispiel #11
0
 public static bool Prefix(PDAScanner.EntryData entryData)
 {
     if (entryData.key == TechType.LavaLizard)
     {
         if (!KnownTech.Contains(ObsidianKnifeID))
         {
             KnownTech.Add(ObsidianKnifeID);
             ErrorMessage.AddMessage("Added blueprint for Obsidian Knife fabrication to database");
         }
     }
     return(true);
 }
Beispiel #12
0
 public static bool Prefix(PDAScanner.EntryData entryData)
 {
     if (entryData.key == TechType.PrecursorPrisonArtifact7)
     {
         if (!KnownTech.Contains(Main.techTypeID))
         {
             KnownTech.Add(Main.techTypeID);
             ErrorMessage.AddMessage(CannonConfig.language_settings["Item_Unlock_Message"]);
         }
     }
     return(true);
 }
        public static void Postfix(ref StringBuilder sb, TechType techType)
        {
            PDAScanner.EntryData entryData = PDAScanner.GetEntryData(techType);
            if (entryData == null || PDAScanner.ContainsCompleteEntry(techType) || CrafterLogic.IsCraftRecipeUnlocked(techType))
            {
                return;
            }

            sb.Clear();
            TooltipFactory.WriteTitle(sb, Main.config.UnKnownTitle);
            TooltipFactory.WriteDescription(sb, Main.config.UnKnownDescription);
        }
 public static bool Prefix(PDAScanner.EntryData entryData)
 {
     if (entryData.key == TechType.PrecursorPrisonArtifact7)
     {
         if (!KnownTech.Contains(AlienRifleMod.ARtech))
         {
             KnownTech.Add(AlienRifleMod.ARtech);
             ErrorMessage.AddMessage("Added blueprint for rifle fabrication to database");
         }
     }
     return(true);
 }
Beispiel #15
0
 // Code here is adapted from Kylinator25's Alien Rifle unlock patch https://github.com/kylinator25/SubnauticaMods/blob/master/AlienRifle/PDAScannerUnlockPatch.cs
 public static bool Prefix(PDAScanner.EntryData entryData)
 {
     if (entryData.key == TechType.Warper)
     {
         if (!KnownTech.Contains(SeraphimBatteryCore.KhaBattID))
         {
             KnownTech.Add(SeraphimBatteryCore.KhaBattID);
             KnownTech.Add(SeraphimBatteryCore.KhaPowCelID);
             ErrorMessage.AddMessage("Added blueprint for biochemical batteries to database");
         }
     }
     return(true);
 }
 public static void Prefix(PDAScanner.EntryData entryData)
 {
     if (entryData.key == TechType.PrecursorPrisonIonGenerator)
     {
         if (!KnownTech.Contains(CubeGeneratorBuildable.TechTypeID))
         {
             KnownTech.Add(AlienEletronicsCase.TechTypeID);
             KnownTech.Add(AlienIngot.TechTypeID);
             KnownTech.Add(CubeGeneratorBuildable.TechTypeID);
             ErrorMessage.AddMessage(CubeGeneratorBuildable.BlueprintUnlockedMsg());
         }
     }
 }
Beispiel #17
0
        public static void Prefix(PDAData data)
        {
            List <TechType> types = new List <TechType>(data.defaultTech);

            foreach (TechType techType in types)
            {
                PDAScanner.EntryData entryData = PDAScanner.GetEntryData(techType);
                if (entryData != null && entryData.locked)
                {
                    data.defaultTech.Remove(techType);
                }
            }
        }
Beispiel #18
0
        public static void Postfix()
        {
            if (PDAScanner.ContainsCompleteEntry(techType) || KnownTech.Contains(techType))
            {
                if (techType == TechType.ScrapMetal && !KnownTech.Contains(TechType.Titanium))
                {
                    PDAScanner.AddByUnlockable(TechType.Titanium, 1);
                    KnownTech.Add(TechType.Titanium);
                }

                if (!KnownTech.Contains(techType))
                {
                    KnownTech.Add(techType);
                }

                PDAScanner.EntryData entryData = PDAScanner.GetEntryData(techType);

                if (entryData != null && entryData.locked)
                {
                    PDAScanner.Unlock(entryData, true, true, true);

                    if (!KnownTech.Contains(entryData.blueprint))
                    {
                        KnownTech.Add(entryData.blueprint);
                    }
                }
#if SN1
                TechType techType2 = CraftData.GetHarvestOutputData(techType);
#elif BZ
                TechType techType2 = TechData.GetHarvestOutput(techType);
#endif
                if (techType2 != TechType.None)
                {
                    if (!KnownTech.Contains(techType2))
                    {
                        KnownTech.Add(techType2);
                    }

                    PDAScanner.EntryData entryData2 = PDAScanner.GetEntryData(techType2);
                    if (entryData2 != null && entryData2.locked)
                    {
                        PDAScanner.Unlock(entryData, true, true, true);

                        if (!KnownTech.Contains(entryData2.blueprint))
                        {
                            KnownTech.Add(entryData2.blueprint);
                        }
                    }
                }
            }
        }
Beispiel #19
0
        // Code here is adapted from Kylinator25's Alien Rifle unlock patch https://github.com/kylinator25/SubnauticaMods/blob/master/AlienRifle/PDAScannerUnlockPatch.cs
        public static bool Prefix(PDAScanner.EntryData entryData)
        {
            if (entryData.key == TechType.SpineEel) // River prowler
            {
                if (!KnownTech.Contains(ReinforcedSuitsCore.ReinforcedStillSuit))
                {
                    KnownTech.Add(ReinforcedSuitsCore.ReinforcedStillSuit, true);
                    DeathRun.saveData.playerSave.setCue("ReinforcedStillSuit", 10);
                    //ErrorMessage.AddMessage("Added blueprint for reinforced still suit to database");
                }
                if (!KnownTech.Contains(ReinforcedSuitsCore.ReinforcedSuit2ID))
                {
                    DeathRun.saveData.playerSave.setCue("ReinforcedSuit2", 5);
                    KnownTech.Add(ReinforcedSuitsCore.ReinforcedSuit2ID, true);
                    //ErrorMessage.AddMessage("Added blueprint for reinforced dive suit mark 2 to database");
                }
            }
            if (entryData.key == TechType.LavaLizard)
            {
                if (!KnownTech.Contains(ReinforcedSuitsCore.ReinforcedSuit3ID))
                {
                    DeathRun.saveData.playerSave.setCue("ReinforcedSuit3", 5);
                    KnownTech.Add(ReinforcedSuitsCore.ReinforcedSuit3ID, true);
                    //ErrorMessage.AddMessage("Added blueprint for reinforced dive suit mark 3 to database");
                }
            }
            if (entryData.key == TechType.LavaLarva && DeathRun.config.enableSpecialtyTanks)
            {
                if (!KnownTech.Contains(O2TanksCore.ChemosynthesisTankID))
                {
                    DeathRun.saveData.playerSave.setCue("ChemosynthesisTank", 5);
                    KnownTech.Add(O2TanksCore.ChemosynthesisTankID, true);
                    //ErrorMessage.AddMessage("Added blueprint for chemosynthesis oxygen tank to database");
                }
            }

            if ((entryData.key == TechType.CaveSkeleton) || (entryData.key == TechType.GhostRayBlue) || (entryData.key == TechType.GhostRayRed))
            {
                if (!KnownTech.Contains(DeathRun.decoModule.TechType))
                {
                    DeathRun.saveData.playerSave.setCue("DecoModule", 5);
                    //PDAEncyclopedia.Add("DecoModule", true);
                    KnownTech.Add(DeathRun.decoModule.TechType, true);
                }
            }
            return(true);
        }
        public static void Postfix()
        {
            PDAScanner.ScanTarget scanTarget = PDAScanner.scanTarget;
            PDAScanner.EntryData  entryData  = PDAScanner.GetEntryData(scanTarget.techType);
            TechType key       = entryData?.key ?? TechType.None;
            TechType blueprint = entryData?.blueprint ?? TechType.None;

            if (scanTarget.techType != TechType.None && CrafterLogic.IsCraftRecipeUnlocked(scanTarget.techType) || (entryData != null && ((blueprint != TechType.None && CrafterLogic.IsCraftRecipeUnlocked(entryData.blueprint)) || (key != TechType.None && CrafterLogic.IsCraftRecipeUnlocked(entryData.key)))) || !scanTarget.isValid || !GameModeUtils.RequiresBlueprints())
            {
                return;
            }
#if SN1
            HandReticle.main.SetInteractText(Main.config.UnKnownLabel, false, HandReticle.Hand.None);
#elif BZ
            HandReticle.main.SetText(HandReticle.TextType.Hand, Main.config.UnKnownLabel, true, GameInput.Button.None);
#endif
        }
Beispiel #21
0
        public static void Callback()
        {
            // When a player scans a fragment, it will be deleted from the world. We want to send out a pickup event
            // before the object can be removed and corresponding scan data is invalidated.
            TechType techType = PDAScanner.scanTarget.techType;

            PDAScanner.EntryData entryData = PDAScanner.GetEntryData(techType);

            // Only do this for fragments and player scans or nearby fish
            if (entryData != null && entryData.destroyAfterScan && PDAScanner.scanTarget.gameObject && !PDAScanner.scanTarget.isPlayer)
            {
                // A lot of fragments are virtual entities (spawned by placeholders in the world).  Sometimes the server only knows the id
                // of the placeholder and not the virtual entity. TODO: we will need to propagate deterministic ids to children entities for
                // these virtual entities.
                NitroxServiceLocator.LocateService <Item>().PickedUp(PDAScanner.scanTarget.gameObject, techType);
            }
        }
Beispiel #22
0
        public static void Postfix(Pickupable pickupable)
        {
            if (newgame && Main.config.Hardcore && !Utils.GetContinueMode() && pickupable.GetTechType() != TechType.FireExtinguisher)
            {
                CoroutineHost.StartCoroutine(GiveHardcoreScanner());
                newgame = false;
                SMLHelper.V2.Handlers.IngameMenuHandler.RegisterOnQuitEvent(() => newgame = true);
            }

            TechType techType = pickupable.GetTechType();

            PDAScanner.EntryData entryData  = PDAScanner.GetEntryData(techType);
            GameObject           gameObject = pickupable.gameObject;

            if (Main.config.ScanOnPickup && Inventory.main.container.Contains(TechType.Scanner) && entryData != null)
            {
                if (!PDAScanner.GetPartialEntryByKey(techType, out PDAScanner.Entry entry))
                {
                    entry = PDAScanner.Add(techType, 1);
                }
                if (entry != null)
                {
                    PDAScanner.partial.Remove(entry);
                    PDAScanner.complete.Add(entry.techType);
                    PDAScanner.NotifyRemove(entry);
                    PDAScanner.Unlock(entryData, true, true, true);
                    KnownTech.Add(techType, false);
                    if (gameObject != null)
                    {
                        gameObject.SendMessage("OnScanned", null, SendMessageOptions.DontRequireReceiver);
                    }
#if SN1
                    ResourceTracker.UpdateFragments();
#endif
                }
            }

            if (!Main.config.Hardcore && entryData == null)
            {
                KnownTech.Add(techType, true);
            }
        }
Beispiel #23
0
        public static bool Prefix(ref PDAScanner.EntryData entryData, ref bool unlockBlueprint)
        {
            if (entryData.key == TechType.PrecursorPrisonArtifact7)
            {
                unlockBlueprint     = true;
                entryData.blueprint = MainPatch.rifleTech;

                string key = "EncyDesc_PrecursorPrisonArtifact7";

                string oldEncy = Language.main.Get(key);

                if (Language.main.currentLanguage == "English")
                {
                    Language.main.strings[key] = oldEncy +
                                                 "\n\nDespite this, it was possible to synthesise a blueprint for the rifle, but it will require a Stasis Rifle to use as a base.";
                }
            }

            return(true);
        }
        public static void Postfix(ScannerTool __instance)
        {
            PDAScanner.ScanTarget scanTarget = PDAScanner.scanTarget;
#if SN1
            PDAScanner.Result result = PDAScanner.CanScan();
#elif BZ
            PDAScanner.Result result = PDAScanner.CanScan(scanTarget);
#endif
            PDAScanner.EntryData entryData = PDAScanner.GetEntryData(PDAScanner.scanTarget.techType);

            if ((entryData != null && (CrafterLogic.IsCraftRecipeUnlocked(entryData.blueprint) || CrafterLogic.IsCraftRecipeUnlocked(entryData.key))) || PDAScanner.ContainsCompleteEntry(scanTarget.techType) || __instance.energyMixin.charge <= 0f || !scanTarget.isValid || result != PDAScanner.Result.Scan || !GameModeUtils.RequiresBlueprints())
            {
                return;
            }
#if SN1
            HandReticle.main.SetInteractText(Main.config.UnKnownLabel, false, HandReticle.Hand.None);
#elif BZ
            HandReticle.main.SetText(HandReticle.TextType.Hand, Main.config.UnKnownLabel, true, GameInput.Button.None);
#endif
        }
Beispiel #25
0
        public override void Process(PDAEntryAdd packet)
        {
            using (packetSender.Suppress <PDAEntryAdd>())
                using (packetSender.Suppress <PDAEntryProgress>())
                {
                    TechType             techType  = packet.TechType.Enum();
                    PDAScanner.EntryData entryData = PDAScanner.GetEntryData(techType);

                    PDAScanner.Entry entry;
                    if (!PDAScanner.GetPartialEntryByKey(techType, out entry))
                    {
                        MethodInfo methodAdd = typeof(PDAScanner).GetMethod("Add", BindingFlags.NonPublic | BindingFlags.Static, null, new Type[] { typeof(TechType), typeof(int) }, null);
                        entry = (PDAScanner.Entry)methodAdd.Invoke(null, new object[] { techType, packet.Unlocked });
                    }

                    if (entry != null)
                    {
                        entry.unlocked++;

                        if (entry.unlocked >= entryData.totalFragments)
                        {
                            List <PDAScanner.Entry> partial  = (List <PDAScanner.Entry>)(typeof(PDAScanner).GetField("partial", BindingFlags.NonPublic | BindingFlags.Static).GetValue(null));
                            HashSet <TechType>      complete = (HashSet <TechType>)(typeof(PDAScanner).GetField("complete", BindingFlags.NonPublic | BindingFlags.Static).GetValue(null));
                            partial.Remove(entry);
                            complete.Add(entry.techType);
                        }
                        else
                        {
                            int totalFragments = entryData.totalFragments;
                            if (totalFragments > 1)
                            {
                                float num2 = (float)entry.unlocked / (float)totalFragments;
                                float arg  = (float)Mathf.RoundToInt(num2 * 100f);
                                ErrorMessage.AddError(Language.main.GetFormat <string, float, int, int>("ScannerInstanceScanned", Language.main.Get(entry.techType.AsString(false)), arg, entry.unlocked, totalFragments));
                            }
                        }
                    }
                }
        }
Beispiel #26
0
 /// <summary>
 /// Adds in a custom <see cref="PDAScanner.EntryData"/>.
 /// </summary>
 /// <param name="entryData">The <see cref="PDAScanner.EntryData"/> of the entry. Must be populated when passed in.</param>
 public static void AddCustomScannerEntry(PDAScanner.EntryData entryData)
 {
     Main.AddCustomScannerEntry(entryData);
 }
Beispiel #27
0
 /// <summary>
 /// Adds in a custom <see cref="PDAScanner.EntryData"/>.
 /// </summary>
 /// <param name="entryData">The <see cref="PDAScanner.EntryData"/> of the entry. Must be populated when passed in.</param>
 void IPDAHandler.AddCustomScannerEntry(PDAScanner.EntryData entryData)
 {
     PDAPatcher.CustomEntryData[entryData.key] = entryData;
 }
Beispiel #28
0
        public virtual void Patch()
        {
            Atlas.Sprite atlasSprite = null;

            if (IconFilePath != null)
            {
                try
                {
                    atlasSprite = ImageUtils.LoadSpriteFromFile(IconFilePath);
                }
                catch
                {
                    SNLogger.Error(NameID, $"File [{IconFilePath}] not Found!");
                }
            }
            else if (IconTechType != TechType.None)
            {
                try
                {
                    atlasSprite = GetResourceIcon(IconTechType);
                }
                catch
                {
                    SNLogger.Error(NameID, $"Resource TechType icon [{IconTechType.ToString()}] not Found!");
                }
            }
            else
            {
                try
                {
                    atlasSprite = GetResourceIcon(PrefabTemplate);
                }
                catch
                {
                    SNLogger.Error(NameID, $"Resource template icon [{PrefabTemplate.ToString()}] not Found!");
                }
            }

            TechType = TechTypeHandler.Main.AddTechType(NameID, FriendlyName, Description, atlasSprite, false);

            PrefabHandler.Main.RegisterPrefab(this);
            CraftDataHandler.Main.SetTechData(TechType, GetRecipe());
            SpriteHandler.Main.RegisterSprite(TechType, atlasSprite);
            CraftDataHandler.Main.SetItemSize(TechType, ItemSize);
            CraftDataHandler.Main.AddToGroup(GroupForPDA, CategoryForPDA, TechType);
            CraftDataHandler.Main.SetEquipmentType(TechType, TypeForEquipment);
            CraftDataHandler.Main.SetQuickSlotType(TechType, TypeForQuickslot);
            CraftDataHandler.Main.SetBackgroundType(TechType, BackgroundType);

            EncyData encyData = GetEncyclopediaData();

            if (encyData != null)
            {
                isEncyExists = true;

                PDAEncyclopedia.EntryData entryData = new PDAEncyclopedia.EntryData()
                {
                    key      = ClassID,
                    path     = EncyHelper.GetEncyPath(encyData.node),
                    nodes    = EncyHelper.GetEncyNodes(encyData.node),
                    unlocked = false,
                    popup    = GetUnitySprite(atlasSprite),
                    image    = encyData.image,
                    audio    = null,
                };

                PDAEncyclopediaHandler.Main.AddCustomEntry(entryData);

                LanguageHandler.Main.SetLanguageLine($"Ency_{ClassID}", encyData.title);
                LanguageHandler.Main.SetLanguageLine($"EncyDesc_{ClassID}", encyData.description);
            }

            if (RequiredForUnlock == TechType.None && _Fragment != null)
            {
                PDAScanner.EntryData scannerEntryData = new PDAScanner.EntryData()
                {
                    key              = _Fragment.TechType,
                    blueprint        = TechType,
                    destroyAfterScan = _Fragment.DestroyAfterScan,
                    encyclopedia     = isEncyExists ? ClassID : null,
                    isFragment       = true,
                    locked           = false,
                    scanTime         = _Fragment.ScanTime,
                    totalFragments   = _Fragment.TotalFragments
                };

                PDAHandler.Main.AddCustomScannerEntry(scannerEntryData);

                KnownTechHandler.Main.SetAnalysisTechEntry(TechType, new TechType[1] {
                    TechType
                }, GetUnitySprite(_Fragment.UnlockSprite));
            }
            else
            {
                KnownTechHandler.Main.SetAnalysisTechEntry(RequiredForUnlock, new TechType[1] {
                    TechType
                }, $"{FriendlyName} blueprint discovered!");
            }

            if (NewTabNode != null)
            {
                CraftTreeHandler.Main.AddTabNode(NewTabNode.craftTree, NewTabNode.uniqueName, NewTabNode.displayName, NewTabNode.sprite);
            }

            for (int i = 0; i < FabricatorTypes.Length; i++)
            {
                if (FabricatorTabs == null)
                {
                    CraftTreeHandler.Main.AddCraftingNode(FabricatorTypes[i], TechType);
                }
                else
                {
                    CraftTreeHandler.Main.AddCraftingNode(FabricatorTypes[i], TechType, FabricatorTabs[i]);
                }
            }
        }
Beispiel #29
0
        private IEnumerator PatchAsync()
        {
            while (!SpriteManager.hasInitialized)
            {
                yield return(null);
            }

            Sprite sprite = GetItemSprite();

            SpriteHandler.Main.RegisterSprite(TechType, sprite);

            PrefabHandler.Main.RegisterPrefab(this);
            CraftDataHandler.Main.SetTechData(TechType, GetRecipe());
            CraftDataHandler.Main.AddToGroup(GroupForPDA, CategoryForPDA, TechType);

            EncyData encyData = GetEncyclopediaData();

            if (encyData != null)
            {
                isEncyExists = true;

                PDAEncyclopedia.EntryData entryData = new PDAEncyclopedia.EntryData()
                {
                    key      = ClassID,
                    path     = EncyHelper.GetEncyPath(encyData.node),
                    nodes    = EncyHelper.GetEncyNodes(encyData.node),
                    kind     = PDAEncyclopedia.EntryData.Kind.Encyclopedia,
                    unlocked = false,
                    popup    = _Fragment != null ? _Fragment.UnlockSprite : sprite,
                    image    = encyData.image,
                    audio    = null,
                    hidden   = false
                };

                PDAEncyclopediaHandler.Main.AddCustomEntry(entryData);

                LanguageHandler.Main.SetLanguageLine($"Ency_{ClassID}", encyData.title);
                LanguageHandler.Main.SetLanguageLine($"EncyDesc_{ClassID}", encyData.description);
            }

            if (RequiredForUnlock == TechType.None && _Fragment != null)
            {
                PDAScanner.EntryData scannerEntryData = new PDAScanner.EntryData()
                {
                    key              = _Fragment.TechType,
                    blueprint        = TechType,
                    destroyAfterScan = _Fragment.DestroyAfterScan,
                    encyclopedia     = isEncyExists ? ClassID : null,
                    isFragment       = true,
                    locked           = false,
                    scanTime         = _Fragment.ScanTime,
                    totalFragments   = _Fragment.TotalFragments,
                    unlockStoryGoal  = false
                };

                PDAHandler.Main.AddCustomScannerEntry(scannerEntryData);

                KnownTechHandler.Main.SetAnalysisTechEntry(TechType, new TechType[1] {
                    TechType
                }, _Fragment.UnlockSprite);
            }
            else
            {
                KnownTechHandler.Main.SetAnalysisTechEntry(RequiredForUnlock, new TechType[1] {
                    TechType
                }, $"{FriendlyName} blueprint discovered!");
            }

            TabNode NewTabNode = GetTabNodeData();

            if (NewTabNode != null)
            {
                CraftTreeHandler.Main.AddTabNode(NewTabNode.craftTree, NewTabNode.uniqueName, NewTabNode.displayName, NewTabNode.sprite);
            }

            foreach (CraftTreeType craftTreeType in GetCraftTreeTypesData().TreeTypes)
            {
                CraftTreeHandler.Main.AddCraftingNode(craftTreeType.TreeType, TechType, craftTreeType.StepsToTab);
            }

            PostPatch();

            yield break;
        }
        /// <summary>
        /// Call this from the MOD main class to execute the patch.
        /// </summary>
        public virtual void Patch()
        {
            Atlas.Sprite sprite = GetItemSprite();

            TechType = TechTypeHandler.Main.AddTechType(TechTypeName, FriendlyName, Description, sprite, false);

            SetCustomLanguageText();

            PrefabHandler.Main.RegisterPrefab(this);
            CraftDataHandler.Main.SetTechData(TechType, GetRecipe());
            SpriteHandler.Main.RegisterSprite(TechType, sprite);
            CraftDataHandler.Main.SetItemSize(TechType, new Vector2int(1, 1));
            CraftDataHandler.Main.AddToGroup(TechGroup.VehicleUpgrades, TechCategory.VehicleUpgrades, TechType);
            CraftDataHandler.Main.SetEquipmentType(TechType, ArmType == ArmType.ExosuitArm ? EquipmentType.ExosuitArm : (EquipmentType)100);
            CraftDataHandler.Main.SetQuickSlotType(TechType, QuickSlotType.Selectable);
            CraftDataHandler.Main.SetBackgroundType(TechType, CraftData.BackgroundType.ExosuitArm);

            EncyData encyData = GetEncyclopediaData();

            if (encyData != null)
            {
                isEncyExists = true;

                PDAEncyclopedia.EntryData entryData = new PDAEncyclopedia.EntryData()
                {
                    key      = ClassID,
                    path     = EncyHelper.GetEncyPath(encyData.node),
                    nodes    = EncyHelper.GetEncyNodes(encyData.node),
                    unlocked = false,
                    popup    = null,
                    image    = encyData.image,
                    audio    = null
                };

                PDAEncyclopediaHandler.Main.AddCustomEntry(entryData);

                LanguageHandler.Main.SetLanguageLine($"Ency_{ClassID}", encyData.title);
                LanguageHandler.Main.SetLanguageLine($"EncyDesc_{ClassID}", encyData.description);
            }

            if (RequiredForUnlock == TechType.None && _Fragment != null)
            {
                PDAScanner.EntryData scannerEntryData = new PDAScanner.EntryData()
                {
                    key              = _Fragment.TechType,
                    blueprint        = TechType,
                    destroyAfterScan = _Fragment.DestroyAfterScan,
                    encyclopedia     = isEncyExists ? ClassID : null,
                    isFragment       = true,
                    locked           = false,
                    scanTime         = _Fragment.ScanTime,
                    totalFragments   = _Fragment.TotalFragments
                };

                PDAHandler.Main.AddCustomScannerEntry(scannerEntryData);

                KnownTechHandler.Main.SetAnalysisTechEntry(TechType, new TechType[1] {
                    TechType
                });
            }
            else
            {
                KnownTechHandler.Main.SetAnalysisTechEntry(RequiredForUnlock, new TechType[1] {
                    TechType
                }, $"{FriendlyName} blueprint discovered!");
            }

            if (ArmType == ArmType.ExosuitArm)
            {
                CraftTreeHandler.Main.AddCraftingNode(CraftTree.Type.SeamothUpgrades, TechType, new string[] { "ExosuitModules" });
            }
            else
            {
                CraftTreeHandler.Main.AddCraftingNode(CraftTree.Type.SeamothUpgrades, TechType, new string[] { "SeamothModules" });
            }

            RegisterArm();
        }