Example #1
0
 public static void OnRecipePickerReturn_Prefix(UIAssemblerWindow __instance, RecipeProto recipe)
 {
     if (SimulatedWorld.Initialized)
     {
         LocalPlayer.SendPacketToLocalStar(new AssemblerRecipeEventPacket(GameMain.data.localPlanet.factoryIndex, __instance.assemblerId, recipe.ID));
     }
 }
Example #2
0
        private void AddAdvancedCopper()
        {
            Logger.LogInfo("AddAdvancedCopper Start");
            RecipeProto advCopper = orgRecipe.Copy();

            advCopper.ID           = 621;
            advCopper.Name         = "铜锭(高效)";
            advCopper.name         = advCopper.Name.Translate();
            advCopper.Description  = "您可以通过加水生成更多的铸锭。";
            advCopper.description  = advCopper.Description.Translate();
            advCopper.Items        = new int[] { 1002, 1000 };
            advCopper.ItemCounts   = new int[] { 6, 4 };
            advCopper.Results      = new int[] { 1104 };
            advCopper.ResultCounts = new int[] { 15 };
            advCopper.Explicit     = true;
            advCopper.TimeSpend    = (60 * 12);
            advCopper.GridIndex    = 1709;
            advCopper.SID          = advCopper.GridIndex.ToString();
            advCopper.sid          = advCopper.GridIndex.ToString().Translate();
            Traverse.Create(advCopper).Field("_iconSprite").SetValue(this.copperIcon);
            var copperIngotItem = LDB.items.Select(1104);

            copperIngotItem.recipes.Add(advCopper);
            LDBTool.PostAddProto(ProtoType.Recipe, advCopper);
            Logger.LogInfo("AddAdvancedCopper End");
        }
Example #3
0
            static bool Prefix(UIReplicatorWindow __instance, ref RecipeProto ___selectedRecipe, ref Text ___multiValueText)
            {
                if (___selectedRecipe == null)
                {
                    return(false);
                }

                var stepModifier = 1;

                if (Input.GetKey(KeyCode.LeftControl))
                {
                    stepModifier = 10;
                }
                if (Input.GetKey(KeyCode.LeftShift))
                {
                    stepModifier = 100;
                }

                if (!__instance.multipliers.ContainsKey(___selectedRecipe.ID))
                {
                    __instance.multipliers[___selectedRecipe.ID] = 1;
                }

                int num = __instance.multipliers[___selectedRecipe.ID] - 1 * stepModifier;

                if (num < 1)
                {
                    num = 1;
                }

                __instance.multipliers[___selectedRecipe.ID] = num;
                ___multiValueText.text = num.ToString() + "x";

                return(false);
            }
Example #4
0
        private void AddAdvancedIron()
        {
            Logger.LogInfo("AddAdvancedIron Start");
            RecipeProto advIron = orgRecipe.Copy();

            advIron.ID           = 620;
            advIron.Name         = "铁锭(高效)";
            advIron.name         = advIron.Name.Translate();
            advIron.Description  = "您可以通过加水生成更多的铸锭。";
            advIron.description  = advIron.Description.Translate();
            advIron.Items        = new int[] { 1001, 1000 };
            advIron.ItemCounts   = new int[] { 6, 4 };
            advIron.Results      = new int[] { 1101 };
            advIron.ResultCounts = new int[] { 15 };
            advIron.Explicit     = true;
            advIron.TimeSpend    = (60 * 12);
            advIron.GridIndex    = 1708;
            advIron.SID          = advIron.GridIndex.ToString();
            advIron.sid          = advIron.GridIndex.ToString().Translate();
            Traverse.Create(advIron).Field("_iconSprite").SetValue(this.ironIcon);
            var ironIngotItem = LDB.items.Select(1101);

            ironIngotItem.recipes.Add(advIron);
            LDBTool.PostAddProto(ProtoType.Recipe, advIron);
            Logger.LogInfo("AddAdvancedIron End");
        }
 public override void ProcessPacket(LaboratoryUpdateEventPacket packet, NebulaConnection conn)
 {
     LabComponent[] pool = GameMain.galaxy.PlanetById(packet.PlanetId)?.factory?.factorySystem?.labPool;
     if (pool != null && packet.LabIndex != -1 && packet.LabIndex < pool.Length && pool[packet.LabIndex].id != -1)
     {
         if (packet.ProductId == -3)
         {
             //Widthdraw produced cubes
             pool[packet.LabIndex].produced[0] = 0;
         }
         else if (packet.ProductId == -2)
         {
             //Research recipe reseted
             pool[packet.LabIndex].SetFunction(false, 0, 0, GameMain.galaxy.PlanetById(packet.PlanetId)?.factory?.entitySignPool);
         }
         else if (packet.ProductId == -1)
         {
             //Center chenged to research-mode
             pool[packet.LabIndex].SetFunction(true, 0, GameMain.data.history.currentTech, GameMain.galaxy.PlanetById(packet.PlanetId)?.factory?.entitySignPool);
         }
         else
         {
             //Cube Recipe changed
             int[]       matrixIds   = LabComponent.matrixIds;
             RecipeProto recipeProto = LDB.items.Select(matrixIds[packet.ProductId]).maincraft;
             pool[packet.LabIndex].SetFunction(false, (recipeProto == null) ? 0 : recipeProto.ID, 0, GameMain.galaxy.PlanetById(packet.PlanetId)?.factory?.entitySignPool);
         }
         GameMain.galaxy.PlanetById(packet.PlanetId)?.factory?.factorySystem?.SyncLabFunctions(GameMain.mainPlayer, packet.LabIndex);
     }
 }
Example #6
0
        /// <summary>
        /// Registers a RecipeProto
        /// </summary>
        /// <param name="id">UNIQUE id of your recipe</param>
        /// <param name="type">Recipe type</param>
        /// <param name="time">Time in ingame ticks. How long item is being made</param>
        /// <param name="input">Array of input IDs</param>
        /// <param name="inCounts">Array of input COUNTS</param>
        /// <param name="output">Array of output IDs</param>
        /// <param name="outCounts">Array of output COUNTS</param>
        /// <param name="description">LocalizedKey of description of this item</param>
        /// <param name="techID">Tech id, which unlock this recipe</param>
        public static void registerRecipe(int id, ERecipeType type, int time, int[] input, int[] inCounts,
                                          int[] output,
                                          int[] outCounts, string description, int techID = 1)
        {
            if (output.Length > 0)
            {
                ItemProto first = items[output[0]];
                TechProto tech  = LDB.techs.Select(techID);

                RecipeProto proto = new RecipeProto
                {
                    Type         = type,
                    Handcraft    = true,
                    TimeSpend    = time,
                    Items        = input,
                    ItemCounts   = inCounts,
                    Results      = output,
                    ResultCounts = outCounts,
                    Description  = description,
                    GridIndex    = first.GridIndex,
                    IconPath     = first.IconPath,
                    Name         = first.Name + "Recipe",
                    preTech      = tech,
                    ID           = id
                };

                LDBTool.PreAddProto(ProtoType.Recipe, proto);
                recipes.Add(id, proto);
            }
        }
        private static void PostLoad()
        {
            var bundle = AssetBundle.LoadFromStream(Assembly.GetExecutingAssembly()
                                                    .GetManifestResourceStream("ProtoRegister.resources"));
            var iconSapling = bundle.LoadAsset <Sprite>("iconSapling");

            var itemSapling = new ItemProto {
                Name        = "sapling",
                ID          = 9150,
                GridIndex   = 1506,
                Type        = EItemType.Resource,
                StackSize   = 200,
                Description = "",
                DescFields  = new [] { EItemDescType.MadeIn }.ToIntArray()
            }.SetIconSprite(iconSapling);

            ProtoRegister.RegisterItem(itemSapling);

            var recipeSapling = new RecipeProto {
                Name         = "sapling",
                ID           = 220,
                GridIndex    = 1610,
                Type         = ERecipeType.Assemble,
                Items        = new[] { 1030 },
                ItemCounts   = new[] { 1 },
                Results      = new[] { itemSapling.ID },
                ResultCounts = new[] { 5 },
                TimeSpend    = 30,
                Handcraft    = true,
                Description  = "",
                preTech      = LDB.techs.Select(1121)
            }.SetIconSprite(iconSapling);

            ProtoRegister.RegisterRecipe(recipeSapling);
        }
Example #8
0
        public void AddSmelterMk2Data()
        {
            var smelter  = LDB.items.Select(2302);
            var smelterr = LDB.recipes.Select(56);

            // Load the required technology to access it
            var preTechSmelterMk2 = LDB.techs.Select(1202);

            // Copy the Protos to a new Smelter MK II building
            ItemProto   smelterMk2  = smelter.Copy();
            RecipeProto smelterMk2r = smelterr.Copy();

            Traverse.Create(smelterMk2).Field("_iconSprite").SetValue(smelter.iconSprite);
            Traverse.Create(smelterMk2r).Field("_iconSprite").SetValue(smelterr.iconSprite);

            smelterMk2r.ID          = 10001;
            smelterMk2r.Name        = "Smelter MK. II";
            smelterMk2r.name        = "Smelter MK. II";
            smelterMk2r.Description = "1.5x the speed of a Smelter";
            smelterMk2r.description = "1.5x the speed of a Smelter";
            smelterMk2r.Items       = new int[] { 2302, 1107, 1303, 1202 }; // The items required to craft it
            //smelterMk2r.Items = new int[] { 1001 };   // The items required to craft it
            smelterMk2r.ItemCounts = new int[] { 1, 4, 4, 8 };
            //smelterMk2r.ItemCounts = new int[] { 1 };
            smelterMk2r.Results    = new int[] { 10001 }; // The result (Smelter MK II)
            smelterMk2r.GridIndex  = 2701;                // Where the recipe is located on the replicator. Format xyzz where x is the page, y is the row, and zz is the column
            smelterMk2r.preTech    = preTechSmelterMk2;   // Set the required technology to be able to access the recipe
            smelterMk2r.SID        = smelterMk2r.GridIndex.ToString();
            smelterMk2r.sid        = smelterMk2r.GridIndex.ToString();
            smelterMk2.Name        = "Smelter MK. II";
            smelterMk2.name        = "Smelter MK. II";
            smelterMk2.Description = "1.5x the speed of a Smelter";
            smelterMk2.description = "1.5x the speed of a Smelter";
            smelterMk2.ID          = 10001;
            smelterMk2.makes       = new List <RecipeProto>();
            smelterMk2.BuildIndex  = 10001;
            smelterMk2.GridIndex   = smelterMk2r.GridIndex;
            smelterMk2.handcraft   = smelterMk2r;
            smelterMk2.maincraft   = smelterMk2r;
            smelterMk2.handcrafts  = new List <RecipeProto>()
            {
                smelterMk2r
            };
            smelterMk2.recipes = new List <RecipeProto>()
            {
                smelterMk2r
            };
            smelterMk2.prefabDesc                     = smelter.prefabDesc.Copy();
            smelterMk2.prefabDesc.modelIndex          = smelterMk2.ModelIndex;
            smelterMk2.prefabDesc.isAssembler         = true;
            smelterMk2.prefabDesc.assemblerSpeed      = 15000; // default is 10000
            smelterMk2.prefabDesc.assemblerRecipeType = ERecipeType.Smelt;
            smelterMk2.prefabDesc.idleEnergyPerTick   = 250;   // desired watts / 60
            smelterMk2.prefabDesc.workEnergyPerTick   = 10667; // desired watts / 60

            LDBTool.PostAddProto(ProtoType.Recipe, smelterMk2r);
            LDBTool.PostAddProto(ProtoType.Item, smelterMk2);
        }
