Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections.Generic;
- using System.IO;
- using PhentrixGames.NewColonyAPI.Classes;
- namespace Examaple.Classes
- {
- /// <summary>
- /// PhentrixGames.NewColonyAPI.Classes.Type - is the main class that will allow the items to be created easily.
- /// PhentrixGames.NewColonyAPI.Interfaces.IAutoType - This interface is searched for by the API and adds the items to the game
- /// </summary>
- [TypeAttribute]
- public class ExampleBlock : PhentrixGames.NewColonyAPI.Classes.Type
- {
- //This is the class where you'll put the item together.
- //"ExampleBlock" is what the game will know the item as without localization (aka this.TypeName)
- //The true/false part is if you want to override the recipe function within this class or not. (the recipes can also be made in seperate files)
- public ExampleBlock() : base("ExampleBlock", true)
- {
- //Should the block be solid (player can't walk thru solid blocks)
- this.IsSolid = true;
- //This is how to give the item an icon, it requires a full path to the icon.
- //So if your icons are in your mod's folder the code would be...
- this.Icon = Path.Combine(ModEntry.ModGamedataDirectory, "ExampleBlockIcon.png");
- //Note that icons have to be 64x64 pixels
- //Can the player break this block (true = yes, false = no)
- this.IsDestructible = true;
- //How long does it take to destroy the block in milliseconds.
- this.DestructionTime = 0;
- //Can this item be placed in the world?
- this.IsPlaceable = true;
- }
- //If you put true in the base you'll need this function.
- //Returning base.AddRecipes() will cause it to error, so you'll have to make the recipe.
- public override List<BaseRecipe> AddRecipes()
- {
- List<BaseRecipe> ret = new List<BaseRecipe>(); //We will need to make a list of BaseRecipe to be able to return
- BaseRecipe rec1 = new BaseRecipe("exampleblockrecipe", true); //BaseRecipe takes a string (ID) and a bool(can the player craft this item)
- InventoryItem result = new InventoryItem("ExampleBlock"); //This is the result of the BaseRecipe (Note you can have NPCs receive more then a single result)
- rec1.Result.Add(result); //We now add the result to the recipe
- InventoryItem requirements = new InventoryItem("logtemperate"); //Now we setup the requirements for the recipe (we'll use a temperate log to make this block)
- rec1.Requirements.Add(requirements); //Adding the requirement to the recipe now
- ret.Add(rec1); //Adding our recipe to our list of recipes
- return ret; //Returning our list of baserecipe
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement