Exemplo n.º 1
0
        public static void RegisterFloraFabricator(List <IDecorationItem> decorationItems)
        {
            Logger.Log("Creating flora craft tree...");
            CustomCraftTreeRoot customTreeRootNode = CreateFloraTree(out CraftTree.Type craftType, decorationItems);

            FloraTreeType = craftType;

            Logger.Log("Registering flora fabricator...");
            // Create a new TechType for the fabricator
            FloraFabTechType = TechTypePatcher.AddTechType(FloraFabID,
                                                           LanguageHelper.GetFriendlyWord("FloraFabricatorName"),
                                                           LanguageHelper.GetFriendlyWord("FloraFabricatorDescription"),
                                                           true);
            // Add new TechType to the buildables (Interior Module group)
            CraftDataPatcher.customBuildables.Add(FloraFabTechType);
            CraftDataPatcher.AddToCustomGroup(TechGroup.InteriorModules, TechCategory.InteriorModule, FloraFabTechType);
            // Set buildable prefab
            CustomPrefabHandler.customPrefabs.Add(new CustomPrefab(FloraFabID, $"Submarine/Build/{FloraFabID}", FloraFabTechType, GetFloraFabPrefab));
            // Set custom sprite for the Habitat Builder Tool menu
            CustomSpriteHandler.customSprites.Add(new CustomSprite(FloraFabTechType, AssetsHelper.Assets.LoadAsset <Sprite>("fabricator_icon_green")));
            // Create and associate recipe to the new TechType
            var customFabRecipe = new TechDataHelper()
            {
                _craftAmount = 1,
                _ingredients = new List <IngredientHelper>(new IngredientHelper[4] {
                    new IngredientHelper(TechType.Titanium, 1),
                    new IngredientHelper(TechType.ComputerChip, 1),
                    new IngredientHelper(TechType.Kyanite, 1),
                    new IngredientHelper(TechType.PrecursorIonCrystal, 1)
                }),
                _techType = FloraFabTechType
            };

            CraftDataPatcher.customTechData[FloraFabTechType] = customFabRecipe;
        }
Exemplo n.º 2
0
        public static void Patch()
        {
            Config.Load();
            var configChanged = Config.TryGet(ref _x, "Scrap metal size", "x")
                                | Config.TryGet(ref _y, "Scrap metal size", "y");

            if (_x <= 0)
            {
                _x = 2;
                Config["Scrap metal size", "x"] = _x;
                Logger.Error("Size of the item can't be less or equal of 0! X was set to 2", LogType.Custom | LogType.Console);
                configChanged = true;
            }
            if (_y <= 0)
            {
                _y = 2;
                Config["Scrap metal size", "y"] = _y;
                Logger.Error("Size of the item can't be less or equal of 0! Y was set to 2", LogType.Custom | LogType.Console);
                configChanged = true;
            }
            if (configChanged)
            {
                Config.Save();
            }
            var techData = new TechDataHelper
            {
                _craftAmount = 2,
                _ingredients = new List <IngredientHelper>()
                {
                    new IngredientHelper(TechType.TitaniumIngot, 1)
                },
                _linkedItems = new List <TechType>()
                {
                    TechType.Titanium,
                    TechType.Titanium
                },
                _techType = TechType.ScrapMetal
            };

            CraftDataPatcher.customTechData.Add(TechType.ScrapMetal, techData);
            CraftTreePatcher.customCraftNodes.Add("Resources/BasicMaterials/ScrapMetal", TechType.ScrapMetal);
            CraftDataPatcher.customItemSizes[TechType.ScrapMetal] = new Vector2int(_x, _y);
            KnownTechPatcher.unlockedAtStart.Add(TechType.ScrapMetal);
        }
Exemplo n.º 3
0
        public static void QPatch()
        {
            Items.AddDummy
            (
                name: "RRRDUMMY",
                languageName: "Replenish Reactor Rod",
                languageTooltip: "Combine a depleted reactor rod with 3 uranium to replenish it!",
                spriteItem: TechType.DepletedReactorRod,
                fabricatorNodePath: "Resources/AdvancedMaterials/RRRDUMMY",
                ingredientItems: new List <IngredientHelper>()
            {
                new IngredientHelper(TechType.DepletedReactorRod, 1),
                new IngredientHelper(TechType.UraniniteCrystal, 3)
            },
                resultingItems: TechType.ReactorRod,
                prefabPath: "WorldEntities/Natural/ReactorRod"
            );

            TechDataHelper data = new TechDataHelper()
            {
                _techType    = RRRItem,
                _craftAmount = 1,
                _ingredients = new List <IngredientHelper>()
                {
                    new IngredientHelper(TechType.DepletedReactorRod, 1),
                    new IngredientHelper(TechType.UraniniteCrystal, 3)
                },
            };

            CraftDataPatcher.customTechData.Add(RRRItem, data);
            CraftTreePatcher.customNodes.Add(new CustomCraftNode(RRRItem, CraftTree.Type.Fabricator, "Resources/AdvancedMaterials/RRRItem"));

            Dictionary <TechType, float> charge = Values.GetValue <BaseNuclearReactor>("charge") as Dictionary <TechType, float>;

            charge.Add(RRRItem, 15000f);

            Values.SetValue <BaseNuclearReactor>("charge", charge);

            HarmonyInstance.Create("alexejheroytb.subnauticamods.replenishreactorrods").PatchAll();
        }
Exemplo n.º 4
0
        /// <summary>
        /// Adds a dummy item
        /// </summary>
        /// <param name="name">The internal name of the item. Can be omitted and it will be automatically generated</param>
        /// <param name="languageName">The name of the item</param>
        /// <param name="languageTooltip">The tooltip of the item</param>
        /// <param name="spriteItem">The <see cref="TechType"/> from which to get the <see cref="Atlas.Sprite"/></param>
        /// <param name="fabricatorNodePath">The path where the item should be added in the fabricator</param>
        /// <param name="ingredientItems">The ingredient item(s) of the recipe. Must be either <see cref="IngredientHelper"/> or a <see cref="List{IngredientHelper}"/> of <see cref="IngredientHelper"/></param>
        /// <param name="resultingItems">The resulting items of the recipe. Must be either <see cref="TechType"/> or a <see cref="List{T}"/> of <see cref="TechType"/></param>
        /// <param name="prefabPath">The path of the prefab. Can be omitted and the item will not have a prefab</param>
        /// <returns>A <see cref="Result"/></returns>
        private static Result AddDummy(string name, string languageName, string languageTooltip, TechType spriteItem, string fabricatorNodePath, List <IngredientHelper> ingredientItems, List <TechType> resultingItems, string prefabPath = null)
        {
            TechType techType = TechTypePatcher.AddTechType(name, languageName, languageTooltip);

            Atlas.Sprite    sprite          = SpriteManager.Get(spriteItem);
            CustomSprite    customSprite    = new CustomSprite(techType, sprite);
            CustomCraftNode customCraftNode = new CustomCraftNode(techType, CraftTree.Type.Fabricator, fabricatorNodePath);
            TechDataHelper  techData        = new TechDataHelper()
            {
                _craftAmount = 0,
                _ingredients = ingredientItems,
                _linkedItems = resultingItems,
                _techType    = techType
            };

            CustomSpriteHandler.customSprites.Add(customSprite);
            CraftDataPatcher.customTechData.Add(techType, techData);
            CraftTreePatcher.customNodes.Add(customCraftNode);

            Result result = new Result()
            {
                CustomCraftNode = customCraftNode,
                CustomSprite    = customSprite,
                Sprite          = sprite,
                TechDataHelper  = techData,
                TechType        = techType,
            };

            if (prefabPath == null)
            {
                return(result);
            }

            PrefabGenerator prefab = new PrefabGenerator(prefabPath, name, techType);

            CustomPrefabHandler.customPrefabs.Add(new CustomPrefab(prefab.InternalName, prefab.NewPrefabPath, prefab.Item, prefab.GameObject));

            return(result);
        }
