Esempio n. 1
0
        public static int registerBuilding(String name, String description, String iconPath, int gridIndex, int modelIndex)
        {
            int id = findAvailableID(2000, LDB.items, items);

            ItemProto proto = new ItemProto
            {
                Type        = EItemType.Production,
                StackSize   = 50,
                IconPath    = iconPath,
                Name        = name,
                Description = description,
                GridIndex   = gridIndex,
                DescFields  = new [] { 22, 11, 12, 1 },
                ID          = id,
                ModelIndex  = modelIndex,
                ModelCount  = 1,
                BuildIndex  = 703,
                BuildMode   = 1,
                IsEntity    = true,
                CanBuild    = true
            };

            LDBTool.PreAddProto(ProtoType.Item, proto);

            items.Add(proto.ID, proto);
            itemLookup.Add(name, proto.ID);
            return(proto.ID);
        }
Esempio n. 2
0
        private void AddItem()
        {
            itemSapling             = LDB.items.Select(1201).Copy();
            itemSapling.ID          = 9150;
            itemSapling.GridIndex   = 1506;
            itemSapling.Type        = EItemType.Resource;
            itemSapling.Name        = "sapling";
            itemSapling.name        = itemSapling.Name.Translate();
            itemSapling.Description = "";
            itemSapling.description = "";
            Traverse.Create(itemSapling).Field("_iconSprite").SetValue(_iconSapling);
            LDBTool.PostAddProto(ProtoType.Item, itemSapling);

            itemCharcoal             = LDB.items.Select(1109).Copy();
            itemCharcoal.ID          = 9151;
            itemCharcoal.GridIndex   = 1507;
            itemCharcoal.Type        = EItemType.Resource;
            itemCharcoal.HeatValue   = 2700000;
            itemCharcoal.ReactorInc  = 0.0f;
            itemCharcoal.Name        = "charcoal";
            itemCharcoal.name        = itemCharcoal.Name.Translate();
            itemCharcoal.Description = "charcoalDesc";
            itemCharcoal.description = itemCharcoal.Description.Translate();
            Traverse.Create(itemCharcoal).Field("_iconSprite").SetValue(_iconCharcoal);
            LDBTool.PostAddProto(ProtoType.Item, itemCharcoal);
        }
Esempio n. 3
0
 private void SetStringProto(StringProto proto, int id, String strCN, String strEN)
 {
     proto.ID   = id;
     proto.Name = strCN;
     proto.name = strCN;
     proto.ZHCN = strCN;
     proto.ENUS = strEN;
     proto.FRFR = strEN;
     LDBTool.PreAddProto(ProtoType.String, proto);
 }
Esempio n. 4
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);
        }
Esempio n. 5
0
 void SetBuildBar()
 {
     LDBTool.SetBuildBar(5, 2, 10001);
     LDBTool.SetBuildBar(5, 3, 10002);
     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);
 }
Esempio n. 6
0
        void AddTranslation()
        {
            StringProto mk1Name = new StringProto();

            mk1Name.ID   = 10500;
            mk1Name.Name = "Smelter MK. I";
            mk1Name.name = "Smelter MK. I";
            mk1Name.ZHCN = "冶炼厂MK。 I";
            mk1Name.ENUS = "Smelter MK. I";
            mk1Name.FRFR = "Smelter MK. I";

            StringProto mk2Name = new StringProto();

            mk2Name.ID   = 10501;
            mk2Name.Name = "Smelter MK. II";
            mk2Name.name = "Smelter MK. II";
            mk2Name.ZHCN = "冶炼厂MK。 II";
            mk2Name.ENUS = "Smelter MK. II";
            mk2Name.FRFR = "Smelter MK. II";

            StringProto mk3Name = new StringProto();

            mk3Name.ID   = 10503;
            mk3Name.Name = "Smelter MK. III";
            mk3Name.name = "Smelter MK. III";
            mk3Name.ZHCN = "冶炼厂MK。 III";
            mk3Name.ENUS = "Smelter MK. III";
            mk3Name.FRFR = "Smelter MK. III";

            StringProto mk2Desc = new StringProto();

            mk2Desc.ID   = 10502;
            mk2Desc.Name = "1.5x the speed of a Smelter MK. I";
            mk2Desc.name = "1.5x the speed of a Smelter MK. I";
            mk2Desc.ZHCN = "冶炼厂速度的1.5倍";
            mk2Desc.ENUS = "1.5x the speed of a Smelter MK. I";
            mk2Desc.FRFR = "1.5x the speed of a Smelter MK. I";

            StringProto mk3Desc = new StringProto();

            mk3Desc.ID   = 10504;
            mk3Desc.Name = "2x the speed of a Smelter MK. I";
            mk3Desc.name = "2x the speed of a Smelter MK. I";
            mk3Desc.ZHCN = "速度是冶炼厂MK的2倍。一世";
            mk3Desc.ENUS = "2x the speed of a Smelter MK. I";
            mk3Desc.FRFR = "2x the speed of a Smelter MK. I";

            LDBTool.PreAddProto(ProtoType.String, mk1Name);
            LDBTool.PreAddProto(ProtoType.String, mk2Name);
            LDBTool.PreAddProto(ProtoType.String, mk3Name);
            LDBTool.PreAddProto(ProtoType.String, mk2Desc);
            LDBTool.PreAddProto(ProtoType.String, mk3Desc);
        }
