Faction Test 100.4.0.0
This commit is contained in:
@@ -47,8 +47,8 @@ namespace Barotrauma
|
||||
CopyCondition = element.GetAttributeBool("copycondition", false);
|
||||
Commonness = element.GetAttributeFloat("commonness", 1.0f);
|
||||
RequiredDeconstructor = element.GetAttributeStringArray("requireddeconstructor",
|
||||
element.Parent?.GetAttributeStringArray("requireddeconstructor", new string[0]) ?? new string[0]);
|
||||
RequiredOtherItem = element.GetAttributeStringArray("requiredotheritem", new string[0]);
|
||||
element.Parent?.GetAttributeStringArray("requireddeconstructor", Array.Empty<string>()) ?? Array.Empty<string>());
|
||||
RequiredOtherItem = element.GetAttributeStringArray("requiredotheritem", Array.Empty<string>());
|
||||
ActivateButtonText = element.GetAttributeString("activatebuttontext", string.Empty);
|
||||
InfoText = element.GetAttributeString("infotext", string.Empty);
|
||||
InfoTextOnOtherItemMissing = element.GetAttributeString("infotextonotheritemmissing", string.Empty);
|
||||
@@ -102,12 +102,13 @@ namespace Barotrauma
|
||||
{
|
||||
public readonly Identifier ItemPrefabIdentifier;
|
||||
|
||||
public ItemPrefab ItemPrefab => ItemPrefab.Prefabs.TryGet(ItemPrefabIdentifier, out var prefab) ? prefab
|
||||
: MapEntityPrefab.FindByName(ItemPrefabIdentifier.Value) as ItemPrefab ?? throw new Exception($"No ItemPrefab with identifier or name \"{ItemPrefabIdentifier}\"");
|
||||
public ItemPrefab ItemPrefab =>
|
||||
ItemPrefab.Prefabs.TryGet(ItemPrefabIdentifier, out var prefab) ? prefab
|
||||
: MapEntityPrefab.FindByName(ItemPrefabIdentifier.Value) as ItemPrefab;
|
||||
|
||||
public override UInt32 UintIdentifier { get; }
|
||||
|
||||
public override IEnumerable<ItemPrefab> ItemPrefabs => ItemPrefab.ToEnumerable();
|
||||
public override IEnumerable<ItemPrefab> ItemPrefabs => ItemPrefab == null ? Enumerable.Empty<ItemPrefab>() : ItemPrefab.ToEnumerable();
|
||||
|
||||
public override ItemPrefab FirstMatchingPrefab => ItemPrefab;
|
||||
|
||||
@@ -122,6 +123,11 @@ namespace Barotrauma
|
||||
using MD5 md5 = MD5.Create();
|
||||
UintIdentifier = ToolBox.IdentifierToUint32Hash(itemPrefab, md5);
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return $"{base.ToString()} ({ItemPrefabIdentifier})";
|
||||
}
|
||||
}
|
||||
|
||||
public class RequiredItemByTag : RequiredItem
|
||||
@@ -146,6 +152,11 @@ namespace Barotrauma
|
||||
using MD5 md5 = MD5.Create();
|
||||
UintIdentifier = ToolBox.IdentifierToUint32Hash(tag, md5);
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return $"{base.ToString()} ({Tag})";
|
||||
}
|
||||
}
|
||||
|
||||
public readonly Identifier TargetItemPrefabIdentifier;
|
||||
@@ -412,7 +423,6 @@ namespace Barotrauma
|
||||
public ImmutableArray<Rectangle> Triggers { get; private set; }
|
||||
|
||||
private ImmutableDictionary<Identifier, float> treatmentSuitability;
|
||||
private readonly List<XElement> fabricationRecipeElements = new List<XElement>();
|
||||
|
||||
/// <summary>
|
||||
/// Is this prefab overriding a prefab in another content package
|
||||
@@ -754,6 +764,9 @@ namespace Barotrauma
|
||||
[Serialize(false, IsPropertySaveable.No)]
|
||||
public bool DontTransferBetweenSubs { get; private set; }
|
||||
|
||||
[Serialize(true, IsPropertySaveable.No)]
|
||||
public bool ShowHealthBar { get; private set; }
|
||||
|
||||
protected override Identifier DetermineIdentifier(XElement element)
|
||||
{
|
||||
Identifier identifier = base.DetermineIdentifier(element);
|
||||
@@ -801,8 +814,6 @@ namespace Barotrauma
|
||||
? category
|
||||
: MapEntityCategory.Misc;
|
||||
|
||||
var parentType = ConfigElement.Parent?.GetAttributeIdentifier("itemtype", "");
|
||||
|
||||
//nameidentifier can be used to make multiple items use the same names and descriptions
|
||||
Identifier nameIdentifier = ConfigElement.GetAttributeIdentifier("nameidentifier", "");
|
||||
|
||||
@@ -818,7 +829,7 @@ namespace Barotrauma
|
||||
name = name.Fallback(OriginalName);
|
||||
}
|
||||
|
||||
if (parentType == "wrecked")
|
||||
if (category == MapEntityCategory.Wrecked)
|
||||
{
|
||||
name = TextManager.GetWithVariable("wreckeditemformat", "[name]", name);
|
||||
}
|
||||
@@ -1145,7 +1156,10 @@ namespace Barotrauma
|
||||
public bool CanBeBoughtFrom(Location.StoreInfo store, out PriceInfo priceInfo)
|
||||
{
|
||||
priceInfo = GetPriceInfo(store);
|
||||
return priceInfo != null && priceInfo.CanBeBought && (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)
|
||||
@@ -1157,7 +1171,16 @@ namespace Barotrauma
|
||||
if (priceInfo == null) { continue; }
|
||||
if (!priceInfo.CanBeBought) { continue; }
|
||||
if ((location.LevelData?.Difficulty ?? 0) < priceInfo.MinLevelDifficulty) { continue; }
|
||||
return true;
|
||||
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;
|
||||
}
|
||||
@@ -1242,13 +1265,12 @@ namespace Barotrauma
|
||||
throw new ArgumentException("Both name and identifier cannot be null.");
|
||||
}
|
||||
|
||||
ItemPrefab prefab;
|
||||
if (identifier.IsEmpty)
|
||||
{
|
||||
//legacy support
|
||||
identifier = GenerateLegacyIdentifier(name);
|
||||
}
|
||||
Prefabs.TryGet(identifier, out prefab);
|
||||
Prefabs.TryGet(identifier, out ItemPrefab prefab);
|
||||
|
||||
//not found, see if we can find a prefab with a matching alias
|
||||
if (prefab == null && !string.IsNullOrEmpty(name))
|
||||
@@ -1296,8 +1318,8 @@ namespace Barotrauma
|
||||
return PreferredContainers.Any(pc => IsItemConditionAcceptable(item, pc) && IsContainerPreferred(pc.Secondary, identifiersOrTags));
|
||||
}
|
||||
|
||||
private bool IsItemConditionAcceptable(Item item, PreferredContainer pc) => item.ConditionPercentage >= pc.MinCondition && item.ConditionPercentage <= pc.MaxCondition;
|
||||
private bool CanBeTransferred(Identifier item, PreferredContainer pc, ItemContainer targetContainer) =>
|
||||
private static bool IsItemConditionAcceptable(Item item, PreferredContainer pc) => item.ConditionPercentage >= pc.MinCondition && item.ConditionPercentage <= pc.MaxCondition;
|
||||
private static bool CanBeTransferred(Identifier item, PreferredContainer pc, ItemContainer targetContainer) =>
|
||||
pc.AllowTransfersHere && (!pc.TransferOnlyOnePerContainer || targetContainer.Inventory.AllItems.None(i => i.Prefab.Identifier == item));
|
||||
|
||||
public static bool IsContainerPreferred(IEnumerable<Identifier> preferences, ItemContainer c) => preferences.Any(id => c.Item.Prefab.Identifier == id || c.Item.HasTag(id));
|
||||
|
||||
Reference in New Issue
Block a user