Exemplo n.º 5
0
        public static void OnGameStart()
        {
            LoadConfig();

            warpCannonTechType  = TechTypePatcher.AddTechType(WARP_CANNON_CLASS_ID, "Warp Cannon", "A tool that allows you to warp 30 meters using Warper technology.");
            warpScalesTechType  = TechTypePatcher.AddTechType(WARP_SCALE_CLASS_ID, "Warp Scale", "A resource obtained from warpers that can be used to craft Warp Batteries.");
            warpBatteryTechType = TechTypePatcher.AddTechType(WARP_BATTERY_CLASS_ID, "Warp Battery", "A battery that powers Warp Cannons.");

            customTechTypes.Add(WARP_CANNON_CLASS_ID, warpCannonTechType);
            customTechTypes.Add(WARP_BATTERY_CLASS_ID, warpBatteryTechType);
            customTechTypes.Add(WARP_SCALE_CLASS_ID, warpScalesTechType);

            var warpCannonData  = new TechDataHelper();
            var warpBatteryData = new TechDataHelper();

            foreach (var techType in IngredientsConfig)
            {
                if (techType.Key == "WarpCannon")
                {
                    warpCannonData._craftAmount = techType.Value.CraftAmount;
                    warpCannonData._techType    = warpCannonTechType;
                    warpCannonData._ingredients = new List <IngredientHelper>();

                    foreach (var ingredient in techType.Value.Ingredients)
                    {
                        var ingredientTech = default(TechType);
                        if (TechTypeExtensions.FromString(ingredient.ItemName, out ingredientTech, false))
                        {
                            warpCannonData._ingredients.Add(new IngredientHelper(ingredientTech, ingredient.Amount));
                        }
                        else if (customTechTypes.TryGetValue(ingredient.ItemName, out ingredientTech))
                        {
                            warpCannonData._ingredients.Add(new IngredientHelper(ingredientTech, ingredient.Amount));
                        }
                    }
                }

                if (techType.Key == "WarpBattery")
                {
                    warpBatteryData._craftAmount = techType.Value.CraftAmount;
                    warpBatteryData._techType    = warpBatteryTechType;
                    warpBatteryData._ingredients = new List <IngredientHelper>();


                    foreach (var ingredient in techType.Value.Ingredients)
                    {
                        var ingredientTech = default(TechType);
                        if (TechTypeExtensions.FromString(ingredient.ItemName, out ingredientTech, false))
                        {
                            warpBatteryData._ingredients.Add(new IngredientHelper(ingredientTech, ingredient.Amount));
                        }
                        else if (customTechTypes.TryGetValue(ingredient.ItemName, out ingredientTech))
                        {
                            warpBatteryData._ingredients.Add(new IngredientHelper(ingredientTech, ingredient.Amount));
                        }
                    }
                }
            }

            CraftDataPatcher.customTechData.Add(warpCannonTechType, warpCannonData);
            CraftDataPatcher.customTechData.Add(warpBatteryTechType, warpBatteryData);

            CraftDataPatcher.customEquipmentTypes.Add(warpCannonTechType, EquipmentType.Hand);
            CraftDataPatcher.customItemSizes.Add(warpCannonTechType, new Vector2int(2, 2));
            CraftDataPatcher.customHarvestTypeList.Add(TechType.Warper, HarvestType.DamageAlive);
            CraftDataPatcher.customHarvestOutputList.Add(TechType.Warper, warpScalesTechType);

            CraftTreePatcher.customCraftNodes.Add("Personal/Tools/WarpCannon", warpCannonTechType);
            CraftTreePatcher.customCraftNodes.Add("Resources/Electronics/WarpBattery", warpBatteryTechType);

            // Load AssetBundle
            AssetBundle = AssetBundle.LoadFromFile(Path.Combine("./QMods/WarpCannon/", "warpcannon.assets"));
            if (AssetBundle == null)
            {
                return;
            }

            // Load GameObjects

            // Load Battery
            var warpCannonBattery = AssetBundle.LoadAsset <GameObject>("WarpBattery") as GameObject;

            Utility.AddBasicComponents(ref warpCannonBattery, "WarpBattery");
            warpCannonBattery.AddComponent <Pickupable>();
            warpCannonBattery.AddComponent <Battery>();
            warpCannonBattery.AddComponent <TechTag>().type = warpBatteryTechType;

            CustomPrefabHandler.customPrefabs.Add(new CustomPrefab("WarpBattery", "WorldEntities/Tools/WarpBattery", warpCannonBattery, warpBatteryTechType));

            // Load Warp Cannon
            var warpCannon = AssetBundle.LoadAsset <GameObject>("WarpCannon");

            Utility.AddBasicComponents(ref warpCannon, WARP_CANNON_CLASS_ID);
            warpCannon.AddComponent <Pickupable>();
            warpCannon.AddComponent <TechTag>().type = warpCannonTechType;

            var fabricating = warpCannon.FindChild("3rd person model").AddComponent <VFXFabricating>();

            fabricating.localMinY   = -0.4f;
            fabricating.localMaxY   = 0.2f;
            fabricating.posOffset   = new Vector3(-0.054f, 0.223f, -0.06f);
            fabricating.eulerOffset = new Vector3(-44.86f, 90f, 0f);
            fabricating.scaleFactor = 1;

            var energyMixin = warpCannon.AddComponent <EnergyMixin>();

            energyMixin.defaultBattery      = warpBatteryTechType;
            energyMixin.storageRoot         = warpCannon.FindChild("3rd person model").AddComponent <ChildObjectIdentifier>();
            energyMixin.compatibleBatteries = new List <TechType> {
                warpBatteryTechType
            };
            energyMixin.allowBatteryReplacement = true;
            energyMixin.batteryModels           = (new List <EnergyMixin.BatteryModels>()
            {
                new EnergyMixin.BatteryModels()
                {
                    techType = warpBatteryTechType,
                    model = warpCannonBattery
                }
            }).ToArray();

            var warpCannonComponent = warpCannon.AddComponent <WarpCannon>();

            warpCannonComponent.Init();
            warpCannonComponent.mainCollider             = warpCannon.AddComponent <BoxCollider>();
            warpCannonComponent.ikAimRightArm            = true;
            warpCannonComponent.useLeftAimTargetOnPlayer = true;

            CustomPrefabHandler.customPrefabs.Add(new CustomPrefab(WARP_CANNON_CLASS_ID, "WorldEntities/Tools/WarpCannon", warpCannon, warpCannonTechType));

            // Load Sprites
            var warpCannonSprite  = AssetBundle.LoadAsset <Sprite>("Warp_Cannon");
            var warpScalesSprite  = AssetBundle.LoadAsset <Sprite>("Warp_Scale");
            var warpBatterySprite = AssetBundle.LoadAsset <Sprite>("Warp_Battery");

            CustomSpriteHandler.customSprites.Add(new CustomSprite(warpCannonTechType, warpCannonSprite));
            CustomSpriteHandler.customSprites.Add(new CustomSprite(warpScalesTechType, warpScalesSprite));
            CustomSpriteHandler.customSprites.Add(new CustomSprite(warpBatteryTechType, warpBatterySprite));
        }
