Build 1.1.4.0
This commit is contained in:
@@ -1,16 +1,33 @@
|
||||
using Barotrauma.IO;
|
||||
using Barotrauma.Extensions;
|
||||
using Barotrauma.IO;
|
||||
using Barotrauma.Items.Components;
|
||||
using Microsoft.Xna.Framework;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Immutable;
|
||||
using System.Linq;
|
||||
using Barotrauma.Extensions;
|
||||
using System.Security.Cryptography;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace Barotrauma
|
||||
{
|
||||
readonly struct SkillRequirementHint
|
||||
{
|
||||
public readonly Identifier Skill;
|
||||
public readonly float Level;
|
||||
public readonly LocalizedString SkillName;
|
||||
|
||||
public LocalizedString GetFormattedText(int skillLevel, string levelColorTag) =>
|
||||
$"{SkillName} {Level} (‖color:{levelColorTag}‖{skillLevel}‖color:end‖)";
|
||||
|
||||
public SkillRequirementHint(ContentXElement element)
|
||||
{
|
||||
Skill = element.GetAttributeIdentifier("identifier", Identifier.Empty);
|
||||
Level = element.GetAttributeFloat("level", 0);
|
||||
SkillName = TextManager.Get("skillname." + Skill);
|
||||
}
|
||||
}
|
||||
|
||||
readonly struct DeconstructItem
|
||||
{
|
||||
public readonly Identifier ItemIdentifier;
|
||||
@@ -315,6 +332,8 @@ namespace Barotrauma
|
||||
public readonly bool TransferOnlyOnePerContainer;
|
||||
public readonly bool AllowTransfersHere = true;
|
||||
|
||||
public readonly float MinLevelDifficulty, MaxLevelDifficulty;
|
||||
|
||||
public PreferredContainer(XElement element)
|
||||
{
|
||||
Primary = XMLExtensions.GetAttributeIdentifierArray(element, "primary", Array.Empty<Identifier>()).ToImmutableHashSet();
|
||||
@@ -330,6 +349,9 @@ namespace Barotrauma
|
||||
TransferOnlyOnePerContainer = element.GetAttributeBool("TransferOnlyOnePerContainer", TransferOnlyOnePerContainer);
|
||||
AllowTransfersHere = element.GetAttributeBool("AllowTransfersHere", AllowTransfersHere);
|
||||
|
||||
MinLevelDifficulty = element.GetAttributeFloat(nameof(MinLevelDifficulty), float.MinValue);
|
||||
MaxLevelDifficulty = element.GetAttributeFloat(nameof(MaxLevelDifficulty), float.MaxValue);
|
||||
|
||||
if (element.GetAttribute("spawnprobability") == null)
|
||||
{
|
||||
//if spawn probability is not defined but amount is, assume the probability is 1
|
||||
@@ -443,6 +465,8 @@ namespace Barotrauma
|
||||
//Containers (by identifiers or tags) that this item should be placed in. These are preferences, which are not enforced.
|
||||
public ImmutableArray<PreferredContainer> PreferredContainers { get; private set; }
|
||||
|
||||
public ImmutableArray<SkillRequirementHint> SkillRequirementHints { get; private set; }
|
||||
|
||||
public SwappableItem SwappableItem
|
||||
{
|
||||
get;
|
||||
@@ -651,6 +675,9 @@ namespace Barotrauma
|
||||
[Serialize(false, IsPropertySaveable.No)]
|
||||
public bool AllowSellingWhenBroken { get; private set; }
|
||||
|
||||
[Serialize(false, IsPropertySaveable.No)]
|
||||
public bool AllowStealingAlways { get; private set; }
|
||||
|
||||
[Serialize(false, IsPropertySaveable.No)]
|
||||
public bool Indestructible { get; private set; }
|
||||
|
||||
@@ -660,6 +687,9 @@ namespace Barotrauma
|
||||
[Serialize(1f, IsPropertySaveable.No)]
|
||||
public float ExplosionDamageMultiplier { get; private set; }
|
||||
|
||||
[Serialize(1f, IsPropertySaveable.No)]
|
||||
public float ItemDamageMultiplier { get; private set; }
|
||||
|
||||
[Serialize(false, IsPropertySaveable.No)]
|
||||
public bool DamagedByProjectiles { get; private set; }
|
||||
|
||||
@@ -772,6 +802,18 @@ namespace Barotrauma
|
||||
[Serialize(1f, IsPropertySaveable.No, description: "How much the bots prioritize this item when they seek for items. For example, bots prioritize less exosuit than the other diving suits. Defaults to 1. Note that there's also a specific CombatPriority for items that can be used as weapons.")]
|
||||
public float BotPriority { get; private set; }
|
||||
|
||||
[Serialize(true, IsPropertySaveable.No)]
|
||||
public bool ShowNameInHealthBar { get; private set; }
|
||||
|
||||
[Serialize(false, IsPropertySaveable.No, description:"Should the bots shoot at this item with turret or not? Disabled by default.")]
|
||||
public bool IsAITurretTarget { get; private set; }
|
||||
|
||||
[Serialize(1.0f, IsPropertySaveable.No, description: "How much the bots prioritize shooting this item with turrets? Defaults to 1. Distance to the target affects the decision making.")]
|
||||
public float AITurretPriority { get; private set; }
|
||||
|
||||
[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; }
|
||||
|
||||
protected override Identifier DetermineIdentifier(XElement element)
|
||||
{
|
||||
Identifier identifier = base.DetermineIdentifier(element);
|
||||
@@ -874,6 +916,15 @@ namespace Barotrauma
|
||||
SerializableProperty.DeserializeProperties(this, ConfigElement);
|
||||
|
||||
LoadDescription(ConfigElement);
|
||||
var skillRequirementHints = new List<SkillRequirementHint>();
|
||||
foreach (var skillRequirementHintElement in ConfigElement.GetChildElements("SkillRequirementHint"))
|
||||
{
|
||||
skillRequirementHints.Add(new SkillRequirementHint(skillRequirementHintElement));
|
||||
}
|
||||
if (skillRequirementHints.Any())
|
||||
{
|
||||
SkillRequirementHints = skillRequirementHints.ToImmutableArray();
|
||||
}
|
||||
|
||||
var allowDroppingOnSwapWith = ConfigElement.GetAttributeIdentifierArray("allowdroppingonswapwith", Array.Empty<Identifier>());
|
||||
AllowDroppingOnSwapWith = allowDroppingOnSwapWith.ToImmutableHashSet();
|
||||
@@ -1167,7 +1218,10 @@ namespace Barotrauma
|
||||
public bool CanBeBoughtFrom(Location.StoreInfo store, out PriceInfo priceInfo)
|
||||
{
|
||||
priceInfo = GetPriceInfo(store);
|
||||
return priceInfo is { CanBeBought: true } && (store?.Location.LevelData?.Difficulty ?? 0) >= priceInfo.MinLevelDifficulty;
|
||||
return
|
||||
priceInfo is { CanBeBought: true } &&
|
||||
(store?.Location.LevelData?.Difficulty ?? 0) >= priceInfo.MinLevelDifficulty &&
|
||||
(!priceInfo.MinReputation.Any() || priceInfo.MinReputation.Any(p => store?.Location.Faction?.Prefab.Identifier == p.Key || store?.Location.SecondaryFaction?.Prefab.Identifier == p.Key));
|
||||
}
|
||||
|
||||
public bool CanBeBoughtFrom(Location location)
|
||||
@@ -1179,6 +1233,15 @@ namespace Barotrauma
|
||||
if (priceInfo == null) { continue; }
|
||||
if (!priceInfo.CanBeBought) { continue; }
|
||||
if (location.LevelData.Difficulty < priceInfo.MinLevelDifficulty) { continue; }
|
||||
if (priceInfo.MinReputation.Any())
|
||||
{
|
||||
if (!priceInfo.MinReputation.Any(p =>
|
||||
location?.Faction?.Prefab.Identifier == p.Key ||
|
||||
location?.SecondaryFaction?.Prefab.Identifier == p.Key))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -1335,11 +1398,43 @@ namespace Barotrauma
|
||||
}
|
||||
|
||||
public Identifier VariantOf { get; }
|
||||
|
||||
public ItemPrefab ParentPrefab { get; set; }
|
||||
|
||||
public void InheritFrom(ItemPrefab parent)
|
||||
{
|
||||
ConfigElement = originalElement.CreateVariantXML(parent.ConfigElement).FromPackage(ConfigElement.ContentPackage);
|
||||
ConfigElement = originalElement.CreateVariantXML(parent.ConfigElement, CheckXML).FromPackage(ConfigElement.ContentPackage);
|
||||
ParseConfigElement(parent);
|
||||
|
||||
void CheckXML(XElement originalElement, XElement variantElement, XElement result)
|
||||
{
|
||||
if (result == null) { return; }
|
||||
if (result.Name.ToIdentifier() == "RequiredItem" &&
|
||||
result.Parent?.Name.ToIdentifier() == "Fabricate")
|
||||
{
|
||||
int originalAmount = originalElement.GetAttributeInt("amount", 1);
|
||||
Identifier originalIdentifier = originalElement.GetAttributeIdentifier("identifier", Identifier.Empty);
|
||||
if (variantElement == null)
|
||||
{
|
||||
//if the variant defines some fabrication requirements, we probably don't want to inherit anything extra from the base item?
|
||||
if (this.originalElement.GetChildElement("Fabricate")?.GetChildElement("RequiredItem") != null)
|
||||
{
|
||||
DebugConsole.AddWarning($"Potential error in item variant \"{Identifier}\": " +
|
||||
$"the item inherits the fabrication requirement of x{originalAmount} \"{originalIdentifier}\" from the base item \"{parent.Identifier}\". " +
|
||||
$"If this is not intentional, you can use empty <RequiredItem /> elements in the item variant to remove any excess inherited fabrication requirements.");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
Identifier resultIdentifier = result.GetAttributeIdentifier("identifier", Identifier.Empty);
|
||||
if (originalAmount > 1 && variantElement.GetAttribute("amount") == null)
|
||||
{
|
||||
DebugConsole.AddWarning($"Potential error in item variant \"{Identifier}\": " +
|
||||
$"the base item \"{parent.Identifier}\" requires x{originalAmount} \"{originalIdentifier}\" to fabricate. " +
|
||||
$"The variant only overrides the required item, not the amount, resulting in a requirement of x{originalAmount} \"{resultIdentifier}\". "+
|
||||
"Specify the amount in the variant to fix this.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
|
||||
Reference in New Issue
Block a user