Fixed only the first inventory of an item being synced (e.g. clients wouldn't get notified when an item is contained in the "output inventory" of a fabricator or deconstructor).

This commit is contained in:
Joonas Rikkonen
2018-07-30 11:00:21 +03:00
parent 9964923eba
commit c66098ca4e
5 changed files with 49 additions and 7 deletions
@@ -1,4 +1,5 @@
using Barotrauma.Items.Components;
using Barotrauma.Networking;
using Microsoft.Xna.Framework;
using System.Collections.Generic;
@@ -84,6 +85,27 @@ namespace Barotrauma
return wasPut;
}
protected override void CreateNetworkEvent()
{
int componentIndex = container.Item.components.IndexOf(container);
if (componentIndex == -1)
{
DebugConsole.Log("Creating a network event for the item \"" + container.Item + "\" failed, ItemContainer not found in components");
return;
}
if (GameMain.Server != null)
{
GameMain.Server.CreateEntityEvent(Owner as IServerSerializable, new object[] { NetEntityEvent.Type.InventoryState, componentIndex });
}
#if CLIENT
else if (GameMain.Client != null)
{
GameMain.Client.CreateEntityEvent(Owner as IClientSerializable, new object[] { NetEntityEvent.Type.InventoryState, componentIndex });
}
#endif
}
public override void RemoveItem(Item item)
{
base.RemoveItem(item);