(17490598f) Don't allow putting items into locked inventories by double-clicking (causes them to be dropped in multiplayer)

This commit is contained in:
Joonas Rikkonen
2019-04-08 13:36:30 +03:00
parent 10776572d2
commit 2efcd200f5
3 changed files with 57 additions and 82 deletions
@@ -61,7 +61,7 @@ namespace Barotrauma
if (vanillaContent == null)
{
// TODO: Dynamic method for defining and finding the vanilla content package.
vanillaContent = SelectedPackages.SingleOrDefault(cp => Path.GetFileName(cp.Path).ToLowerInvariant() == "vanilla 0.9.xml");
vanillaContent = ContentPackage.List.SingleOrDefault(cp => Path.GetFileName(cp.Path).ToLowerInvariant() == "vanilla 0.9.xml");
}
return vanillaContent;
}
@@ -539,7 +539,11 @@ namespace Barotrauma
if (item.ParentInventory != this)
{
//in another inventory -> attempt to place in the character's inventory
if (allowInventorySwap)
if (item.ParentInventory.Locked)
{
return QuickUseAction.None;
}
else if (allowInventorySwap)
{
return item.ParentInventory is CharacterInventory ?
QuickUseAction.TakeFromCharacter : QuickUseAction.TakeFromContainer;
@@ -548,18 +552,24 @@ namespace Barotrauma
else
{
var selectedContainer = character.SelectedConstruction?.GetComponent<ItemContainer>();
if (selectedContainer != null && selectedContainer.Inventory != null && allowInventorySwap)
if (selectedContainer != null &&
selectedContainer.Inventory != null &&
!selectedContainer.Inventory.Locked &&
allowInventorySwap)
{
//player has selected the inventory of another item -> attempt to move the item there
return QuickUseAction.PutToContainer;
}
else if (character.SelectedCharacter != null && character.SelectedCharacter.Inventory != null && allowInventorySwap)
else if (character.SelectedCharacter != null &&
character.SelectedCharacter.Inventory != null &&
!character.SelectedCharacter.Inventory.Locked &&
allowInventorySwap)
{
//player has selected the inventory of another character -> attempt to move the item there
return QuickUseAction.PutToCharacter;
}
else if (character.SelectedBy != null && Character.Controlled == character.SelectedBy &&
character.SelectedBy.Inventory != null && allowInventorySwap)
character.SelectedBy.Inventory != null && !character.SelectedBy.Inventory.Locked && allowInventorySwap)
{
return QuickUseAction.TakeFromCharacter;
}