public static void generateRecipes() { //ServerLog.LogAsyncMessage(new LogMessage("Begining " + NAME + " recipe generation", LogType.Log)); DecorLogger.LogToFile("Begining " + NAME + " recipe generation"); if (GenerateTypeConfig.DecorConfigFileTrue && GenerateTypeConfig.DecorTypes.TryGetValue(LocalGenerateConfig.NAME, out List <DecorType> blockTypes)) { foreach (var currentType in blockTypes) { var typeName = GenerateTypeConfig.TYPEPREFIX + NAME + "." + currentType.name; var typeNameRecipe = typeName + ".Recipe"; //ServerLog.LogAsyncMessage(new LogMessage("Generating recipe " + typeNameRecipe, LogType.Log)); DecorLogger.LogToFile("Generating recipe " + typeNameRecipe); var recipe = new TypeRecipeBase(); recipe.name = typeNameRecipe; recipe.requires.Add(new RecipeItem(currentType.type)); recipe.results.Add(new RecipeResult(typeName)); recipe.Job = GenerateTypeConfig.DecorJobRecipe; //var newRecipe = new Recipe(recipe.name, recipe.requires, recipe.results, recipe.defaultLimit, 0, (int)recipe.defaultPriority); //var newRecipe = new Recipe(recipe.name, recipe.requires, recipe.results, recipe.defaultLimit, (byte)recipe.defaultPriority); var requirements = new List <InventoryItem>(); var results = new List <RecipeResult>(); recipe.JsonSerialize(); DecorLogger.LogToFile("JSON - " + recipe.JsonSerialize().ToString()); foreach (var ri in recipe.requires) { if (ItemTypes.IndexLookup.TryGetIndex(ri.type, out var itemIndex)) { requirements.Add(new InventoryItem(itemIndex, ri.amount)); } else { DecorLogger.LogToFile("\"" + typeNameRecipe + "\" bad requirement \"" + ri.type + "\""); } } foreach (var ri in recipe.results) { results.Add(ri); } var newRecipe = new Recipe(recipe.name, requirements, results, recipe.defaultLimit, 0, (int)recipe.defaultPriority); ServerManager.RecipeStorage.AddLimitTypeRecipe(recipe.Job, newRecipe); //ServerManager.RecipeStorage.AddLimitTypeRecipe(recipe.Job, newRecipe); } } }
public static void generateTypes() { if (GenerateTypeConfig.DecorConfigFileTrue) { //ServerLog.LogAsyncMessage(new LogMessage("Begining " + NAME + " generation", LogType.Log)); using (StreamWriter outputFile = new StreamWriter(System.IO.Path.Combine(GenerateTypeConfig.GAME_SAVEFILE, "TypeList.txt"), true)) { outputFile.WriteLine(NAME + " types:"); } DecorLogger.LogToFile("Begining " + NAME + " generation"); JSONNode list = new JSONNode(NodeType.Array); if (GenerateTypeConfig.DecorConfigFileTrue && GenerateTypeConfig.DecorTypes.TryGetValue(NAME, out List <DecorType> blockTypes)) { foreach (var currentType in blockTypes) { //ServerLog.LogAsyncMessage(new LogMessage("Found parent " + currentType.type, LogType.Log)); //ServerLog.LogAsyncMessage(new LogMessage("Found texture " + currentType.texture, LogType.Log)); var typeName = GenerateTypeConfig.TYPEPREFIX + NAME + "." + currentType.name; //ServerLog.LogAsyncMessage(new LogMessage("Generating type " + typeName, LogType.Log)); DecorLogger.LogToFile("Generating type \"" + typeName + "\" with \"name\": \"" + currentType.name + "\" \"type\": \"" + currentType.type + "\" \"texture\": \"" + currentType.texture + "\""); var Typesbase = new TypeSpecs(); Typesbase.baseType.categories.Add(currentType.texture); Typesbase.typeName = typeName; Typesbase.baseType.sideall = currentType.texture; //Typesbase.baseType.onRemoveType = typeName; //Typesbase.baseType.onRemove.Add.typeName; list.AddToArray(Typesbase.JsonSerialize()); DecorLogger.LogToFile("JSON - " + Typesbase.JsonSerialize().ToString()); using (StreamWriter outputFile = new StreamWriter(System.IO.Path.Combine(GenerateTypeConfig.GAME_SAVEFILE, "TypeList.txt"), true)) { outputFile.WriteLine("Type \"" + typeName + "\" has texture \"" + currentType.texture + "\""); } } } ItemTypesServer.BlockRotator.Patches.AddPatch(new ItemTypesServer.BlockRotator.BlockGeneratePatch(GenerateTypeConfig.MOD_FOLDER, -99999, list)); using (StreamWriter outputFile = new StreamWriter(System.IO.Path.Combine(GenerateTypeConfig.GAME_SAVEFILE, "TypeList.txt"), true)) { outputFile.WriteLine(""); } } }
public static void generateTypes(Dictionary <string, ItemTypeRaw> types) { var name = "Slab"; using (StreamWriter outputFile = new StreamWriter(System.IO.Path.Combine(GenerateTypeConfig.GAME_SAVEFILE, "TypeList.txt"), true)) { outputFile.WriteLine(name + " types:"); } DecorLogger.LogToFile("Begining " + name + " generation"); List <string> typesAdded = new List <string>(); List <string> categories = new List <string>(categoryBase.categories); categories.Add(name); var TypeParent = new DecorTypeBase(); TypeParent.icon = GenerateTypeConfig.MOD_ICON_PATH + name + GenerateTypeConfig.ICONTYPE; var TypeUp = new DecorTypeBase(); TypeUp.mesh = GenerateTypeConfig.MOD_MESH_PATH + name + ".up" + GenerateTypeConfig.MESHTYPE; TypeUp.colliders.boxes = typeColliders.Colliders_Dict[name + "Up"]; var TypeDown = new DecorTypeBase(); TypeDown.mesh = GenerateTypeConfig.MOD_MESH_PATH + name + ".down" + GenerateTypeConfig.MESHTYPE; TypeDown.colliders.boxes = typeColliders.Colliders_Dict[name + "Down"]; if (GenerateTypeConfig.DecorTypes.TryGetValue("_ALL", out List <DecorType> allBlockTypes)) { foreach (var currentType in allBlockTypes) { var typeName = GenerateTypeConfig.TYPEPREFIX + name + "." + currentType.name; var typeDownName = typeName + ".down"; var typeUpName = typeName + ".up"; if (!typesAdded.Contains(typeName)) { DecorLogger.LogToFile("Generating type \"" + typeName + "\" with \"name\": \"" + currentType.name + "\" \"type\": \"" + currentType.type + "\" \"texture\": \"" + currentType.texture + "\""); TypeParent.name = typeName; TypeParent.categories = new List <string>(categories); TypeParent.categories.Add(currentType.texture); TypeParent.sideall = currentType.texture; TypeParent.rotatablexn = typeUpName; TypeParent.rotatablexp = typeUpName; TypeParent.rotatablezn = typeDownName; TypeParent.rotatablezp = typeDownName; TypeUp.name = typeUpName; TypeUp.parentType = typeName; TypeDown.name = typeDownName; TypeDown.parentType = typeName; typesAdded.Add(typeName); types.Add(typeName, new ItemTypeRaw(typeName, TypeParent.JsonSerialize())); types.Add(typeUpName, new ItemTypeRaw(typeUpName, TypeUp.JsonSerialize())); types.Add(typeDownName, new ItemTypeRaw(typeDownName, TypeDown.JsonSerialize())); DecorLogger.LogToFile("JSON - " + TypeParent.JsonSerialize().ToString() + TypeUp.JsonSerialize().ToString() + TypeDown.JsonSerialize().ToString()); using (StreamWriter outputFile = new StreamWriter(System.IO.Path.Combine(GenerateTypeConfig.GAME_SAVEFILE, "TypeList.txt"), true)) { outputFile.WriteLine("Type \"" + typeName + "\" has texture \"" + currentType.texture + "\""); } } else { DecorLogger.LogToFile("Type with \"name\": \"" + currentType.name + "\" already exists for \"" + name + "\" check decor file for duplicates, type skipped"); } } } if (GenerateTypeConfig.DecorTypes.TryGetValue(name, out List <DecorType> BlockTypes)) { foreach (var currentType in BlockTypes) { var typeName = GenerateTypeConfig.TYPEPREFIX + name + "." + currentType.name; var typeDownName = typeName + ".down"; var typeUpName = typeName + ".up"; if (!typesAdded.Contains(typeName)) { DecorLogger.LogToFile("Generating type \"" + typeName + "\" with \"name\": \"" + currentType.name + "\" \"type\": \"" + currentType.type + "\" \"texture\": \"" + currentType.texture + "\""); TypeParent.name = typeName; TypeParent.categories = new List <string>(categories); TypeParent.categories.Add(currentType.texture); TypeParent.sideall = currentType.texture; TypeParent.rotatablexn = typeUpName; TypeParent.rotatablexp = typeUpName; TypeParent.rotatablezn = typeDownName; TypeParent.rotatablezp = typeDownName; TypeUp.name = typeUpName; TypeDown.name = typeDownName; typesAdded.Add(typeName); types.Add(typeName, new ItemTypeRaw(typeName, TypeParent.JsonSerialize())); types.Add(typeUpName, new ItemTypeRaw(typeUpName, TypeUp.JsonSerialize())); types.Add(typeDownName, new ItemTypeRaw(typeDownName, TypeDown.JsonSerialize())); DecorLogger.LogToFile("JSON - " + TypeParent.JsonSerialize().ToString()); using (StreamWriter outputFile = new StreamWriter(System.IO.Path.Combine(GenerateTypeConfig.GAME_SAVEFILE, "TypeList.txt"), true)) { outputFile.WriteLine("Type \"" + typeName + "\" has texture \"" + currentType.texture + "\""); } } else { DecorLogger.LogToFile("Type with \"name\": \"" + currentType.name + "\" already exists for \"" + name + "\" check decor file for duplicates, type skipped"); } } } using (StreamWriter outputFile = new StreamWriter(System.IO.Path.Combine(GenerateTypeConfig.GAME_SAVEFILE, "TypeList.txt"), true)) { outputFile.WriteLine(""); } }