(b6f451292) Moved crafting recipes from the fabricator xml to the xmls of the items. Makes it possible for modders to add new craftable items without having to modify the fabricators. Closes #1001

This commit is contained in:
Joonas Rikkonen
2019-04-01 22:51:37 +03:00
parent 508bd960be
commit 8b12f85f48
8 changed files with 260 additions and 188 deletions
@@ -12,7 +12,7 @@ namespace Barotrauma.Items.Components
{
public void ServerRead(ClientNetObject type, NetBuffer msg, Client c)
{
int itemIndex = msg.ReadRangedInteger(-1, fabricableItems.Count - 1);
int itemIndex = msg.ReadRangedInteger(-1, fabricationRecipes.Count - 1);
item.CreateServerEvent(this);
@@ -25,17 +25,17 @@ namespace Barotrauma.Items.Components
else
{
//if already fabricating the selected item, return
if (fabricatedItem != null && fabricableItems.IndexOf(fabricatedItem) == itemIndex) return;
if (itemIndex < 0 || itemIndex >= fabricableItems.Count) return;
if (fabricatedItem != null && fabricationRecipes.IndexOf(fabricatedItem) == itemIndex) return;
if (itemIndex < 0 || itemIndex >= fabricationRecipes.Count) return;
StartFabricating(fabricableItems[itemIndex], c.Character);
StartFabricating(fabricationRecipes[itemIndex], c.Character);
}
}
public void ServerWrite(NetBuffer msg, Client c, object[] extraData = null)
{
int itemIndex = fabricatedItem == null ? -1 : fabricableItems.IndexOf(fabricatedItem);
msg.WriteRangedInteger(-1, fabricableItems.Count - 1, itemIndex);
int itemIndex = fabricatedItem == null ? -1 : fabricationRecipes.IndexOf(fabricatedItem);
msg.WriteRangedInteger(-1, fabricationRecipes.Count - 1, itemIndex);
UInt16 userID = fabricatedItem == null || user == null ? (UInt16)0 : user.ID;
msg.Write(userID);
}