public ExteriorPlantPotPrefab(string plantPotId, string displayName, string tooltip, string basePotPath, TechType basePotTechType) : base(plantPotId, $"Submarine/Build/{plantPotId}")
        {
            this.basePlantPotPath = basePotPath;

            // Register the TechType
            TechType = TechTypeHandler.AddTechType(plantPotId, displayName, tooltip, false);

            // Register the Sprite(icon) of the new TechType with the icon of the base plant pot.
            SpriteHandler.RegisterSprite(TechType, SpriteManager.Get(basePotTechType));

            // Set the recipe of the TechType.
            CraftDataHandler.SetTechData(TechType, new TechData()
            {
                craftAmount = 1,
                Ingredients = new List <Ingredient>()
                {
                    new Ingredient(TechType.Titanium, 2)
                }
            });

            // Add it as a buildable.
            CraftDataHandler.AddBuildable(TechType);

            // Add it to the group in the PDA.
            CraftDataHandler.AddToGroup(TechGroup.ExteriorModules, TechCategory.ExteriorOther, TechType);

            // Set it to unlock after the base TechType is unlocked.
            KnownTechHandler.SetAnalysisTechEntry(basePotTechType, new List <TechType>()
            {
                TechType
            });

            // Register this prefab.
            PrefabHandler.RegisterPrefab(this);
        }
Exemplo n.º 2
0
        public void Patch()
        {
            if (this.IsPatched)
            {
                return;
            }

            this.TechType = TechTypeHandler.AddTechType(this.ClassID, this.FriendlyName, this.Description, this.UnlocksAtStart);

            if (!this.UnlocksAtStart)
            {
                KnownTechHandler.SetAnalysisTechEntry(this.RequiredForUnlock, new TechType[] { this.TechType });
            }

            if (this.Sprite == null)
            {
                this.Sprite = ImageUtils.LoadSpriteFromFile(IOUtilities.Combine(ExecutingFolder, this.PluginFolder, this.IconFileName));
            }

            SpriteHandler.RegisterSprite(this.TechType, this.Sprite);

            CraftDataHandler.SetTechData(this.TechType, GetBlueprintRecipe());

            CraftDataHandler.AddToGroup(TechGroup.Resources, TechCategory.Electronics, this.TechType);

            CraftDataHandler.SetEquipmentType(this.TechType, this.ChargerType);

            CraftTreeHandler.AddCraftingNode(CraftTree.Type.Fabricator, this.TechType, this.StepsToFabricatorTab);

            PrefabHandler.RegisterPrefab(this);

            AddToList();

            this.IsPatched = true;
        }
        public void Patch(bool auxConsolesEnabled)
        {
            this.TechType = TechTypeHandler.AddTechType(NameID, FriendlyName, Description, false);

            if (!auxConsolesEnabled) // Even if the options have this be disabled,
            {
                return;              // we still want to run through the AddTechType methods to prevent mismatched TechTypeIDs as these settings are switched
            }
            LanguageHandler.SetLanguageLine(HandOverText, "Access Auxiliary Cyclops Upgrade Console");
            CraftDataHandler.AddBuildable(this.TechType);
            CraftDataHandler.AddToGroup(TechGroup.InteriorModules, TechCategory.InteriorModule, this.TechType);

            PrefabHandler.RegisterPrefab(this);

            var recipe = new TechData()
            {
                craftAmount = 1,
                Ingredients = new List <Ingredient>(new Ingredient[3]
                {
                    new Ingredient(TechType.AdvancedWiringKit, 1),
                    new Ingredient(TechType.Titanium, 2),
                    new Ingredient(TechType.Lead, 1),
                })
            };

            CraftDataHandler.SetTechData(this.TechType, recipe);
            SpriteHandler.RegisterSprite(this.TechType, @"./QMods/MoreCyclopsUpgrades/Assets/AuxCyUpgradeConsole.png");
            KnownTechHandler.SetAnalysisTechEntry(TechType.CyclopsHullModule1, new TechType[1] {
                this.TechType
            }, $"{FriendlyName} blueprint discovered!");
        }
Exemplo n.º 4
0
        public virtual void Patch()
        {
            Atlas.Sprite sprite;

            if (NameUsingForFiles != null)
            {
                sprite = ImageUtils.LoadSpriteFromFile($"./QMods/{NameUsingForFiles}/Assets/{NameUsingForFiles}.png");
            }
            else
            {
                sprite = GetResourceIcon(PrefabTemplate);
            }


            TechType = TechTypeHandler.AddTechType(NameID, FriendlyName, Description, sprite, false);
            SpriteHandler.RegisterSprite(TechType, sprite);
            CraftTreeHandler.AddCraftingNode(FabricatorType, TechType, FabricatorTab);
            CraftDataHandler.SetTechData(TechType, GetRecipe());
            CraftDataHandler.AddToGroup(GroupForPDA, CategoryForPDA, TechType);
            CraftDataHandler.SetEquipmentType(TechType, TypeForEquipment);
            CraftDataHandler.SetQuickSlotType(TechType, TypeForQuickslot);
            CraftDataHandler.SetItemSize(TechType, ItemSize);

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

            PrefabHandler.RegisterPrefab(this);
        }
Exemplo n.º 5
0
        public void RegisterFloraFabricator(List <IDecorationItem> decorationItems)
        {
            if (this.IsRegistered == false)
            {
                // Create new Craft Tree Type
                CreateCustomTree(out CraftTree.Type craftType, decorationItems);
                this.TreeTypeID = craftType;

                // Add the new TechType to the buildables
                CraftDataHandler.AddBuildable(this.TechType);

                // Add the new TechType to the group of Interior Module buildables
                CraftDataHandler.AddToGroup(TechGroup.InteriorModules, TechCategory.InteriorModule, this.TechType, TechType.Fabricator);

                // Register handover text
                LanguageHandler.SetLanguageLine(HandOverText, LanguageHelper.GetFriendlyWord(HandOverText));

                // Unlock at start
                KnownTechHandler.UnlockOnStart(this.TechType);

                // Set the buildable prefab
                PrefabHandler.RegisterPrefab(this);

                // Register sprite
                SpriteHandler.RegisterSprite(this.TechType, AssetsHelper.Assets.LoadAsset <Sprite>("fabricator_icon_green"));

                // Load texture
                this.ColoredTexture = AssetsHelper.Assets.LoadAsset <Texture2D>("submarine_fabricator_green");

                // Associate the recipie to the new TechType
                CraftDataHandler.SetTechData(this.TechType, this.Recipe);

                this.IsRegistered = true;
            }
        }
