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.
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
using Microsoft.Xna.Framework;
|
using Barotrauma.Networking;
|
||||||
|
using Microsoft.Xna.Framework;
|
||||||
using Microsoft.Xna.Framework.Graphics;
|
using Microsoft.Xna.Framework.Graphics;
|
||||||
using System;
|
using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@@ -169,7 +170,18 @@ namespace Barotrauma.Items.Components
|
|||||||
|
|
||||||
draggingConnected.RemoveConnection(item);
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -724,7 +724,7 @@ namespace Barotrauma
|
|||||||
|
|
||||||
var item = new Item(screwdriverPrefab, Vector2.Zero, null);
|
var item = new Item(screwdriverPrefab, Vector2.Zero, null);
|
||||||
|
|
||||||
dummyCharacter.Inventory.TryPutItem(item, new List<InvSlotType>() {InvSlotType.RightHand});
|
dummyCharacter.Inventory.TryPutItem(item, null, new List<InvSlotType>() { InvSlotType.RightHand });
|
||||||
|
|
||||||
wiringToolPanel = CreateWiringPanel();
|
wiringToolPanel = CreateWiringPanel();
|
||||||
}
|
}
|
||||||
@@ -816,7 +816,7 @@ namespace Barotrauma
|
|||||||
existingWire.Remove();
|
existingWire.Remove();
|
||||||
}
|
}
|
||||||
|
|
||||||
dummyCharacter.Inventory.TryPutItem(wire, slotIndex, false);
|
dummyCharacter.Inventory.TryPutItem(wire, slotIndex, false, dummyCharacter);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ namespace Barotrauma
|
|||||||
{
|
{
|
||||||
if (!character.SelectedItems.Contains(weapon))
|
if (!character.SelectedItems.Contains(weapon))
|
||||||
{
|
{
|
||||||
character.Inventory.TryPutItem(weapon, 3, false);
|
character.Inventory.TryPutItem(weapon, 3, false, character);
|
||||||
weapon.Equip(character);
|
weapon.Equip(character);
|
||||||
}
|
}
|
||||||
character.CursorPosition = enemy.Position;
|
character.CursorPosition = enemy.Position;
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ namespace Barotrauma
|
|||||||
if (character.Inventory.Items[i] == null) continue;
|
if (character.Inventory.Items[i] == null) continue;
|
||||||
|
|
||||||
//try to move the existing item to LimbSlot.Any and continue if successful
|
//try to move the existing item to LimbSlot.Any and continue if successful
|
||||||
if (character.Inventory.TryPutItem(character.Inventory.Items[i], new List<InvSlotType>() { InvSlotType.Any })) continue;
|
if (character.Inventory.TryPutItem(character.Inventory.Items[i], character, new List<InvSlotType>() { InvSlotType.Any })) continue;
|
||||||
|
|
||||||
//if everything else fails, simply drop the existing item
|
//if everything else fails, simply drop the existing item
|
||||||
character.Inventory.Items[i].Drop();
|
character.Inventory.Items[i].Drop();
|
||||||
@@ -95,7 +95,7 @@ namespace Barotrauma
|
|||||||
|
|
||||||
if (targetSlot > -1 && character.Inventory.IsInLimbSlot(targetItem, InvSlotType.Any))
|
if (targetSlot > -1 && character.Inventory.IsInLimbSlot(targetItem, InvSlotType.Any))
|
||||||
{
|
{
|
||||||
character.Inventory.TryPutItem(targetItem, targetSlot, false);
|
character.Inventory.TryPutItem(targetItem, targetSlot, false, character);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -576,7 +576,7 @@ namespace Barotrauma
|
|||||||
if (item == null) continue;
|
if (item == null) continue;
|
||||||
|
|
||||||
item.TryInteract(this, true, true, true);
|
item.TryInteract(this, true, true, true);
|
||||||
inventory.TryPutItem(item, i, false, false);
|
inventory.TryPutItem(item, i, false, null, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -162,7 +162,7 @@ namespace Barotrauma
|
|||||||
for (int i = 0; i < character.Inventory.Items.Length; i++)
|
for (int i = 0; i < character.Inventory.Items.Length; i++)
|
||||||
{
|
{
|
||||||
if (character.Inventory.Items[i] == null) continue;
|
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;
|
character.Enabled = false;
|
||||||
|
|||||||
@@ -117,11 +117,11 @@ namespace Barotrauma
|
|||||||
List<InvSlotType> allowedSlots = new List<InvSlotType>(item.AllowedSlots);
|
List<InvSlotType> allowedSlots = new List<InvSlotType>(item.AllowedSlots);
|
||||||
allowedSlots.Remove(InvSlotType.Any);
|
allowedSlots.Remove(InvSlotType.Any);
|
||||||
|
|
||||||
character.Inventory.TryPutItem(item, allowedSlots);
|
character.Inventory.TryPutItem(item, null, allowedSlots);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
character.Inventory.TryPutItem(item, item.AllowedSlots);
|
character.Inventory.TryPutItem(item, null, item.AllowedSlots);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (item.Prefab.Name == "ID Card" && spawnPoint != null)
|
if (item.Prefab.Name == "ID Card" && spawnPoint != null)
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ namespace Barotrauma
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// If there is room, puts the item in the inventory and returns true, otherwise returns false
|
/// If there is room, puts the item in the inventory and returns true, otherwise returns false
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public override bool TryPutItem(Item item, List<InvSlotType> allowedSlots = null, bool createNetworkEvent = true)
|
public override bool TryPutItem(Item item, Character user, List<InvSlotType> allowedSlots = null, bool createNetworkEvent = true)
|
||||||
{
|
{
|
||||||
if (allowedSlots == null || !allowedSlots.Any()) return false;
|
if (allowedSlots == null || !allowedSlots.Any()) return false;
|
||||||
|
|
||||||
@@ -100,7 +100,7 @@ namespace Barotrauma
|
|||||||
{
|
{
|
||||||
if (Items[i] != null || limbSlots[i] != InvSlotType.Any) continue;
|
if (Items[i] != null || limbSlots[i] != InvSlotType.Any) continue;
|
||||||
|
|
||||||
PutItem(item, i, true, createNetworkEvent);
|
PutItem(item, i, user, true, createNetworkEvent);
|
||||||
item.Unequip(character);
|
item.Unequip(character);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -128,7 +128,7 @@ namespace Barotrauma
|
|||||||
{
|
{
|
||||||
if (allowedSlot.HasFlag(limbSlots[i]) && Items[i] == null)
|
if (allowedSlot.HasFlag(limbSlots[i]) && Items[i] == null)
|
||||||
{
|
{
|
||||||
PutItem(item, i, !placed, createNetworkEvent);
|
PutItem(item, i, user, !placed, createNetworkEvent);
|
||||||
item.Equip(character);
|
item.Equip(character);
|
||||||
placed = true;
|
placed = true;
|
||||||
}
|
}
|
||||||
@@ -144,7 +144,7 @@ namespace Barotrauma
|
|||||||
return placed;
|
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
|
//there's already an item in the slot
|
||||||
if (Items[index] != null)
|
if (Items[index] != null)
|
||||||
@@ -174,8 +174,8 @@ namespace Barotrauma
|
|||||||
Items[currentIndex] = null;
|
Items[currentIndex] = null;
|
||||||
Items[index] = null;
|
Items[index] = null;
|
||||||
//if the item in the slot can be moved to the slot of the moved item
|
//if the item in the slot can be moved to the slot of the moved item
|
||||||
if (TryPutItem(existingItem, currentIndex, false, createNetworkEvent) &&
|
if (TryPutItem(existingItem, currentIndex, false, user, createNetworkEvent) &&
|
||||||
TryPutItem(item, index, false, createNetworkEvent))
|
TryPutItem(item, index, false, user, createNetworkEvent))
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -185,8 +185,8 @@ namespace Barotrauma
|
|||||||
Items[index] = null;
|
Items[index] = null;
|
||||||
|
|
||||||
//swapping the items failed -> move them back to where they were
|
//swapping the items failed -> move them back to where they were
|
||||||
TryPutItem(item, currentIndex, false, createNetworkEvent);
|
TryPutItem(item, currentIndex, false, user, createNetworkEvent);
|
||||||
TryPutItem(existingItem, index, false, createNetworkEvent);
|
TryPutItem(existingItem, index, false, user, createNetworkEvent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -198,7 +198,7 @@ namespace Barotrauma
|
|||||||
if (!item.AllowedSlots.Contains(InvSlotType.Any)) return false;
|
if (!item.AllowedSlots.Contains(InvSlotType.Any)) return false;
|
||||||
if (Items[index] != null) return Items[index] == item;
|
if (Items[index] != null) return Items[index] == item;
|
||||||
|
|
||||||
PutItem(item, index, true, createNetworkEvent);
|
PutItem(item, index, user, true, createNetworkEvent);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -224,12 +224,12 @@ namespace Barotrauma
|
|||||||
|
|
||||||
if (!slotsFree) return false;
|
if (!slotsFree) return false;
|
||||||
|
|
||||||
return TryPutItem(item, new List<InvSlotType>() {placeToSlots}, createNetworkEvent);
|
return TryPutItem(item, user, new List<InvSlotType>() { 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();
|
CreateSlots();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -247,30 +247,30 @@ namespace Barotrauma
|
|||||||
{
|
{
|
||||||
if (doubleClickedItem.ParentInventory != this)
|
if (doubleClickedItem.ParentInventory != this)
|
||||||
{
|
{
|
||||||
TryPutItem(doubleClickedItem, doubleClickedItem.AllowedSlots, true);
|
TryPutItem(doubleClickedItem, Character.Controlled, doubleClickedItem.AllowedSlots, true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var selectedContainer = character.SelectedConstruction?.GetComponent<ItemContainer>();
|
var selectedContainer = character.SelectedConstruction?.GetComponent<ItemContainer>();
|
||||||
if (selectedContainer != null && selectedContainer.Inventory != null)
|
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)
|
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
|
else //doubleclicked and no other inventory is selected
|
||||||
{
|
{
|
||||||
//not equipped -> attempt to equip
|
//not equipped -> attempt to equip
|
||||||
if (IsInLimbSlot(doubleClickedItem, InvSlotType.Any))
|
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
|
//equipped -> attempt to unequip
|
||||||
else if (doubleClickedItem.AllowedSlots.Contains(InvSlotType.Any))
|
else if (doubleClickedItem.AllowedSlots.Contains(InvSlotType.Any))
|
||||||
{
|
{
|
||||||
TryPutItem(doubleClickedItem, new List<InvSlotType>() { InvSlotType.Any }, true);
|
TryPutItem(doubleClickedItem, Character.Controlled, new List<InvSlotType>() { InvSlotType.Any }, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ namespace Barotrauma.Items.Components
|
|||||||
|
|
||||||
protected virtual bool OnPicked(Character picker)
|
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;
|
if (!picker.HasSelectedItem(item) && item.body != null) item.body.Enabled = false;
|
||||||
this.picker = picker;
|
this.picker = picker;
|
||||||
|
|||||||
@@ -183,7 +183,7 @@ namespace Barotrauma.Items.Components
|
|||||||
{
|
{
|
||||||
if (!containableItems.Any(x => x.MatchesItem(item))) return false;
|
if (!containableItems.Any(x => x.MatchesItem(item))) return false;
|
||||||
|
|
||||||
if (Inventory.TryPutItem(item))
|
if (Inventory.TryPutItem(item, null))
|
||||||
{
|
{
|
||||||
IsActive = true;
|
IsActive = true;
|
||||||
if (hideItems && item.body != null) item.body.Enabled = false;
|
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++)
|
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;
|
if (item == null) continue;
|
||||||
|
|
||||||
Inventory.TryPutItem(item, i, false, false);
|
Inventory.TryPutItem(item, i, false, null, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
itemIds = null;
|
itemIds = null;
|
||||||
|
|||||||
@@ -154,7 +154,7 @@ namespace Barotrauma.Items.Components
|
|||||||
{
|
{
|
||||||
ushort wireId = msg.ReadUInt16();
|
ushort wireId = msg.ReadUInt16();
|
||||||
|
|
||||||
Item wireItem = MapEntity.FindEntityByID(wireId) as Item;
|
Item wireItem = Entity.FindEntityByID(wireId) as Item;
|
||||||
if (wireItem == null) continue;
|
if (wireItem == null) continue;
|
||||||
|
|
||||||
Wire wireComponent = wireItem.GetComponent<Wire>();
|
Wire wireComponent = wireItem.GetComponent<Wire>();
|
||||||
@@ -165,7 +165,7 @@ namespace Barotrauma.Items.Components
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
item.CreateServerEvent<ConnectionPanel>(this);
|
item.CreateServerEvent(this);
|
||||||
|
|
||||||
//check if the character can access this connectionpanel
|
//check if the character can access this connectionpanel
|
||||||
//and all the wires they're trying to connect
|
//and all the wires they're trying to connect
|
||||||
@@ -183,24 +183,50 @@ namespace Barotrauma.Items.Components
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Networking.GameServer.Log(item.Name + " rewired by " + c.Character.Name, ServerLog.MessageType.ItemInteraction);
|
|
||||||
|
|
||||||
//update the connections
|
//update the connections
|
||||||
for (int i = 0; i < Connections.Count; i++)
|
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();
|
Connections[i].ClearConnections();
|
||||||
|
|
||||||
for (int j = 0; j < wireCounts[i]; j++)
|
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];
|
Connections[i].Wires[j] = wires[i,j];
|
||||||
wires[i, j].Connect(Connections[i], true);
|
wires[i, j].Connect(Connections[i], true);
|
||||||
|
|
||||||
var otherConnection = Connections[i].Wires[j].OtherConnection(Connections[i]);
|
var otherConnection = Connections[i].Wires[j].OtherConnection(Connections[i]);
|
||||||
|
|
||||||
Networking.GameServer.Log(
|
GameServer.Log(item.Name + " rewired by " + c.Character.Name+ ": " +
|
||||||
item.Name + " (" + Connections[i].Name + ") -> " +
|
Connections[i].Name + " -> " +
|
||||||
(otherConnection == null ? "none" : otherConnection.Item.Name + " (" + (otherConnection.Name) + ")"), ServerLog.MessageType.ItemInteraction);
|
(otherConnection == null ? "none" : otherConnection.Item.Name + " (" + (otherConnection.Name) + ")"), ServerLog.MessageType.ItemInteraction);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -187,21 +187,21 @@ namespace Barotrauma.Items.Components
|
|||||||
|
|
||||||
public override void Equip(Character character)
|
public override void Equip(Character character)
|
||||||
{
|
{
|
||||||
ClearConnections();
|
ClearConnections(character);
|
||||||
|
|
||||||
IsActive = true;
|
IsActive = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Unequip(Character character)
|
public override void Unequip(Character character)
|
||||||
{
|
{
|
||||||
ClearConnections();
|
ClearConnections(character);
|
||||||
|
|
||||||
IsActive = false;
|
IsActive = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Drop(Character dropper)
|
public override void Drop(Character dropper)
|
||||||
{
|
{
|
||||||
ClearConnections();
|
ClearConnections(dropper);
|
||||||
|
|
||||||
IsActive = false;
|
IsActive = false;
|
||||||
}
|
}
|
||||||
@@ -252,7 +252,7 @@ namespace Barotrauma.Items.Components
|
|||||||
|
|
||||||
public override bool Pick(Character picker)
|
public override bool Pick(Character picker)
|
||||||
{
|
{
|
||||||
ClearConnections();
|
ClearConnections(picker);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -295,11 +295,31 @@ namespace Barotrauma.Items.Components
|
|||||||
Drawable = IsActive || sections.Count > 0;
|
Drawable = IsActive || sections.Count > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ClearConnections()
|
private void ClearConnections(Character user = null)
|
||||||
{
|
{
|
||||||
nodes.Clear();
|
nodes.Clear();
|
||||||
sections.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++)
|
for (int i = 0; i < 2; i++)
|
||||||
{
|
{
|
||||||
if (connections[i] == null) continue;
|
if (connections[i] == null) continue;
|
||||||
|
|||||||
@@ -137,21 +137,21 @@ namespace Barotrauma
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// If there is room, puts the item in the inventory and returns true, otherwise returns false
|
/// If there is room, puts the item in the inventory and returns true, otherwise returns false
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public virtual bool TryPutItem(Item item, List<InvSlotType> allowedSlots = null, bool createNetworkEvent = true)
|
public virtual bool TryPutItem(Item item, Character user, List<InvSlotType> allowedSlots = null, bool createNetworkEvent = true)
|
||||||
{
|
{
|
||||||
int slot = FindAllowedSlot(item);
|
int slot = FindAllowedSlot(item);
|
||||||
if (slot < 0) return false;
|
if (slot < 0) return false;
|
||||||
|
|
||||||
PutItem(item, slot, true, createNetworkEvent);
|
PutItem(item, slot, user, true, createNetworkEvent);
|
||||||
return true;
|
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 (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;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
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 (Owner == null) return;
|
||||||
|
|
||||||
if (removeItem)
|
if (removeItem)
|
||||||
{
|
{
|
||||||
item.Drop(null);
|
item.Drop(user);
|
||||||
if (item.ParentInventory != null) item.ParentInventory.RemoveItem(item);
|
if (item.ParentInventory != null) item.ParentInventory.RemoveItem(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -321,7 +321,7 @@ namespace Barotrauma
|
|||||||
if (draggingItem != Items[slotIndex])
|
if (draggingItem != Items[slotIndex])
|
||||||
{
|
{
|
||||||
//selectedSlot = slotIndex;
|
//selectedSlot = slotIndex;
|
||||||
if (TryPutItem(draggingItem, slotIndex, true))
|
if (TryPutItem(draggingItem, slotIndex, true, Character.Controlled))
|
||||||
{
|
{
|
||||||
#if CLIENT
|
#if CLIENT
|
||||||
if (slots != null) slots[slotIndex].ShowBorderHighlight(Color.White, 0.1f, 0.4f);
|
if (slots != null) slots[slotIndex].ShowBorderHighlight(Color.White, 0.1f, 0.4f);
|
||||||
@@ -412,7 +412,7 @@ namespace Barotrauma
|
|||||||
{
|
{
|
||||||
if (!item.CanClientAccess(c)) continue;
|
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;
|
var item = Entity.FindEntityByID(receivedItemIDs[i]) as Item;
|
||||||
if (item == null) continue;
|
if (item == null) continue;
|
||||||
|
|
||||||
TryPutItem(item, i, true, false);
|
TryPutItem(item, i, true, null, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -470,7 +470,7 @@ namespace Barotrauma
|
|||||||
foreach (Item containedItem in ContainedItems)
|
foreach (Item containedItem in ContainedItems)
|
||||||
{
|
{
|
||||||
var containedClone = containedItem.Clone();
|
var containedClone = containedItem.Clone();
|
||||||
clone.ownInventory.TryPutItem(containedClone as Item);
|
clone.ownInventory.TryPutItem(containedClone as Item, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return clone;
|
return clone;
|
||||||
@@ -1520,11 +1520,11 @@ namespace Barotrauma
|
|||||||
if (inventory != null)
|
if (inventory != null)
|
||||||
{
|
{
|
||||||
if (inventorySlotIndex >= 0 && inventorySlotIndex < 255 &&
|
if (inventorySlotIndex >= 0 && inventorySlotIndex < 255 &&
|
||||||
inventory.TryPutItem(item, inventorySlotIndex, false, false))
|
inventory.TryPutItem(item, inventorySlotIndex, false, null, false))
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
inventory.TryPutItem(item, item.AllowedSlots, false);
|
inventory.TryPutItem(item, null, item.AllowedSlots, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
return item;
|
return item;
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
using Barotrauma.Items.Components;
|
using Barotrauma.Items.Components;
|
||||||
using Microsoft.Xna.Framework;
|
using Microsoft.Xna.Framework;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace Barotrauma
|
namespace Barotrauma
|
||||||
{
|
{
|
||||||
@@ -38,9 +39,9 @@ namespace Barotrauma
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public override bool TryPutItem(Item item, System.Collections.Generic.List<InvSlotType> allowedSlots = null, bool createNetworkEvent = true)
|
public override bool TryPutItem(Item item, Character user, List<InvSlotType> allowedSlots = null, bool createNetworkEvent = true)
|
||||||
{
|
{
|
||||||
bool wasPut = base.TryPutItem(item, allowedSlots, createNetworkEvent);
|
bool wasPut = base.TryPutItem(item, user, allowedSlots, createNetworkEvent);
|
||||||
|
|
||||||
if (wasPut)
|
if (wasPut)
|
||||||
{
|
{
|
||||||
@@ -59,9 +60,9 @@ namespace Barotrauma
|
|||||||
return wasPut;
|
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)
|
if (wasPut)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ namespace Barotrauma
|
|||||||
if (Inventory != null)
|
if (Inventory != null)
|
||||||
{
|
{
|
||||||
spawnedItem = new Item(Prefab, Vector2.Zero, null);
|
spawnedItem = new Item(Prefab, Vector2.Zero, null);
|
||||||
Inventory.TryPutItem(spawnedItem, spawnedItem.AllowedSlots);
|
Inventory.TryPutItem(spawnedItem, null, spawnedItem.AllowedSlots);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user