public override void OnResearchComplete(ScienceManagerPlayer manager, EResearchCompletionReason reason) { RecipeStorage.GetPlayerStorage(manager.Player).SetRecipeAvailability("pipliz.crafter.bronzeanvil", true, "pipliz.crafter"); RecipeStorage.GetPlayerStorage(manager.Player).SetRecipeAvailability("pipliz.crafter.bow", true, "pipliz.crafter"); RecipeStorage.GetPlayerStorage(manager.Player).SetRecipeAvailability("pipliz.crafter.bowstring", true, "pipliz.crafter"); RecipePlayer.UnlockOptionalRecipe(manager.Player, "pipliz.player.bronzeanvil"); }
/// <summary> /// Called when this researchable is completed by a player. /// </summary> /// <param name="manager">Player's individual science manager.</param> /// <param name="reason">Will equal EResearchCompletionReason.ProgressCompleted when this research is completed by a player.</param> public void OnResearchComplete(ScienceManagerPlayer manager, EResearchCompletionReason reason) { if (reason == EResearchCompletionReason.ProgressCompleted) { foreach (OptionalRecReference U in Unlocks) { if (U.limitType != null) { RecipeStorage.GetPlayerStorage(manager.Player).SetRecipeAvailability(U.NPCCrafted, true, U.limitType); } if (U.PlayerCrafted != null) { RecipePlayer.UnlockOptionalRecipe(manager.Player, U.PlayerCrafted); } } foreach (OptionalRecReference L in Locks) { if (L.limitType != null) { RecipeStorage.GetPlayerStorage(manager.Player).SetRecipeAvailability(L.NPCCrafted, false, L.limitType); } if (L.PlayerCrafted != null) { // need to figure out how to do this. } } } }
public static void LoadRecipes() { buildtoolRecipe = new Recipe(JOB_ITEM_KEY + ".recipe", new List <InventoryItem> () { new InventoryItem(BuiltinBlocks.IronIngot, 1), new InventoryItem(BuiltinBlocks.Planks, 1) }, new InventoryItem(JOB_ITEM_KEY, 1), 0); RecipeStorage.AddDefaultLimitTypeRecipe("pipliz.crafter", buildtoolRecipe); RecipePlayer.AddDefaultRecipe(buildtoolRecipe); }
public static void AfterWorldLoad() { var iron = new InventoryItem(BuiltinBlocks.BronzeIngot, 2); var tools = new InventoryItem(BuiltinBlocks.CopperTools, 1); var planks = new InventoryItem(BuiltinBlocks.Planks, 4); var recipe = new Recipe(JOB_RECIPE, new List<InventoryItem>() { iron, tools, planks }, new InventoryItem(JOB_ITEM_KEY, 1), 2); RecipePlayer.AddOptionalRecipe(recipe); RecipeStorage.AddOptionalLimitTypeRecipe(Items.ItemFactory.JOB_CRAFTER, recipe); }
public override void OnResearchComplete(ScienceManagerPlayer manager, EResearchCompletionReason reason) { RecipeStorage.GetPlayerStorage(manager.Player).SetRecipeAvailability("pipliz.crafter.oven", true, "pipliz.crafter"); RecipeStorage.GetPlayerStorage(manager.Player).SetRecipeAvailability("pipliz.crafter.grindstone", true, "pipliz.crafter"); RecipePlayer.UnlockOptionalRecipe(manager.Player, "pipliz.player.oven"); RecipePlayer.UnlockOptionalRecipe(manager.Player, "pipliz.player.grindstone"); if (reason == EResearchCompletionReason.ProgressCompleted) { Stockpile.GetStockPile(manager.Player).Add(BlockTypes.Builtin.BuiltinBlocks.WheatStage1, 400); if (manager.Player.IsConnected) { Chatting.Chat.Send(manager.Player, "You received 400 wheat seeds!"); } } }
public static void OnPlayerRecipeSettingChanged(RecipeStorage.PlayerRecipeStorage storage, Recipe recipe, Box <RecipeStorage.RecipeSetting> recipeSetting) { //If the setting changed is from a fake player if (storage.Player.ID.type == NetworkID.IDType.Steam && storage.Player.ID.steamID.GetEAccountType() == Steamworks.EAccountType.k_EAccountTypeAnonUser) { Team team = TeamManager.GetTeamManager().GetTeamOfFakePlayer(storage.Player); if (null == team) { return; } foreach (Players.Player plr in team.GetConnectedPlayersPlayers()) { RecipePlayer.SendRecipes(plr); //Recipes in job (how many create) Synchronization (Depends on the stockpile) } } }
/// <summary> /// Called when this researchable is completed by a player. /// </summary> /// <param name="manager">Player's individual science manager.</param> /// <param name="reason">Will equal EResearchCompletionReason.ProgressCompleted when this research is completed by a player.</param> public void OnResearchComplete(ScienceManagerPlayer manager, EResearchCompletionReason reason) { if (reason == EResearchCompletionReason.ProgressCompleted) { foreach (Unlock U in Unlocks) { if (U.limitType != null) { RecipeStorage.GetPlayerStorage(manager.Player).SetRecipeAvailability(U.NPCCrafted, true, U.limitType); } if (U.PlayerCrafted != null) { RecipePlayer.UnlockOptionalRecipe(manager.Player, U.PlayerCrafted); } } } }
/// <summary> /// Does all the work of adding this recipe to the server's database. Should be called in the AfterItemTypesDefined callback. /// </summary> public void addRecipeToLimitType() { if (enabled) { try { // First remove any recipes we are replacing. foreach (string deleteMe in Replaces) { Pipliz.Log.Write("{0}: Recipe {1} is marked as replacing {2}, attempting to comply.", NAMESPACE == null ? "" : NAMESPACE, this.Name, deleteMe); RecipeHelper.tryRemoveRecipe(deleteMe); } // Convert shell references into actual InventoryItem objects. foreach (ItemShell I in Results) { if (Variables.itemsMaster == null) { Pipliz.Log.WriteError("{0}.SimpleRecipe.addRecipeToLimitType() has reached a critical error: 'Variables.itemsMaster' is not yet available. Recipe: {1}", NAMESPACE == null ? "" : NAMESPACE, this.Name); } else { string useKey = I.asSimpleItem == null ? I.strItemkey : I.asSimpleItem.ID; if (Variables.itemsMaster.ContainsKey(useKey)) { realResults.Add(new InventoryItem(useKey, I.intAmount)); } else { Pipliz.Log.WriteError("{0}: A problem occurred adding recipe RESULT {1} to recipe {2}, the item key was not found.", NAMESPACE == null ? "" : NAMESPACE, I.strItemkey, this.Name); } } } foreach (ItemShell I in Requirements) { if (Variables.itemsMaster == null) { Pipliz.Log.WriteError("{0}.SimpleRecipe.addRecipeToLimitType() has reached a critical error: 'Variables.itemsMaster' is not yet available. Recipe: {1}", NAMESPACE == null ? "" : NAMESPACE, this.Name); } else { string useKey = I.asSimpleItem == null ? I.strItemkey : I.asSimpleItem.ID; if (Variables.itemsMaster.ContainsKey(useKey)) { realRequirements.Add(new InventoryItem(useKey, I.intAmount)); } else { Pipliz.Log.WriteError("{0}: A problem occurred adding recipe REQUIREMENT {1} to recipe {2}, the item key was not found.", NAMESPACE == null ? "" : NAMESPACE, I.strItemkey, this.Name); } } } // Build actual Recipe object. Recipe thisRecipe = new Recipe(this.fullName, this.realRequirements, this.realResults, this.defaultLimit, this.isOptional, this.defaultPriority); // Commence registering it. Pipliz.Log.Write("{0}: Attempting to register recipe {1}", NAMESPACE == null ? "" : NAMESPACE, thisRecipe.Name); if (this.limitType != null) { if (isOptional) { Pipliz.Log.Write("{0}: Attempting to register optional limit type recipe {1}", NAMESPACE == null ? "" : NAMESPACE, thisRecipe.Name); RecipeStorage.AddOptionalLimitTypeRecipe(limitType, thisRecipe); } else { Pipliz.Log.Write("{0}: Attempting to register default limit type recipe {1}", NAMESPACE == null ? "" : NAMESPACE, thisRecipe.Name); RecipeStorage.AddDefaultLimitTypeRecipe(limitType, thisRecipe); } } if (userCraftable) { Recipe playerRecipe = new Recipe("player." + this.Name, this.realRequirements, this.realResults, this.defaultLimit, this.isOptional); Pipliz.Log.Write("{0}: Attempting to register default player type recipe {1}", NAMESPACE == null ? "" : NAMESPACE, playerRecipe.Name); RecipePlayer.AddDefaultRecipe(playerRecipe); } } catch (Exception ex) { Pipliz.Log.WriteError("{0}: Error adding recipe: {1}", NAMESPACE == null ? "" : NAMESPACE, ex.Message); } } else { Pipliz.Log.Write("{0}: Recipe {1} has been disabled and will NOT be registered.", NAMESPACE == null ? "" : NAMESPACE, this.Name); } }
public static void LoadRecipes() { foreach (string fullDirPath in Directory.GetDirectories(BlocksDirectory)) { string packageName = Path.GetFileName(fullDirPath); if (packageName.Equals("examples")) { continue; } Pipliz.Log.Write(string.Format("Started loading '{0}' recipes...", packageName)); try { foreach (string[] jobAndFilename in new string[][] { new string[] { "workbench", "crafting.json" }, new string[] { "tailorshop", "tailoring.json" }, new string[] { "grindstone", "grinding.json" }, new string[] { "mint", "minting.json" }, new string[] { "shop", "shopping.json" }, new string[] { "technologisttable", "technologist.json" }, new string[] { "furnace", "smelting.json" }, new string[] { "oven", "baking.json" } }) { JSONNode jsonRecipes; if (Pipliz.JSON.JSON.Deserialize(MultiPath.Combine(BlocksDirectory, packageName, jobAndFilename [1]), out jsonRecipes, false)) { if (jsonRecipes.NodeType == NodeType.Array) { foreach (JSONNode craftingEntry in jsonRecipes.LoopArray()) { foreach (string recipePart in new string[] { "results", "requires" }) { JSONNode jsonRecipeParts = craftingEntry.GetAs <JSONNode> (recipePart); foreach (JSONNode jsonRecipePart in jsonRecipeParts.LoopArray()) { string type = jsonRecipePart.GetAs <string> ("type"); string realtype; if (type.StartsWith(VANILLA_PREFIX)) { realtype = type.Substring(VANILLA_PREFIX.Length); } else { realtype = MOD_PREFIX + packageName + "." + type; } Pipliz.Log.Write(string.Format("Rewriting block recipe type from '{0}' to '{1}'", type, realtype)); jsonRecipePart.SetAs("type", realtype); } } Recipe craftingRecipe = new Recipe(craftingEntry); RecipeStorage.AddRecipe(craftingRecipe); RecipeStorage.AddBlockToRecipeMapping(jobAndFilename [0], craftingRecipe.Name); if (jobAndFilename [1].Equals("crafting.json")) { RecipePlayer.AddDefaultRecipe(craftingRecipe); } } } else { Pipliz.Log.WriteError(string.Format("Expected json array in {0}, but got {1} instead", jobAndFilename [1], jsonRecipes.NodeType)); } } } } catch (Exception exception) { Pipliz.Log.WriteError(string.Format("Exception while loading recipes from {0}; {1}", packageName, exception.Message)); } } }
public static void LoadRecipes() { RecipePlayer.AddDefaultRecipe(new Recipe(JOB_ITEM_KEY + ".recipe", new InventoryItem(BuiltinBlocks.Planks, 1), new InventoryItem(JOB_ITEM_KEY, 1), 0)); }