Exemplo n.º 6
0
    void BuildPort(Region r)
    {
        Vector2Int loc = r.GetPortPosition();
        Vector2    rot = Vector2.zero;
        int        n   = 0;

        if (MapMetrics.InsideMap(loc.y, loc.x) && regions[regionIndex[loc.y, loc.x]].iswater)
        {
            n++; rot += new Vector2(1, 1);
        }
        if (MapMetrics.InsideMap(loc.y, loc.x - 1) && regions[regionIndex[loc.y, loc.x - 1]].iswater)
        {
            n++; rot += new Vector2(-1, 1);
        }
        if (MapMetrics.InsideMap(loc.y - 1, loc.x) && regions[regionIndex[loc.y - 1, loc.x]].iswater)
        {
            n++; rot += new Vector2(1, -1);
        }
        if (MapMetrics.InsideMap(loc.y - 1, loc.x - 1) && regions[regionIndex[loc.y - 1, loc.x - 1]].iswater)
        {
            n++; rot += new Vector2(-1, -1);
        }
        // rot /= n;
        Port port = Instantiate(PrefabHandler.GetPort(r.owner.fraction), Ports);

        port.transform.position = MapMetrics.PerturbedCorner(loc);
        port.transform.rotation = Quaternion.Euler(0, Vector2.SignedAngle(rot, new Vector2(0, -1)), 0);
        port.CornerPosition     = loc + rot.normalized * 0.5f;
        port.Region             = r;
        r.Port = port;
        port.gameObject.SetActive(false);
    }
        protected override void Patch()
        {
            DepletedNuclearModuleID = TechTypeHandler.AddTechType(DepletedNameID, FriendlyName, Description, false);

            RefillNuclearModuleID = TechTypeHandler.AddTechType(RefillNameID,
                                                                "Reload Cyclops Nuclear Module",
                                                                "Reload a Depleted Cyclops Nuclear Module with a Reactor Rod",
                                                                false);

            if (CyclopsModule.ModulesEnabled) // Even if the options have this be disabled,
            {                                 // we still want to run through the AddTechType methods to prevent mismatched TechTypeIDs as these settings are switched
                SpriteHandler.RegisterSprite(DepletedNuclearModuleID, $"./QMods/MoreCyclopsUpgrades/Assets/DepletedCyclopsNuclearModule.png");
                SpriteHandler.RegisterSprite(RefillNuclearModuleID, $"./QMods/MoreCyclopsUpgrades/Assets/CyclopsNuclearModule.png");

                CraftDataHandler.SetTechData(RefillNuclearModuleID, GetRecipe());
                KnownTechHandler.SetAnalysisTechEntry(TechType.BaseNuclearReactor, new TechType[1] {
                    RefillNuclearModuleID
                }, "Reload of cyclops nuclear module available.");

                PrefabHandler.RegisterPrefab(this);
                PrefabHandler.RegisterPrefab(new RefillNuclearModule(RefillNuclearModuleID));

                LanguageHandler.SetLanguageLine(DepletedEventKey, "Nuclear Reactor Module depleted");
            }

            this.NukFabricator.Patch(CyclopsModule.ModulesEnabled);
        }
Exemplo n.º 8
0
        public static void Patch()
        {
            bundle = AssetBundle.LoadFromFile("QMods/AlienRifle2/alienrifle");

            rifleTech = TechTypeHandler.AddTechType("AlienRifleWeapon", "Alien Rifle", "An ancient weapon found in an alien facility", ImageUtils.LoadSpriteFromFile("QMods/AlienRifle2/Assets/alienrifle.png"), false);

            PrefabHandler.RegisterPrefab(new RiflePrefab("AlienRifleWeapon", "WorldEntities/Tools/AlienRifle", rifleTech));

            CraftDataHandler.SetEquipmentType(rifleTech, EquipmentType.Hand);
            TechData data = new TechData();

            data.Ingredients = new List <Ingredient>()
            {
                new Ingredient(TechType.StasisRifle, 1),
                new Ingredient(TechType.Magnetite, 3),
                new Ingredient(TechType.PlasteelIngot, 2),
                new Ingredient(TechType.PrecursorIonCrystal, 1)
            };
            data.craftAmount = 1;

            CraftDataHandler.SetTechData(rifleTech, data);
            CraftDataHandler.SetItemSize(rifleTech, 2, 2);
            CraftTreeHandler.AddTabNode(CraftTree.Type.Workbench, "StasisRifleMods", "Stasis Rifle Upgrades", ImageUtils.LoadSpriteFromFile("QMods/AlienRifle2/Assets/stasisrifleupgrades.png"));
            CraftTreeHandler.AddCraftingNode(CraftTree.Type.Workbench, rifleTech, "StasisRifleMods", "Alien Rifle");

            HarmonyInstance inst = HarmonyInstance.Create("Kylinator25.AlienRifle.V2");

            inst.PatchAll(typeof(MainPatch).Assembly);
        }
Exemplo n.º 9
0
 public static void FirstStart()
 {
     //if RandyKnapp WhiteLights is installed disable my light color change
     //Debug.Log($"whiteLightsPath is {File.Exists(whiteLightsPath)}");
     if (File.Exists(whiteLightsPath))
     {
         othermods = true;
     }
     else
     {
         othermods = false;
     }
     PrefabHandler.RegisterPrefab(new BetterSeaglide());
     if (othermods)
     {
         Menus.ConfigWhiteLights.Load();
         OptionsPanelHandler.RegisterModOptions(new Menus.OptionsWhiteLights());
         SecondStart();
     }
     //if RandyKnapp WhiteLights is not installed enable my light color change
     else
     {
         Menus.Config.Load();
         OptionsPanelHandler.RegisterModOptions(new Menus.Options());
         SecondStart();
     }
 }
