Unstable 1.1.14.0
This commit is contained in:
@@ -43,9 +43,9 @@ namespace Barotrauma
|
||||
public readonly bool CopyCondition;
|
||||
|
||||
//tag/identifier of the deconstructor(s) that can be used to deconstruct the item into this
|
||||
public readonly string[] RequiredDeconstructor;
|
||||
public readonly Identifier[] RequiredDeconstructor;
|
||||
//tag/identifier of other item(s) that that need to be present in the deconstructor to deconstruct the item into this
|
||||
public readonly string[] RequiredOtherItem;
|
||||
public readonly Identifier[] RequiredOtherItem;
|
||||
//text to display on the deconstructor's activate button when this output is available
|
||||
public readonly string ActivateButtonText;
|
||||
public readonly string InfoText;
|
||||
@@ -63,9 +63,9 @@ namespace Barotrauma
|
||||
OutConditionMax = element.GetAttributeFloat("outconditionmax", element.GetAttributeFloat("outcondition", 1.0f));
|
||||
CopyCondition = element.GetAttributeBool("copycondition", false);
|
||||
Commonness = element.GetAttributeFloat("commonness", 1.0f);
|
||||
RequiredDeconstructor = element.GetAttributeStringArray("requireddeconstructor",
|
||||
element.Parent?.GetAttributeStringArray("requireddeconstructor", Array.Empty<string>()) ?? Array.Empty<string>());
|
||||
RequiredOtherItem = element.GetAttributeStringArray("requiredotheritem", Array.Empty<string>());
|
||||
RequiredDeconstructor = element.GetAttributeIdentifierArray("requireddeconstructor",
|
||||
element.Parent?.GetAttributeIdentifierArray("requireddeconstructor", Array.Empty<Identifier>()) ?? Array.Empty<Identifier>());
|
||||
RequiredOtherItem = element.GetAttributeIdentifierArray("requiredotheritem", Array.Empty<Identifier>());
|
||||
ActivateButtonText = element.GetAttributeString("activatebuttontext", string.Empty);
|
||||
InfoText = element.GetAttributeString("infotext", string.Empty);
|
||||
InfoTextOnOtherItemMissing = element.GetAttributeString("infotextonotheritemmissing", string.Empty);
|
||||
@@ -88,20 +88,27 @@ namespace Barotrauma
|
||||
|
||||
public abstract ItemPrefab FirstMatchingPrefab { get; }
|
||||
|
||||
public LocalizedString OverrideHeader { get; }
|
||||
public LocalizedString OverrideDescription { get; }
|
||||
|
||||
public RequiredItem(int amount, float minCondition, float maxCondition, bool useCondition, LocalizedString overrideDescription)
|
||||
public RequiredItem(int amount, float minCondition, float maxCondition, bool useCondition, LocalizedString overrideDescription, LocalizedString overrideHeader, Identifier defaultItem)
|
||||
{
|
||||
Amount = amount;
|
||||
MinCondition = minCondition;
|
||||
MaxCondition = maxCondition;
|
||||
UseCondition = useCondition;
|
||||
OverrideHeader = overrideHeader;
|
||||
OverrideDescription = overrideDescription;
|
||||
DefaultItem = defaultItem;
|
||||
}
|
||||
public readonly int Amount;
|
||||
public readonly float MinCondition;
|
||||
public readonly float MaxCondition;
|
||||
public readonly bool UseCondition;
|
||||
/// <summary>
|
||||
/// Used only when there's multiple optional items.
|
||||
/// </summary>
|
||||
public readonly Identifier DefaultItem;
|
||||
|
||||
public bool IsConditionSuitable(float conditionPercentage)
|
||||
{
|
||||
@@ -138,8 +145,8 @@ namespace Barotrauma
|
||||
return item?.Prefab.Identifier == ItemPrefabIdentifier;
|
||||
}
|
||||
|
||||
public RequiredItemByIdentifier(Identifier itemPrefab, int amount, float minCondition, float maxCondition, bool useCondition, LocalizedString overrideDescription) :
|
||||
base(amount, minCondition, maxCondition, useCondition, overrideDescription)
|
||||
public RequiredItemByIdentifier(Identifier itemPrefab, int amount, float minCondition, float maxCondition, bool useCondition, LocalizedString overrideDescription, LocalizedString overrideHeader) :
|
||||
base(amount, minCondition, maxCondition, useCondition, overrideDescription, overrideHeader, defaultItem: Identifier.Empty)
|
||||
{
|
||||
ItemPrefabIdentifier = itemPrefab;
|
||||
using MD5 md5 = MD5.Create();
|
||||
@@ -158,9 +165,26 @@ namespace Barotrauma
|
||||
|
||||
public override UInt32 UintIdentifier { get; }
|
||||
|
||||
public override IEnumerable<ItemPrefab> ItemPrefabs => ItemPrefab.Prefabs.Where(p => p.Tags.Contains(Tag));
|
||||
private readonly List<ItemPrefab> cachedPrefabs = new List<ItemPrefab>();
|
||||
|
||||
public override ItemPrefab FirstMatchingPrefab => ItemPrefab.Prefabs.FirstOrDefault(p => p.Tags.Contains(Tag));
|
||||
private Md5Hash prevContentPackagesHash;
|
||||
|
||||
public override IEnumerable<ItemPrefab> ItemPrefabs
|
||||
{
|
||||
get
|
||||
{
|
||||
if (prevContentPackagesHash == null ||
|
||||
!prevContentPackagesHash.Equals(ContentPackageManager.EnabledPackages.MergedHash))
|
||||
{
|
||||
cachedPrefabs.Clear();
|
||||
cachedPrefabs.AddRange(ItemPrefab.Prefabs.Where(p => p.Tags.Contains(Tag)));
|
||||
prevContentPackagesHash = ContentPackageManager.EnabledPackages.MergedHash;
|
||||
}
|
||||
return cachedPrefabs;
|
||||
}
|
||||
}
|
||||
|
||||
public override ItemPrefab FirstMatchingPrefab => ItemPrefabs.FirstOrDefault();
|
||||
|
||||
public override bool MatchesItem(Item item)
|
||||
{
|
||||
@@ -168,8 +192,8 @@ namespace Barotrauma
|
||||
return item.HasTag(Tag);
|
||||
}
|
||||
|
||||
public RequiredItemByTag(Identifier tag, int amount, float minCondition, float maxCondition, bool useCondition, LocalizedString overrideDescription)
|
||||
: base(amount, minCondition, maxCondition, useCondition, overrideDescription)
|
||||
public RequiredItemByTag(Identifier tag, int amount, float minCondition, float maxCondition, bool useCondition, LocalizedString overrideDescription, LocalizedString overrideHeader, Identifier defaultItem)
|
||||
: base(amount, minCondition, maxCondition, useCondition, overrideDescription, overrideHeader, defaultItem)
|
||||
{
|
||||
Tag = tag;
|
||||
using MD5 md5 = MD5.Create();
|
||||
@@ -186,7 +210,7 @@ namespace Barotrauma
|
||||
public ItemPrefab TargetItem => ItemPrefab.Prefabs[TargetItemPrefabIdentifier];
|
||||
|
||||
private readonly Lazy<LocalizedString> displayName;
|
||||
public LocalizedString DisplayName
|
||||
public LocalizedString DisplayName
|
||||
=> ItemPrefab.Prefabs.ContainsKey(TargetItemPrefabIdentifier) ? displayName.Value : "";
|
||||
public readonly ImmutableArray<RequiredItem> RequiredItems;
|
||||
public readonly ImmutableArray<Identifier> SuitableFabricatorIdentifiers;
|
||||
@@ -198,6 +222,7 @@ namespace Barotrauma
|
||||
public readonly uint RecipeHash;
|
||||
public readonly int Amount;
|
||||
public readonly int? Quality;
|
||||
public readonly bool HideForNonTraitors;
|
||||
|
||||
/// <summary>
|
||||
/// How many of this item the fabricator can create (< 0 = unlimited)
|
||||
@@ -230,6 +255,8 @@ namespace Barotrauma
|
||||
FabricationLimitMin = element.GetAttributeInt(nameof(FabricationLimitMin), limitDefault);
|
||||
FabricationLimitMax = element.GetAttributeInt(nameof(FabricationLimitMax), limitDefault);
|
||||
|
||||
HideForNonTraitors = element.GetAttributeBool(nameof(HideForNonTraitors), false);
|
||||
|
||||
if (element.GetAttribute(nameof(Quality)) != null)
|
||||
{
|
||||
Quality = element.GetAttributeInt(nameof(Quality), 0);
|
||||
@@ -266,10 +293,15 @@ namespace Barotrauma
|
||||
bool useCondition = subElement.GetAttributeBool("usecondition", true);
|
||||
int amount = subElement.GetAttributeInt("count", subElement.GetAttributeInt("amount", 1));
|
||||
|
||||
LocalizedString description = string.Empty;
|
||||
if (subElement.GetAttributeString("description", string.Empty) is string texTag && !texTag.IsNullOrEmpty())
|
||||
LocalizedString overrideDescription = string.Empty;
|
||||
if (subElement.GetAttributeString("description", string.Empty) is string descriptionTag && !descriptionTag.IsNullOrEmpty())
|
||||
{
|
||||
description = TextManager.Get(texTag);
|
||||
overrideDescription = TextManager.Get(descriptionTag);
|
||||
}
|
||||
LocalizedString overrideHeader = string.Empty;
|
||||
if (subElement.GetAttributeString("header", string.Empty) is string headerTag && !headerTag.IsNullOrEmpty())
|
||||
{
|
||||
overrideHeader = TextManager.Get(headerTag);
|
||||
}
|
||||
|
||||
if (requiredItemIdentifier != Identifier.Empty)
|
||||
@@ -284,7 +316,7 @@ namespace Barotrauma
|
||||
amount += requiredItems[existing].Amount;
|
||||
requiredItems.RemoveAt(existing);
|
||||
}
|
||||
requiredItems.Add(new RequiredItemByIdentifier(requiredItemIdentifier, amount, minCondition, maxCondition, useCondition, description));
|
||||
requiredItems.Add(new RequiredItemByIdentifier(requiredItemIdentifier, amount, minCondition, maxCondition, useCondition, overrideDescription, overrideHeader));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -298,7 +330,8 @@ namespace Barotrauma
|
||||
amount += requiredItems[existing].Amount;
|
||||
requiredItems.RemoveAt(existing);
|
||||
}
|
||||
requiredItems.Add(new RequiredItemByTag(requiredItemTag, amount, minCondition, maxCondition, useCondition, description));
|
||||
Identifier defaultItem = subElement.GetAttributeIdentifier("defaultitem", Identifier.Empty);
|
||||
requiredItems.Add(new RequiredItemByTag(requiredItemTag, amount, minCondition, maxCondition, useCondition, overrideDescription, overrideHeader, defaultItem));
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -316,12 +349,13 @@ namespace Barotrauma
|
||||
uint outputId = ToolBox.IdentifierToUint32Hash(TargetItemPrefabIdentifier, md5);
|
||||
|
||||
var requiredItems = string.Join(':', RequiredItems
|
||||
.Select(i => i.UintIdentifier)
|
||||
.Select(i => string.Join(',', i)));
|
||||
.Select(static i => $"{i.UintIdentifier}:{i.Amount}")
|
||||
.Select(static i => string.Join(',', i)));
|
||||
// above but include the item amount
|
||||
|
||||
var requiredSkills = string.Join(':', RequiredSkills.Select(s => $"{s.Identifier}:{s.Level}"));
|
||||
|
||||
uint retVal = ToolBox.StringToUInt32Hash($"{Amount}|{outputId}|{RequiredTime}|{requiredItems}|{requiredSkills}", md5);
|
||||
uint retVal = ToolBox.StringToUInt32Hash($"{Amount}|{outputId}|{RequiredTime}|{RequiresRecipe}|{requiredItems}|{requiredSkills}", md5);
|
||||
if (retVal == 0) { retVal = 1; }
|
||||
return retVal;
|
||||
}
|
||||
@@ -681,6 +715,9 @@ namespace Barotrauma
|
||||
[Serialize(0.0f, IsPropertySaveable.No)]
|
||||
public float OffsetOnSelected { get; private set; }
|
||||
|
||||
[Serialize(false, IsPropertySaveable.No, description: "Should the character who's selected the item grab it (hold their hand on it, the same way as they do when repairing)? Defaults to true on items that have an ItemContainer component.")]
|
||||
public bool GrabWhenSelected { get; set; }
|
||||
|
||||
private float health;
|
||||
|
||||
[Serialize(100.0f, IsPropertySaveable.No)]
|
||||
@@ -749,7 +786,7 @@ namespace Barotrauma
|
||||
[Serialize(false, IsPropertySaveable.No)]
|
||||
public bool DisableItemUsageWhenSelected { get; private set; }
|
||||
|
||||
[Serialize("", IsPropertySaveable.No)]
|
||||
[Serialize("metalcrate", IsPropertySaveable.No)]
|
||||
public string CargoContainerIdentifier { get; private set; }
|
||||
|
||||
[Serialize(false, IsPropertySaveable.No)]
|
||||
@@ -802,7 +839,40 @@ namespace Barotrauma
|
||||
public int MaxStackSize
|
||||
{
|
||||
get { return maxStackSize; }
|
||||
private set { maxStackSize = MathHelper.Clamp(value, 1, Inventory.MaxStackSize); }
|
||||
private set { maxStackSize = MathHelper.Clamp(value, 1, Inventory.MaxPossibleStackSize); }
|
||||
}
|
||||
|
||||
private int maxStackSizeCharacterInventory;
|
||||
[Serialize(-1, IsPropertySaveable.No)]
|
||||
public int MaxStackSizeCharacterInventory
|
||||
{
|
||||
get { return maxStackSizeCharacterInventory; }
|
||||
private set { maxStackSizeCharacterInventory = Math.Min(value, Inventory.MaxPossibleStackSize); }
|
||||
}
|
||||
|
||||
private int maxStackSizeHoldableOrWearableInventory;
|
||||
[Serialize(-1, IsPropertySaveable.No)]
|
||||
public int MaxStackSizeHoldableOrWearableInventory
|
||||
{
|
||||
get { return maxStackSizeHoldableOrWearableInventory; }
|
||||
private set { maxStackSizeHoldableOrWearableInventory = Math.Min(value, Inventory.MaxPossibleStackSize); }
|
||||
}
|
||||
|
||||
public int GetMaxStackSize(Inventory inventory)
|
||||
{
|
||||
if (inventory is CharacterInventory && maxStackSizeCharacterInventory > 0)
|
||||
{
|
||||
return maxStackSizeCharacterInventory;
|
||||
}
|
||||
else if (maxStackSizeHoldableOrWearableInventory > 0 &&
|
||||
inventory?.Owner is Item item && (item.GetComponent<Holdable>() != null || item.GetComponent<Wearable>() != null))
|
||||
{
|
||||
return maxStackSizeHoldableOrWearableInventory;
|
||||
}
|
||||
else
|
||||
{
|
||||
return maxStackSize;
|
||||
}
|
||||
}
|
||||
|
||||
[Serialize(false, IsPropertySaveable.No)]
|
||||
@@ -830,13 +900,19 @@ namespace Barotrauma
|
||||
|
||||
[Serialize(1.0f, IsPropertySaveable.No, description: "How much the bots prioritize shooting this item with slow turrets, like railguns? Defaults to 1. Not used if AITurretPriority is 0. Distance to the target affects the decision making.")]
|
||||
public float AISlowTurretPriority { get; private set; }
|
||||
|
||||
|
||||
[Serialize(float.PositiveInfinity, IsPropertySaveable.No, description: "The max distance at which the bots are allowed to target the items. Defaults to infinity.")]
|
||||
public float AITurretTargetingMaxDistance { get; private set; }
|
||||
|
||||
[Serialize(false, IsPropertySaveable.Yes, description: "If enabled, taking items from this container is never considered stealing.")]
|
||||
public bool AllowStealingContainedItems { get; private set; }
|
||||
|
||||
[Serialize("255,255,255,255", IsPropertySaveable.No, description: "Used in circuit box to set the color of the nodes.")]
|
||||
public Color SignalComponentColor { get; private set; }
|
||||
|
||||
[Serialize(false, IsPropertySaveable.No, description: "If enabled, the player is unable to open the middle click menu when this item is selected.")]
|
||||
public bool DisableCommandMenuWhenSelected { get; set; }
|
||||
|
||||
protected override Identifier DetermineIdentifier(XElement element)
|
||||
{
|
||||
Identifier identifier = base.DetermineIdentifier(element);
|
||||
@@ -1040,7 +1116,7 @@ namespace Barotrauma
|
||||
{
|
||||
DebugConsole.ThrowError(
|
||||
$"Error in item prefab \"{ToString()}\": " +
|
||||
$"{prevRecipe.DisplayName} has the same hash as {newRecipe.DisplayName}. " +
|
||||
$"{prevRecipe.TargetItemPrefabIdentifier} has the same hash as {newRecipe.TargetItemPrefabIdentifier}. " +
|
||||
$"This will cause issues with fabrication."
|
||||
);
|
||||
}
|
||||
@@ -1172,6 +1248,11 @@ namespace Barotrauma
|
||||
#endif
|
||||
|
||||
this.allowedLinks = ConfigElement.GetAttributeIdentifierArray("allowedlinks", Array.Empty<Identifier>()).ToImmutableHashSet();
|
||||
|
||||
GrabWhenSelected = ConfigElement.GetAttributeBool(
|
||||
nameof(GrabWhenSelected),
|
||||
ConfigElement.GetChildElement(nameof(ItemContainer)) != null &&
|
||||
ConfigElement.GetChildElement("Body") == null);
|
||||
}
|
||||
|
||||
public CommonnessInfo? GetCommonnessInfo(Level level)
|
||||
|
||||
Reference in New Issue
Block a user