Example #9
0
            static bool Prefix(UIReplicatorWindow __instance, RecipeProto ___selectedRecipe, MechaForge ___mechaForge)
            {
                if (___selectedRecipe == null)
                {
                    return(false);
                }

                if (!___selectedRecipe.Handcraft)
                {
                    UIRealtimeTip.Popup("该配方".Translate() + ___selectedRecipe.madeFromString + "生产".Translate(), true, 0);
                }
                else
                {
                    int id = ___selectedRecipe.ID;
                    if (!GameMain.history.RecipeUnlocked(id))
                    {
                        UIRealtimeTip.Popup("配方未解锁".Translate(), true, 0);
                    }
                    else
                    {
                        int num = ___mechaForge.PredictTaskCount(___selectedRecipe.ID, 500);

                        var count = 1;

                        if (Input.GetKey(KeyCode.LeftControl))
                        {
                            count *= 10;
                        }
                        if (Input.GetKey(KeyCode.LeftShift))
                        {
                            count *= 100;
                        }
                        if (Input.GetKey(KeyCode.LeftAlt))
                        {
                            count *= num;
                        }

                        if (count > num)
                        {
                            count = num;
                        }
                        if (count == 0)
                        {
                            UIRealtimeTip.Popup("材料不足".Translate(), true, 0);
                        }
                        else if (___mechaForge.AddTask(id, count) == null)
                        {
                            UIRealtimeTip.Popup("材料不足".Translate(), true, 0);
                        }
                        else
                        {
                            GameMain.history.RegFeatureKey(1000104);
                        }
                    }
                }

                return(false);
            }
Example #10
0
        public void AddStorage4Data()
        {
            var storage2  = LDB.items.Select(2102);
            var storage2r = LDB.recipes.Select(91);

            // Load the required technology to access it
            var preTechStorage4 = LDB.techs.Select(1605);

            // Copy the Protos to a new Storage Mk III building
            ItemProto   storage4  = storage2.Copy();
            RecipeProto storage4r = storage2r.Copy();

            Traverse.Create(storage4).Field("_iconSprite").SetValue(storage2.iconSprite);
            Traverse.Create(storage4r).Field("_iconSprite").SetValue(storage2.iconSprite);

            storage4r.ID          = 302;
            storage4r.Name        = "Storage MK. IV";
            storage4r.name        = "Storage MK. IV";
            storage4r.Description = "Holds twice as many items as a Storage MK. III";
            storage4r.description = "Holds twice as many items as a Storage MK. III";
            //storage4r.Items = new int[] { 1107, 1108 };   // The items required to craft it
            storage4r.Items = new int[] { 1101 };   // The items required to craft it
            //storage4r.ItemCounts = new int[] { 8, 12 };
            storage4r.ItemCounts = new int[] { 1 };
            storage4r.Results    = new int[] { 2104 }; // The result (Storage Mk IV)
            storage4r.GridIndex  = 2602;               // Where the recipe is located on the replicator. Format xyzz where x is the page, y is the row, and zz is the column
            storage4r.preTech    = preTechStorage4;    // Set the required technology to be able to access the recipe
            storage4r.SID        = storage4r.GridIndex.ToString();
            storage4r.sid        = storage4r.GridIndex.ToString();
            storage4.Name        = "Storage MK. IV";
            storage4.name        = "Storage MK. IV";
            storage4.Description = "Holds twice as many items as a Storage MK. III";
            storage4.description = "Holds twice as many items as a Storage MK. III";
            storage4.ID          = 2104;
            storage4.makes       = new List <RecipeProto>();
            storage4.BuildIndex  = 354;
            storage4.GridIndex   = storage4r.GridIndex;
            storage4.handcraft   = storage4r;
            storage4.maincraft   = storage4r;
            storage4.handcrafts  = new List <RecipeProto>()
            {
                storage4r
            };
            storage4.recipes = new List <RecipeProto>()
            {
                storage4r
            };
            storage4.prefabDesc            = storage2.prefabDesc.Copy();
            storage4.prefabDesc.modelIndex = storage4.ModelIndex;
            storage4.prefabDesc.storageCol = 20;
            storage4.prefabDesc.storageRow = 12;
            storage4.prefabDesc.isStorage  = true;

            LDBTool.PostAddProto(ProtoType.Recipe, storage4r);
            LDBTool.PostAddProto(ProtoType.Item, storage4);
        }
Example #11
0
        private void AddRecipe()
        {
            recipeSapling              = LDB.recipes.Select(5).Copy();
            recipeSapling.ID           = 220;
            recipeSapling.GridIndex    = 1610;
            recipeSapling.Type         = ERecipeType.Assemble;
            recipeSapling.Name         = "sapling";
            recipeSapling.name         = recipeSapling.Name.Translate();
            recipeSapling.Items        = new[] { 1030 };
            recipeSapling.ItemCounts   = new[] { 1 };
            recipeSapling.Results      = new[] { itemSapling.ID };
            recipeSapling.ResultCounts = new[] { 5 };
            recipeSapling.TimeSpend    = 30;
            recipeSapling.Description  = "";
            recipeSapling.description  = "";
            recipeSapling.preTech      = LDB.techs.Select(1121);
            Traverse.Create(recipeSapling).Field("_iconSprite").SetValue(_iconSapling);
            LDBTool.PostAddProto(ProtoType.Recipe, recipeSapling);

            recipePlant              = LDB.recipes.Select(23).Copy();
            recipePlant.ID           = 221;
            recipePlant.GridIndex    = 1611;
            recipePlant.Explicit     = true;
            recipePlant.Type         = ERecipeType.Chemical;
            recipePlant.Name         = "plantRecipe";
            recipePlant.name         = recipePlant.Name.Translate();
            recipePlant.Items        = new[] { itemSapling.ID, 1000 };
            recipePlant.ItemCounts   = new[] { 10, 20 };
            recipePlant.Results      = new[] { 1030, 1031 };
            recipePlant.ResultCounts = new[] { 12, 15 };
            recipePlant.TimeSpend    = 3600;
            recipePlant.Description  = "plantRecipeDesc";
            recipePlant.description  = recipePlant.Description.Translate();
            recipePlant.preTech      = LDB.techs.Select(1121);
            Traverse.Create(recipePlant).Field("_iconSprite").SetValue(_iconOriWood);
            LDBTool.PostAddProto(ProtoType.Recipe, recipePlant);

            recipeCharcoal              = LDB.recipes.Select(17).Copy();
            recipeCharcoal.ID           = 222;
            recipeCharcoal.GridIndex    = 1612;
            recipeCharcoal.Type         = ERecipeType.Smelt;
            recipeCharcoal.Name         = "";
            recipeCharcoal.name         = "";
            recipeCharcoal.Items        = new[] { 1030 };
            recipeCharcoal.ItemCounts   = new[] { 2 };
            recipeCharcoal.Results      = new[] { itemCharcoal.ID };
            recipeCharcoal.ResultCounts = new[] { 2 };
            recipeCharcoal.TimeSpend    = 120;
            recipeCharcoal.Description  = "";
            recipeCharcoal.description  = "";
            recipeCharcoal.preTech      = LDB.techs.Select(1401);
            Traverse.Create(recipeCharcoal).Field("_iconSprite").SetValue(_iconCharcoal);
            LDBTool.PostAddProto(ProtoType.Recipe, recipeCharcoal);
        }
Example #12
0
        public void AddTank2Data()
        {
            var tank  = LDB.items.Select(2106);
            var tankr = LDB.recipes.Select(114);

            // Load the required technology to access it
            var preTechTank2 = LDB.techs.Select(1123);

            // Copy the Protos to a new tank Mk III building
            ItemProto   tank2  = tank.Copy();
            RecipeProto tank2r = tankr.Copy();

            Traverse.Create(tank2).Field("_iconSprite").SetValue(tank.iconSprite);
            Traverse.Create(tank2r).Field("_iconSprite").SetValue(tank.iconSprite);

            tank2r.ID          = 10102;
            tank2r.Name        = "Storage tank MK. II";
            tank2r.name        = "Storage tank MK. II";
            tank2r.Description = "Holds 4x the fluid as a Storage tank MK. I";
            tank2r.description = "Holds 4x the fluid as a Storage tank MK. I";
            tank2r.Items       = new int[] { 1106, 1108, 1110 }; // The items required to craft it
            tank2r.ItemCounts  = new int[] { 16, 8, 8 };
            tank2r.Results     = new int[] { 10102 };            // The result (tank Mk III)
            tank2r.GridIndex   = 2602;                           // Where the recipe is located on the replicator. Format xyzz where x is the page, y is the row, and zz is the column
            tank2r.preTech     = preTechTank2;                   // Set the required technology to be able to access the recipe
            tank2r.SID         = tank2r.GridIndex.ToString();
            tank2r.sid         = tank2r.GridIndex.ToString();
            tank2.Name         = "Storage tank MK. II";
            tank2.name         = "Storage tank MK. II";
            tank2.Description  = "Holds 4x the fluid as a Storage tank MK. I";
            tank2.description  = "Holds 4x the fluid as a Storage tank MK. I";
            tank2.ID           = 10102;
            tank2.makes        = new List <RecipeProto>();
            tank2.BuildIndex   = 10102;
            tank2.GridIndex    = tank2r.GridIndex;
            tank2.handcraft    = tank2r;
            tank2.maincraft    = tank2r;
            tank2.handcrafts   = new List <RecipeProto>()
            {
                tank2r
            };
            tank2.recipes = new List <RecipeProto>()
            {
                tank2r
            };
            tank2.prefabDesc                   = tank.prefabDesc.Copy();
            tank2.prefabDesc.modelIndex        = tank2.ModelIndex;
            tank2.prefabDesc.isTank            = true;
            tank2.prefabDesc.fluidStorageCount = 40000;

            LDBTool.PostAddProto(ProtoType.Recipe, tank2r);
            LDBTool.PostAddProto(ProtoType.Item, tank2);
        }