Exemplo n.º 10
0
        /// <summary>
        /// Initializes a new <see cref="Spawnable"/>, the basic class needed for any item that can be spawned into the Subnautica game world.
        /// </summary>
        /// <param name="classId">The main internal identifier for this item. Your item's <see cref="TechType"/> will be created using this name.</param>
        /// <param name="friendlyName">The name displayed in-game for this item whether in the open world or in the inventory.</param>
        /// <param name="description">The description for this item; Typically seen in the PDA, inventory, or crafting screens.</param>
        protected Spawnable(string classId, string friendlyName, string description)
            : base(classId, $"{classId}Prefab")
        {
            if (string.IsNullOrEmpty(classId))
            {
                Logger.Log($"ClassID for Spawnables must be a non-empty value.", LogLevel.Error);
                throw new ArgumentException($"Error patching Spawnable");
            }

            FriendlyName = friendlyName;
            Description  = description;

            CorePatchEvents += () =>
            {
                PrefabHandler.RegisterPrefab(this);
                SpriteHandler.RegisterSprite(TechType, GetItemSprite());

                if (!SizeInInventory.Equals(defaultSize))
                {
                    CraftDataHandler.SetItemSize(TechType, SizeInInventory);
                }

                if (EntityInfo != null && BiomesToSpawnIn != null)
                {
                    LootDistributionHandler.AddLootDistributionData(this, BiomesToSpawnIn, EntityInfo);
                }
                else if (EntityInfo != null)
                {
                    WorldEntityDatabaseHandler.AddCustomInfo(ClassID, EntityInfo);
                }
            };
        }
Exemplo n.º 11
0
        // Token: 0x06000001 RID: 1 RVA: 0x00002050 File Offset: 0x00000250
        public void PrePatch()
        {
            AssetBundle.LoadFromFile(Path.Combine("Qmods" + "EggMod" + "eggs.assets"));
            TechTypeHandler.AddTechType("GhostRayBlueEgg", "Ghost Ray Egg", "this is the egg from the ghostRay");
            TechTypeHandler.AddTechType("GhostRayBlueEggUndiscovered", "GhostRayBlueEggUndiscovered", "ghostrayegg");
            TechTypeHandler.AddTechType("GhostRayRedEgg", "GhostRayRedEgg", "ghost Ray Red Egg");
            TechTypeHandler.AddTechType("GhostRayRedEggUndiscovered", "GhostRayRedEggUndiscovered", "GhostRayRedEggUndiscovered");
            Dictionary <TechType, float> dictionary = typeof(BaseBioReactor).GetField("charge", BindingFlags.Static | BindingFlags.NonPublic).GetValue(null) as Dictionary <TechType, float>;

            WaterParkCreature.waterParkCreatureParameters[TechType.GhostRayBlue]           = new WaterParkCreatureParameters(0.05f, 0.2f, 0.5f, 1f, false);
            WaterParkCreature.waterParkCreatureParameters[TechType.GhostRayRed]            = new WaterParkCreatureParameters(0.05f, 0.2f, 0.5f, 1f, false);
            WaterParkCreature.waterParkCreatureParameters[TechType.ReaperLeviathan]        = new WaterParkCreatureParameters(0.03f, 0.05f, 0.5f, 1f, false);
            WaterParkCreature.waterParkCreatureParameters[TechType.GhostLeviathan]         = new WaterParkCreatureParameters(0.03f, 0.05f, 0.5f, 1f, false);
            WaterParkCreature.waterParkCreatureParameters[TechType.GhostLeviathanJuvenile] = new WaterParkCreatureParameters(0.03f, 0.05f, 0.5f, 1f, false);
            WaterParkCreature.waterParkCreatureParameters[TechType.SeaDragon] = new WaterParkCreatureParameters(0.03f, 0.05f, 0.5f, 1f, false);
            WaterParkCreature.creatureEggs[TechType.GhostRayBlue]             = (TechType)9999;
            WaterParkCreature.creatureEggs[TechType.GhostRayRed] = (TechType)6969;
            CraftDataHandler.SetItemSize(TechType.GhostRayBlue, 3, 3);
            CraftDataHandler.SetItemSize(TechType.GhostRayRed, 3, 3);
            GhostRayBlueEggPrefab ghostRayBlueEggPrefab = new GhostRayBlueEggPrefab("WorldEntities/Eggs/GhostRayBlueEgg", "GhostRayBlueEggID");

            ghostRayBlueEggPrefab.LoadResource();
            PrefabHandler.RegisterPrefab(this);
            GhostRayRedEggPrefab ghostRayRedEggPrefab = new GhostRayRedEggPrefab("WorldEntities/Eggs/GhostRayRedEgg", "GhostRayRedEggID");

            ghostRayRedEggPrefab.LoadResource();
            CustomResourceManager.customResources.Add(ghostRayRedEggPrefab);
        }
Exemplo n.º 12
0
 public static void Patch()
 {
     // Add the techtype
     tank = TechTypeHandler.AddTechType("SolarOxygenTank", "Solar-powered Oxygen Tank", "An solar-powered oxygen tank which replenishes in the daylight!");
     // Apply prefab
     PrefabHandler.RegisterPrefab(new TankPrefab());
     // Add recipe
     CraftDataHandler.SetTechData(tank, new TechData()
     {
         craftAmount = 1,
         Ingredients = new List <Ingredient>()
         {
             new Ingredient(TechType.AdvancedWiringKit, 1),
             new Ingredient(TechType.EnameledGlass, 1),
             new Ingredient(TechType.Copper, 2),
             new Ingredient(TechType.Quartz, 2),
             new Ingredient(TechType.Pipe, 3),
             new Ingredient(TechType.PlasteelTank, 1),
         }
     });
     // Add it to the crafting tree
     CraftTreeHandler.AddCraftingNode(CraftTree.Type.Fabricator, tank, "Personal", "Equipment");
     // Make the background purple
     CraftDataHandler.SetBackgroundType(tank, CraftData.BackgroundType.ExosuitArm);
     // Double it's crafting time
     CraftDataHandler.SetCraftingTime(tank, 6f);
     // Make it equipable in the tank slot
     CraftDataHandler.SetEquipmentType(tank, EquipmentType.Tank);
     // Make it take a lot of inventory space
     CraftDataHandler.SetItemSize(tank, 3, 3);
     // Start patching
     HarmonyInstance.Create("alexejheroytb.subnauticamods.solaroxygentank").PatchAll(Assembly.GetExecutingAssembly());
 }
