Adding Items in Code - JBurlison/Pandaros.API GitHub Wiki
To adding items in code is very simple. Just inherit from the CSType class and override the properties you wish to implement. Don't worry about registering the item or anything, Settlers uses reflection to find all items by inheritance and will handle all the registering for you. See JSON Code samples for detailed property information.
public class Adamantine : CSType
{
public static string NAME = "Pandaros.Settlers.AutoLoad.Adamantine";
public override string name { get; set; } = NAME;
public override int? maxStackSize => 600;
public override bool? isPlaceable => false;
public override string icon { get; set; } = GameLoader.ICON_PATH + "Adamantine.png";
public override List<string> categories { get; set; } = new List<string>()
{
"ingredient",
"Adamantine"
};
}
I wont go over any existing properties that the base game provides for types but there are new ones that Settlers introduces.
ItemRarity serves no function in game, it is merely adds tool tip text to display how rare an item is.
public enum ItemRarity
{
Common = 0,
Uncommon = 1,
Rare = 2,
Artifact = 3
}
The static item property will keep an item in the stockpile at all times. If you die or lose it in any way, settlers will put it back in the stockpile. This is useful for items such as menu items and tools.
It has a name (i usually just make this the item name.) Required science key (it will appear after this science is researched) and required permission for the permission manager, so only if the colony owner has a specific permission, they will get the item.
public class StaticItem
{
public string Name { get; set; }
public string RequiredScience { get; set; }
public string RequiredPermission { get; set; }
}
The open menu settings allows the item to open a Wiki Only the UIURL and the item name are required.
public class OpenMenuSettings
{
public string UIUrl { get; set; }
public Shared.PlayerClickedData.EClickType ActivateClickType { get; set; } = Shared.PlayerClickedData.EClickType.Right;
public string ItemName { get; set; }
}
To create magical armor inherit IArmor and PlayerMagicItem OR MagicArmor.
To create magical armor inherit IWeapon and PlayerMagicItem OR MagicWeapon.
To create magic items inherit CSType and IPlayerMagicItem OR PlayerMagicItem. ensure IsMagical = true