Exemplo n.º 6
0
 public static void Patch()
 {
     try
     {
         Log.Info("Started loading");
         Config.Load();
         var configChanged = Config.TryGet(ref _x, "Scrap metal", "Size", "x")
                             | Config.TryGet(ref _y, "Scrap metal", "Size", "y")
                             | Config.TryGet(ref _debug, "Enable debugging");
         Log.Debug("Config loaded");
         Log.Debug("Loading asset bundle...");
         var assetBundle = AssetBundle.LoadFromFile(@"./QMods/UnpackIngots/Assets/unpackingotsassets.assets");
         Log.Debug("Asset bundle loaded");
         Log.Debug("Checking config for errors... (0/4)");
         if (_x <= 0)
         {
             _x = 2;
             Config["Scrap metal", "Size", "x"] = _x;
             Log.Warning("Scrap metal size can't be less than 1");
             Log.Info("X was set to 1");
             configChanged = true;
         }
         Log.Debug("Checking config for errors... (1/4)");
         if (_x > 6)
         {
             _x = 2;
             Config["Scrap metal", "Size", "x"] = _x;
             Log.Warning("Scrap metal size can't be greater than 6");
             Log.Info("X was set to 1");
             configChanged = true;
         }
         Log.Debug("Checking config for errors... (2/4)");
         if (_y <= 0)
         {
             _y = 2;
             Config["Scrap metal", "Size", "y"] = _y;
             Log.Warning("Scrap metal size can't be less than 1");
             Log.Info("Y was set to 1");
             configChanged = true;
         }
         Log.Debug("Checking config for errors... (3/4)");
         if (_y > 8)
         {
             _y = 8;
             Config["Scrap metal", "Size", "y"] = _y;
             Log.Warning("Scrap metal size can't be greater than 8");
             Log.Info("Y was set to 1");
             configChanged = true;
         }
         Log.Debug("Checking config for errors... (4/4)");
         Log.Debug("Error check complete");
         if (configChanged)
         {
             Log.Debug("Saving config...");
             Config.Save();
             Log.Debug("Config saved");
         }
         Log.Debug("Adding TechTypes... (0/2)");
         var dummy = TechTypePatcher.AddTechType("UIdummyP", "Unpack Plasteel Ingots", "Turn one plasteel ingot into 1 titanium ingot and 2 lithium");
         Log.Debug("Adding TechTypes... (1/2)");
         var dummy2 = TechTypePatcher.AddTechType("UIdummyT", "Unpack Titanium Ingots", "Turn one titanium ingot into 10 titanium");
         Log.Debug("Adding TechTypes... (2/2)");
         Log.Debug("TechTypes added");
         Log.Debug("Loading TechDatas... (0/2)");
         var techData = new TechDataHelper
         {
             _craftAmount = 0,
             _ingredients = new List <IngredientHelper>()
             {
                 new IngredientHelper(TechType.PlasteelIngot, 1)
             },
             _linkedItems = new List <TechType>()
             {
                 TechType.TitaniumIngot,
                 TechType.Lithium,
                 TechType.Lithium
             },
             _techType = dummy
         };
         Log.Debug("Loading TechDatas... (1/2)");
         var techData2 = new TechDataHelper
         {
             _craftAmount = 0,
             _ingredients = new List <IngredientHelper>()
             {
                 new IngredientHelper(TechType.TitaniumIngot, 1)
             },
             _linkedItems = new List <TechType>()
             {
                 TechType.Titanium,
                 TechType.Titanium,
                 TechType.Titanium,
                 TechType.Titanium,
                 TechType.Titanium,
                 TechType.Titanium,
                 TechType.Titanium,
                 TechType.Titanium,
                 TechType.Titanium,
                 TechType.Titanium
             },
             _techType = dummy2
         };
         Log.Debug("Loading TechDatas... (2/2)");
         Log.Debug("TechDatas loaded");
         Log.Debug("Loading Atlas sprites... (0/2)");
         var sprite = SpriteManager.Get(TechType.Lithium);
         Log.Debug("Loading Atlas sprites... (1/2)");
         var sprite2 = SpriteManager.Get(TechType.Titanium);
         Log.Debug("Loading Atlas sprites... (2/2)");
         Log.Debug("Atlas sprites loaded");
         Log.Debug("Loading UnityEngine sprite...");
         var tabsprite = assetBundle.LoadAsset <Sprite>("unpackingotsfabricatortab");
         if (tabsprite == null)
         {
             Log.Error("UnityEngine sprite is null");
         }
         Log.Debug("UnityEngine sprite loaded");
         Log.Debug("Applying Atlas sprites... (0/2)");
         CustomSpriteHandler.customSprites.Add(new CustomSprite(dummy, sprite));
         Log.Debug("Applying Atlas sprites... (1/2)");
         CustomSpriteHandler.customSprites.Add(new CustomSprite(dummy2, sprite2));
         Log.Debug("Applying Atlas sprites... (2/2)");
         Log.Debug("Atlas sprites applied");
         Log.Debug("Linking TechDatas and TechTypes... (0/2)");
         CraftDataPatcher.customTechData.Add(dummy, techData);
         Log.Debug("Linking TechDatas and TechTypes... (1/2)");
         CraftDataPatcher.customTechData.Add(dummy2, techData2);
         Log.Debug("Linking TechDatas and TechTypes... (2/2)");
         Log.Debug("TechDatas and TechTypes linked");
         Log.Debug("Adding Fabricator tab...");
         CraftTreePatcher.customTabs.Add(new CustomCraftTab("Resources/BasicMaterials/UnpackIngots", "Unpack Ingots", CraftScheme.Fabricator, tabsprite));
         Log.Debug("Fabricator tabs added");
         Log.Debug("Adding Fabricator nodes... (0/2)");
         CraftTreePatcher.customNodes.Add(new CustomCraftNode(dummy, CraftScheme.Fabricator, "Resources/BasicMaterials/UnpackIngots/dummy"));
         Log.Debug("Adding Fabricator nodes... (1/2)");
         CraftTreePatcher.customNodes.Add(new CustomCraftNode(dummy2, CraftScheme.Fabricator, "Resources/BasicMaterials/UnpackIngots/dummy2"));
         Log.Debug("Adding Fabricator nodes... (2/2)");
         Log.Debug("Fabricator nodes added");
         Log.Info("Finished loading");
     }
     catch (Exception e)
     {
         Log.e(e);
     }
 }