Example #13
0
        /// <summary>
        /// Add list contains to ProtoSet
        /// </summary>
        private static void AddProtosToSet <T>(ProtoSet <T> protoSet, List <Proto> protos) where T : Proto
        {
            var array = protoSet.dataArray;

            protoSet.Init(array.Length + protos.Count);
            for (int i = 0; i < array.Length; i++)
            {
                protoSet.dataArray[i] = array[i];
            }

            for (int i = 0; i < protos.Count; i++)
            {
                protoSet.dataArray[array.Length + i] = protos[i] as T;

                if (protos[i] is ItemProto item)
                {
                    item.index = array.Length + i;
                }

                if (protos[i] is RecipeProto)
                {
                    RecipeProto proto = protos[i] as RecipeProto;
                    if (proto.preTech != null)
                    {
                        ArrayAddItem(ref proto.preTech.UnlockRecipes, proto.ID);
                        ArrayAddItem(ref proto.preTech.unlockRecipeArray, proto);
                    }
                }

                LDBToolPlugin.logger.LogInfo($"Add {protos[i].ID} {protos[i].Name.Translate()} to {protoSet.GetType().Name}.");
            }

            var dataIndices = new Dictionary <int, int>();

            for (int i = 0; i < protoSet.dataArray.Length; i++)
            {
                protoSet.dataArray[i].sid             = protoSet.dataArray[i].SID;
                dataIndices[protoSet.dataArray[i].ID] = i;
            }

            protoSet.dataIndices = dataIndices;
            if (protoSet is StringProtoSet stringProtoSet)
            {
                for (int i = array.Length; i < protoSet.dataArray.Length; i++)
                {
                    stringProtoSet.nameIndices[protoSet.dataArray[i].Name] = i;
                }
            }
        }
Example #14
0
 public static bool OnPlusButtonClick(UIReplicatorWindow __instance, ref RecipeProto ___selectedRecipe, ref Dictionary <int, int> ___multipliers, ref Text ___multiValueText)
 {
     if (___selectedRecipe != null)
     {
         // if the recipe hasn't been loaded before, set the craft amount to default value (1)
         if (!___multipliers.ContainsKey(___selectedRecipe.ID))
         {
             ___multipliers[___selectedRecipe.ID] = 1;
         }
         ___multipliers[___selectedRecipe.ID]++;
         ___multiValueText.text = ___multipliers[___selectedRecipe.ID].ToString() + "x";
         return(false);
     }
     return(false);
 }
Example #15
0
        /// <summary>
        /// 添加多个数据到数据表
        /// </summary>
        private static void AddProtosToSet <T>(ProtoSet <T> protoSet, List <Proto> protos) where T : Proto
        {
            var array = protoSet.dataArray;

            protoSet.Init(array.Length + protos.Count);
            for (int i = 0; i < array.Length; i++)
            {
                protoSet.dataArray[i] = array[i];
            }
            for (int i = 0; i < protos.Count; i++)
            {
                protoSet.dataArray[array.Length + i] = protos[i] as T;

                if (protos[i] is ItemProto)
                {
                    Traverse.Create(protos[i]).Property("index").SetValue(array.Length + i);
                }
                if (protos[i] is RecipeProto)
                {
                    RecipeProto proto = protos[i] as RecipeProto;
                    if (proto.preTech != null)
                    {
                        ArrayAddItem <int>(ref proto.preTech.UnlockRecipes, proto.ID);
                        ArrayAddItem <RecipeProto>(ref proto.preTech.unlockRecipeArray, proto);
                    }
                }
                Debug.Log($"[LDBTool]Add {protos[i].ID} {protos[i].Name.Translate()} to {protoSet.GetType().Name}.");
            }
            var dataIndices = new Dictionary <int, int>();

            for (int i = 0; i < protoSet.dataArray.Length; i++)
            {
                protoSet.dataArray[i].sid             = protoSet.dataArray[i].SID;
                dataIndices[protoSet.dataArray[i].ID] = i;
            }
            Traverse.Create(protoSet).Field("dataIndices").SetValue(dataIndices);
            if (protoSet is ProtoSet <StringProto> )
            {
                var nameIndices = Traverse.Create(protoSet).Field("nameIndices").GetValue <Dictionary <string, int> >();
                for (int i = array.Length; i < protoSet.dataArray.Length; i++)
                {
                    nameIndices[protoSet.dataArray[i].Name] = i;
                }
                Traverse.Create(protoSet).Field("nameIndices").SetValue(nameIndices);
            }
        }
Example #16
0
        public void ChangeRecipe(int oldRecipe, RecipeProto newRecipe)
        {
            for (int i = 0; i < inspector.blueprint.buildings.Length; i++)
            {
                if (inspector.blueprint.buildings[i].recipeId == oldRecipe)
                {
                    inspector.blueprint.buildings[i].recipeId = newRecipe.ID;
                }
            }


            if (inspector.usage == UIBlueprintInspector.EUsage.Paste)
            {
                inspector.pasteBuildTool.ResetStates();
            }

            inspector.Refresh(true, true, true);
        }
Example #17
0
        /// <summary>
        /// Registers a TechProto for a technology.
        /// Total amount of each jello is calculated like this: N = H*C/3600, where H - total hash count, C - items per minute of jello.
        /// </summary>
        /// <param name="id"> UNIQUE ID of the technology</param>
        /// <param name="name">LocalizedKey of name of the tech</param>
        /// <param name="description">LocalizedKey of description of the tech</param>
        /// <param name="conclusion">LocalizedKey of conclusion of the tech upon completion</param>
        /// <param name="PreTechs">Techs which lead to this tech</param>
        /// <param name="Jellos">Items required to research the tech</param>
        /// <param name="ItemPoints">Amount of items per minute required to research the tech</param>
        /// <param name="HashNeeded">Number of hashes needed required to research the tech</param>
        /// <param name="UnlockRecipes">Once the technology has completed, what recipes are unlocked</param>
        /// <param name="position">Vector2 position of the technology on the technology screen</param>

        public static TechProto registerTech(int id, String name, String description, String conclusion, int[] PreTechs, int[] Jellos, int[] ItemPoints, long HashNeeded,
                                             int[] UnlockRecipes, Vector2 position)

        {
            RecipeProto first = recipes.ContainsKey(UnlockRecipes[0]) ? recipes[UnlockRecipes[0]] : LDB.recipes.Select(UnlockRecipes[0]);

            bool isLabTech = Jellos.Any(itemId => LabComponent.matrixIds.Contains(itemId));


            TechProto proto = new TechProto
            {
                ID               = id,
                Name             = name,
                Desc             = description,
                Published        = true,
                Conclusion       = conclusion,
                IconPath         = first.IconPath,
                IsLabTech        = isLabTech,
                PreTechs         = PreTechs,
                Items            = Jellos,
                ItemPoints       = ItemPoints,
                HashNeeded       = HashNeeded,
                UnlockRecipes    = UnlockRecipes,
                AddItems         = new int[] { }, // what items to gift after research is done
                AddItemCounts    = new int[] { },
                Position         = position,
                PreTechsImplicit = new int[] { }, //Those funky implicit requirements
                UnlockFunctions  = new int[] { }, //Upgrades.
                UnlockValues     = new double[] { },
            };

            for (int i = 0; i < proto.PreTechs.Length; i++)
            {
                TechProto OldTech = LDB.techs.Select(PreTechs[i]);
                techUpdateList.Add(OldTech, proto); //OldTech = Tech whose PostTechArray needs editing
            }

            LDBTool.PreAddProto(ProtoType.Tech, proto);
            techs.Add(id, proto);

            return(proto);
        }
        public override void ProcessPacket(LaboratoryUpdateEventPacket packet, NebulaConnection conn)
        {
            PlanetFactory factory = GameMain.galaxy.PlanetById(packet.PlanetId)?.factory;

            LabComponent[] pool = factory?.factorySystem?.labPool;
            if (pool != null && packet.LabIndex != -1 && packet.LabIndex < pool.Length && pool[packet.LabIndex].id != -1)
            {
                using (Multiplayer.Session.Factories.IsIncomingRequest.On())
                {
                    Multiplayer.Session.Factories.PacketAuthor = NebulaModAPI.AUTHOR_NONE;
                    if (packet.ProductId == -4)
                    {
                        pool[packet.LabIndex].forceAccMode = !pool[packet.LabIndex].forceAccMode;
                    }
                    else if (packet.ProductId == -3)
                    {
                        //Widthdraw produced cubes
                        pool[packet.LabIndex].produced[0] = 0;
                    }
                    else if (packet.ProductId == -2)
                    {
                        //Research recipe reseted
                        pool[packet.LabIndex].SetFunction(false, 0, 0, factory.entitySignPool);
                    }
                    else if (packet.ProductId == -1)
                    {
                        //Center chenged to research-mode
                        pool[packet.LabIndex].SetFunction(true, 0, GameMain.data.history.currentTech, factory.entitySignPool);
                    }
                    else
                    {
                        //Cube Recipe changed
                        int[]       matrixIds   = LabComponent.matrixIds;
                        RecipeProto recipeProto = LDB.items.Select(matrixIds[packet.ProductId]).maincraft;
                        pool[packet.LabIndex].SetFunction(false, (recipeProto == null) ? 0 : recipeProto.ID, 0, factory.entitySignPool);
                    }
                    factory.factorySystem?.SyncLabFunctions(GameMain.mainPlayer, packet.LabIndex);
                    factory.factorySystem?.SyncLabForceAccMode(GameMain.mainPlayer, packet.LabIndex);
                }
            }
        }
Example #19
0
        /// <summary>
        /// Registers a RecipeProto
        /// </summary>
        /// <param name="id">UNIQUE id of your recipe</param>
        /// <param name="type">Recipe type</param>
        /// <param name="time">Time in ingame ticks. How long item is being made</param>
        /// <param name="input">Array of input IDs</param>
        /// <param name="inCounts">Array of input COUNTS</param>
        /// <param name="output">Array of output IDs</param>
        /// <param name="outCounts">Array of output COUNTS</param>
        /// <param name="description">LocalizedKey of description of this item</param>
        /// <param name="techID">Tech id, which unlock this recipe</param>
        public static RecipeProto registerRecipe(int id, ERecipeType type, int time, int[] input, int[] inCounts,
                                                 int[] output,
                                                 int[] outCounts, string description, int techID = 0)
        {
            if (output.Length > 0)
            {
                ItemProto first = items.ContainsKey(output[0]) ? items[output[0]] : LDB.items.Select(output[0]);

                TechProto tech = null;
                if (techID != 0 && LDB.techs.Exist(techID))
                {
                    tech = LDB.techs.Select(techID);
                }

                RecipeProto proto = new RecipeProto
                {
                    Type         = type,
                    Handcraft    = true,
                    TimeSpend    = time,
                    Items        = input,
                    ItemCounts   = inCounts,
                    Results      = output,
                    ResultCounts = outCounts,
                    Description  = description,
                    GridIndex    = first.GridIndex,
                    IconPath     = first.IconPath,
                    Name         = first.Name + "Recipe",
                    preTech      = tech,
                    ID           = id
                };

                LDBTool.PreAddProto(ProtoType.Recipe, proto);
                recipes.Add(id, proto);

                return(proto);
            }

            throw new ArgumentException("Output array must not be empty");
        }