Esempio n. 7
0
        //All of these register a specified proto in LDBTool
        public static int registerModel(String prefabPath)
        {
            int id = findAvailableID(100, LDB.models, models);

            ModelProto proto = new ModelProto
            {
                Name       = id.ToString(),
                PrefabPath = prefabPath,
                ID         = id
            };

            LDBTool.PreAddProto(ProtoType.Model, proto);
            models.Add(proto.ID, proto);
            return(proto.ID);
        }
Esempio n. 8
0
        private static void VFPreloadPrePatch()
        {
            if (LDBTool.Finshed)
            {
                return;
            }
            LDBToolPlugin.logger.LogInfo("Pre Loading...");
            if (LDBTool.PreAddDataAction != null)
            {
                LDBTool.PreAddDataAction();
                LDBTool.PreAddDataAction = null;
            }

            LDBTool.AddProtos(LDBTool.PreToAdd);
        }
Esempio n. 9
0
        private void AddTranslate()
        {
            stringSapling         = new StringProtoJP(28500, "sapling", "Sapling", "苗木");
            stringPlantRecipe     = new StringProtoJP(28501, "plantRecipe", "Log (original)", "木材(原始的)");
            stringPlantRecipeDesc = new StringProtoJP(28502, "plantRecipeDesc", "Growing trees.", "木を育てる。");
            stringCharcoal        = new StringProtoJP(28503, "charcoal", "Charcoal", "木炭");
            stringCharcoalDesc    = new StringProtoJP(28504, "charcoalDesc",
                                                      "Ordinary fuel. obtained by smelting wood, has the same energy as coal.",
                                                      "平凡な燃料です。木を製錬することで得られ、石炭と同等のエネルギーを有します。");

            LDBTool.PreAddProto(ProtoType.String, stringSapling);
            LDBTool.PreAddProto(ProtoType.String, stringPlantRecipe);
            LDBTool.PreAddProto(ProtoType.String, stringPlantRecipeDesc);
            LDBTool.PreAddProto(ProtoType.String, stringCharcoal);
            LDBTool.PreAddProto(ProtoType.String, stringCharcoalDesc);
        }
Esempio n. 10
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);
        }
Esempio n. 11
0
        private static void EditAllProtos <T>(ProtoSet <T> protoSet)
            where T : Proto
        {
            foreach (T proto in protoSet.dataArray)
            {
                if (proto == null)
                {
                    continue;
                }

                try
                {
                    LDBTool.EditDataAction(proto);
                }
                catch (Exception e)
                {
                    LDBToolPlugin.logger.LogWarning($"Edit Error: ID:{proto.ID} Type:{proto.GetType().Name} {e.Message}");
                }
            }
        }
Esempio n. 12
0
        private static void VFPreloadPostPatch()
        {
            if (LDBTool.Finshed)
            {
                return;
            }
            LDBToolPlugin.logger.LogInfo("Post Loading...");
            if (LDBTool.PostAddDataAction != null)
            {
                LDBTool.PostAddDataAction();
                LDBTool.PostAddDataAction = null;
            }

            LDBTool.AddProtos(LDBTool.PostToAdd);

            if (LDBTool.EditDataAction != null)
            {
                foreach (PropertyInfo propertyInfo in typeof(LDB).GetProperties())
                {
                    Type setType = propertyInfo.PropertyType;
                    if (!setType.IsConstructedGenericType)
                    {
                        setType = setType.BaseType;
                    }

                    Type protoType = setType.GetGenericArguments()[0];

                    object protoSet = propertyInfo.GetValue(null);

                    MethodInfo method = typeof(VFPreload_Patch).GetMethod(nameof(EditAllProtos), AccessTools.all).MakeGenericMethod(protoType);
                    method.Invoke(null, new[] { protoSet });
                }
            }

            GameMain.iconSet.loaded = false;
            GameMain.iconSet.Create();
            LDBTool.SetBuildBar();
            LDBTool.Finshed = true;
            LDBToolPlugin.logger.LogInfo("Done.");
        }