Exemplo n.º 7
0
 /// <summary>
 /// Loads a custom item
 /// </summary>
 /// <param name="name">Item's internal name</param>
 /// <param name="languageName">Item's display name</param>
 /// <param name="languageTooltip">Item's tooltip</param>
 /// <param name="from">Item's ingredient</param>
 /// <param name="fromstring">Item's ingredient's name</param>
 /// <param name="inassetbundles">What assetbundle the sprite of the item is in</param>
 /// <param name="assetPath">The name of the sprite</param>
 /// <param name="alt_assetPath">The name of the alternative sprite</param>
 public static void Custom(string name, string languageName, string languageTooltip, TechType from, string alt_assetPath, string assetPath, InAssetBundles inassetbundles = InAssetBundles.All)
 {
     try
     {
         var _x              = 1;
         var _y              = 1;
         var _a              = 10;
         var _e              = true;
         var Config          = MI.Config.cfgfile;
         var moreingots      = Load.moreingots;
         var ingotsplus      = Load.ingotsplus;
         var moreingots_salt = Load.moreingots_salt;
         var ingotsplus_salt = Load.ingotsplus_salt;
         var fromstring      = from.ToString();
         Config.TryGet(ref _x, languageName, "Size", "x");
         Config.TryGet(ref _y, languageName, "Size", "y");
         Config.TryGet(ref _a, languageName, "Craft amount");
         Config.TryGet(ref _e, languageName, "Enabled");
         Log.Debug(languageName, Status.Start);
         if (_e == false)
         {
             Log.Debug(languageName, "Item is disabled");
             return;
         }
         Log.Debug(languageName, "Checking config data for errors... (0/6)");
         if (_x <= 0)
         {
             _x = 1;
             Config[languageName, "Size", "x"] = _x;
             Log.Warning(languageName, "X can't be less than 1");
             Log.Info(languageName, "X was set to 1");
         }
         Log.Debug(languageName, "Checking config data for errors... (1/6)");
         if (_x > 6)
         {
             _x = 1;
             Config[languageName, "Size", "x"] = _x;
             Log.Warning(languageName, "X can't be greater than 6");
             Log.Info(languageName, "X was set to 1");
         }
         Log.Debug(languageName, "Checking config data for errors... (2/6)");
         if (_y <= 0)
         {
             _y = 1;
             Config[languageName, "Size", "y"] = _y;
             Log.Warning(languageName, "Y can't be less than 1");
             Log.Info(languageName, "Y was set to 1");
         }
         Log.Debug(languageName, "Checking config data for errors... (3/6)");
         if (_y > 8)
         {
             _y = 1;
             Config[languageName, "Size", "y"] = _y;
             Log.Warning(languageName, "Y can't be greater than 8");
             Log.Info(languageName, "Y was set to 1");
         }
         Log.Debug(languageName, "Checking config data for errors... (4/6)");
         if (_a <= 0)
         {
             _a = 10;
             Config[languageName, "Craft amount"] = _a;
             Log.Warning(languageName, "Craft amount can't be less than 1");
             Log.Info(languageName, "Craft amount was set to 10");
         }
         Log.Debug(languageName, "Checking config data for errors... (5/6)");
         if (_a > 10)
         {
             _a = 10;
             Config[languageName, "Craft amount"] = _a;
             Log.Warning(languageName, "Craft amount can't be greater than 10");
             Log.Info(languageName, "Craft amount was set to 10");
         }
         Log.Debug(languageName, "Checking config data for errors... (6/6)");
         Log.Debug(languageName, "Error check complete");
         MI.Config.Save(languageName);
         Log.Debug(languageName, "Adding TechType...");
         var techType = TechTypePatcher.AddTechType(name, languageName, languageTooltip);
         Log.Debug(languageName, "TechType added");
         Log.Debug(languageName, "Loading TechDatas... (0/2)");
         var techData = new TechDataHelper
         {
             _craftAmount = 1,
             _ingredients = new List <IngredientHelper>()
             {
                 new IngredientHelper(from, _a)
             },
             _techType = techType
         };
         Log.Debug(languageName, "Loading TechDatas... (1/2)");
         var techDataB = new TechDataHelper
         {
             _craftAmount = _a,
             _ingredients = new List <IngredientHelper>()
             {
                 new IngredientHelper(techType, 1)
             },
             _techType = from
         };
         Log.Debug(languageName, "Loading TechDatas... (2/2)");
         Log.Debug(languageName, "TechDatas loaded");
         Log.Debug(languageName, "Adding unlock on start for " + from + "...");
         KnownTechPatcher.unlockedAtStart.Add(from);
         Log.Debug(languageName, "Unlock on start added for " + from);
         Log.Debug(languageName, "Adding TechTypes to the PDA Databank... (0/2)");
         CraftDataPatcher.AddToCustomGroup(TechGroup.Resources, TechCategory.BasicMaterials, techType);
         Log.Debug(languageName, "Adding TechTypes to the PDA Databank... (1/2)");
         CraftDataPatcher.AddToCustomGroup(TechGroup.Resources, TechCategory.BasicMaterials, from);
         Log.Debug(languageName, "Adding TechTypes to the PDA Databank... (2/2)");
         Log.Debug(languageName, "TechTypes added to the PDA Databank");
         Log.Debug(languageName, "Linking TechDatas with TechTypes... (0/2)");
         CraftDataPatcher.customTechData.Add(techType, techData);
         Log.Debug(languageName, "Linking TechDatas with TechTypes... (1/2)");
         CraftDataPatcher.customTechData.Add(from, techDataB);
         Log.Debug(languageName, "Linking TechDatas with TechTypes... (2/2)");
         Log.Debug(languageName, "TechDatas linked with TechTypes");
         Log.Debug(languageName, "Adding Fabricator nodes... (0/2)");
         CraftTreePatcher.customNodes.Add(new CustomCraftNode(techType, CraftScheme.Fabricator, "Resources/Craft/" + name));
         Log.Debug(languageName, "Adding Fabricator nodes... (1/2)");
         CraftTreePatcher.customNodes.Add(new CustomCraftNode(from, CraftScheme.Fabricator, "Resources/Unpack/" + fromstring));
         Log.Debug(languageName, "Adding Fabricator nodes... (2/2)");
         Log.Debug(languageName, "Fabricator nodes added");
         Log.Debug(languageName, "Applying item sizes...");
         CraftDataPatcher.customItemSizes[key : techType] = new Vector2int(_x, _y);
         Log.Debug(languageName, "Item sizes applied");
         Log.Debug(languageName, "Starting sprite loading...");
         if (inassetbundles == InAssetBundles.All)
         {
             if (MI.Config._alttextures)
             {
                 Log.Debug(languageName, "Asset bundle \"moreingots\" selected");
                 Log.Debug(languageName, "Obtaining sprite...");
                 if (moreingots.LoadAsset <Sprite>(alt_assetPath) == null)
                 {
                     Log.Error(languageName, "Sprite is null");
                     Log.Debug(languageName, Status.Stop);
                     return;
                 }
                 var alt_sprite = moreingots.LoadAsset <Sprite>(alt_assetPath);
                 Log.Debug(languageName, "Sprite obtained");
                 Log.Debug(languageName, "Applying sprite...");
                 CustomSpriteHandler.customSprites.Add(new CustomSprite(techType, alt_sprite));
                 Log.Debug(languageName, "Sprite applied");
             }
             else
             {
                 Log.Debug(languageName, "Asset bundle \"yenzen-ingotsplus\" selected");
                 Log.Debug(languageName, "Obtaining sprite...");
                 if (ingotsplus.LoadAsset <Sprite>(assetPath) == null)
                 {
                     Log.Error(languageName, "Sprite is null");
                     Log.Debug(languageName, Status.Stop);
                     return;
                 }
                 var sprite = ingotsplus.LoadAsset <Sprite>(assetPath);
                 Log.Debug(languageName, "Sprite obtained");
                 Log.Debug(languageName, "Applying sprite...");
                 CustomSpriteHandler.customSprites.Add(new CustomSprite(techType, sprite));
                 Log.Debug(languageName, "Sprite applied");
             }
         }
         if (inassetbundles == InAssetBundles.Salt)
         {
             if (MI.Config._alttextures)
             {
                 Log.Debug(languageName, "Asset bundle \"salt-alexejheroytb\" selected");
                 Log.Debug(languageName, "Obtaining sprite...");
                 if (moreingots_salt.LoadAsset <Sprite>(alt_assetPath) == null)
                 {
                     Log.Error(languageName, "Sprite is null");
                     Log.Debug(languageName, Status.Stop);
                     return;
                 }
                 var alt_sprite = moreingots_salt.LoadAsset <Sprite>(alt_assetPath);
                 Log.Debug(languageName, "Sprite obtained");
                 Log.Debug(languageName, "Applying sprite...");
                 CustomSpriteHandler.customSprites.Add(new CustomSprite(techType, alt_sprite));
                 Log.Debug(languageName, "Sprite applied");
             }
             else
             {
                 Log.Debug(languageName, "Asset bundle \"salt-yenzen\" selected");
                 Log.Debug(languageName, "Obtaining sprite...");
                 if (ingotsplus_salt.LoadAsset <Sprite>(assetPath) == null)
                 {
                     Log.Error(languageName, "Sprite is null");
                     Log.Debug(languageName, Status.Stop);
                     return;
                 }
                 var sprite = ingotsplus_salt.LoadAsset <Sprite>(assetPath);
                 Log.Debug(languageName, "Sprite obtained");
                 Log.Debug(languageName, "Applying sprite...");
                 CustomSpriteHandler.customSprites.Add(new CustomSprite(techType, sprite));
                 Log.Debug(languageName, "Sprite applied");
             }
         }
         if (inassetbundles == InAssetBundles.Sulphur)
         {
             Log.Debug(languageName, "Asset bundle \"sulphur\" selected");
             Log.Debug(languageName, "Obtaining sprite...");
             if (sulphur.LoadAsset <Sprite>(assetPath) == null)
             {
                 Log.Error(languageName, "Sprite is null");
                 Log.Debug(languageName, Status.Stop);
                 return;
             }
             var s_sprite = sulphur.LoadAsset <Sprite>(assetPath);
             Log.Debug(languageName, "Sprite obtained");
             Log.Debug(languageName, "Applying sprite...");
             CustomSpriteHandler.customSprites.Add(new CustomSprite(techType, s_sprite));
             Log.Debug(languageName, "Sprite applied");
         }
         Log.Debug(languageName, Status.Stop);
     }
     catch (Exception e)
     {
         Log.e(e);
     }
 }