Example #20
0
            public static void Postfix(RecipeProto __instance)
            {
                var name = DSP_RecipeDumper.Translate.Get("recipe" + __instance.ID);

                DSP_RecipeDumper.Logger.Log("[recipe." + name + "]");
                DSP_RecipeDumper.Logger.Log("name = \'" + __instance.name + "\'");
                DSP_RecipeDumper.Logger.Log("timeSpend = " + __instance.TimeSpend);
                if (__instance.Type > 0)
                {
                    DSP_RecipeDumper.Logger.Log("madeFrom = \'" + __instance.madeFromString + "\'");
                }
                DSP_RecipeDumper.Logger.Log("type = \'" + __instance.Type + "\'");
                DSP_RecipeDumper.Logger.Log("handcraft = " + __instance.Handcraft.ToString().ToLower());
                DSP_RecipeDumper.Logger.Log("explicit = " + __instance.Explicit.ToString().ToLower());
                if (__instance.preTech != (TechProto)null)
                {
                    DSP_RecipeDumper.Logger.Log("preTech = \'" + __instance.preTech.Name.Translate() + "\'");
                }
                if (__instance.IconPath.Length > 0)
                {
                    DSP_RecipeDumper.Logger.Log("iconPath = \'" + __instance.IconPath + "\'");
                }
                if (__instance.Items.Length > 0)
                {
                    DSP_RecipeDumper.Logger.Log("[recipe." + name + ".items]");
                    for (int i = 0; i < __instance.Items.Length; i++)
                    {
                        DSP_RecipeDumper.Logger.Log(DSP_RecipeDumper.Translate.Get("item" + __instance.Items[i]) + " = " + __instance.ItemCounts[i]);
                    }
                }
                if (__instance.Results.Length > 0)
                {
                    DSP_RecipeDumper.Logger.Log("[recipe." + name + ".results]");
                    for (int i = 0; i < __instance.Results.Length; i++)
                    {
                        DSP_RecipeDumper.Logger.Log(DSP_RecipeDumper.Translate.Get("item" + __instance.Results[i]) + " = " + __instance.ResultCounts[i]);
                    }
                }
            }
            public static bool OnMinusButtonClick(UIReplicatorWindow __instance, ref RecipeProto ___selectedRecipe, ref Dictionary <int, int> ___multipliers, ref Text ___multiValueText, ref MechaForge ___mechaForge)
            {
                if (___selectedRecipe == null)
                {
                    return(false);
                }

                var stepModifier = 1;

                if (Input.GetKey(KeyCode.LeftControl))
                {
                    stepModifier = 10;
                }
                if (Input.GetKey(KeyCode.LeftShift))
                {
                    stepModifier = 100;
                }
                if (Input.GetKey(KeyCode.LeftAlt))
                {
                    stepModifier = ___mechaForge.PredictTaskCount(___selectedRecipe.ID, 1000000) - 1;
                }

                if (!__instance.multipliers.ContainsKey(___selectedRecipe.ID))
                {
                    __instance.multipliers[___selectedRecipe.ID] = 1;
                }
                int num = __instance.multipliers[___selectedRecipe.ID] - 1 * stepModifier;

                if (num < 1)
                {
                    num = 1;
                }
                __instance.multipliers[___selectedRecipe.ID] = num;
                ___multiValueText.text = num.ToString() + "x";

                return(false);
            }
Example #22
0
 public static string GetSignalDisplayName(int signalId)
 {
     if (signalId < 1000)
     {
         SignalProto signal = LDB.signals.Select(signalId);
         return(signal.name);
         //return $"signal-{signalId}";
     }
     if (signalId < 20000)
     {
         ItemProto proto = LDB.items.Select(signalId);
         return(proto.name);
     }
     if (signalId < 40000)
     {
         RecipeProto proto = LDB.recipes.Select(signalId - 20000);
         return(proto.name);
     }
     else
     {
         TechProto proto = LDB.techs.Select(signalId - 40000);
         return(proto.name);
     }
 }
Example #23
0
            public static void OnOkButtonClick(UIReplicatorWindow __instance, ref RecipeProto ___selectedRecipe, ref Dictionary <int, int> ___multipliers, ref MechaForge ___mechaForge)
            {
                if (___selectedRecipe != null)
                {
                    int num = 1;

                    if (___multipliers.ContainsKey(___selectedRecipe.ID))
                    {
                        num = ___multipliers[___selectedRecipe.ID];
                    }

                    if (num < 1)
                    {
                        num = 1;
                    }

                    int num2 = ___mechaForge.PredictTaskCount(___selectedRecipe.ID, 99);
                    if (num > num2)
                    {
                        num = num2;
                    }
                    ___mechaForge.AddTask(___selectedRecipe.ID, num);
                }
            }
Example #24
0
    public static void LabAdd(Player player, int labId)
    {
        var pf           = player.factory;
        var fs           = pf.factorySystem;
        var target       = fs.labPool[labId];
        var entity       = pf.entityPool[target.entityId];
        var entityitemId = pf.entityPool[target.entityId].protoId;
        var pcid         = target.pcId;

        BugInfo += "\nkeyCount;" + keyCount;
        BugInfo += "\nentityitemId;" + entityitemId;
        BugInfo += "\n";

        if (CheckCanUp(player, entityitemId, true) && !target.researchMode && target.recipeId > 0)
        {
            canUp    = true;
            BugInfo += "\nspeed:" + target.timeSpend;
            BugInfo += "\ninhandItemId:" + player.inhandItemId;
            BugInfo += "\nworkEnergyPerTic:" + pf.powerSystem.consumerPool[pcid].workEnergyPerTick;
            int         recipeId    = target.recipeId;
            RecipeProto recipeProto = LDB.recipes.Select(recipeId);
            int         oldSpeed    = recipeProto.TimeSpend * 10000;
            string      speedText   = ((int)(oldSpeed / (float)target.timeSpend)).ToString();
            showInfo = $"\n\n< {ST.速度}" + speedText + " >";
            checkKey();
            if (key())
            {
                UIRealtimeTip.Popup(ST.建造叠加 + "+", false);
                BugInfo += "\n" + player.inhandItemId;
                int nowSpeed = (int)(oldSpeed / (float)target.timeSpend);
                fs.labPool[labId].timeSpend = oldSpeed / (nowSpeed + 1);
                pf.powerSystem.consumerPool[pcid].workEnergyPerTick += (long)(8000 * powerUp);
                useItem(player, 2901);
            }
        }
    }
        /// <summary>
        /// 添加传送带数据
        /// </summary>
        void AddBeltData()
        {
            // 因为部分数据可以复用,所以直接从现有库中读取
            var belt3   = LDB.items.Select(2003);
            var belt3r  = LDB.recipes.Select(92);
            var preTech = LDB.techs.Select(1605);

            ItemProto   belt4  = belt3.Copy();
            RecipeProto belt4r = belt3r.Copy();
            ItemProto   belt5  = belt3.Copy();
            RecipeProto belt5r = belt3r.Copy();

            // MK.I
            Traverse.Create(belt4).Field("_iconSprite").SetValue(belt4Icon);
            Traverse.Create(belt4r).Field("_iconSprite").SetValue(belt4Icon);
            belt4r.ID          = 201;
            belt4r.Name        = "超级传送带MKI";
            belt4r.name        = "超级传送带MKI".Translate();
            belt4r.Description = "超级传送带MKI描述";
            belt4r.description = "超级传送带MKI描述".Translate();
            belt4r.Items       = new int[] { 2003, 1205, 1406 }; // 合成材料
            belt4r.Results     = new int[] { 2004 };             // 合成结果
            belt4r.GridIndex   = 2501;                           // 在合成表中的位置,第2页,第5排,第1个
            belt4r.preTech     = preTech;
            belt4r.SID         = belt4r.GridIndex.ToString();
            belt4r.sid         = belt4r.GridIndex.ToString();
            belt4.Name         = "超级传送带MKI";
            belt4.name         = "超级传送带MKI".Translate();
            belt4.Description  = "超级传送带MKI描述";
            belt4.description  = "超级传送带MKI描述".Translate();
            belt4.ID           = 2004;
            belt4.makes        = new List <RecipeProto>();
            belt4.BuildIndex   = 304; // 不要和现有序号重复
            belt4.GridIndex    = belt4r.GridIndex;
            belt4.handcraft    = belt4r;
            belt4.maincraft    = belt4r;
            belt4.handcrafts   = new List <RecipeProto>()
            {
                belt4r
            };
            belt4.recipes = new List <RecipeProto>()
            {
                belt4r
            };                                                  // 设置有哪些配方可以合成此物品(用于UI显示)
            belt4.prefabDesc               = belt3.prefabDesc.Copy();
            belt4.prefabDesc.modelIndex    = belt4.ModelIndex;
            belt4.prefabDesc.beltSpeed     = 10;
            belt4.prefabDesc.beltPrototype = 2004;
            belt4.prefabDesc.isBelt        = true;
            belt4.Grade = 4;

            // MK.II
            Traverse.Create(belt5).Field("_iconSprite").SetValue(belt5Icon);
            Traverse.Create(belt5r).Field("_iconSprite").SetValue(belt5Icon);
            belt5r.ID          = 202;
            belt5r.Name        = "超级传送带MKII";
            belt5r.name        = "超级传送带MKII".Translate();
            belt5r.Description = "超级传送带MKII描述";
            belt5r.description = "超级传送带MKII描述".Translate();
            belt5r.Items       = new int[] { 2004, 1205, 1210 }; // 合成材料
            belt5r.Results     = new int[] { 2005 };             // 合成结果
            belt5r.GridIndex   = 2502;                           // 在合成表中的位置,第2页,第5排,第2个
            belt5r.preTech     = preTech;
            belt5r.SID         = belt5r.GridIndex.ToString();
            belt5r.sid         = belt5r.GridIndex.ToString();
            belt5.Name         = "超级传送带MKII";
            belt5.name         = "超级传送带MKII".Translate();
            belt5.Description  = "超级传送带MKII描述";
            belt5.description  = "超级传送带MKII描述".Translate();
            belt5.ID           = 2005;
            belt5.makes        = new List <RecipeProto>();
            belt5.BuildIndex   = 305; // 不要和现有序号重复
            belt5.GridIndex    = belt5r.GridIndex;
            belt5.handcraft    = belt5r;
            belt5.maincraft    = belt5r;
            belt5.handcrafts   = new List <RecipeProto>()
            {
                belt5r
            };
            belt5.recipes = new List <RecipeProto>()
            {
                belt5r
            };                                                  // 设置有哪些配方可以合成此物品(用于UI显示)
            belt5.prefabDesc               = belt3.prefabDesc.Copy();
            belt5.prefabDesc.modelIndex    = belt5.ModelIndex;
            belt5.prefabDesc.beltSpeed     = 20;
            belt5.prefabDesc.beltPrototype = 2005;
            belt5.prefabDesc.isBelt        = true;
            belt5.Grade = 5;

            LDBTool.PostAddProto(ProtoType.Recipe, belt4r);
            LDBTool.PostAddProto(ProtoType.Item, belt4);
            LDBTool.PostAddProto(ProtoType.Recipe, belt5r);
            LDBTool.PostAddProto(ProtoType.Item, belt5);
            AddMatAndMesh();
        }
