Unstable 0.1300.0.10
This commit is contained in:
@@ -124,7 +124,7 @@ namespace Barotrauma
|
||||
public override bool CanBePut(Item item, int i)
|
||||
{
|
||||
return
|
||||
base.CanBePut(item, i) && item.AllowedSlots.Contains(SlotTypes[i]) &&
|
||||
base.CanBePut(item, i) && item.AllowedSlots.Any(s => s.HasFlag(SlotTypes[i])) &&
|
||||
(SlotTypes[i] == InvSlotType.Any || slots[i].ItemCount < 1);
|
||||
}
|
||||
|
||||
@@ -206,7 +206,7 @@ namespace Barotrauma
|
||||
if (allowedSlots != null && !allowedSlots.Contains(InvSlotType.Any))
|
||||
{
|
||||
int slot = FindLimbSlot(allowedSlots.First());
|
||||
if (slot > -1 && slots[slot].Items.Any(it => it != item) && slots[slot].First().Prefab.AllowDroppingOnSwap)
|
||||
if (slot > -1 && slots[slot].Items.Any(it => it != item) && slots[slot].First().AllowDroppingOnSwapWith(item))
|
||||
{
|
||||
foreach (Item existingItem in slots[slot].Items.ToList())
|
||||
{
|
||||
|
||||
@@ -12,11 +12,11 @@ namespace Barotrauma.Items.Components
|
||||
{
|
||||
partial class Steering : Powered, IServerSerializable, IClientSerializable
|
||||
{
|
||||
public const float AutopilotMinDistToPathNode = 30.0f;
|
||||
|
||||
private const float AutopilotRayCastInterval = 0.5f;
|
||||
private const float RecalculatePathInterval = 5.0f;
|
||||
|
||||
private const float AutopilotMinDistToPathNode = 30.0f;
|
||||
|
||||
private const float AutoPilotSteeringLerp = 0.1f;
|
||||
|
||||
private const float AutoPilotMaxSpeed = 0.5f;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using Barotrauma.Networking;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace Barotrauma.Items.Components
|
||||
@@ -31,6 +32,19 @@ namespace Barotrauma.Items.Components
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Can be used to display messages on the terminal via status effects
|
||||
/// </summary>
|
||||
public string ShowMessage
|
||||
{
|
||||
get { return messageHistory.Count == 0 ? string.Empty : messageHistory.Last(); }
|
||||
set
|
||||
{
|
||||
if (string.IsNullOrEmpty(value)) { return; }
|
||||
ShowOnDisplay(value);
|
||||
}
|
||||
}
|
||||
|
||||
private string OutputValue { get; set; }
|
||||
|
||||
public Terminal(Item item, XElement element)
|
||||
|
||||
@@ -659,12 +659,12 @@ namespace Barotrauma
|
||||
else
|
||||
{
|
||||
swapSuccessful =
|
||||
(existingItems.All(existingItem => otherInventory.TryPutItem(existingItem, otherIndex, false, false, user, createNetworkEvent)) ||
|
||||
existingItems.Count == 1 && otherInventory.TryPutItem(existingItems.First(),user, CharacterInventory.anySlot, createNetworkEvent))
|
||||
(existingItems.All(existingItem => otherInventory.TryPutItem(existingItem, otherIndex, false, false, user, createNetworkEvent)) ||
|
||||
existingItems.Count == 1 && otherInventory.TryPutItem(existingItems.First(), user, CharacterInventory.anySlot, createNetworkEvent))
|
||||
&&
|
||||
stackedItems.Distinct().All(stackedItem => TryPutItem(stackedItem, index, false, false, user, createNetworkEvent));
|
||||
|
||||
if (!swapSuccessful && existingItems.Count == 1 && existingItems[0].Prefab.AllowDroppingOnSwap)
|
||||
if (!swapSuccessful && existingItems.Count == 1 && existingItems[0].AllowDroppingOnSwapWith(item))
|
||||
{
|
||||
existingItems[0].Drop(user, createNetworkEvent);
|
||||
swapSuccessful = stackedItems.Distinct().Any(stackedItem => TryPutItem(stackedItem, index, false, false, user, createNetworkEvent));
|
||||
|
||||
@@ -1102,6 +1102,27 @@ namespace Barotrauma
|
||||
if (findNewHull) { FindHull(); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Is dropping the item allowed when trying to swap it with the other item
|
||||
/// </summary>
|
||||
public bool AllowDroppingOnSwapWith(Item otherItem)
|
||||
{
|
||||
if (!Prefab.AllowDroppingOnSwap || otherItem == null) { return false; }
|
||||
if (Prefab.AllowDroppingOnSwapWith.Any())
|
||||
{
|
||||
foreach (string tagOrIdentifier in Prefab.AllowDroppingOnSwapWith)
|
||||
{
|
||||
if (otherItem.prefab.Identifier.Equals(tagOrIdentifier, StringComparison.OrdinalIgnoreCase)) { return true; }
|
||||
if (otherItem.HasTag(tagOrIdentifier)) { return true; }
|
||||
}
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public void SetActiveSprite()
|
||||
{
|
||||
SetActiveSpriteProjSpecific();
|
||||
|
||||
@@ -517,6 +517,12 @@ namespace Barotrauma
|
||||
[Serialize(false, false)]
|
||||
public bool AllowDroppingOnSwap { get; private set; }
|
||||
|
||||
private readonly HashSet<string> allowDroppingOnSwapWith = new HashSet<string>();
|
||||
public IEnumerable<string> AllowDroppingOnSwapWith
|
||||
{
|
||||
get { return allowDroppingOnSwapWith; }
|
||||
}
|
||||
|
||||
public Vector2 Size => size;
|
||||
|
||||
public bool CanBeBought => (DefaultPrice != null && DefaultPrice.CanBeBought) || (locationPrices != null && locationPrices.Any(p => p.Value.CanBeBought));
|
||||
@@ -657,7 +663,7 @@ namespace Barotrauma
|
||||
{
|
||||
category = MapEntityCategory.Misc;
|
||||
}
|
||||
Category = category;
|
||||
Category = category;
|
||||
|
||||
var parentType = element.Parent?.GetAttributeString("itemtype", "") ?? string.Empty;
|
||||
|
||||
@@ -695,7 +701,7 @@ namespace Barotrauma
|
||||
identifier = GenerateLegacyIdentifier(originalName);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (string.Equals(parentType, "wrecked", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
if (!string.IsNullOrEmpty(name))
|
||||
@@ -703,7 +709,7 @@ namespace Barotrauma
|
||||
name = TextManager.GetWithVariable("wreckeditemformat", "[name]", name);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (string.IsNullOrEmpty(name))
|
||||
{
|
||||
DebugConsole.ThrowError($"Unnamed item ({identifier}) in {filePath}!");
|
||||
@@ -715,11 +721,11 @@ namespace Barotrauma
|
||||
(element.GetAttributeStringArray("aliases", null, convertToLowerInvariant: true) ??
|
||||
element.GetAttributeStringArray("Aliases", new string[0], convertToLowerInvariant: true));
|
||||
Aliases.Add(originalName.ToLowerInvariant());
|
||||
|
||||
Triggers = new List<Rectangle>();
|
||||
DeconstructItems = new List<DeconstructItem>();
|
||||
FabricationRecipes = new List<FabricationRecipe>();
|
||||
DeconstructTime = 1.0f;
|
||||
|
||||
Triggers = new List<Rectangle>();
|
||||
DeconstructItems = new List<DeconstructItem>();
|
||||
FabricationRecipes = new List<FabricationRecipe>();
|
||||
DeconstructTime = 1.0f;
|
||||
|
||||
if (element.Attribute("allowasextracargo") != null)
|
||||
{
|
||||
@@ -755,6 +761,16 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
var allowDroppingOnSwapWith = element.GetAttributeStringArray("allowdroppingonswapwith", new string[0]);
|
||||
if (allowDroppingOnSwapWith.Any())
|
||||
{
|
||||
AllowDroppingOnSwap = true;
|
||||
foreach (string tag in allowDroppingOnSwapWith)
|
||||
{
|
||||
this.allowDroppingOnSwapWith.Add(tag);
|
||||
}
|
||||
}
|
||||
|
||||
foreach (XElement subElement in element.Elements())
|
||||
{
|
||||
switch (subElement.Name.ToString().ToLowerInvariant())
|
||||
|
||||
Reference in New Issue
Block a user