Build 0.18.2.0
This commit is contained in:
@@ -275,7 +275,11 @@ namespace Barotrauma
|
||||
switch (subElement.Name.ToString().ToLowerInvariant())
|
||||
{
|
||||
case "chooserandom":
|
||||
LoadSubElement(subElement.Elements().ToArray().GetRandom(random));
|
||||
var subElements = subElement.Elements();
|
||||
if (subElements.Any())
|
||||
{
|
||||
LoadSubElement(subElements.ToArray().GetRandom(random));
|
||||
}
|
||||
break;
|
||||
default:
|
||||
LoadSubElement(subElement);
|
||||
|
||||
@@ -85,7 +85,7 @@ namespace Barotrauma
|
||||
|
||||
public readonly Identifier[] ForbiddenAmmunition;
|
||||
|
||||
public static WreckAIConfig GetRandom() => Prefabs.GetRandom(Rand.RandSync.ServerAndClient);
|
||||
public static WreckAIConfig GetRandom() => Prefabs.OrderBy(p => p.UintIdentifier).GetRandom(Rand.RandSync.ServerAndClient);
|
||||
|
||||
protected override Identifier DetermineIdentifier(XElement element)
|
||||
{
|
||||
|
||||
@@ -94,11 +94,67 @@ namespace Barotrauma
|
||||
|
||||
public Vector2 SheetIndex => Preset.SheetIndex;
|
||||
|
||||
public ContentXElement HairElement => CharacterInfo.Hairs?.ElementAtOrDefault(HairIndex);
|
||||
public ContentXElement HairWithHatElement => CharacterInfo.Hairs?.ElementAtOrDefault(HairWithHatIndex);
|
||||
public ContentXElement BeardElement => CharacterInfo.Beards?.ElementAtOrDefault(BeardIndex);
|
||||
public ContentXElement MoustacheElement => CharacterInfo.Moustaches?.ElementAtOrDefault(MoustacheIndex);
|
||||
public ContentXElement FaceAttachment => CharacterInfo.FaceAttachments?.ElementAtOrDefault(FaceAttachmentIndex);
|
||||
public ContentXElement HairElement
|
||||
{
|
||||
get
|
||||
{
|
||||
if (CharacterInfo.Hairs == null) { return null; }
|
||||
if (hairIndex >= CharacterInfo.Hairs.Count)
|
||||
{
|
||||
DebugConsole.AddWarning($"Hair index out of range (character: {CharacterInfo?.Name ?? "null"}, index: {hairIndex})");
|
||||
}
|
||||
return CharacterInfo.Hairs.ElementAtOrDefault(hairIndex);
|
||||
}
|
||||
}
|
||||
public ContentXElement HairWithHatElement
|
||||
{
|
||||
get
|
||||
{
|
||||
if (CharacterInfo.Hairs == null) { return null; }
|
||||
if (HairWithHatIndex >= CharacterInfo.Hairs.Count)
|
||||
{
|
||||
DebugConsole.AddWarning($"Hair with hat index out of range (character: {CharacterInfo?.Name ?? "null"}, index: {HairWithHatIndex})");
|
||||
}
|
||||
return CharacterInfo.Hairs.ElementAtOrDefault(HairWithHatIndex);
|
||||
}
|
||||
}
|
||||
|
||||
public ContentXElement BeardElement
|
||||
{
|
||||
get
|
||||
{
|
||||
if (CharacterInfo.Beards == null) { return null; }
|
||||
if (BeardIndex >= CharacterInfo.Beards.Count)
|
||||
{
|
||||
DebugConsole.AddWarning($"Beard index out of range (character: {CharacterInfo?.Name ?? "null"}, index: {BeardIndex})");
|
||||
}
|
||||
return CharacterInfo.Beards.ElementAtOrDefault(BeardIndex);
|
||||
}
|
||||
}
|
||||
public ContentXElement MoustacheElement
|
||||
{
|
||||
get
|
||||
{
|
||||
if (CharacterInfo.Moustaches == null) { return null; }
|
||||
if (MoustacheIndex >= CharacterInfo.Moustaches.Count)
|
||||
{
|
||||
DebugConsole.AddWarning($"Moustache index out of range (character: {CharacterInfo?.Name ?? "null"}, index: {MoustacheIndex})");
|
||||
}
|
||||
return CharacterInfo.Moustaches.ElementAtOrDefault(MoustacheIndex);
|
||||
}
|
||||
}
|
||||
public ContentXElement FaceAttachment
|
||||
{
|
||||
get
|
||||
{
|
||||
if (CharacterInfo.FaceAttachments == null) { return null; }
|
||||
if (FaceAttachmentIndex >= CharacterInfo.FaceAttachments.Count)
|
||||
{
|
||||
DebugConsole.AddWarning($"Face attachment index out of range (character: {CharacterInfo?.Name ?? "null"}, index: {FaceAttachmentIndex})");
|
||||
}
|
||||
return CharacterInfo.FaceAttachments.ElementAtOrDefault(FaceAttachmentIndex);
|
||||
}
|
||||
}
|
||||
|
||||
public HeadInfo(CharacterInfo characterInfo, HeadPreset headPreset, int hairIndex = 0, int beardIndex = 0, int moustacheIndex = 0, int faceAttachmentIndex = 0)
|
||||
{
|
||||
@@ -130,6 +186,10 @@ namespace Barotrauma
|
||||
head = value;
|
||||
HeadSprite = null;
|
||||
AttachmentSprites = null;
|
||||
hairs = null;
|
||||
beards = null;
|
||||
moustaches = null;
|
||||
faceAttachments = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -843,7 +903,14 @@ namespace Barotrauma
|
||||
public void RecreateHead(ImmutableHashSet<Identifier> tags, int hairIndex, int beardIndex, int moustacheIndex, int faceAttachmentIndex)
|
||||
{
|
||||
HeadPreset headPreset = Prefab.Heads.FirstOrDefault(h => h.TagSet.SetEquals(tags));
|
||||
if (headPreset == null) { headPreset = Prefab.Heads.GetRandomUnsynced(); }
|
||||
if (headPreset == null)
|
||||
{
|
||||
if (tags.Count == 1)
|
||||
{
|
||||
headPreset = Prefab.Heads.FirstOrDefault(h => h.TagSet.Contains(tags.First()));
|
||||
}
|
||||
headPreset ??= Prefab.Heads.GetRandomUnsynced();
|
||||
}
|
||||
head = new HeadInfo(this, headPreset, hairIndex, beardIndex, moustacheIndex, faceAttachmentIndex);
|
||||
ReloadHeadAttachments();
|
||||
}
|
||||
|
||||
@@ -352,7 +352,7 @@ namespace Barotrauma
|
||||
|
||||
public Vector2 Position
|
||||
{
|
||||
get { return ConvertUnits.ToDisplayUnits(body.SimPosition); }
|
||||
get { return ConvertUnits.ToDisplayUnits(body?.SimPosition ?? Vector2.Zero); }
|
||||
}
|
||||
|
||||
public Vector2 SimPosition
|
||||
|
||||
@@ -574,7 +574,7 @@ namespace Barotrauma
|
||||
public float AggressionGreed { get; private set; }
|
||||
|
||||
[Serialize(0f, IsPropertySaveable.Yes, description: "If the health drops below this threshold, the character flees. In percentages."), Editable(minValue: 0f, maxValue: 100f)]
|
||||
public float FleeHealthThreshold { get; private set; }
|
||||
public float FleeHealthThreshold { get; set; }
|
||||
|
||||
[Serialize(false, IsPropertySaveable.Yes, description: "Does the character attack when provoked? When enabled, overrides the predefined targeting state with Attack and increases the priority of it."), Editable()]
|
||||
public bool AttackWhenProvoked { get; private set; }
|
||||
|
||||
Reference in New Issue
Block a user