Exemplo n.º 13
0
        protected virtual void Patch()
        {
            this.TechType = TechTypeHandler.AddTechType(NameID, FriendlyName, Description, RequiredForUnlock == TechType.None);

            if (!ModulesEnabled) // Even if the options have this be disabled,
            {
                return;          // we still want to run through the AddTechType methods to prevent mismatched TechTypeIDs as these settings are switched
            }
            if (RequiredForUnlock == TechType.None)
            {
                KnownTechHandler.UnlockOnStart(this.TechType);
            }
            else
            {
                KnownTechHandler.SetAnalysisTechEntry(RequiredForUnlock, new TechType[1] {
                    this.TechType
                }, $"{FriendlyName} blueprint discovered!");
            }

            PrefabHandler.RegisterPrefab(this);

            SpriteHandler.RegisterSprite(this.TechType, $"./QMods/MoreCyclopsUpgrades/Assets/{NameID}.png");

            CraftDataHandler.SetTechData(this.TechType, GetRecipe());

            if (AddToCraftTree)
            {
                CraftTreeHandler.AddCraftingNode(Fabricator, this.TechType, FabricatorTabs);
            }

            CraftDataHandler.SetEquipmentType(this.TechType, EquipmentType.CyclopsModule);
            CraftDataHandler.AddToGroup(TechGroup.Cyclops, TechCategory.CyclopsUpgrades, this.TechType);

            SetStaticTechTypeID(this.TechType);
        }
Exemplo n.º 14
0
        public static void Patch()
        {
            darktest = AssetBundle.LoadFromFile(Environment.CurrentDirectory + "/QMods/techpistol/Assets");
            Atlas.Sprite Icon = new Atlas.Sprite(darktest.LoadAsset <Sprite>("Icon"));
            var          gun  = TechTypeHandler.AddTechType("techpistol", "tech pistol", "tech pistol", true);

            SpriteHandler.RegisterSprite(gun, Icon);
            GunPrefab gunper = new GunPrefab("techpistol", "WorldEntities/Tools/techpistol", gun);

            PrefabHandler.RegisterPrefab(gunper);
            CraftDataHandler.SetEquipmentType(gun, EquipmentType.Hand);
            var techData = new TechData()
            {
                craftAmount = 1,
                Ingredients = new List <Ingredient>()
                {
                    new Ingredient(TechType.SeaTreaderPoop, 1),
                    new Ingredient(TechType.TitaniumIngot, 2),
                    new Ingredient(TechType.Lubricant, 1),
                    new Ingredient(TechType.EnameledGlass, 3),
                }
            };

            CraftDataHandler.SetTechData(gun, techData);
            CraftDataHandler.SetCraftingTime(gun, 5f);
            CraftTreeHandler.AddCraftingNode(CraftTree.Type.Fabricator, gun, "Personal", "Tools", "techpistol");
            CraftDataHandler.SetItemSize(gun, 2, 2);
        }
Exemplo n.º 15
0
        public static void Patch()
        {
            try
            {
                var harmony = HarmonyInstance.Create("MrPurple6411.SeamothDrillArm");
                harmony.PatchAll(Assembly.GetExecutingAssembly());

                var exosuit = Resources.Load <GameObject>("WorldEntities/Tools/Exosuit").GetComponent <Exosuit>();
                ExosuitThermalReactorCharge = exosuit.thermalReactorCharge;

                var exosuitDrillArmGO = (GameObject)GetArmPrefabMethod.Invoke(exosuit, new object[] { TechType.ExosuitDrillArmModule });
                var exosuitDrillArm   = exosuitDrillArmGO.GetComponent <ExosuitDrillArm>();
                DrillLoopHit = exosuitDrillArm.loopHit;
                DrillLoop    = exosuitDrillArm.loop;

                var path = @"./QMods/QuickMiner/mod.json";
                if (!File.Exists(path))
                {
                    Console.WriteLine("[SeamothDrillArm] Quick Miner not installed; node health set to default");
                }
                else
                {
                    Console.WriteLine("[SeamothDrillArm] Quick Miner IS installed; reading config...");
                    var    qmConfigJson      = File.ReadAllText(path);
                    string nodeHealthPattern = "\"NodeHealth\"\\s*:\\s*(\\d+\\.?\\d*)";
                    Match  match             = Regex.Match(qmConfigJson, nodeHealthPattern);
                    if (match.Success)
                    {
                        GroupCollection iAmGroup     = match.Groups;
                        float           qmNodeHealth = 0;
                        if (float.TryParse(iAmGroup[1].Value, out qmNodeHealth))
                        {
                            Console.WriteLine("[SeamothDrillArm] New node health is " + qmNodeHealth + ", based on QM config.");
                            DrillNodeHealth = qmNodeHealth;
                        }
                        else
                        {
                            Console.WriteLine("[SeamothDrillArm] Read QM config, but couldn't get the value! Using the default value of 50.");
                            DrillNodeHealth = 50f;
                        }
                    }
                    else
                    {
                        Console.WriteLine("[SeamothDrillArm] Couldn't find the node health config! Using the default value of 50.");
                        DrillNodeHealth = 50f;
                    }
                }

                PrefabHandler.RegisterPrefab(new SeamothDrillModule());

                Console.WriteLine("[SeamothDrillArm] Succesfully patched!");
            }
            catch (Exception e)
            {
                Console.WriteLine("[SeamothDrillArm] Caught exception! " + e.InnerException.Message);
                Console.WriteLine(e.InnerException.StackTrace);
            }
        }