Exemplo n.º 8
0
        public static void Patch()
        {
            Logger.ClearCustomLog();
            Logger.Debug("Loading start...");

            var ab = AssetBundle.LoadFromFile(
                $"./QMods/{Assembly.GetExecutingAssembly().GetName().Name}/testing.assets");

            Logger.Debug("Bundle name: " + ab.name);

            var cube = ab.LoadAsset <GameObject>("Cube");

            Logger.Debug("Cube name: " + cube.name);

            Utility.AddBasicComponents(ref cube, "Cube");
            Logger.Debug("BasicComponents added!");

            var techType = TechTypePatcher.AddTechType("Cube", "Cube", "Just a funny cube");

            Logger.Debug("TechType created!");

            var constructable = cube.AddComponent <Constructable>();

            constructable.allowedInBase           = true;
            constructable.allowedOnGround         = true;
            constructable.allowedInSub            = true;
            constructable.allowedOnCeiling        = false;
            constructable.allowedOnConstructables = true;
            constructable.allowedOnWall           = true;
            constructable.allowedOutside          = true;
            constructable.techType = techType;
            var model = cube.FindChild("Sphere");

            constructable.model = model;
            var modelname = model?.name ?? "NULL";

            Logger.Debug($"Constructable added! Model: {modelname}");

            var techTag = cube.AddComponent <TechTag>();

            techTag.type = techType;
            Logger.Debug("techTag added!");

            var rb = cube.GetComponent <Rigidbody>();

            Object.DestroyImmediate(rb);
            Logger.Debug("Rigitbody killed!");

            CustomPrefabHandler.customPrefabs.Add(new CustomPrefab("Cube", "Submarine/Build/Cube", cube, techType));
            Logger.Debug("Customprefab added!");

            var techData = new TechDataHelper
            {
                _ingredients = new List <IngredientHelper>()
                {
                    new IngredientHelper(TechType.Titanium, 1)
                },
                _techType = techType
            };

            Logger.Debug("techData added!");

            CraftDataPatcher.customTechData.Add(techType, techData);
            Logger.Debug("techData added to custom list!");

            CraftDataPatcher.customBuildables.Add(techType);
            Logger.Debug("techType added to custom Buildables!");

            CraftDataPatcher.AddToCustomGroup(TechGroup.InteriorModules, TechCategory.InteriorModule, techType);
            Logger.Debug("techType added to the groups!");
        }