Example #26
0
        private void Awake()
        {
            logger = Logger;
            config = Config;

            string pluginfolder = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

            resources = new ResourceData(MODGUID, "BetterMachines", pluginfolder);
            resources.LoadAssetBundle("bettermachines");
            resources.ResolveVertaFolder();
            ProtoRegistry.AddResource(resources);

            #region Strings

            ProtoRegistry.EditString("电弧熔炉", "Arc Smelter (MK.I)", "电弧熔炉 (MK.I)");
            ProtoRegistry.RegisterString("smelterMk2", "Arc Smelter (MK.II)", "电弧熔炉 (MK.II)");
            ProtoRegistry.EditString("位面熔炉", "Plane Smelter (MK.III)", "位面熔炉 (MK.III)");

            ProtoRegistry.EditString("化工厂", "Chemical Plant MK.I", "化工厂 MK.I");
            ProtoRegistry.RegisterString("chemicalPlantMk2", "Chemical Plant MK.II", "化工厂 MK.II");
            ProtoRegistry.RegisterString("chemicalPlantMk3", "Chemical Plant MK.III", "化工厂 MK.III");

            ProtoRegistry.RegisterString("storageMk3", "Storage MK.III", "型储物仓 MK.III");
            ProtoRegistry.RegisterString("storageMk4", "Storage MK.IV", "型储物仓 MK.IV");

            ProtoRegistry.EditString("储液罐", "Liquid Tank MK.I", "储液罐 MK.I", "Réservoir de stockage de liquide MK.I");
            ProtoRegistry.RegisterString("liquidTankMk2", "Liquid Tank MK.II", "储液罐 MK.II", "Réservoir de stockage de liquide MK.II");
            ProtoRegistry.RegisterString("liquidTankMk3", "Liquid Tank MK.III", "储液罐 MK.III", "Réservoir de stockage de liquide MK.III");

            ProtoRegistry.RegisterString("smelterMk2Desc", "High temperature arc smelting can smelt ores and metals, and also be used for purification and crystal smelting. By increasing maximum furnace temperature arc smelter can now smelt faster!");
            ProtoRegistry.EditString("位面冶金结果",
                                     "You have unlocked the more advanced smelter ━━ <color=\"#FD965ECC\">Plane Smelter</color>, which is faster as an Arc Smelter (MK.II)!",
                                     "你解锁了更高级的熔炉━━<color=\"#FD965ECC\">位面熔炉</color>, 它的速度比电弧炉(MK.II)还要高!",
                                     "You have unlocked the more advanced smelter ━━ <color=\"#FD965ECC\">Plane Smelter</color>, which is faster as an Arc Smelter (MK.II)!");

            ProtoRegistry.RegisterString("chemicalPlantMk2Desc", "Chemical facility. Can process the primary products of Crude oil into more advanced chemical products. Production speed has been increased.");
            ProtoRegistry.RegisterString("chemicalPlantMk3Desc", "Chemical facility. Can process the primary products of Crude oil into more advanced chemical products. Production speed has been greatly increased.");

            ProtoRegistry.EditString("I小型储物仓", "Storage MK.I is designed to store Solids.");
            ProtoRegistry.EditString("I大型储物仓", "Storage MK.II is designed to store Solids. Thanks to new materials it has more capacity than Storage Mk.I");
            ProtoRegistry.RegisterString("storageMk3Desc", "Storage MK.III is designed to store Solids. Thanks to new materials it has more capacity than Storage Mk.II");
            ProtoRegistry.RegisterString("storageMk4Desc", "Storage MK.IV is designed to store Solids. Thanks to new materials it has more capacity than Storage Mk.III");

            ProtoRegistry.EditString("I储液罐", "Liquid Tank MK.I is designed to store Liquids. When dismantling a non-empty Storage Tank any remaining fluid will be lost.");
            ProtoRegistry.RegisterString("liquidTankMk2Desc", "Liquid Tank MK.II is designed to store Liquids. Thanks to new materials it has more capacity than Liquid Tank Mk.I. When dismantling a non-empty Storage Tank any remaining fluid will be lost.");
            ProtoRegistry.RegisterString("liquidTankMk3Desc", "Liquid Tank MK.III is designed to store Liquids. Thanks to new materials it has more capacity than Liquid Tank Mk.II. When dismantling a non-empty Storage Tank any remaining fluid will be lost.");

            ProtoRegistry.RegisterString("highDensityStorageTech", "High density storage");
            ProtoRegistry.RegisterString("highDensityStorageTechDesc", "By using new stronger materials maximum capacity of Storages and Liquid Tanks can be increased.");
            ProtoRegistry.RegisterString("highDensityStorageTechConc", "You have obtained new Storage MK.IV and Liquid Tank Mk.III, which have increased storage capacity");

            ProtoRegistry.RegisterString("beltMk4", "Belt MK.IV");
            ProtoRegistry.RegisterString("beltMk4Desc", "Allows to transport items around. I have heard that it's so fast, that the game doesn't understand what to do with it.");



            #endregion

            #region Materials

            Material smelterMk2Part1 = ProtoRegistry.CreateMaterial("VF Shaders/Forward/PBR Standard", "smelter-mk2-part1", "#DB5860FF",
                                                                    new[]
            {
                "Assets/BetterMachines/Textures/smelter-mk1-lod0-a",
                "Assets/BetterMachines/Textures/smelter-mk1-lod0-n",
                "Assets/BetterMachines/Textures/smelter-mk1-lod0-s",
                "Assets/BetterMachines/Textures/smelter-mk1-lod0-e",
                "Assets/BetterMachines/Textures/smelter-mk1-lod0-j"
            });

            smelterMk2Part1.SetFloat(emissionSwitch, 1);
            smelterMk2Part1.SetFloat(emissionUsePower, 1);

            smelterMk2Part1.SetFloat(albedoMultiplier, 1.3f);
            smelterMk2Part1.SetFloat(emissionMultiplier, 10);
            smelterMk2Part1.SetFloat(emissionJitter, 0.5f);

            Material smelterMk2Part2 = ProtoRegistry.CreateMaterial("VF Shaders/Forward/PBR Standard", "smelter-mk2-part2", "#DB5860FF",
                                                                    new[]
            {
                "Assets/BetterMachines/Textures/smelter-mk3-lod0-a",
                "Assets/BetterMachines/Textures/smelter-mk3-lod0-n",
                "Assets/BetterMachines/Textures/smelter-mk3-lod0-s",
                "Assets/BetterMachines/Textures/smelter-mk3-lod0-e"
            });

            smelterMk2Part2.SetFloat(emissionSwitch, 1);
            smelterMk2Part2.SetFloat(emissionUsePower, 1);

            smelterMk2Part2.SetFloat(albedoMultiplier, 1.3f);
            smelterMk2Part2.SetFloat(emissionMultiplier, 10);
            smelterMk2Part2.SetFloat(emissionJitter, 0.5f);

            Material smelterMk2Lods = ProtoRegistry.CreateMaterial("VF Shaders/Forward/PBR Standard", "smelter-mk2-lods", "#DB5860FF",
                                                                   new[]
            {
                "Assets/BetterMachines/Textures/smelter-mk2-lod1-a",
                "Assets/BetterMachines/Textures/smelter-mk2-lod1-n",
                "Assets/BetterMachines/Textures/smelter-mk2-lod1-s",
                "Assets/BetterMachines/Textures/smelter-mk2-lod1-e"
            });

            smelterMk2Lods.SetFloat(emissionSwitch, 1);
            smelterMk2Lods.SetFloat(emissionUsePower, 1);
            smelterMk2Lods.SetFloat(alphaClip, 0.5f);

            Material storageMat = ProtoRegistry.CreateMaterial("VF Shaders/Forward/PBR Standard", "storage-mat", "#DB5860FF",
                                                               new[]
            {
                "Assets/BetterMachines/Textures/storage-a",
                "Assets/BetterMachines/Textures/storage-n",
                "Assets/BetterMachines/Textures/storage-s"
            });

            Material storageMatLod1 = ProtoRegistry.CreateMaterial("VF Shaders/Forward/PBR Standard", "storage-mat", "#DB5860FF",
                                                                   new[]
            {
                "Assets/BetterMachines/Textures/storage-lod-a",
                "Assets/BetterMachines/Textures/storage-lod-n",
                "Assets/BetterMachines/Textures/storage-lod-s"
            });

            storageMatLod1.SetFloat(alphaClip, 0.5f);

            Material blackMat =
                ProtoRegistry.CreateMaterial("VF Shaders/Forward/Black Mask", "black", "#00000000");

            blackMat.renderQueue = 2980;
            blackMat.SetColor(tintColor, Color.black);
            blackMat.SetFloat(invFade, 1.5f);

            Material blackMatToggle =
                ProtoRegistry.CreateMaterial("VF Shaders/Forward/Black Mask Vertex Toggle", "liquid-tank-black", "#00000000");

            blackMatToggle.renderQueue = 2980;
            blackMatToggle.SetColor(tintColor, Color.black);
            blackMatToggle.SetFloat(invFade, 1.5f);

            Material liquidTankMat = ProtoRegistry.CreateMaterial("VF Shaders/Forward/PBR Standard Vertex Toggle", "liquid-tank-mat", "#FFFFFFFF",
                                                                  new[]
            {
                "Assets/BetterMachines/Textures/storage-tank-a",
                "Assets/BetterMachines/Textures/storage-tank-n",
                "Assets/BetterMachines/Textures/storage-tank-s"
            });

            Material liquidTankGlassMat =
                ProtoRegistry.CreateMaterial("VF Shaders/Forward/PBR Standard Tank Vertex Toggle", "liquid-tank-glass-mat", "#F2FFFA42", new []
            {
                "", "",
                "Assets/BetterMachines/Textures/storage-tank-glass-s"
            });
            liquidTankGlassMat.renderQueue = 2989;
            liquidTankGlassMat.SetFloat(albedoMultiplier, 3);
            liquidTankGlassMat.SetFloat(bumpScale, 1);
            liquidTankGlassMat.SetFloat(emissionMultiplier, 10);
            liquidTankGlassMat.SetFloat(smoothMultiplier, 0.8f);
            liquidTankGlassMat.SetFloat(emissionSwitch, 1);
            liquidTankGlassMat.SetColor(specularColor, new Color(0.1981132f, 0.1981132f, 0.1981132f, 1));
            liquidTankGlassMat.SetColor(rimColor, new Color(0.6039216f, 0.8462228f, 0.8588235f, 1));

            string[] chemicalTextures =
            {
                "Assets/BetterMachines/Textures/chemical-plant-a",
                "Assets/BetterMachines/Textures/chemical-plant-n",
                "Assets/BetterMachines/Textures/chemical-plant-s",
                "Assets/BetterMachines/Textures/chemical-plant-e"
            };

            Material chemicalPlantMatMk2 = ProtoRegistry.CreateMaterial("VF Shaders/Forward/PBR Standard", "chemical-plant-mk2", "#00FFE8FF", chemicalTextures);

            Material chemicalPlantMatMk3 = ProtoRegistry.CreateMaterial("VF Shaders/Forward/PBR Standard", "chemical-plant-mk2", "#5FB9FFFF", chemicalTextures);

            Material chemicalPlantMatGlass = ProtoRegistry.CreateMaterial("VF Shaders/Forward/PBR Standard Glass", "chemical-plant-glass", "#D7F7FF29",
                                                                          new [] {
                "", "",
                "Assets/BetterMachines/Textures/chemical-plant-glass-s"
            });

            chemicalPlantMatGlass.renderQueue = 3001;
            chemicalPlantMatGlass.SetColor(emissionColor, Color.black);
            chemicalPlantMatGlass.SetColor(rimColor, new Color(0.6448024f, 0.8279268f, 0.8490566f, 1f));

            Material chemicalPlantMatWater = ProtoRegistry.CreateMaterial("VF Shaders/Forward/PBR Standard Glass", "chemical-plant-glass",
                                                                          new Color(1f, 0.6380855f, 0.1650943f, 0.5176471f));

            chemicalPlantMatWater.renderQueue = 3000;
            chemicalPlantMatWater.SetColor(emissionColor, Color.black);

            string[] chemicallodTextures =
            {
                "Assets/BetterMachines/Textures/chemical-plant-lod-a",
                "Assets/BetterMachines/Textures/chemical-plant-lod-n",
                "Assets/BetterMachines/Textures/chemical-plant-lod-s",
                "Assets/BetterMachines/Textures/chemical-plant-lod-e"
            };

            Material chemicalPlantMatMk2Lod = ProtoRegistry.CreateMaterial("VF Shaders/Forward/PBR Standard", "chemical-plant-mk2", "#00FFE8FF", chemicallodTextures);
            Material chemicalPlantMatMk3Lod = ProtoRegistry.CreateMaterial("VF Shaders/Forward/PBR Standard", "chemical-plant-mk2", "#5FB9FFFF", chemicallodTextures);


            gizmoMat = resources.bundle.LoadAsset <Material>("Assets/BetterMachines/Materials/SolidGizmo.mat");
            gizmoMat.shaderKeywords = new[] { "_ALPHABLEND_ON", "_EMISSION" };

            gizmoLineMat = resources.bundle.LoadAsset <Material>("Assets/BetterMachines/Materials/SolidLine.mat");
            gizmoLineMat.shaderKeywords = new[] { "_ALPHABLEND_ON", "_EMISSION" };

            #endregion

            #region Items

            ItemProto smelterMk3Item = LDB.items.Select(2315);
            smelterMk3Item.SetIcon("Assets/BetterMachines/Icons/smelter-3", false);

            smelterMk2item = ProtoRegistry.RegisterItem(3700, "smelterMk2", "smelterMk2Desc",
                                                        "Assets/BetterMachines/Icons/smelter-2", ProtoRegistry.GetGridIndex(2, 5, 4), 50, EItemType.Production);

            ItemProto chemicalPlantMk2item = ProtoRegistry.RegisterItem(3701, "chemicalPlantMk2", "chemicalPlantMk2Desc",
                                                                        "Assets/BetterMachines/Icons/chemical-plant-mk2", ProtoRegistry.GetGridIndex(2, 5, 5), 50, EItemType.Production);

            ItemProto chemicalPlantMk3item = ProtoRegistry.RegisterItem(3702, "chemicalPlantMk3", "chemicalPlantMk3Desc",
                                                                        "Assets/BetterMachines/Icons/chemical-plant-mk3", ProtoRegistry.GetGridIndex(2, 6, 5), 50, EItemType.Production);

            ItemProto storageMk3Item = ProtoRegistry.RegisterItem(3703, "storageMk3", "storageMk3Desc",
                                                                  "Assets/BetterMachines/Icons/storage-3", ProtoRegistry.GetGridIndex(2, 1, 6), 50, EItemType.Logistics);

            ItemProto storageMk4Item = ProtoRegistry.RegisterItem(3704, "storageMk4", "storageMk4Desc",
                                                                  "Assets/BetterMachines/Icons/storage-4", ProtoRegistry.GetGridIndex(2, 2, 6), 50, EItemType.Logistics);

            ItemProto tankMk2Item = ProtoRegistry.RegisterItem(3705, "liquidTankMk2", "liquidTankMk2Desc",
                                                               "Assets/BetterMachines/Icons/storage-tank-2", ProtoRegistry.GetGridIndex(2, 1, 5), 50, EItemType.Logistics);

            ItemProto tankMk3Item = ProtoRegistry.RegisterItem(3706, "liquidTankMk3", "liquidTankMk3Desc",
                                                               "Assets/BetterMachines/Icons/storage-tank-3", ProtoRegistry.GetGridIndex(2, 2, 5), 50, EItemType.Logistics);

            beltMk4Item = ProtoRegistry.RegisterItem(3707, "beltMk4", "beltMk4Desc",
                                                     "Assets/BetterMachines/Icons/belt-4", ProtoRegistry.GetGridIndex(2, 3, 5), 300, EItemType.Logistics);


            #endregion

            #region Models

            ProtoRegistry.RegisterModel(260, smelterMk2item, "Assets/BetterMachines/Machines/smelter-mk2",
                                        new [] { smelterMk2Part1, smelterMk2Part2 }, new[] { 22, 11, 12, 1 }, 502, 2, new [] { 2302, 0, 2315 });
            ProtoRegistry.AddLodMaterials("Assets/BetterMachines/Machines/smelter-mk2", 1, new [] { smelterMk2Lods });
            ProtoRegistry.AddLodMaterials("Assets/BetterMachines/Machines/smelter-mk2", 2, new [] { smelterMk2Lods });

            ProtoRegistry.RegisterModel(261, chemicalPlantMk2item, "Assets/BetterMachines/Machines/chemical-plant-mk2",
                                        new [] { chemicalPlantMatMk2, chemicalPlantMatGlass, blackMat, chemicalPlantMatWater }, new[] { 22, 11, 12, 1 }, 704, 2, new [] { 2309, 0, chemicalPlantMk3item.ID });
            ProtoRegistry.AddLodMaterials("Assets/BetterMachines/Machines/chemical-plant-mk2", 1, new [] { chemicalPlantMatMk2Lod, chemicalPlantMatGlass });
            ProtoRegistry.AddLodMaterials("Assets/BetterMachines/Machines/chemical-plant-mk2", 2, new [] { chemicalPlantMatMk2Lod, chemicalPlantMatGlass });

            ProtoRegistry.RegisterModel(262, chemicalPlantMk3item, "Assets/BetterMachines/Machines/chemical-plant-mk3",
                                        new [] { chemicalPlantMatMk3, chemicalPlantMatGlass, blackMat, chemicalPlantMatWater }, new[] { 22, 11, 12, 1 }, 705, 3, new [] { 2309, chemicalPlantMk2item.ID, 0 });
            ProtoRegistry.AddLodMaterials("Assets/BetterMachines/Machines/chemical-plant-mk3", 1, new [] { chemicalPlantMatMk3Lod, chemicalPlantMatGlass });
            ProtoRegistry.AddLodMaterials("Assets/BetterMachines/Machines/chemical-plant-mk3", 2, new [] { chemicalPlantMatMk3Lod, chemicalPlantMatGlass });

            ProtoRegistry.RegisterModel(263, storageMk3Item, "Assets/BetterMachines/Machines/storage-3",
                                        new [] { storageMat }, new[] { 17, 1 }, 403);
            ProtoRegistry.AddLodMaterials("Assets/BetterMachines/Machines/storage-3", 1, new [] { storageMatLod1 });


            ProtoRegistry.RegisterModel(264, storageMk4Item, "Assets/BetterMachines/Machines/storage-4",
                                        new [] { storageMat }, new[] { 17, 1 }, 404);
            ProtoRegistry.AddLodMaterials("Assets/BetterMachines/Machines/storage-4", 1, new [] { storageMatLod1 });

            liquidTankMk2 = ProtoRegistry.RegisterModel(265, tankMk2Item, "Assets/BetterMachines/Machines/liquid-tank-mk2",
                                                        new [] { liquidTankMat, blackMatToggle, liquidTankGlassMat }, new[] { 30, 1 }, 406, 0, new int [0], 3);

            liquidTankMk3 = ProtoRegistry.RegisterModel(266, tankMk3Item, "Assets/BetterMachines/Machines/liquid-tank-mk3",
                                                        new [] { liquidTankMat, blackMatToggle, liquidTankGlassMat }, new[] { 30, 1 }, 407, 0, new int[0], 3);

            beltMk4 = ProtoRegistry.RegisterModel(267, beltMk4Item, "Assets/BetterMachines/Machines/belt-4",
                                                  null, new[] { 15, 1 }, 304, 4, new [] { 2001, 2002, 2003, 0 });

            #endregion

            #region Recipes

            // Smelter mk2 <= Smelter mk1,  Titanium alloy * 4, Processor * 4, Magnetic coil * 8
            ProtoRegistry.RegisterRecipe(250, ERecipeType.Assemble, 240, new[] { 2302, 1107, 1303, 1202 }, new[] { 1, 4, 4, 8 },
                                         new[] { smelterMk2item.ID }, new[] { 1 }, "smelterMk2Desc", 1202);

            // Smelter mk3 <= Smelter mk2,  Particle container * 8, Plane filter * 4, Particle broadband * 8
            ProtoRegistry.EditRecipe(116, ERecipeType.Assemble, 300, new[] { smelterMk2item.ID, 1206, 1304, 1402 }, new[] { 1, 8, 4, 8 },
                                     new[] { 2315 }, new[] { 1 }, "smelterMk3Desc", 1417, ProtoRegistry.GetGridIndex(2, 6, 4));

            // Chem plant mk2 <= Chem plant mk1, Titanium alloy * 4, Titanium glass * 4, Processor * 4
            ProtoRegistry.RegisterRecipe(251, ERecipeType.Assemble, 360, new[] { 2309, 1107, 1119, 1303 }, new[] { 1, 4, 4, 4 },
                                         new[] { chemicalPlantMk2item.ID }, new[] { 1 }, "chemicalPlantMk2Desc", 1202);

            // Chem plant mk3 <= Chem plant mk2, Particle broadband * 4,  Plane filter * 2, Quantum chip * 2
            ProtoRegistry.RegisterRecipe(252, ERecipeType.Assemble, 420, new[] { chemicalPlantMk2item.ID, 1402, 1304, 1305 }, new[] { 1, 4, 2, 2 },
                                         new[] { chemicalPlantMk3item.ID }, new[] { 1 }, "chemicalPlantMk2Desc", 1203);

            ProtoRegistry.RegisterRecipe(253, ERecipeType.Assemble, 300, new[] { 1106, 1108 }, new[] { 12, 12 },
                                         new[] { storageMk3Item.ID }, new[] { 1 }, "storageMk3Desc", 1604);

            RecipeProto storageMk4Recipe = ProtoRegistry.RegisterRecipe(254, ERecipeType.Assemble, 360, new[] { 1107, 1108 }, new[] { 16, 16 },
                                                                        new[] { storageMk4Item.ID }, new[] { 1 }, "storageMk4Desc", 1851);

            ProtoRegistry.RegisterRecipe(255, ERecipeType.Assemble, 300, new[] { 1103, 1108, 1110 }, new[] { 12, 12, 8 },
                                         new[] { tankMk2Item.ID }, new[] { 1 }, "liquidTankMk2Desc", 1603);

            RecipeProto liquidTankMk3Recipe = ProtoRegistry.RegisterRecipe(256, ERecipeType.Assemble, 360, new[] { 1107, 1108, 1119 }, new[] { 16, 16, 12 },
                                                                           new[] { tankMk3Item.ID }, new[] { 1 }, "liquidTankMk3Desc", 1851);

            ProtoRegistry.RegisterTech(1851, "highDensityStorageTech", "highDensityStorageTechDesc", "highDensityStorageTechConc", "Assets/BetterMachines/Icons/high-density-storage",
                                       new[] { 1414 }, new[] { 6001, 6002, 6003 }, new[] { 20, 20, 2 }, 216000, new[] { storageMk4Recipe.ID, liquidTankMk3Recipe.ID }, new Vector2(37, 13));

            ProtoRegistry.RegisterRecipe(257, ERecipeType.Assemble, 360, new[] { 2003, 1304, 1124 }, new[] { 3, 1, 1 },
                                         new[] { beltMk4Item.ID }, new[] { 3 }, "beltMk4Desc", 1605);

            #endregion

            LDBTool.SetBuildBar(3, 4, beltMk4Item.ID); // Insert belt mk4
            LDBTool.SetBuildBar(3, 5, 2011);
            LDBTool.SetBuildBar(3, 6, 2012);
            LDBTool.SetBuildBar(3, 7, 2013);
            LDBTool.SetBuildBar(3, 8, 2040);
            LDBTool.SetBuildBar(3, 9, 2030);
            LDBTool.SetBuildBar(3, 10, 2020);

            LDBTool.SetBuildBar(4, 5, 2106);  //Move default position for Liquid Tank mk1

            LDBTool.SetBuildBar(5, 2, smelterMk2item.ID);
            LDBTool.SetBuildBar(5, 3, 2315);  //Move default position for Plane Smelter (MK.III)
            LDBTool.SetBuildBar(5, 4, 2303);
            LDBTool.SetBuildBar(5, 5, 2304);
            LDBTool.SetBuildBar(5, 6, 2305);
            LDBTool.SetBuildBar(5, 7, 2308);
            LDBTool.SetBuildBar(5, 8, 2309);
            LDBTool.SetBuildBar(5, 9, 2314);
            LDBTool.SetBuildBar(5, 10, 2310);

            Harmony harmony = new Harmony(MODGUID);
            harmony.PatchAll(Assembly.GetExecutingAssembly());

            ProtoRegistry.onLoadingFinished += ModifySpeed;
        }
 public static void OnRecipePickerReturn_Postfix(UIAssemblerWindow __instance, RecipeProto recipe)
 {
     if (Multiplayer.IsActive)
     {
         Multiplayer.Session.Network.SendPacketToLocalStar(new AssemblerRecipeEventPacket(GameMain.data.localPlanet.id, __instance.assemblerId, recipe.ID));
     }
 }