Exemplo n.º 16
0
        void registerPrefabAndTechData()
        {
            PrefabHandler.RegisterPrefab(this);

            if (getTechData() is TechData techData)
            {
                CraftDataHandler.SetTechData(TechType, techData);
            }
        }
Exemplo n.º 17
0
        public virtual void Patch()
        {
            Atlas.Sprite sprite = null;

            if (IconFilename != null)
            {
                string iconfilePath = $"./QMods/{IconFilename}/Assets/{IconFilename}.png";

                try
                {
                    sprite = ImageUtils.LoadSpriteFromFile(iconfilePath);
                }
                catch
                {
                    SNLogger.Log($"[{NameID}] ***ERROR! File [{iconfilePath}] not Found! ");
                }
            }
            else if (IconTechType != TechType.None)
            {
                try
                {
                    sprite = GetResourceIcon(IconTechType);
                }
                catch
                {
                    SNLogger.Log($"[{NameID}] ***ERROR! Resource TechType icon [{IconTechType.ToString()}] not Found! ");
                }
            }
            else
            {
                try
                {
                    sprite = GetResourceIcon(PrefabTemplate);
                }
                catch
                {
                    SNLogger.Log($"[{NameID}] ***ERROR! Resource template icon [{PrefabTemplate.ToString()}] not Found! ");
                }
            }


            TechType = TechTypeHandler.AddTechType(NameID, FriendlyName, Description, sprite, false);
            SpriteHandler.RegisterSprite(TechType, sprite);
            CraftTreeHandler.AddCraftingNode(FabricatorType, TechType, FabricatorTab);
            CraftDataHandler.SetTechData(TechType, GetRecipe());
            CraftDataHandler.AddToGroup(GroupForPDA, CategoryForPDA, TechType);
            CraftDataHandler.SetEquipmentType(TechType, TypeForEquipment);
            CraftDataHandler.SetQuickSlotType(TechType, TypeForQuickslot);
            CraftDataHandler.SetItemSize(TechType, ItemSize);
            CraftDataHandler.SetBackgroundType(TechType, BackgroundType);
            KnownTechHandler.SetAnalysisTechEntry(RequiredForUnlock, new TechType[1] {
                TechType
            }, $"{FriendlyName} blueprint discovered!");

            PrefabHandler.RegisterPrefab(this);
        }
Exemplo n.º 18
0
        public PrefabHelper(string classid, string prefabfilename, TechType techtype, Func <GameObject> function)
        {
            Prefab prefab = new Prefab(classid, prefabfilename, techtype)
            {
                Function = function
            };

            this.prefab = prefab;
            PrefabHandler.RegisterPrefab(this);
        }
        public void Patch()
        {
            ModdedItems.Initialize();

            // Create new Craft Tree Type
            CreateCustomTree(out CraftTree.Type craftType);
            this.TreeTypeID = craftType;

            // Create a new TechType for new fabricator
            this.TechType = TechTypeHandler.AddTechType(
                internalName: NameID,
                displayName: FriendlyName,
                tooltip: "Construct vehicle upgrade modules from the comfort of your favorite habitat or cyclops.",
                sprite: ImageUtils.LoadSpriteFromFile(@"./QMods/VModFabricator/Assets/VModFabIcon.png"),
                unlockAtStart: false);

            // Create a Recipie for the new TechType
            var customFabRecipe = new TechData()
            {
                craftAmount = 1,
                Ingredients = new List <Ingredient>(new Ingredient[4]
                {
                    new Ingredient(TechType.Titanium, 2),
                    new Ingredient(TechType.ComputerChip, 1),
                    new Ingredient(TechType.Diamond, 1),
                    new Ingredient(TechType.Lead, 1),
                })
            };

            // Add the new TechType to the buildables
            CraftDataHandler.AddBuildable(this.TechType);

            // Add the new TechType to the group of Interior Module buildables
            CraftDataHandler.AddToGroup(TechGroup.InteriorModules, TechCategory.InteriorModule, this.TechType);

            LanguageHandler.SetLanguageLine(HandOverText, "Use Vehicle Module Fabricator");

            // Set the buildable prefab
            PrefabHandler.RegisterPrefab(this);

            // Associate the recipie to the new TechType
            CraftDataHandler.SetTechData(this.TechType, customFabRecipe);

            // Set which blueprints unlock the VMod Fabricator
            string unlockMessage = $"{FriendlyName} blueprint discovered!";
            var    unlockThis    = new TechType[1] {
                this.TechType
            };

            KnownTechHandler.SetAnalysisTechEntry(TechType.Workbench, unlockThis, unlockMessage);
            KnownTechHandler.SetAnalysisTechEntry(TechType.BaseUpgradeConsole, unlockThis, unlockMessage);
            KnownTechHandler.SetAnalysisTechEntry(TechType.Cyclops, unlockThis, unlockMessage);
        }