Exemplo n.º 9
0
        public static void Patch()
        {
            try
            {
                #region Patching

                var harmony = HarmonyInstance.Create("com.ahk1221.moreseamothupgrades");
                harmony.PatchAll(Assembly.GetExecutingAssembly());

                LanguagePatcher.customLines.Add("Tooltip_VehicleHullModule3", "Enhances diving depth. Does not stack"); // To update conflicts about the maximity.

                #endregion

                #region Extract From Exosuit

                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;

                #endregion

                #region Add TechTypes

                SeamothHullModule4   = TechTypePatcher.AddTechType("SeamothHullModule4", "Seamoth depth module MK4", "Enhances diving depth. Does not stack.");
                SeamothHullModule5   = TechTypePatcher.AddTechType("SeamothHullModule5", "Seamoth depth module MK5", "Enhances diving depth to maximum. Does not stack.");
                SeamothThermalModule = TechTypePatcher.AddTechType("SeamothThermalModule", "Seamoth thermal reactor", "Recharges power cells in hot areas. Doesn't stack.");
                SeamothDrillModule   = TechTypePatcher.AddTechType("SeamothDrillModule", "Seamoth drill module", "Enables the Seamoth to mine resources like the PRAWN Drill Arm.");

                #endregion

                #region Add Recipes

                var seamothHullModule4Recipe = new TechDataHelper()
                {
                    _techType    = SeamothHullModule4,
                    _ingredients = new List <IngredientHelper>()
                    {
                        new IngredientHelper(TechType.VehicleHullModule3, 1),
                        new IngredientHelper(TechType.PlasteelIngot, 1),
                        new IngredientHelper(TechType.Nickel, 2),
                        new IngredientHelper(TechType.AluminumOxide, 3)
                    },
                    _craftAmount = 1
                };

                var seamothHullModule5Recipe = new TechDataHelper()
                {
                    _techType    = SeamothHullModule5,
                    _ingredients = new List <IngredientHelper>()
                    {
                        new IngredientHelper(SeamothHullModule4, 1),
                        new IngredientHelper(TechType.Titanium, 5),
                        new IngredientHelper(TechType.Lithium, 2),
                        new IngredientHelper(TechType.Kyanite, 3)
                    },
                    _craftAmount = 1
                };

                var seamothThermalModuleRecipe = new TechDataHelper()
                {
                    _techType    = SeamothThermalModule,
                    _craftAmount = 1,
                    _ingredients = new List <IngredientHelper>()
                    {
                        new IngredientHelper(TechType.Kyanite, 1),
                        new IngredientHelper(TechType.Polyaniline, 2),
                        new IngredientHelper(TechType.WiringKit, 1)
                    }
                };

                var seamothDrillModuleRecipe = new TechDataHelper()
                {
                    _techType    = SeamothDrillModule,
                    _craftAmount = 1,
                    _ingredients = new List <IngredientHelper>()
                    {
                        new IngredientHelper(TechType.ExosuitDrillArmModule, 1),
                        new IngredientHelper(TechType.Diamond, 2),
                        new IngredientHelper(TechType.Titanium, 2)
                    }
                };

                CraftDataPatcher.customTechData[SeamothHullModule4]   = seamothHullModule4Recipe;
                CraftDataPatcher.customTechData[SeamothHullModule5]   = seamothHullModule5Recipe;
                CraftDataPatcher.customTechData[SeamothThermalModule] = seamothThermalModuleRecipe;
                CraftDataPatcher.customTechData[SeamothDrillModule]   = seamothDrillModuleRecipe;

                CraftTreePatcher.customNodes.Add(new CustomCraftNode(SeamothHullModule4, CraftTree.Type.Workbench, "SeamothMenu/SeamothHullModule4"));
                CraftTreePatcher.customNodes.Add(new CustomCraftNode(SeamothHullModule5, CraftTree.Type.Workbench, "SeamothMenu/SeamothHullModule5"));
                CraftTreePatcher.customNodes.Add(new CustomCraftNode(SeamothThermalModule, CraftTree.Type.SeamothUpgrades, "SeamothModules/SeamothThermalModule"));
                CraftTreePatcher.customNodes.Add(new CustomCraftNode(SeamothDrillModule, CraftTree.Type.SeamothUpgrades, "SeamothModules/SeamothDrillModule"));

                #endregion

                #region Equipment Types

                CraftDataPatcher.customEquipmentTypes[SeamothHullModule4]   = EquipmentType.SeamothModule;
                CraftDataPatcher.customEquipmentTypes[SeamothHullModule5]   = EquipmentType.SeamothModule;
                CraftDataPatcher.customEquipmentTypes[SeamothThermalModule] = EquipmentType.SeamothModule;
                CraftDataPatcher.customEquipmentTypes[SeamothDrillModule]   = EquipmentType.SeamothModule;

                //TODO: SMLHelper: Add CraftDataPatcher.customSlotTypes.
                var slotTypes = (Dictionary <TechType, QuickSlotType>) typeof(CraftData).GetField("slotTypes", BindingFlags.NonPublic | BindingFlags.Static).GetValue(null);
                slotTypes[SeamothDrillModule] = QuickSlotType.Selectable;

                #endregion

                #region Add Prefabs

                CustomPrefabHandler.customPrefabs.Add(new CustomPrefab(
                                                          "SeamothHullModule4",
                                                          "WorldEntities/Tools/SeamothHullModule4",
                                                          SeamothHullModule4,
                                                          GetSeamothHullModuleIV));

                CustomPrefabHandler.customPrefabs.Add(new CustomPrefab(
                                                          "SeamothHullModule5",
                                                          "WorldEntities/Tools/SeamothHullModule5",
                                                          SeamothHullModule5,
                                                          GetSeamothHullModuleV));

                CustomPrefabHandler.customPrefabs.Add(new CustomPrefab(
                                                          "SeamothThermalModule",
                                                          "WorldEntities/Tools/SeamothThermalModule",
                                                          SeamothThermalModule,
                                                          GetSeamothThermalModule));

                CustomPrefabHandler.customPrefabs.Add(new CustomPrefab(
                                                          "SeamothDrillModule",
                                                          "WorldEntities/Tools/SeamothDrillModule",
                                                          SeamothDrillModule,
                                                          GetSeamothDrillModule));

                #endregion

                #region Add Sprites

                var depthSprite = SpriteManager.Get(TechType.VehicleHullModule3);

                CustomSpriteHandler.customSprites.Add(new CustomSprite(SeamothHullModule4, depthSprite));
                CustomSpriteHandler.customSprites.Add(new CustomSprite(SeamothHullModule5, depthSprite));

                var thermalReactorSprite = SpriteManager.Get(TechType.ExosuitThermalReactorModule);

                CustomSpriteHandler.customSprites.Add(new CustomSprite(SeamothThermalModule, thermalReactorSprite));

                var assetBundle = AssetBundle.LoadFromFile(@"./QMods/MoreSeamothUpgrades/moreseamothupgrades.assets");
                var drillSprite = assetBundle.LoadAsset <Sprite>("SeamothDrill");

                CustomSpriteHandler.customSprites.Add(new CustomSprite(SeamothDrillModule, drillSprite));

                #endregion

                Console.WriteLine("[MoreSeamothUpgrades] Succesfully patched!");
            }
            catch (Exception e)
            {
                Console.WriteLine("[MoreSeamothUpgrades] Caught exception! " + e.InnerException.Message);
                Console.WriteLine(e.InnerException.StackTrace);
            }
        }
