From 575b643c62807d731dab2d8679ad5f06c06c7910 Mon Sep 17 00:00:00 2001 From: Joonas Rikkonen Date: Mon, 17 Jul 2017 23:27:31 +0300 Subject: [PATCH] Added "user" parameter to Inventory.PutItem and Inventory.TryPutItem. + More descriptive wiring logging: the logs don't list all the wires in a connectionpanel but only the changes a player does to the wiring. Disconnecting wires by picking them up and wiring done by the host are also logged now. --- .../Items/Components/Signal/Connection.cs | 16 ++++++- .../Source/Screens/EditMapScreen.cs | 4 +- .../AI/Objectives/AIObjectiveCombat.cs | 2 +- .../AI/Objectives/AIObjectiveGetItem.cs | 4 +- .../Source/Characters/Character.cs | 2 +- .../Source/Characters/HuskInfection.cs | 2 +- .../Source/Characters/Jobs/Job.cs | 4 +- .../Source/Items/CharacterInventory.cs | 40 +++++++++--------- .../Items/Components/Holdable/Pickable.cs | 2 +- .../Source/Items/Components/ItemContainer.cs | 6 +-- .../Components/Signal/ConnectionPanel.cs | 42 +++++++++++++++---- .../Source/Items/Components/Signal/Wire.cs | 30 ++++++++++--- .../Source/Items/Inventory.cs | 20 ++++----- .../BarotraumaShared/Source/Items/Item.cs | 6 +-- .../Source/Items/ItemInventory.cs | 9 ++-- .../Source/Networking/EntitySpawner.cs | 2 +- 16 files changed, 125 insertions(+), 66 deletions(-) diff --git a/Barotrauma/BarotraumaClient/Source/Items/Components/Signal/Connection.cs b/Barotrauma/BarotraumaClient/Source/Items/Components/Signal/Connection.cs index 25a887888..0fba6f5c5 100644 --- a/Barotrauma/BarotraumaClient/Source/Items/Components/Signal/Connection.cs +++ b/Barotrauma/BarotraumaClient/Source/Items/Components/Signal/Connection.cs @@ -1,4 +1,5 @@ -using Microsoft.Xna.Framework; +using Barotrauma.Networking; +using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using System; using System.Linq; @@ -169,7 +170,18 @@ namespace Barotrauma.Items.Components draggingConnected.RemoveConnection(item); - if (draggingConnected.Connect(this, !alreadyConnected, true)) Wires[index] = draggingConnected; + if (draggingConnected.Connect(this, !alreadyConnected, true)) + { + GameServer.Log(item.Name + " rewired by " + Character.Controlled.Name, ServerLog.MessageType.ItemInteraction); + + var otherConnection = draggingConnected.OtherConnection(this); + + GameServer.Log(item.Name + " rewired by " + Character.Controlled.Name + ": " + + Name + " -> " + + (otherConnection == null ? "none" : otherConnection.Item.Name + " (" + (otherConnection.Name) + ")"), ServerLog.MessageType.ItemInteraction); + + Wires[index] = draggingConnected; + } } } } diff --git a/Barotrauma/BarotraumaClient/Source/Screens/EditMapScreen.cs b/Barotrauma/BarotraumaClient/Source/Screens/EditMapScreen.cs index 31efcef9d..d4059e8bd 100644 --- a/Barotrauma/BarotraumaClient/Source/Screens/EditMapScreen.cs +++ b/Barotrauma/BarotraumaClient/Source/Screens/EditMapScreen.cs @@ -724,7 +724,7 @@ namespace Barotrauma var item = new Item(screwdriverPrefab, Vector2.Zero, null); - dummyCharacter.Inventory.TryPutItem(item, new List() {InvSlotType.RightHand}); + dummyCharacter.Inventory.TryPutItem(item, null, new List() { InvSlotType.RightHand }); wiringToolPanel = CreateWiringPanel(); } @@ -816,7 +816,7 @@ namespace Barotrauma existingWire.Remove(); } - dummyCharacter.Inventory.TryPutItem(wire, slotIndex, false); + dummyCharacter.Inventory.TryPutItem(wire, slotIndex, false, dummyCharacter); return true; diff --git a/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveCombat.cs b/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveCombat.cs index f73e03969..b4f1a61f0 100644 --- a/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveCombat.cs +++ b/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveCombat.cs @@ -46,7 +46,7 @@ namespace Barotrauma { if (!character.SelectedItems.Contains(weapon)) { - character.Inventory.TryPutItem(weapon, 3, false); + character.Inventory.TryPutItem(weapon, 3, false, character); weapon.Equip(character); } character.CursorPosition = enemy.Position; diff --git a/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveGetItem.cs b/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveGetItem.cs index a6561e2ce..07aec2f29 100644 --- a/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveGetItem.cs +++ b/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveGetItem.cs @@ -83,7 +83,7 @@ namespace Barotrauma if (character.Inventory.Items[i] == null) continue; //try to move the existing item to LimbSlot.Any and continue if successful - if (character.Inventory.TryPutItem(character.Inventory.Items[i], new List() { InvSlotType.Any })) continue; + if (character.Inventory.TryPutItem(character.Inventory.Items[i], character, new List() { InvSlotType.Any })) continue; //if everything else fails, simply drop the existing item character.Inventory.Items[i].Drop(); @@ -95,7 +95,7 @@ namespace Barotrauma if (targetSlot > -1 && character.Inventory.IsInLimbSlot(targetItem, InvSlotType.Any)) { - character.Inventory.TryPutItem(targetItem, targetSlot, false); + character.Inventory.TryPutItem(targetItem, targetSlot, false, character); } } else diff --git a/Barotrauma/BarotraumaShared/Source/Characters/Character.cs b/Barotrauma/BarotraumaShared/Source/Characters/Character.cs index 66701c31b..0c4276b8e 100644 --- a/Barotrauma/BarotraumaShared/Source/Characters/Character.cs +++ b/Barotrauma/BarotraumaShared/Source/Characters/Character.cs @@ -576,7 +576,7 @@ namespace Barotrauma if (item == null) continue; item.TryInteract(this, true, true, true); - inventory.TryPutItem(item, i, false, false); + inventory.TryPutItem(item, i, false, null, false); } } } diff --git a/Barotrauma/BarotraumaShared/Source/Characters/HuskInfection.cs b/Barotrauma/BarotraumaShared/Source/Characters/HuskInfection.cs index 48abfc1fd..9c894310a 100644 --- a/Barotrauma/BarotraumaShared/Source/Characters/HuskInfection.cs +++ b/Barotrauma/BarotraumaShared/Source/Characters/HuskInfection.cs @@ -162,7 +162,7 @@ namespace Barotrauma for (int i = 0; i < character.Inventory.Items.Length; i++) { if (character.Inventory.Items[i] == null) continue; - husk.Inventory.TryPutItem(character.Inventory.Items[i], i, true); + husk.Inventory.TryPutItem(character.Inventory.Items[i], i, true, null); } character.Enabled = false; diff --git a/Barotrauma/BarotraumaShared/Source/Characters/Jobs/Job.cs b/Barotrauma/BarotraumaShared/Source/Characters/Jobs/Job.cs index 99ea1cb83..ea81ddd99 100644 --- a/Barotrauma/BarotraumaShared/Source/Characters/Jobs/Job.cs +++ b/Barotrauma/BarotraumaShared/Source/Characters/Jobs/Job.cs @@ -117,11 +117,11 @@ namespace Barotrauma List allowedSlots = new List(item.AllowedSlots); allowedSlots.Remove(InvSlotType.Any); - character.Inventory.TryPutItem(item, allowedSlots); + character.Inventory.TryPutItem(item, null, allowedSlots); } else { - character.Inventory.TryPutItem(item, item.AllowedSlots); + character.Inventory.TryPutItem(item, null, item.AllowedSlots); } if (item.Prefab.Name == "ID Card" && spawnPoint != null) diff --git a/Barotrauma/BarotraumaShared/Source/Items/CharacterInventory.cs b/Barotrauma/BarotraumaShared/Source/Items/CharacterInventory.cs index 561c6799a..51f4a1dd0 100644 --- a/Barotrauma/BarotraumaShared/Source/Items/CharacterInventory.cs +++ b/Barotrauma/BarotraumaShared/Source/Items/CharacterInventory.cs @@ -80,7 +80,7 @@ namespace Barotrauma /// /// If there is room, puts the item in the inventory and returns true, otherwise returns false /// - public override bool TryPutItem(Item item, List allowedSlots = null, bool createNetworkEvent = true) + public override bool TryPutItem(Item item, Character user, List allowedSlots = null, bool createNetworkEvent = true) { if (allowedSlots == null || !allowedSlots.Any()) return false; @@ -100,7 +100,7 @@ namespace Barotrauma { if (Items[i] != null || limbSlots[i] != InvSlotType.Any) continue; - PutItem(item, i, true, createNetworkEvent); + PutItem(item, i, user, true, createNetworkEvent); item.Unequip(character); return true; } @@ -128,7 +128,7 @@ namespace Barotrauma { if (allowedSlot.HasFlag(limbSlots[i]) && Items[i] == null) { - PutItem(item, i, !placed, createNetworkEvent); + PutItem(item, i, user, !placed, createNetworkEvent); item.Equip(character); placed = true; } @@ -144,7 +144,7 @@ namespace Barotrauma return placed; } - public override bool TryPutItem(Item item, int index, bool allowSwapping, bool createNetworkEvent = true) + public override bool TryPutItem(Item item, int index, bool allowSwapping, Character user, bool createNetworkEvent = true) { //there's already an item in the slot if (Items[index] != null) @@ -174,10 +174,10 @@ namespace Barotrauma Items[currentIndex] = null; Items[index] = null; //if the item in the slot can be moved to the slot of the moved item - if (TryPutItem(existingItem, currentIndex, false, createNetworkEvent) && - TryPutItem(item, index, false, createNetworkEvent)) + if (TryPutItem(existingItem, currentIndex, false, user, createNetworkEvent) && + TryPutItem(item, index, false, user, createNetworkEvent)) { - + } else { @@ -185,11 +185,11 @@ namespace Barotrauma Items[index] = null; //swapping the items failed -> move them back to where they were - TryPutItem(item, currentIndex, false, createNetworkEvent); - TryPutItem(existingItem, index, false, createNetworkEvent); + TryPutItem(item, currentIndex, false, user, createNetworkEvent); + TryPutItem(existingItem, index, false, user, createNetworkEvent); } } - + return combined; } @@ -198,7 +198,7 @@ namespace Barotrauma if (!item.AllowedSlots.Contains(InvSlotType.Any)) return false; if (Items[index] != null) return Items[index] == item; - PutItem(item, index, true, createNetworkEvent); + PutItem(item, index, user, true, createNetworkEvent); return true; } @@ -223,13 +223,13 @@ namespace Barotrauma } if (!slotsFree) return false; - - return TryPutItem(item, new List() {placeToSlots}, createNetworkEvent); + + return TryPutItem(item, user, new List() { placeToSlots }, createNetworkEvent); } - protected override void PutItem(Item item, int i, bool removeItem = true, bool createNetworkEvent = true) + protected override void PutItem(Item item, int i, Character user, bool removeItem = true, bool createNetworkEvent = true) { - base.PutItem(item, i, removeItem, createNetworkEvent); + base.PutItem(item, i, user, removeItem, createNetworkEvent); CreateSlots(); } @@ -247,30 +247,30 @@ namespace Barotrauma { if (doubleClickedItem.ParentInventory != this) { - TryPutItem(doubleClickedItem, doubleClickedItem.AllowedSlots, true); + TryPutItem(doubleClickedItem, Character.Controlled, doubleClickedItem.AllowedSlots, true); } else { var selectedContainer = character.SelectedConstruction?.GetComponent(); if (selectedContainer != null && selectedContainer.Inventory != null) { - selectedContainer.Inventory.TryPutItem(doubleClickedItem, doubleClickedItem.AllowedSlots, true); + selectedContainer.Inventory.TryPutItem(doubleClickedItem, Character.Controlled, doubleClickedItem.AllowedSlots, true); } else if (character.SelectedCharacter != null && character.SelectedCharacter.Inventory != null) { - character.SelectedCharacter.Inventory.TryPutItem(doubleClickedItem, doubleClickedItem.AllowedSlots, true); + character.SelectedCharacter.Inventory.TryPutItem(doubleClickedItem, Character.Controlled, doubleClickedItem.AllowedSlots, true); } else //doubleclicked and no other inventory is selected { //not equipped -> attempt to equip if (IsInLimbSlot(doubleClickedItem, InvSlotType.Any)) { - TryPutItem(doubleClickedItem, doubleClickedItem.AllowedSlots.FindAll(i => i != InvSlotType.Any), true); + TryPutItem(doubleClickedItem, Character.Controlled, doubleClickedItem.AllowedSlots.FindAll(i => i != InvSlotType.Any), true); } //equipped -> attempt to unequip else if (doubleClickedItem.AllowedSlots.Contains(InvSlotType.Any)) { - TryPutItem(doubleClickedItem, new List() { InvSlotType.Any }, true); + TryPutItem(doubleClickedItem, Character.Controlled, new List() { InvSlotType.Any }, true); } } } diff --git a/Barotrauma/BarotraumaShared/Source/Items/Components/Holdable/Pickable.cs b/Barotrauma/BarotraumaShared/Source/Items/Components/Holdable/Pickable.cs index 33785fd66..e689dfb70 100644 --- a/Barotrauma/BarotraumaShared/Source/Items/Components/Holdable/Pickable.cs +++ b/Barotrauma/BarotraumaShared/Source/Items/Components/Holdable/Pickable.cs @@ -72,7 +72,7 @@ namespace Barotrauma.Items.Components protected virtual bool OnPicked(Character picker) { - if (picker.Inventory.TryPutItem(item, allowedSlots)) + if (picker.Inventory.TryPutItem(item, picker, allowedSlots)) { if (!picker.HasSelectedItem(item) && item.body != null) item.body.Enabled = false; this.picker = picker; diff --git a/Barotrauma/BarotraumaShared/Source/Items/Components/ItemContainer.cs b/Barotrauma/BarotraumaShared/Source/Items/Components/ItemContainer.cs index e5786602f..fe41248ab 100644 --- a/Barotrauma/BarotraumaShared/Source/Items/Components/ItemContainer.cs +++ b/Barotrauma/BarotraumaShared/Source/Items/Components/ItemContainer.cs @@ -183,7 +183,7 @@ namespace Barotrauma.Items.Components { if (!containableItems.Any(x => x.MatchesItem(item))) return false; - if (Inventory.TryPutItem(item)) + if (Inventory.TryPutItem(item, null)) { IsActive = true; if (hideItems && item.body != null) item.body.Enabled = false; @@ -200,10 +200,10 @@ namespace Barotrauma.Items.Components for (ushort i = 0; i < itemIds.Length; i++) { - Item item = MapEntity.FindEntityByID(itemIds[i]) as Item; + Item item = Entity.FindEntityByID(itemIds[i]) as Item; if (item == null) continue; - Inventory.TryPutItem(item, i, false, false); + Inventory.TryPutItem(item, i, false, null, false); } itemIds = null; diff --git a/Barotrauma/BarotraumaShared/Source/Items/Components/Signal/ConnectionPanel.cs b/Barotrauma/BarotraumaShared/Source/Items/Components/Signal/ConnectionPanel.cs index d052f9166..9704cd3db 100644 --- a/Barotrauma/BarotraumaShared/Source/Items/Components/Signal/ConnectionPanel.cs +++ b/Barotrauma/BarotraumaShared/Source/Items/Components/Signal/ConnectionPanel.cs @@ -154,7 +154,7 @@ namespace Barotrauma.Items.Components { ushort wireId = msg.ReadUInt16(); - Item wireItem = MapEntity.FindEntityByID(wireId) as Item; + Item wireItem = Entity.FindEntityByID(wireId) as Item; if (wireItem == null) continue; Wire wireComponent = wireItem.GetComponent(); @@ -165,7 +165,7 @@ namespace Barotrauma.Items.Components } } - item.CreateServerEvent(this); + item.CreateServerEvent(this); //check if the character can access this connectionpanel //and all the wires they're trying to connect @@ -182,25 +182,51 @@ namespace Barotrauma.Items.Components } } } - - Networking.GameServer.Log(item.Name + " rewired by " + c.Character.Name, ServerLog.MessageType.ItemInteraction); - + //update the connections for (int i = 0; i < Connections.Count; i++) { + Wire[] prevWires = new Wire[Connections[i].Wires.Length]; + Array.Copy(Connections[i].Wires, prevWires, prevWires.Length); + Connections[i].ClearConnections(); for (int j = 0; j < wireCounts[i]; j++) { - if (wires[i, j] == null) continue; + if (wires[i, j] == null) + { + if (prevWires[j] != null) + { + if (prevWires[j].Connections[0] != null && prevWires[j].Connections[1] != null) + { + GameServer.Log(c.Character.Name + " disconnected a wire from " + + prevWires[j].Connections[0].Item.Name + " (" + prevWires[j].Connections[0].Name + ") to " + + prevWires[j].Connections[1].Item.Name + " (" + prevWires[j].Connections[1].Name + ")", ServerLog.MessageType.ItemInteraction); + } + else if (prevWires[j].Connections[0] != null) + { + GameServer.Log(c.Character.Name + " disconnected a wire from " + + prevWires[j].Connections[0].Item.Name + " (" + prevWires[j].Connections[0].Name + ")", ServerLog.MessageType.ItemInteraction); + } + else if (prevWires[j].Connections[1] != null) + { + GameServer.Log(c.Character.Name + " disconnected a wire from " + + prevWires[j].Connections[1].Item.Name + " (" + prevWires[j].Connections[1].Name + ")", ServerLog.MessageType.ItemInteraction); + } + } + continue; + } + + //already connected, no need to do anything + if (wires[i, j] == prevWires[j]) continue; Connections[i].Wires[j] = wires[i,j]; wires[i, j].Connect(Connections[i], true); var otherConnection = Connections[i].Wires[j].OtherConnection(Connections[i]); - Networking.GameServer.Log( - item.Name + " (" + Connections[i].Name + ") -> " + + GameServer.Log(item.Name + " rewired by " + c.Character.Name+ ": " + + Connections[i].Name + " -> " + (otherConnection == null ? "none" : otherConnection.Item.Name + " (" + (otherConnection.Name) + ")"), ServerLog.MessageType.ItemInteraction); } } diff --git a/Barotrauma/BarotraumaShared/Source/Items/Components/Signal/Wire.cs b/Barotrauma/BarotraumaShared/Source/Items/Components/Signal/Wire.cs index ea38d0d63..78477ed5a 100644 --- a/Barotrauma/BarotraumaShared/Source/Items/Components/Signal/Wire.cs +++ b/Barotrauma/BarotraumaShared/Source/Items/Components/Signal/Wire.cs @@ -187,21 +187,21 @@ namespace Barotrauma.Items.Components public override void Equip(Character character) { - ClearConnections(); + ClearConnections(character); IsActive = true; } public override void Unequip(Character character) { - ClearConnections(); + ClearConnections(character); IsActive = false; } public override void Drop(Character dropper) { - ClearConnections(); + ClearConnections(dropper); IsActive = false; } @@ -252,7 +252,7 @@ namespace Barotrauma.Items.Components public override bool Pick(Character picker) { - ClearConnections(); + ClearConnections(picker); return true; } @@ -295,10 +295,30 @@ namespace Barotrauma.Items.Components Drawable = IsActive || sections.Count > 0; } - private void ClearConnections() + private void ClearConnections(Character user = null) { nodes.Clear(); sections.Clear(); + + if (user != null) + { + if (connections[0] != null && connections[1] != null) + { + GameServer.Log(Character.Controlled.Name + " disconnected a wire from " + + connections[0].Item.Name + " (" + connections[0].Name + ") to "+ + connections[1].Item.Name + " (" + connections[1].Name + ")", ServerLog.MessageType.ItemInteraction); + } + else if (connections[0] != null) + { + GameServer.Log(Character.Controlled.Name + " disconnected a wire from " + + connections[0].Item.Name + " (" + connections[0].Name + ")", ServerLog.MessageType.ItemInteraction); + } + else if (connections[1] != null) + { + GameServer.Log(Character.Controlled.Name + " disconnected a wire from " + + connections[1].Item.Name + " (" + connections[1].Name + ")", ServerLog.MessageType.ItemInteraction); + } + } for (int i = 0; i < 2; i++) { diff --git a/Barotrauma/BarotraumaShared/Source/Items/Inventory.cs b/Barotrauma/BarotraumaShared/Source/Items/Inventory.cs index 8a55363ba..dd0bab863 100644 --- a/Barotrauma/BarotraumaShared/Source/Items/Inventory.cs +++ b/Barotrauma/BarotraumaShared/Source/Items/Inventory.cs @@ -137,21 +137,21 @@ namespace Barotrauma /// /// If there is room, puts the item in the inventory and returns true, otherwise returns false /// - public virtual bool TryPutItem(Item item, List allowedSlots = null, bool createNetworkEvent = true) + public virtual bool TryPutItem(Item item, Character user, List allowedSlots = null, bool createNetworkEvent = true) { int slot = FindAllowedSlot(item); if (slot < 0) return false; - PutItem(item, slot, true, createNetworkEvent); + PutItem(item, slot, user, true, createNetworkEvent); return true; } - public virtual bool TryPutItem(Item item, int i, bool allowSwapping, bool createNetworkEvent = true) + public virtual bool TryPutItem(Item item, int i, bool allowSwapping, Character user, bool createNetworkEvent = true) { if (Owner == null) return false; - if (CanBePut(item,i)) + if (CanBePut(item, i)) { - PutItem(item, i, true, createNetworkEvent); + PutItem(item, i, user, true, createNetworkEvent); return true; } else @@ -163,13 +163,13 @@ namespace Barotrauma } } - protected virtual void PutItem(Item item, int i, bool removeItem = true, bool createNetworkEvent = true) + protected virtual void PutItem(Item item, int i, Character user, bool removeItem = true, bool createNetworkEvent = true) { if (Owner == null) return; if (removeItem) { - item.Drop(null); + item.Drop(user); if (item.ParentInventory != null) item.ParentInventory.RemoveItem(item); } @@ -321,7 +321,7 @@ namespace Barotrauma if (draggingItem != Items[slotIndex]) { //selectedSlot = slotIndex; - if (TryPutItem(draggingItem, slotIndex, true)) + if (TryPutItem(draggingItem, slotIndex, true, Character.Controlled)) { #if CLIENT if (slots != null) slots[slotIndex].ShowBorderHighlight(Color.White, 0.1f, 0.4f); @@ -412,7 +412,7 @@ namespace Barotrauma { if (!item.CanClientAccess(c)) continue; } - TryPutItem(item, i, true, false); + TryPutItem(item, i, true, c.Character, false); } } @@ -509,7 +509,7 @@ namespace Barotrauma var item = Entity.FindEntityByID(receivedItemIDs[i]) as Item; if (item == null) continue; - TryPutItem(item, i, true, false); + TryPutItem(item, i, true, null, false); } } diff --git a/Barotrauma/BarotraumaShared/Source/Items/Item.cs b/Barotrauma/BarotraumaShared/Source/Items/Item.cs index 039851237..ae694236a 100644 --- a/Barotrauma/BarotraumaShared/Source/Items/Item.cs +++ b/Barotrauma/BarotraumaShared/Source/Items/Item.cs @@ -470,7 +470,7 @@ namespace Barotrauma foreach (Item containedItem in ContainedItems) { var containedClone = containedItem.Clone(); - clone.ownInventory.TryPutItem(containedClone as Item); + clone.ownInventory.TryPutItem(containedClone as Item, null); } } return clone; @@ -1520,11 +1520,11 @@ namespace Barotrauma if (inventory != null) { if (inventorySlotIndex >= 0 && inventorySlotIndex < 255 && - inventory.TryPutItem(item, inventorySlotIndex, false, false)) + inventory.TryPutItem(item, inventorySlotIndex, false, null, false)) { return null; } - inventory.TryPutItem(item, item.AllowedSlots, false); + inventory.TryPutItem(item, null, item.AllowedSlots, false); } return item; diff --git a/Barotrauma/BarotraumaShared/Source/Items/ItemInventory.cs b/Barotrauma/BarotraumaShared/Source/Items/ItemInventory.cs index b7c369de4..d506f91c2 100644 --- a/Barotrauma/BarotraumaShared/Source/Items/ItemInventory.cs +++ b/Barotrauma/BarotraumaShared/Source/Items/ItemInventory.cs @@ -1,5 +1,6 @@ using Barotrauma.Items.Components; using Microsoft.Xna.Framework; +using System.Collections.Generic; namespace Barotrauma { @@ -38,9 +39,9 @@ namespace Barotrauma } - public override bool TryPutItem(Item item, System.Collections.Generic.List allowedSlots = null, bool createNetworkEvent = true) + public override bool TryPutItem(Item item, Character user, List allowedSlots = null, bool createNetworkEvent = true) { - bool wasPut = base.TryPutItem(item, allowedSlots, createNetworkEvent); + bool wasPut = base.TryPutItem(item, user, allowedSlots, createNetworkEvent); if (wasPut) { @@ -59,9 +60,9 @@ namespace Barotrauma return wasPut; } - public override bool TryPutItem(Item item, int i, bool allowSwapping, bool createNetworkEvent = true) + public override bool TryPutItem(Item item, int i, bool allowSwapping, Character user, bool createNetworkEvent = true) { - bool wasPut = base.TryPutItem(item, i, allowSwapping, createNetworkEvent); + bool wasPut = base.TryPutItem(item, i, allowSwapping, user, createNetworkEvent); if (wasPut) { diff --git a/Barotrauma/BarotraumaShared/Source/Networking/EntitySpawner.cs b/Barotrauma/BarotraumaShared/Source/Networking/EntitySpawner.cs index 366aa3f00..fd08e1f61 100644 --- a/Barotrauma/BarotraumaShared/Source/Networking/EntitySpawner.cs +++ b/Barotrauma/BarotraumaShared/Source/Networking/EntitySpawner.cs @@ -49,7 +49,7 @@ namespace Barotrauma if (Inventory != null) { spawnedItem = new Item(Prefab, Vector2.Zero, null); - Inventory.TryPutItem(spawnedItem, spawnedItem.AllowedSlots); + Inventory.TryPutItem(spawnedItem, null, spawnedItem.AllowedSlots); } else {