Exemplo n.º 20
0
        public static void Load()
        {
            try
            {
                assetBundle = AssetBundle.LoadFromFile("./QMods/AncientSword/Assets/ancient_sword");

                if (assetBundle == null)
                {
                    Debug.Log("[AncientSword] AssetBundle is NULL!");
                }
                else
                {
                    Debug.Log($"[AncientSword] AssetBundle loaded, name: {assetBundle.name}");
                }

                Atlas.Sprite swordIcon = null;
                swordIcon = ImageUtils.LoadSpriteFromFile($"./QMods/AncientSword/Assets/AncientSword.png");

                SwordTechType = TechTypeHandler.AddTechType("AncientSword", "Ancient Sword", "An ancient sword from Earth.\nFound in an ancient Precursor facility.");

                SpriteHandler.RegisterSprite(SwordTechType, swordIcon);

                SwordPrefab swordPrefab = new SwordPrefab("AncientSword", "WorldEntities/Tools/AncientSword", SwordTechType);

                PrefabHandler.RegisterPrefab(swordPrefab);

                var techData = new TechData
                {
                    craftAmount = 1,
                    Ingredients = new List <Ingredient>()
                    {
                        new Ingredient(TechType.Titanium, 2),
                        new Ingredient(TechType.Copper, 2)
                    },
                };

                CraftDataHandler.SetTechData(SwordTechType, techData);

                CraftTreeHandler.AddCraftingNode(CraftTree.Type.Fabricator, SwordTechType, new string[] { "Personal", "Tools", "AncientSword" });

                CraftDataHandler.SetItemSize(SwordTechType, new Vector2int(2, 2));

                CraftDataHandler.SetEquipmentType(SwordTechType, EquipmentType.Hand);

                //HarmonyInstance.Create("Subnautica.AncientSword.mod").PatchAll(Assembly.GetExecutingAssembly());
            }
            catch (Exception ex)
            {
                Debug.LogException(ex);
            }
        }
Exemplo n.º 21
0
        public void Patch()
        {
            // Register this Prefab with SMLHelper
            PrefabHandler.RegisterPrefab(this);

            // Create a new TechType for new Buildable
            this.TechType = TechTypeHandler.AddTechType
                            (
                NameID,
                FriendlyName,
                "This machine gathers resources from underground veins and pulls them to the surface.",
                ImageUtils.LoadSpriteFromFile(@"./BaseDrillMod/BaseDrillIcon.png"),
                true
                            );

            // Add the new TechType to the buildables
            CraftDataHandler.AddBuildable(this.TechType);

            // Add the new TechType to the group of Interior Module buildables
            CraftDataHandler.AddToGroup(TechGroup.InteriorModules, TechCategory.InteriorModule, this.TechType);

            LanguageHandler.SetLanguageLine(HandOverText, "Resource Drill");

            // Create new instance of TechData and apply the recipie to it
            TechData techData = new TechData
            {
                craftAmount = 1,
                Ingredients = new List <Ingredient>(new Ingredient[]
                {
                    new Ingredient(TechType.TitaniumIngot, 2),
                    new Ingredient(TechType.Diamond, 2),
                    new Ingredient(TechType.Lithium, 4),
                    new Ingredient(TechType.AdvancedWiringKit, 1),
                    new Ingredient(TechType.Lubricant, 1)
                })
            };

            // Associate TechType and TechData
            CraftDataHandler.SetTechData(base.TechType, techData);

            // Set which blueprints unlock the Item
            string unlockMessage = $"{FriendlyName} blueprint discovered!";
            var    unlockThis    = new TechType[1] {
                this.TechType
            };

            KnownTechHandler.SetAnalysisTechEntry(TechType.BaseMapRoom, unlockThis, unlockMessage);
            BaseDrillModule instance = new BaseDrillModule();

            instance.GetGameObject();
        }
Exemplo n.º 22
0
        public static void Patch()
        {
            try
            {
                bund = AssetBundle.LoadFromFile(Environment.CurrentDirectory + "/QMods/AlienRifle/alienrifle");
                Atlas.Sprite rifleIcon = null;
                try
                {
                    rifleIcon = ImageUtils.LoadSpriteFromFile("./QMods/AlienRifle/RifleIcon.PNG", TextureFormat.BC7);
                }
                catch
                {
                    Console.WriteLine("[AlienRifle] Couldn't convert rifle sprite to Atlas.Sprite ");
                }
                ARtech = TechTypeHandler.AddTechType("AlienRifle", "Alien Rifle", "A strange weapon found in an ancient facility");

                if (rifleIcon != null)
                {
                    SpriteHandler.RegisterSprite(ARtech, rifleIcon);
                }

                RiflePrefab prefab = new RiflePrefab("AlienRifle", "WorldEntities/Tools/AlienRifle", ARtech);

                PrefabHandler.RegisterPrefab(prefab);

                var techData = new TechData
                {
                    craftAmount = 1,
                    Ingredients = new List <Ingredient>()
                    {
                        new Ingredient(TechType.PlasteelIngot, 2),
                        new Ingredient(TechType.Nickel, 5),
                        new Ingredient(TechType.AdvancedWiringKit, 1),
                        new Ingredient(TechType.Glass, 5)
                    },
                };
                CraftDataHandler.SetTechData(ARtech, techData);
                CraftTreeHandler.AddCraftingNode(CraftTree.Type.Fabricator, ARtech, new string[] { "Personal", "Tools", "AlienRifle" });

                CraftDataHandler.SetItemSize(ARtech, new Vector2int(2, 2));
                CraftDataHandler.SetEquipmentType(ARtech, EquipmentType.Hand);

                HarmonyInstance inst = HarmonyInstance.Create("com.kylinator.alienrifle");
                inst.PatchAll(Assembly.GetExecutingAssembly());

                Debug.Log("[AlienRifle] Loading Alien Rifle finished!");
            } catch (Exception e)
            {
                Debug.Log("[AlienRifle] Failed to load Alien Rifle: " + e.Message + e.StackTrace);
            }
        }
Exemplo n.º 23
0
        private void RegisterBasics()
        {
            PrefabHandler.RegisterPrefab(this);

            string assetsFolder = this.AssetsFolder;

            if (string.IsNullOrEmpty(assetsFolder))
            {
                Logger.Log($"AssetsFolder property for Spawnable instance of {this.ClassID} must have a non-empty value.", LogLevel.Error);
                throw new Exception($"Error patching Spawnable:{this.ClassID}");
            }

            SpriteHandler.RegisterSprite(this.TechType, $"./QMods/{assetsFolder.Trim('/')}/{this.IconFileName}");
        }