Exemplo n.º 10
0
        public static void Patch()
        {
            Debug.Log("Patching base clocks");
            QPatch.harmony = HarmonyInstance.Create("com.baseclocks.mod");
            BaseClocksConfig.Load();
            OptionsPanelHandler.RegisterModOptions(new BaseClocksModOptions());

            AssetBundle assetBundle = AssetBundle.LoadFromFile("./QMods/BaseClocks/clocks");

            s_ModPath = "./QMods/BaseClocks";

            GameObject sign     = Resources.Load <GameObject>("Submarine/Build/Sign");
            Font       signFont = sign.GetComponentInChildren <Text>(true).font;

            Shader   marmosetUber    = Shader.Find("MarmosetUBER");
            Material marmosetUberMat = new Material(marmosetUber);

#if LOG
            string desktopPath = System.Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
            string fullpath    = string.Concat(desktopPath, "/MarmosetUBERProperties.txt");

            using (System.IO.TextWriter tw = System.IO.File.CreateText(fullpath))
            {
                PrintShaderProperty("_Color", marmosetUberMat, tw);
                PrintShaderProperty("_ReflectColor", marmosetUberMat, tw);
                tw.Line();

                PrintShaderProperty("_Cube", marmosetUberMat, tw);
                PrintShaderProperty("_MainTex", marmosetUberMat, tw);
                tw.Line();

                PrintShaderProperty("_MarmoSpecEnum", marmosetUberMat, tw);
                tw.Line();

                PrintShaderProperty("_Roughness", marmosetUberMat, tw);
                PrintShaderProperty("_Glossiness", marmosetUberMat, tw);
                PrintShaderProperty("_Gloss", marmosetUberMat, tw);
                PrintShaderProperty("_Metal", marmosetUberMat, tw);
                PrintShaderProperty("_Metallic", marmosetUberMat, tw);
                PrintShaderProperty("_Metalness", marmosetUberMat, tw);
                PrintShaderProperty("_Metallicness", marmosetUberMat, tw);
                PrintShaderProperty("_ReflectColor", marmosetUberMat, tw);
                PrintShaderProperty("_Reflectivity", marmosetUberMat, tw);
                tw.Line();

                PrintShaderProperty("_Spec", marmosetUberMat, tw);
                PrintShaderProperty("_SpecTex", marmosetUberMat, tw);
                PrintShaderProperty("_SpecColor", marmosetUberMat, tw);
                PrintShaderProperty("_SpecColor2", marmosetUberMat, tw);
                PrintShaderProperty("_SpecColor3", marmosetUberMat, tw);
                PrintShaderProperty("_SpecCubeIBL", marmosetUberMat, tw);
                PrintShaderProperty("_SpecInt", marmosetUberMat, tw);
                PrintShaderProperty("_SpecGlossMap", marmosetUberMat, tw);
                PrintShaderProperty("_Specular", marmosetUberMat, tw);
                PrintShaderProperty("_Shininess", marmosetUberMat, tw);
                PrintShaderProperty("_SpecularAmount", marmosetUberMat, tw);
                tw.Line();

                PrintShaderProperty("_EnableGlow", marmosetUberMat, tw);
                PrintShaderProperty("_SIGMap", marmosetUberMat, tw);

                PrintShaderProperty("_AffectedByDayNightCycle", marmosetUberMat, tw);
                tw.Line();

                PrintShaderProperty("_SelfIllumination", marmosetUberMat, tw);
                PrintShaderProperty("_EnableGlow", marmosetUberMat, tw);
                PrintShaderProperty("_GlowColor", marmosetUberMat, tw);
                PrintShaderProperty("_Illum", marmosetUberMat, tw);
                PrintShaderProperty("_GlowStrength", marmosetUberMat, tw);
                PrintShaderProperty("_GlowStrengthNight", marmosetUberMat, tw);

                tw.Line();

                PrintShaderProperty("_Fresnel", marmosetUberMat, tw);
                PrintShaderProperty("_FresnelFade", marmosetUberMat, tw);

                tw.Line();

                PrintShaderProperty("_BaseLight", marmosetUberMat, tw);
                PrintShaderProperty("_AO", marmosetUberMat, tw);
                tw.Close();
            }
#endif

            //Analogue clock
            GameObject analogueBaseClock = assetBundle.LoadAsset <GameObject>("Actual Time Analog Clock UGUI");

            SMLHelper.V2.Utility.PrefabUtils.AddBasicComponents(ref analogueBaseClock, k_ClassID);

            ReplaceMaterialShader(analogueBaseClock, marmosetUber, true, true);

            ApplySkyApplier(analogueBaseClock);

            Constructable constructable = analogueBaseClock.AddComponent <Constructable>();

            constructable.allowedOnWall   = true;
            constructable.allowedInSub    = true;
            constructable.allowedOnGround = false;
            constructable.allowedOutside  = false;
            constructable.model           = analogueBaseClock.transform.GetChild(0).gameObject;

            DestroyPhysicsComponents(analogueBaseClock);

            ConstructableBounds constructableBounds = analogueBaseClock.AddComponent <ConstructableBounds>();

            TechTag           techTag = analogueBaseClock.AddComponent <TechTag>();
            BaseAnalogueClock actualTimeAnalogueClock = analogueBaseClock.AddComponent <BaseAnalogueClock>();

            actualTimeAnalogueClock.HourHand   = analogueBaseClock.transform.GetChild(1).GetChild(1);
            actualTimeAnalogueClock.MinuteHand = analogueBaseClock.transform.GetChild(1).GetChild(2);
            actualTimeAnalogueClock.SecondHand = analogueBaseClock.transform.GetChild(1).GetChild(3);

            TechData techData = new TechData();
            techData.Ingredients.Add(new Ingredient(TechType.Titanium, 1));
            techData.Ingredients.Add(new Ingredient(TechType.CopperWire, 1));

            BaseClockBuildable analogueClockBuildable = new BaseClockBuildable(k_ClassID, "Analogue Clock", "An Analogue clock.", "analogueClock.png", analogueBaseClock.gameObject, techData);
            analogueClockBuildable.Patch();
            Debug.Log("Patched analogueClockBuildable");

            //Digital clock
            GameObject digitalBaseClock = assetBundle.LoadAsset <GameObject>("Actual Time Digital Clock UGUI");

            SMLHelper.V2.Utility.PrefabUtils.AddBasicComponents(ref digitalBaseClock, k_ClassID_Digital);

            ReplaceMaterialShader(digitalBaseClock, marmosetUber);

            ApplySkyApplier(digitalBaseClock);

            constructable = digitalBaseClock.AddComponent <Constructable>();

            constructable.allowedOnWall   = true;
            constructable.allowedInSub    = true;
            constructable.allowedOnGround = false;
            constructable.allowedOutside  = false;
            constructable.model           = digitalBaseClock.transform.GetChild(0).gameObject;

            DestroyPhysicsComponents(digitalBaseClock);

            constructableBounds = digitalBaseClock.AddComponent <ConstructableBounds>();

            techTag = digitalBaseClock.AddComponent <TechTag>();

            BaseDigitalClock digitalClock = digitalBaseClock.AddComponent <BaseDigitalClock>();
            digitalClock.Text       = digitalBaseClock.transform.GetChild(1).GetChild(0).GetComponent <Text>();
            digitalClock.PeriodText = digitalBaseClock.transform.GetChild(1).GetChild(1).GetComponent <Text>();
            digitalClock.SetFont(signFont);

            techData = new TechData();
            techData.Ingredients.Add(new Ingredient(TechType.Titanium, 1));
            techData.Ingredients.Add(new Ingredient(TechType.CopperWire, 1));

            LanguageHandler.SetLanguageLine(BaseClock.k_SetGameTime, "Set to Normal Time");
            LanguageHandler.SetLanguageLine(BaseClock.k_SetSystemTime, "Set to System Time");

            BaseClockBuildable digitalClockBuildable = new BaseClockBuildable(k_ClassID_Digital, "Digital Clock", "A Digital clock.", "digitalClock.png", digitalClock.gameObject, techData);
            digitalClockBuildable.Patch();
            Debug.Log("Patched digitalClockBuildable");

#if INCLUDE_TEST_BUILDABLES
            //Material balls.
            techType = TechTypePatcher.AddTechType(k_ClassID_Materials, "Material Balls", "Material Test");

            GameObject materialBalls = assetBundle.LoadAsset <GameObject>("Material Balls");

            Utility.AddBasicComponents(ref materialBalls, k_ClassID_Materials);
            DestroyPhysicsComponents(materialBalls);

            constructable = materialBalls.AddComponent <Constructable>();

            constructable.allowedOnWall           = false;
            constructable.allowedInSub            = true;
            constructable.allowedOnGround         = true;
            constructable.allowedOnCeiling        = false;
            constructable.allowedOnConstructables = false;
            constructable.allowedOutside          = true;
            constructable.model = materialBalls.transform.GetChild(0).gameObject;

            constructable.name = "Material Balls";

            constructableBounds = materialBalls.AddComponent <ConstructableBounds>();

            techTag      = materialBalls.AddComponent <TechTag>();
            techTag.type = techType;

            ReplaceMaterialShader(materialBalls, marmosetUber, false, true);
            AddSkyApplier(materialBalls);

            materialBalls.AddComponent <MaterialLogger>();

            CustomPrefabHandler.customPrefabs.Add(new CustomPrefab(k_ClassID_Materials, "Submarine/Build/MaterialBalls", materialBalls, techType));

            techDataHelper = new TechDataHelper();
            techDataHelper._ingredients = new List <IngredientHelper>();
            techDataHelper._ingredients.Add(new IngredientHelper(TechType.Titanium, 1));
            techDataHelper._techType = techType;

            CraftDataPatcher.customTechData.Add(techType, techDataHelper);
            CraftDataPatcher.customBuildables.Add(techType);

            dictionary[TechGroup.InteriorModules][TechCategory.InteriorModule].Add(techType);

            //Texture test.
            techType = TechTypePatcher.AddTechType(k_ClassID_TextureTest, "Texture Test", "Texture Test");

            GameObject textureTest = assetBundle.LoadAsset <GameObject>("Texture Test");

            Utility.AddBasicComponents(ref textureTest, k_ClassID_TextureTest);
            DestroyPhysicsComponents(textureTest);

            constructable = textureTest.AddComponent <Constructable>();

            constructable.allowedOnWall           = true;
            constructable.allowedInSub            = true;
            constructable.allowedOnGround         = false;
            constructable.allowedOnCeiling        = false;
            constructable.allowedOnConstructables = false;
            constructable.allowedOutside          = false;
            constructable.model = textureTest.transform.GetChild(0).gameObject;

            constructable.name = "Texture Test";

            constructableBounds = textureTest.AddComponent <ConstructableBounds>();

            techTag      = textureTest.AddComponent <TechTag>();
            techTag.type = techType;

            ReplaceMaterialShader(textureTest, marmosetUber, true, true);

            AddSkyApplier(textureTest);

            textureTest.AddComponent <MaterialLogger>();

            CustomPrefabHandler.customPrefabs.Add(new CustomPrefab(k_ClassID_TextureTest, "Submarine/Build/TextureTest", textureTest, techType));

            techDataHelper = new TechDataHelper();
            techDataHelper._ingredients = new List <IngredientHelper>();
            techDataHelper._ingredients.Add(new IngredientHelper(TechType.Titanium, 1));
            techDataHelper._techType = techType;

            CraftDataPatcher.customTechData.Add(techType, techDataHelper);
            CraftDataPatcher.customBuildables.Add(techType);

            dictionary[TechGroup.InteriorModules][TechCategory.InteriorModule].Add(techType);
#endif
#if LOG
            //Print small locker objects and components to desktop.
            fullpath = string.Concat(desktopPath, "/FabricatorComponents.txt");

            GameObject fabricator     = Resources.Load <GameObject>("Submarine/Build/Fabricator");
            GameObject medicalCabinet = Resources.Load <GameObject>("Submarine/Build/MedicalCabinet");

            if (fabricator != null)
            {
                using (System.IO.TextWriter tw = System.IO.File.CreateText(fullpath))
                {
                    PrintComponents(fabricator, tw);
                    tw.Close();
                }
                MaterialLogger.LogMaterialsToDesktop(fabricator);
            }

            fullpath = string.Concat(desktopPath, "/SignComponents.txt");

            if (sign != null)
            {
                using (System.IO.TextWriter tw = System.IO.File.CreateText(fullpath))
                {
                    PrintComponents(sign, tw);
                    tw.Close();
                }
            }

            fullpath = string.Concat(desktopPath, "/MedicalCabinetComponents.txt");
            if (medicalCabinet != null)
            {
                using (System.IO.TextWriter tw = System.IO.File.CreateText(fullpath))
                {
                    PrintComponents(medicalCabinet, tw);
                    tw.Close();
                }
                MaterialLogger.LogMaterialsToDesktop(medicalCabinet);
            }

            MaterialLogger.LogMaterialsToDesktop(analogueBaseClock);


            Resources.UnloadAsset(sign);
            Resources.UnloadAsset(fabricator);
            Resources.UnloadAsset(medicalCabinet);
            MonoBehaviour.Destroy(marmosetUberMat);
#endif
        }