Example #28
0
        public void AddSmelterMk3Data()
        {
            var smelter  = LDB.items.Select(2302);
            var smelterr = LDB.recipes.Select(56);

            // Copy the Protos to a new Storage Mk III building
            ItemProto   smelterMk3  = smelter.Copy();
            RecipeProto smelterMk3r = smelterr.Copy();

            Traverse.Create(smelterMk3).Field("_iconSprite").SetValue(smelter.iconSprite);
            Traverse.Create(smelterMk3r).Field("_iconSprite").SetValue(smelterr.iconSprite);

            smelterMk3r.ID          = 10002;
            smelterMk3r.Name        = "Smelter MK. III";
            smelterMk3r.name        = "Smelter MK. III".Translate();
            smelterMk3r.Description = "2x the speed of a Smelter MK. I";
            smelterMk3r.description = "2x the speed of a Smelter MK. I".Translate();
            smelterMk3r.Items       = new int[] { 10001, 1206, 1305, 1202 }; // The items required to craft it
            //smelterMk3r.Items = new int[] { 1001 };
            smelterMk3r.ItemCounts = new int[] { 1, 8, 2, 20 };
            //smelterMk3r.ItemCounts = new int[] { 1 };
            smelterMk3r.Results    = new int[] { 10002 };
            smelterMk3r.GridIndex  = 2406;    // Where the recipe is located on the replicator. Format xyzz where x is the page, y is the row, and zz is the column
            smelterMk3r.SID        = smelterMk3r.GridIndex.ToString();
            smelterMk3r.sid        = smelterMk3r.GridIndex.ToString();
            smelterMk3.Name        = "Smelter MK. III";
            smelterMk3.name        = "Smelter MK. III".Translate();
            smelterMk3.Description = "2x the speed of a Smelter MK. I";
            smelterMk3.description = "2x the speed of a Smelter MK. I".Translate();
            smelterMk3.ID          = 10002;
            smelterMk3.makes       = new List <RecipeProto>();
            smelterMk3.BuildIndex  = 10002;
            smelterMk3.GridIndex   = smelterMk3r.GridIndex;
            smelterMk3.handcraft   = smelterMk3r;
            smelterMk3.maincraft   = smelterMk3r;
            smelterMk3.handcrafts  = new List <RecipeProto>()
            {
                smelterMk3r
            };
            smelterMk3.recipes = new List <RecipeProto>()
            {
                smelterMk3r
            };
            smelterMk3.prefabDesc                     = smelter.prefabDesc.Copy();
            smelterMk3.prefabDesc.modelIndex          = smelterMk3.ModelIndex;
            smelterMk3.prefabDesc.isAssembler         = true;
            smelterMk3.prefabDesc.assemblerSpeed      = 20000;
            smelterMk3.prefabDesc.assemblerRecipeType = ERecipeType.Smelt;
            smelterMk3.prefabDesc.idleEnergyPerTick   = 300;   // desired watts / 60
            smelterMk3.prefabDesc.workEnergyPerTick   = 15000; // desired watts / 60
            smelterMk3.Grade     = 3;
            smelterMk3.Upgrades  = new int[] { 2302, 10001, 10002 };
            smelterMk3.StackSize = 50;

            var quantum    = LDB.techs.Select(1303);
            var metallurgy = LDB.techs.Select(1401);

            TechProto mk3 = quantum.Copy();

            Traverse.Create(mk3).Field("_iconSprite").SetValue(metallurgy.iconSprite);

            mk3.name             = "Quantum Metallurgy";
            mk3.Name             = "Quantum Metallurgy";
            mk3.ID               = 506;
            mk3.SID              = "";
            mk3.sid              = "";
            mk3.Desc             = "Quantum mechanics can be utilised to smelt at super speeds";
            mk3.description      = "Quantum mechanics can be utilised to smelt at super speeds";
            mk3.Conclusion       = "";
            mk3.Published        = true;
            mk3.Level            = 0;
            mk3.MaxLevel         = 0;
            mk3.Position         = new Vector2(49f, -15f);
            mk3.PreTechsImplicit = new int[] { };
            mk3.postTechArray    = new TechProto[] { };
            mk3.PreTechsImplicit = new int[] { 505 };
            mk3.PreTechs         = new int[] { 1303 };
            mk3.Items            = new int[] { 6001, 6002, 6003, 6004 };
            mk3.itemArray        = new ItemProto[] { LDB.items.Select(6001), LDB.items.Select(6002), LDB.items.Select(6003), LDB.items.Select(6004) };
            mk3.ItemPoints       = new int[] { 10, 10, 10, 10 };
            mk3.HashNeeded       = 432000;

            quantum.postTechArray = new TechProto[] { LDB.techs.Select(1705), LDB.techs.Select(1203), mk3 };

            // Load the required technology to access it
            mk3.unlockRecipeArray = new RecipeProto[] { };
            mk3.UnlockRecipes     = new int[] { };
            smelterMk3r.preTech   = mk3;  // Set the required technology to be able to access the recipe

            LDBTool.PostAddProto(ProtoType.Tech, mk3);
            LDBTool.PostAddProto(ProtoType.Recipe, smelterMk3r);
            LDBTool.PostAddProto(ProtoType.Item, smelterMk3);
        }