Exemplo n.º 24
0
        public virtual void Patch()
        {
            TechType = TechTypeHandler.AddTechType(NameID, FriendlyName, Description, ImageUtils.LoadSpriteFromFile($"./QMods/LaserCannon/Assets/{NameID}.png"), false);

            CraftTreeHandler.AddCraftingNode(FabricatorType, TechType, FabricatorTab);
            CraftDataHandler.SetTechData(TechType, GetRecipe());

            PrefabHandler.RegisterPrefab(this);

            KnownTechHandler.SetAnalysisTechEntry(RequiredForUnlock, new TechType[1] {
                TechType
            }, $"{FriendlyName} blueprint discovered!");
            CraftDataHandler.AddToGroup(GroupForPDA, CategoryForPDA, TechType);
        }
        public virtual void Patch_B()
        {
            Atlas.Sprite sprite = null;

            if (IconFilename != null)
            {
                try
                {
                    sprite = ImageUtils.LoadSpriteFromFile($"./QMods/{IconFilename}/Assets/{IconFilename}.png");
                }
                catch
                {
                    SNLogger.Log($"[{_ClassID}] ***ERROR! File [{IconFilename}.png] not Found! ");
                }
            }
            else if (IconTechType != TechType.None)
            {
                try
                {
                    sprite = GetResourceIcon(IconTechType);
                }
                catch
                {
                    SNLogger.Log($"[{_ClassID}] ***ERROR! Resource TechType icon [{IconTechType.ToString()}] not Found! ");
                }
            }
            else
            {
                try
                {
                    sprite = GetResourceIcon(PrefabTemplate);
                }
                catch
                {
                    SNLogger.Log($"[{_ClassID}] ***ERROR! Resource template icon [{PrefabTemplate.ToString()}] not Found! ");
                }
            }


            TechType = TechTypeHandler.AddTechType(_ClassID, _FriendlyName, _Description, sprite, false);
            SpriteHandler.RegisterSprite(TechType, sprite);
            CraftDataHandler.SetTechData(TechType, GetRecipe());
            CraftDataHandler.AddToGroup(GroupForPDA, CategoryForPDA, TechType);
            KnownTechHandler.SetAnalysisTechEntry(RequiredForUnlock, new TechType[1] {
                TechType
            }, $"{_FriendlyName} blueprint discovered!");

            PrefabHandler.RegisterPrefab(this);
        }
        private void Patch()
        {
            if (IsPatched)
            {
                return; // Already patched. Skip all this.
            }
            if (Prerequisite != null && !Prerequisite.IsPatched)
            {
                Prerequisite.Patch(); // Go and patch the prerequisite craftable first
            }
            PrePatch();               // Run any prepatch overrides

            if (PatchTechTypeOnly)    // Register just the TechType to preserve the ID.
            {
                this.TechType = TechTypeHandler.AddTechType(NameID, FriendlyName, Description, false);
            }
            else // Full patching
            {
                this.TechType = TechTypeHandler.AddTechType(
                    internalName: NameID,
                    displayName: FriendlyName,
                    tooltip: Description,
                    sprite: ImageUtils.LoadSpriteFromFile($"./QMods/UpgradedVehicles/Assets/{NameID}.png"),
                    unlockAtStart: false);

                CraftTreeHandler.AddCraftingNode(FabricatorType, this.TechType, FabricatorTab);
                CraftDataHandler.SetTechData(this.TechType, GetRecipe());

                PrefabHandler.RegisterPrefab(this);

                if (Config.ForceUnlockAtStart)
                {
                    KnownTechHandler.UnlockOnStart(this.TechType);
                }
                else
                {
                    KnownTechHandler.SetAnalysisTechEntry(RequiredForUnlock, new TechType[1] {
                        this.TechType
                    }, $"{FriendlyName} blueprint discovered!");
                }

                CraftDataHandler.AddToGroup(GroupForPDA, CategoryForPDA, this.TechType);
            }

            PostPatch(); // Run any postpatch overrides

            IsPatched = true;
        }
Exemplo n.º 27
0
        //public static TechType RepulsionKnifeID;

        public static void Patch()
        {
            RoseLogger.PatchStart(modName, "1.0.0");
            try
            {
                Atlas.Sprite obsidianKnifeIcon = null;
                obsidianKnifeIcon = ImageUtils.LoadSpriteFromFile($"./QMods/MoreKnives/Assets/ObsidianKnife.png");

                ObsidianKnifeID = TechTypeHandler.AddTechType("obsidianknife", "Obsidian Knife", "An enhanced knife that exudes a rapidly cooling magma, forming a sharp obsidian edge.");

                SpriteHandler.RegisterSprite(ObsidianKnifeID, obsidianKnifeIcon);

                KnifePrefab obsidianKnifePrefab = new KnifePrefab("obsidianknife", "WorldEntities/Tools/ObsidianKnife", ObsidianKnifeID);

                DropItems.PatchDropItems();

                var techDataObsidian = new TechData
                {
                    craftAmount = 1,
                    Ingredients = new List <Ingredient>()
                    {
                        new Ingredient(TechType.Knife, 1),
                        new Ingredient(DropItems.ObsidianFlakeID, 1),
                    },
                };

                CraftDataHandler.SetTechData(ObsidianKnifeID, techDataObsidian);

                CraftTreeHandler.AddCraftingNode(CraftTree.Type.Workbench, ObsidianKnifeID, new string[] { "Survival Knife", "obsidianknife" });

                CraftDataHandler.SetItemSize(ObsidianKnifeID, new Vector2int(1, 1));

                CraftDataHandler.SetEquipmentType(ObsidianKnifeID, EquipmentType.Hand);

                PrefabHandler.RegisterPrefab(obsidianKnifePrefab);

                var harmony = HarmonyInstance.Create("rose.moreknives.mod");
                harmony.PatchAll(Assembly.GetExecutingAssembly());


                RoseLogger.PatchComplete(modName);
            }

            catch (Exception ex)
            {
                RoseLogger.PatchFailed(modName, ex);
            }
        }
        // This patch is handled by the Nuclear Charger
        internal void Patch(bool nukFabricatorEnabled)
        {
            // Create new Craft Tree Type
            CreateCustomTree(out CraftTree.Type craftType);
            TreeTypeID = craftType;

            // Create a new TechType for new fabricator
            this.TechType = TechTypeHandler.AddTechType(NameID, FriendlyName,
                                                        "A specialized fabricator for safe handling of radioactive energy sources.", false);

            if (!nukFabricatorEnabled) // Even if the options have this be disabled,
            {
                return;                // we still want to run through the AddTechType methods to prevent mismatched TechTypeIDs as these settings are switched
            }
            // Create a Recipie for the new TechType
            var customFabRecipe = new TechData()
            {
                craftAmount = 1,
                Ingredients = new List <Ingredient>(new Ingredient[4]
                {
                    new Ingredient(TechType.Titanium, 2),
                    new Ingredient(TechType.ComputerChip, 1),
                    new Ingredient(TechType.Magnetite, 1),
                    new Ingredient(TechType.Lead, 2),
                })
            };

            // Add the new TechType to the buildables
            CraftDataHandler.AddBuildable(this.TechType);

            // Add the new TechType to the group of Interior Module buildables
            CraftDataHandler.AddToGroup(TechGroup.InteriorModules, TechCategory.InteriorModule, this.TechType);

            // Set the buildable prefab
            PrefabHandler.RegisterPrefab(this);

            LanguageHandler.SetLanguageLine(HandOverText, "Use Nuclear Fabricator");

            // Set the custom sprite for the Habitat Builder Tool menu
            SpriteHandler.RegisterSprite(this.TechType, @"./QMods/MoreCyclopsUpgrades/Assets/NuclearFabricatorI.png");

            // Associate the recipie to the new TechType
            CraftDataHandler.SetTechData(this.TechType, customFabRecipe);

            KnownTechHandler.SetAnalysisTechEntry(TechType.BaseNuclearReactor, new TechType[1] {
                this.TechType
            }, $"{FriendlyName} blueprint discovered!");
        }
