Barotrauma/BarotraumaShared/Source/Items/Components/ItemComponent.cs
This commit is contained in:
juanjp600
2017-12-20 19:46:53 -03:00
75 changed files with 2109 additions and 596 deletions
@@ -119,9 +119,12 @@ namespace Barotrauma
get { return prefab.Name; }
}
private string description;
[Editable, Serialize("", true)]
public string Description
{
get { return prefab.Description; }
get { return description == null ? prefab.Description : description; }
set { description = value; }
}
public float ImpactTolerance
@@ -1359,12 +1362,12 @@ namespace Barotrauma
if (ContainedItems == null || ContainedItems.All(i => i == null))
{
GameServer.Log(c.Character.Name + " used item " + Name, ServerLog.MessageType.ItemInteraction);
GameServer.Log(c.Character.LogName + " used item " + Name, ServerLog.MessageType.ItemInteraction);
}
else
{
GameServer.Log(
c.Character.Name + " used item " + Name + " (contained items: " + string.Join(", ", Array.FindAll(ContainedItems, i => i != null).Select(i => i.Name)) + ")",
c.Character.LogName + " used item " + Name + " (contained items: " + string.Join(", ", Array.FindAll(ContainedItems, i => i != null).Select(i => i.Name)) + ")",
ServerLog.MessageType.ItemInteraction);
}
@@ -1458,6 +1461,7 @@ namespace Barotrauma
if (GameMain.Server == null) return;
msg.Write(Prefab.Name);
msg.Write(Description);
msg.Write(ID);
if (ParentInventory == null || ParentInventory.Owner == null)
@@ -1476,7 +1480,8 @@ namespace Barotrauma
msg.Write(index < 0 ? (byte)255 : (byte)index);
}
if (Name == "ID Card") msg.Write(Tags);
//TODO: See if tags are different from their prefab before sending 'em
msg.Write(Tags);
}
public static Item ReadSpawnData(NetBuffer msg, bool spawn = true)
@@ -1484,6 +1489,7 @@ namespace Barotrauma
if (GameMain.Server != null) return null;
string itemName = msg.ReadString();
string itemDesc = msg.ReadString();
ushort itemId = msg.ReadUInt16();
ushort inventoryId = msg.ReadUInt16();
@@ -1507,11 +1513,7 @@ namespace Barotrauma
}
}
string tags = "";
if (itemName == "ID Card")
{
tags = msg.ReadString();
}
string tags = msg.ReadString();
if (!spawn) return null;
@@ -1541,6 +1543,7 @@ namespace Barotrauma
var item = new Item(itemPrefab, pos, sub);
item.Description = itemDesc;
item.ID = itemId;
if (sub != null)
{