Example #29
0
        public void AddSmelterMk2Data()
        {
            var smelter  = LDB.items.Select(2302);
            var smelterr = LDB.recipes.Select(56);

            // Copy the Protos to a new Storage Mk III building
            ItemProto   smelterMk2  = smelter.Copy();
            RecipeProto smelterMk2r = smelterr.Copy();

            Traverse.Create(smelterMk2).Field("_iconSprite").SetValue(smelter.iconSprite);
            Traverse.Create(smelterMk2r).Field("_iconSprite").SetValue(smelterr.iconSprite);

            smelterMk2r.ID          = 10001;
            smelterMk2r.Name        = "Smelter MK. II";
            smelterMk2r.name        = "Smelter MK. II".Translate();
            smelterMk2r.Description = "1.5x the speed of a Smelter MK. I";
            smelterMk2r.description = "1.5x the speed of a Smelter MK. I".Translate();
            smelterMk2r.Items       = new int[] { 2302, 1107, 1303, 1202 }; // The items required to craft it (Smelter, titanium alloy, processor, magnetic coil)
            //smelterMk2r.Items = new int[] { 1001 };   // The items required to craft it
            smelterMk2r.ItemCounts = new int[] { 1, 4, 4, 8 };
            //smelterMk2r.ItemCounts = new int[] { 1 };
            smelterMk2r.Results    = new int[] { 10001 }; // The result (Smelter MK 2)
            smelterMk2r.GridIndex  = 2405;                // Where the recipe is located on the replicator. Format xyzz where x is the page, y is the row, and zz is the column
            smelterMk2r.SID        = smelterMk2r.GridIndex.ToString();
            smelterMk2r.sid        = smelterMk2r.GridIndex.ToString();
            smelterMk2.Name        = "Smelter MK. II";
            smelterMk2.name        = "Smelter MK. II".Translate();
            smelterMk2.Description = "1.5x the speed of a Smelter MK. I";
            smelterMk2.description = "1.5x the speed of a Smelter MK. I".Translate();
            smelterMk2.ID          = 10001;
            smelterMk2.makes       = new List <RecipeProto>();
            smelterMk2.BuildIndex  = 508;
            smelterMk2.GridIndex   = smelterMk2r.GridIndex;
            smelterMk2.handcraft   = smelterMk2r;
            smelterMk2.maincraft   = smelterMk2r;
            smelterMk2.handcrafts  = new List <RecipeProto>()
            {
                smelterMk2r
            };
            smelterMk2.recipes = new List <RecipeProto>()
            {
                smelterMk2r
            };
            smelterMk2.prefabDesc                     = smelter.prefabDesc.Copy();
            smelterMk2.prefabDesc.modelIndex          = smelterMk2.ModelIndex;
            smelterMk2.prefabDesc.isAssembler         = true;
            smelterMk2.prefabDesc.assemblerSpeed      = 15000; // default is 10000
            smelterMk2.prefabDesc.assemblerRecipeType = ERecipeType.Smelt;
            smelterMk2.prefabDesc.idleEnergyPerTick   = 250;   // desired watts / 60
            smelterMk2.prefabDesc.workEnergyPerTick   = 10667; // desired watts / 60
            smelterMk2.Grade     = 2;
            smelterMk2.Upgrades  = new int[] { 2302, 10001, 10002 };
            smelterMk2.StackSize = 50;

            var processor  = LDB.techs.Select(1302);
            var metallugry = LDB.techs.Select(1401);

            TechProto mk2 = processor.Copy();

            Traverse.Create(mk2).Field("_iconSprite").SetValue(metallugry.iconSprite);

            mk2.name             = "Improved Metallurgy";
            mk2.Name             = "Improved Metallurgy";
            mk2.ID               = 505;
            mk2.SID              = "";
            mk2.sid              = "";
            mk2.Desc             = "Advances in computer components allow you to smelt items faster";
            mk2.description      = "Advances in computer components allow you to smelt items faster";
            mk2.Conclusion       = "";   // the message that appears when you unlock
            mk2.Published        = true; // false = accelerants
            mk2.Level            = 0;
            mk2.MaxLevel         = 0;
            mk2.Position         = new Vector2(33f, -4.75f);
            mk2.PreTechsImplicit = new int[] { 1401 };
            mk2.postTechArray    = new TechProto[] { };

            // I have no f*****g clue how exactly the amount of items is calculated, but this works so I'm sticking with it
            // What I did for now is just take the values for High-speed processing and manipulate them.
            // So the total blue for High-speed is 600, I wanted 800 for this research. 800 / 600 * 108000 (the HashNeeded for high-speed) = 144000
            // Set the items to blue and red jelly
            mk2.Items     = new int[] { 6001, 6002 };
            mk2.itemArray = new ItemProto[] { LDB.items.Select(6001), LDB.items.Select(6002) };
            // Time the labs take to use an item?
            mk2.ItemPoints = new int[] { 20, 10 };
            // Total hash
            mk2.HashNeeded = 144000;

            processor.postTechArray = new TechProto[] { LDB.techs.Select(1202), LDB.techs.Select(1312), mk2 };

            // Load the required technology to access it
            mk2.unlockRecipeArray = new RecipeProto[] { };
            mk2.UnlockRecipes     = new int[] { };
            smelterMk2r.preTech   = mk2;  // Set the required technology to be able to access the recipe

            LDBTool.PostAddProto(ProtoType.Tech, mk2);
            LDBTool.PostAddProto(ProtoType.Recipe, smelterMk2r);
            LDBTool.PostAddProto(ProtoType.Item, smelterMk2);
        }