Exemplo n.º 29
0
        /// <summary>
        /// Initializes a new <see cref="Spawnable"/>, the basic class needed for any item that can be spawned into the Subnautica game world.
        /// </summary>
        /// <param name="classId">The main internal identifier for this item. Your item's <see cref="TechType"/> will be created using this name.</param>
        /// <param name="friendlyName">The name displayed in-game for this item whether in the open world or in the inventory.</param>
        /// <param name="description">The description for this item; Typically seen in the PDA, inventory, or crafting screens.</param>
        protected Spawnable(string classId, string friendlyName, string description)
            : base(classId, $"{classId}Prefab")
        {
            if (string.IsNullOrEmpty(classId))
            {
                Logger.Log($"ClassID for Spawnables must be a non-empty value.", LogLevel.Error);
                throw new ArgumentException($"Error patching Spawnable");
            }

            FriendlyName = friendlyName;
            Description  = description;

            CorePatchEvents += () =>
            {
                PrefabHandler.RegisterPrefab(this);

#if SUBNAUTICA
                SpriteHandler.RegisterSprite(TechType, GetItemSprite());
#elif BELOWZERO
                CoroutineHost.StartCoroutine(RegisterSpriteAsync());
#endif
                if (!SizeInInventory.Equals(defaultSize))
                {
                    CraftDataHandler.SetItemSize(TechType, SizeInInventory);
                }

                if (EntityInfo != null)
                {
                    if (BiomesToSpawnIn != null)
                    {
                        LootDistributionHandler.AddLootDistributionData(this, BiomesToSpawnIn, EntityInfo);
                    }
                    else
                    {
                        WorldEntityDatabaseHandler.AddCustomInfo(ClassID, EntityInfo);
                    }
                }

                if (CoordinatedSpawns != null)
                {
                    foreach (var(position, eulerAngles) in CoordinatedSpawns)
                    {
                        CoordinatedSpawnsHandler.RegisterCoordinatedSpawn(new SpawnInfo(TechType, position, eulerAngles));
                    }
                }
            };
        }
        public static void Patch()
        {
            try
            {
                // Hook up with harmony
                var harmony = HarmonyInstance.Create("com.standpeter.seamothhabitatbuilder");
                harmony.PatchAll(Assembly.GetExecutingAssembly());

                // Create TechType and register its inventory icon
                SeamothBuilderModule = TechTypeHandler.AddTechType("SeamothBuilderModule", "Seamoth habitat builder", "Allows the Seamoth to perform habitat construction tasks.");
                SpriteHandler.RegisterSprite(SeamothBuilderModule, "QMods/SeamothHabitatBuilder/Assets/SeamothBuilderModule.png");

                // Create blueprint
                TechData blueprint = new TechData
                {
                    craftAmount = 1,
                    Ingredients = new List <Ingredient>(2)
                    {
                        new Ingredient(TechType.Builder, 1),
                        new Ingredient(TechType.AdvancedWiringKit, 1)
                    }
                };
                CraftDataHandler.SetTechData(SeamothBuilderModule, blueprint);

                // Make the item craftable
                const string subTree = "Seamoth modules";
                CraftTreeHandler.AddCraftingNode(CraftTree.Type.SeamothUpgrades, SeamothBuilderModule, subTree);
                KnownTechHandler.UnlockOnStart(SeamothBuilderModule);

                // Set how the new item gets used
                CraftDataHandler.AddToGroup(TechGroup.VehicleUpgrades, TechCategory.VehicleUpgrades, SeamothBuilderModule);
                CraftDataHandler.SetQuickSlotType(SeamothBuilderModule, QuickSlotType.Selectable);
                CraftDataHandler.SetEquipmentType(SeamothBuilderModule, EquipmentType.SeamothModule);

                // Register the prefab for the item
                ModPrefab prefab = new SeamothBuilderPrefab("SeamothBuilder", "WorldEntities/Tools/SeamothBuilderModule", SeamothBuilderModule);
                PrefabHandler.RegisterPrefab(prefab);

                Console.WriteLine("[SeamothHabitatBuilder] Succesfully patched!");
            }
            catch (Exception e)
            {
                Console.WriteLine("[SeamothHabitatBuilder] Caught exception! " + e.InnerException.Message);
                Console.WriteLine(e.InnerException.StackTrace);
            }
        }