Exemplo n.º 11
0
        public static void ApplyTechData()
        {
            if (ingredients.Count == 0)
            {
                Log.Warning(name, "The item has no valid ingredients and will not be able to be crafted!");
            }
            if (ingredients.Count == 1)
            {
                techData = new TechDataHelper
                {
                    _craftAmount = 1,
                    _ingredients = new List <IngredientHelper>()
                    {
                        ingredients.GetLast()
                    },
                    _techType = techType
                };
            }
            if (ingredients.Count == 2)
            {
                var i1 = ingredients.GetLast();
                ingredients.Remove(i1);

                techData = new TechDataHelper
                {
                    _craftAmount = 1,
                    _ingredients = new List <IngredientHelper>()
                    {
                        i1,
                        ingredients.GetLast()
                    },
                    _techType = techType
                };
            }
            if (ingredients.Count == 3)
            {
                var i1 = ingredients.GetLast();
                ingredients.Remove(i1);
                var i2 = ingredients.GetLast();
                ingredients.Remove(i2);

                techData = new TechDataHelper
                {
                    _craftAmount = 1,
                    _ingredients = new List <IngredientHelper>()
                    {
                        i1,
                        i2,
                        ingredients.GetLast()
                    },
                    _techType = techType
                };
            }
            if (ingredients.Count == 4)
            {
                var i1 = ingredients.GetLast();
                ingredients.Remove(i1);
                var i2 = ingredients.GetLast();
                ingredients.Remove(i2);
                var i3 = ingredients.GetLast();
                ingredients.Remove(i3);

                techData = new TechDataHelper
                {
                    _craftAmount = 1,
                    _ingredients = new List <IngredientHelper>()
                    {
                        i1,
                        i2,
                        i3,
                        ingredients.GetLast()
                    },
                    _techType = techType
                };
            }
            if (ingredients.Count == 5)
            {
                var i1 = ingredients.GetLast();
                ingredients.Remove(i1);
                var i2 = ingredients.GetLast();
                ingredients.Remove(i2);
                var i3 = ingredients.GetLast();
                ingredients.Remove(i3);
                var i4 = ingredients.GetLast();
                ingredients.Remove(i4);

                techData = new TechDataHelper
                {
                    _craftAmount = 1,
                    _ingredients = new List <IngredientHelper>()
                    {
                        i1,
                        i2,
                        i3,
                        i4,
                        ingredients.GetLast()
                    },
                    _techType = techType
                };
            }
            CraftDataPatcher.customTechData.Add(techType, techData);
        }