Example #30
0
        void calRaws(int itemId, double count, int layer, string target, ArrayList rawLayerList)
        {
            bool hasByProducts = false;

            if (LDB.items.Select(itemId).recipes.Count > 0)//有合成配方的物品
            {
                int customedRecipeId;
                //如果没有设置自定义配方或本物品已经设置的自定义配方属于上一个修改自定义配方的子树,则本物品自定义配方恢复为默认配方
                if (defaultRecipes.ContainsKey(itemId))
                {
                    customRecipes[target] = defaultRecipes[itemId];
                }
                else if (!customRecipes.ContainsKey(target) || lastCustomedTarget != null && lastCustomedTarget.Length < target.Length && target.IndexOf(lastCustomedTarget, 0, lastCustomedTarget.Length) != -1)
                {
                    customRecipes[target] = 0;
                }
                customedRecipeId = (int)customRecipes[target];
                //自定义配方id为-1时表示自提供该物品
                if (customedRecipeId == -1)
                {
                    if (rawLayerList.Count < layer + 1)
                    {
                        rawLayerList.Add(new ArrayList());
                    }
                    Hashtable itemInfo = new Hashtable();
                    itemInfo.Add("itemId", itemId);
                    itemInfo.Add("count", count);
                    itemInfo.Add("type", 1);
                    itemInfo.Add("target", target);
                    itemInfo.Add("column", maxColumn);
                    ((ArrayList)rawLayerList[layer]).Add(itemInfo);
                    return;
                }
                //获取该物品的指定配方
                RecipeProto recipe = LDB.items.Select(itemId).recipes[customedRecipeId];
                //计算该物品对于配方的倍率
                double times = count;
                for (int i = 0; i < recipe.Results.Length; i++)//计算配方倍率
                {
                    if (recipe.Results[i] == itemId)
                    {
                        times = count / recipe.ResultCounts[i];
                        break;
                    }
                }
                //本物品层
                if (rawLayerList.Count < layer + 1)
                {
                    rawLayerList.Add(new ArrayList());
                }

                //加本层合成物
                for (int i = 0; i < recipe.Results.Length; i++)
                {
                    bool isByProducts = recipe.Results[i] != itemId;
                    if (isByProducts)
                    {
                        hasByProducts = true;
                    }
                    else
                    {
                        //加工厂信息
                        if (rawLayerList.Count < layer + 2)
                        {
                            rawLayerList.Add(new ArrayList());
                        }
                        int    factId     = 0;
                        double time_times = 1;
                        switch (recipe.Type)
                        {
                        case ERecipeType.None:
                            break;

                        case ERecipeType.Smelt:
                            factId = 2302;
                            break;

                        case ERecipeType.Chemical:
                            factId = 2309;
                            break;

                        case ERecipeType.Refine:
                            factId = 2308;
                            break;

                        case ERecipeType.Assemble:
                            //三种制造台
                            if (defaultFactory != -2)
                            {
                                customFactory[target] = defaultFactory;
                            }
                            else if (!customFactory.ContainsKey(target) || lastCustomedTarget != null && lastCustomedTarget.Length <= target.Length && target.IndexOf(lastCustomedTarget, 0, lastCustomedTarget.Length) != -1)
                            {
                                customFactory[target] = 2304;
                            }

                            factId = (int)customFactory[target];
                            if (factId == 2303)
                            {
                                time_times = 0.75;
                            }
                            else if (factId == 2304)
                            {
                                time_times = 1;
                            }
                            else
                            {
                                time_times = 1.5;
                            }
                            break;

                        case ERecipeType.Particle:
                            factId = 2310;
                            break;

                        case ERecipeType.Exchange:
                            factId = 2209;
                            break;

                        case ERecipeType.PhotonStore:
                            factId = 2208;
                            break;

                        case ERecipeType.Fractionate:
                            factId = 2314;
                            break;

                        case ERecipeType.Research:
                            factId = 2901;
                            break;
                        }
                        double factCount = times / (time_times * (60.0 / (recipe.TimeSpend / 60.0)));
                        bool   notFull   = false;
                        if ((int)factCount < factCount)
                        {
                            notFull   = true;
                            factCount = (int)factCount + 1;
                        }
                        Hashtable factoryInfo = new Hashtable();
                        factoryInfo.Add("itemId", factId);
                        factoryInfo.Add("count", factCount);
                        factoryInfo.Add("type", 4);
                        factoryInfo.Add("target", target);
                        factoryInfo.Add("column", maxColumn);
                        factoryInfo.Add("notFull", notFull);
                        ((ArrayList)rawLayerList[layer + 1]).Add(factoryInfo);
                    }
                    Hashtable itemInfo = new Hashtable();
                    itemInfo.Add("itemId", recipe.Results[i]);
                    itemInfo.Add("count", recipe.ResultCounts[i] * times);
                    itemInfo.Add("type", isByProducts?2:3);
                    itemInfo.Add("target", target);
                    itemInfo.Add("column", maxColumn + (isByProducts?1:0));
                    ((ArrayList)rawLayerList[layer]).Add(itemInfo);
                }
                //计算本层所需原料
                for (int i = 0; i < recipe.Items.Length; i++)
                {
                    if (i > 0)
                    {
                        maxColumn++;
                    }
                    calRaws(recipe.Items[i], recipe.ItemCounts[i] * times, layer + 2, target + i, rawLayerList);
                }
                if (hasByProducts)
                {
                    maxColumn++;
                }
            }
            else
            {
                //加本层原料
                if (rawLayerList.Count < layer + 1)
                {
                    rawLayerList.Add(new ArrayList());
                }
                Hashtable itemInfo = new Hashtable();
                itemInfo.Add("itemId", itemId);
                itemInfo.Add("count", count);
                itemInfo.Add("type", 0);
                itemInfo.Add("target", target);
                itemInfo.Add("column", maxColumn);
                ((ArrayList)rawLayerList[layer]).Add(itemInfo);
            }
        }