2ad9b5d...2f107db

commit 2f107db0475bf4b9a8b6f405b9ce8ec489cbc0ba
Author: Joonas Rikkonen <poe.regalis@gmail.com>
Date:   Thu Feb 7 16:30:24 2019 +0200

    Another nullref fix to the OpenHealthWindow property setter. Closes #1090

commit 1d15d18d2501bedaa1b42ac8e0e7e09e2600960e
Author: Joonas Rikkonen <poe.regalis@gmail.com>
Date:   Thu Feb 7 16:19:05 2019 +0200

    Fixed crashing when an incompatible content package is selected in config.xml or if the content package cannot be found. Happened because the game attempted to use TextManager.Get before text files had been loaded. Partially fixes #1093

commit 9ec1980fe90bcae65333c188b265ba16a6db6c05
Author: ezjamsen <ezjames.fi@gmail.com>
Date:   Thu Feb 7 16:16:53 2019 +0200

    added correct effects for alien blood

commit b6d2c56910b5d58477703abc6785ef80719a89a6
Author: ezjamsen <ezjames.fi@gmail.com>
Date:   Thu Feb 7 15:41:25 2019 +0200

    adjustments to fent, glue and antibiotics

commit 8df16acdaac0a521fe09fb62c6815a46a87f6f25
Author: Joonas Rikkonen <poe.regalis@gmail.com>
Date:   Thu Feb 7 15:30:51 2019 +0200

    More descriptive ping exception error messages (only shown in debug builds now), some extra checks to prevent using the workshop without steam (although the checks that actually matter are implemented at Steam's side now)

commit 959c503c140196287ab60ec2357feb8bd5c85b18
Author: Joonas Rikkonen <poe.regalis@gmail.com>
Date:   Thu Feb 7 14:00:48 2019 +0200

    Don't allow severing the joint between a moloch's shell and the "bladder"

commit 0c0b033016c2e82b8cf1b5a4e3f6faa9cde39f40
Author: Joonas Rikkonen <poe.regalis@gmail.com>
Date:   Thu Feb 7 13:51:58 2019 +0200

    Fixed incorrect item panel positioning in the crew command interface when the sub is docked to something. Closes #1082

commit 68366a4bf3c73b70288f043199d3ab9b2f5f4d06
Author: Joonas Rikkonen <poe.regalis@gmail.com>
Date:   Thu Feb 7 13:23:38 2019 +0200

    Fixed outdated damage modifiers in security and clown gear (used damage types instead of afflictions), not defining any affliction types for a damage modifier makes it affect all types of damage. Closes #1088

commit 5d3ab5084b8bc5357bc4a53993ad8dfcc44d0412
Author: Joonas Rikkonen <poe.regalis@gmail.com>
Date:   Thu Feb 7 13:04:55 2019 +0200

    Fixed client-side nullref exception if the round ends while the health window is open. Closes #1090

commit 8249d789a60dfe4bcdd1705d26d6ca36ed407058
Author: Joonas Rikkonen <poe.regalis@gmail.com>
Date:   Thu Feb 7 12:48:34 2019 +0200

    The dedicated server doesn't initialize a Steam client (not required to use any of the Steam server functionality). Fixes players being unable to log in as a client when they're hosting a dedicated server on another machine. TODO: SteamCMD support

commit 55fb0bb1ba4bb8385dabbf6e40d4651bf86294a9
Author: ezjamsen <ezjames.fi@gmail.com>
Date:   Thu Feb 7 12:31:46 2019 +0200

    Added linked hulls

commit 937d50dca50d8c889a7c11b55765c208d2d16b67
Merge: 8109ae1a3 57731761f
Author: EdusFF <pitkanen.eetu@gmail.com>
Date:   Thu Feb 7 12:16:43 2019 +0200

    Merge branch 'dev' of https://github.com/Regalis11/Barotrauma into dev

commit 8109ae1a3377910ff9bf066ccac582d879dfb0a4
Author: EdusFF <pitkanen.eetu@gmail.com>
Date:   Thu Feb 7 12:16:37 2019 +0200

    Fixed: AI not reloading coilgun if an empty box of ammunition is inserted.

commit 57731761f64bb33a4f4e7baa38367cfb7cf1f873
Author: itchyOwl <lauri.harkanen@gmail.com>
Date:   Thu Feb 7 12:10:59 2019 +0200

    Refactor character head customization logic and store the data in a dedicated class. In the net lobby, generate new head when the user presses the right arrow button. Pressing the left arrow will restore the previous head. When the user presses the right arrow after the left arrow, the first head is restored again. So it's effectively (and technically) undo/redo logic.

commit 37577931e2706ce432cee2d48cd55990bc2bab4a
Author: itchyOwl <lauri.harkanen@gmail.com>
Date:   Thu Feb 7 12:04:49 2019 +0200

    Add properties for getting the count of the undo and redo stacks.

commit f226beb05a55749ac961e3a33ac594fdf903fc3b
Author: Joonas Rikkonen <poe.regalis@gmail.com>
Date:   Wed Feb 6 21:15:56 2019 +0200

    Fixes to hull linking & displaying them as one hull on the minimap:
    - Links between hulls are now saved.
    - Simplified grouping logic (just store a list of linked hulls in hulldata).
    - Fixed water/oxygen calculations (use the average of the values instead of their sum).
    TODO: DRY (there's now duplicate linking logic in Item and Hull), merge the hull sprites on the minimap, maybe automatize the linking?

commit 5dfea1fbb24c5bd91605caf65baaac9aca9cfbbf
Merge: 2ad9b5de4 d06a1557f
Author: Joonas Rikkonen <poe.regalis@gmail.com>
Date:   Wed Feb 6 20:18:31 2019 +0200

    Merge branch 'dev' of https://github.com/Regalis11/Barotrauma into dev

commit d06a1557ffb85cd32bbb884fadef60b6d9dd27cf
Author: Alex <olimpickusa6@gmail.com>
Date:   Wed Feb 6 18:26:40 2019 +0200

    Test for connecting hulls task
This commit is contained in:
Joonas Rikkonen
2019-03-18 21:13:11 +02:00
parent 74f32d14d4
commit 58c92888b7
32 changed files with 836 additions and 386 deletions
@@ -14,8 +14,83 @@ namespace Barotrauma
public enum Gender { None, Male, Female };
public enum Race { None, White, Black, Asian };
// TODO: Generating the HeadInfo could be simplified.
partial class CharacterInfo
{
public class HeadInfo
{
private int _headSpriteId;
public int HeadSpriteId
{
get { return _headSpriteId; }
set
{
_headSpriteId = value;
if (_headSpriteId < (int)headSpriteRange.X)
{
_headSpriteId = (int)headSpriteRange.Y;
}
if (_headSpriteId > (int)headSpriteRange.Y)
{
_headSpriteId = (int)headSpriteRange.X;
}
}
}
public Vector2 headSpriteRange;
public Gender gender;
public Race race;
public int HairIndex { get; set; } = -1;
public int BeardIndex { get; set; } = -1;
public int MoustacheIndex { get; set; } = -1;
public int FaceAttachmentIndex { get; set; } = -1;
public XElement HairElement { get; set; }
public XElement BeardElement { get; set; }
public XElement MoustacheElement { get; set; }
public XElement FaceAttachment { get; set; }
public HeadInfo() { }
public HeadInfo(int headId)
{
_headSpriteId = headId;
}
public void ResetAttachmentIndices()
{
HairIndex = -1;
BeardIndex = -1;
MoustacheIndex = -1;
FaceAttachmentIndex = -1;
}
}
private HeadInfo head = new HeadInfo();
public HeadInfo Head
{
get { return head; }
set
{
if (head != value && value != null)
{
head = value;
if (head.race == Race.None)
{
head.race = GetRandomRace();
}
if (head.gender == Gender.None)
{
head.gender = GetRandomGender();
}
CalculateHeadSpriteRange();
Head.HeadSpriteId = value.HeadSpriteId;
HeadSprite = null;
AttachmentSprites = null;
}
}
}
private static Dictionary<string, XDocument> cachedConfigs = new Dictionary<string, XDocument>();
private static ushort idCounter;
@@ -70,7 +145,97 @@ namespace Barotrauma
public int Salary;
private Vector2 headSpriteRange;
private Sprite headSprite;
public Sprite HeadSprite
{
get
{
if (headSprite == null)
{
LoadHeadSprite();
}
return headSprite;
}
private set
{
if (headSprite != null)
{
headSprite.Remove();
}
headSprite = value;
}
}
private Sprite portrait;
public Sprite Portrait
{
get
{
if (portrait == null)
{
LoadHeadSprite();
}
return portrait;
}
private set
{
if (portrait != null)
{
portrait.Remove();
}
portrait = value;
}
}
private Sprite portraitBackground;
public Sprite PortraitBackground
{
get
{
if (portraitBackground == null)
{
var portraitBackgroundElement = SourceElement.Element("portraitbackground");
if (portraitBackgroundElement != null)
{
portraitBackground = new Sprite(portraitBackgroundElement.Element("sprite"));
}
}
return portraitBackground;
}
private set
{
if (portraitBackground != null)
{
portraitBackground.Remove();
}
portraitBackground = value;
}
}
private List<WearableSprite> attachmentSprites;
public List<WearableSprite> AttachmentSprites
{
get
{
if (attachmentSprites == null)
{
LoadAttachmentSprites();
}
return attachmentSprites;
}
private set
{
if (attachmentSprites != null)
{
attachmentSprites.ForEach(s => s.Sprite?.Remove());
}
attachmentSprites = value;
}
}
public XElement SourceElement { get; set; }
public readonly string ragdollFileName = string.Empty;
private Sprite headSprite;
public Sprite HeadSprite
@@ -114,35 +279,14 @@ namespace Barotrauma
}
}
private Sprite portraitBackground;
public Sprite PortraitBackground
{
get
{
if (portraitBackground == null)
{
var portraitBackgroundElement = SourceElement.Element("portraitbackground");
if (portraitBackgroundElement != null)
{
portraitBackground = new Sprite(portraitBackgroundElement.Element("sprite"));
}
}
return portraitBackground;
}
}
private NPCPersonalityTrait personalityTrait;
private List<WearableSprite> attachmentSprites;
public List<WearableSprite> AttachmentsSprites
{
get
{
if (attachmentSprites == null)
{
LoadAttachmentSprites();
}
return attachmentSprites;
}
}
//unique ID given to character infos in MP
//used by clients to identify which infos are the same to prevent duplicate characters in round summary
public ushort ID;
public XElement InventoryData;
public XElement SourceElement { get; set; }
@@ -186,22 +330,17 @@ namespace Barotrauma
get { return personalityTrait; }
}
private int headSpriteId;
/// <summary>
/// Setting the value with this property also resets the head attachments. Use Head.headSpriteId if you don't want that.
/// </summary>
public int HeadSpriteId
{
get { return headSpriteId; }
get { return Head.HeadSpriteId; }
set
{
int oldId = headSpriteId;
headSpriteId = value;
Vector2 spriteRange = headSpriteRange;
if (headSpriteId < (int)spriteRange.X) headSpriteId = (int)(spriteRange.Y);
if (headSpriteId > (int)spriteRange.Y) headSpriteId = (int)(spriteRange.X);
headSprite = null;
attachmentSprites = null;
Head.HeadSpriteId = value;
HeadSprite = null;
AttachmentSprites = null;
ResetHeadAttachments();
}
}
@@ -209,47 +348,50 @@ namespace Barotrauma
private Gender gender;
public Gender Gender
{
get { return gender; }
get { return Head.gender; }
set
{
if (gender == value) return;
gender = value;
if (gender == Gender.None)
if (Head.gender == value) return;
Head.gender = value;
if (Head.gender == Gender.None)
{
Gender = Gender.Male;
//SetRandomGender();
Head.gender = Gender.Male;
}
CalculateHeadSpriteRange();
ResetHeadAttachments();
headSprite = null;
attachmentSprites = null;
//SetRandomHead();
//LoadHeadSprite();
HeadSprite = null;
AttachmentSprites = null;
}
}
private Race race;
public Race Race
{
get { return race; }
get { return Head.race; }
set
{
if (race == value) { return; }
race = value;
if (race == Race.None)
if (Head.race == value) { return; }
Head.race = value;
if (Head.race == Race.None)
{
race = Race.White;
//SetRandomRace();
Head.race = Race.White;
}
CalculateHeadSpriteRange();
ResetHeadAttachments();
headSprite = null;
attachmentSprites = null;
//SetRandomHead();
//LoadHeadSprite();
HeadSprite = null;
AttachmentSprites = null;
}
}
public int HairIndex { get => Head.HairIndex; set => Head.HairIndex = value; }
public int BeardIndex { get => Head.BeardIndex; set => Head.BeardIndex = value; }
public int MoustacheIndex { get => Head.MoustacheIndex; set => Head.MoustacheIndex = value; }
public int FaceAttachmentIndex { get => Head.FaceAttachmentIndex; set => Head.FaceAttachmentIndex = value; }
public XElement HairElement { get => Head.HairElement; set => Head.HairElement = value; }
public XElement BeardElement { get => Head.BeardElement; set => Head.BeardElement = value; }
public XElement MoustacheElement { get => Head.MoustacheElement; set => Head.MoustacheElement = value; }
public XElement FaceAttachment { get => Head.FaceAttachment; set => Head.FaceAttachment = value; }
private RagdollParams ragdoll;
public RagdollParams Ragdoll
{
@@ -268,6 +410,8 @@ namespace Barotrauma
set { ragdoll = value; }
}
public bool IsAttachmentsLoaded => HairIndex > -1 && BeardIndex > -1 && MoustacheIndex > -1 && FaceAttachmentIndex > -1;
// Used for creating the data
public CharacterInfo(string file, string name = "", Gender gender = Gender.None, JobPrefab jobPrefab = null, string ragdollFileName = null)
{
@@ -279,18 +423,18 @@ namespace Barotrauma
SourceElement = doc.Root;
if (doc.Root.GetAttributeBool("genders", false))
{
this.gender = gender == Gender.None ? GetRandomGender() : gender;
Head.gender = gender == Gender.None ? GetRandomGender() : gender;
}
if (!Enum.TryParse(doc.Root.GetAttributeString("race", "None"), true, out race))
if (!Enum.TryParse(doc.Root.GetAttributeString("race", "None"), true, out Head.race))
{
race = GetRandomRace();
Head.race = GetRandomRace();
}
if (race == Race.None)
if (Head.race == Race.None)
{
race = GetRandomRace();
Head.race = GetRandomRace();
}
CalculateHeadSpriteRange();
SetRandomHeadID();
Head.HeadSpriteId = GetRandomHeadID();
Job = (jobPrefab == null) ? Job.Random(Rand.RandSync.Server) : new Job(jobPrefab);
if (!string.IsNullOrEmpty(name))
{
@@ -304,14 +448,14 @@ namespace Barotrauma
string firstNamePath = doc.Root.Element("name").GetAttributeString("firstname", "");
if (firstNamePath != "")
{
firstNamePath = firstNamePath.Replace("[GENDER]", (this.gender == Gender.Female) ? "female" : "male");
firstNamePath = firstNamePath.Replace("[GENDER]", (Head.gender == Gender.Female) ? "female" : "male");
Name = ToolBox.GetRandomLine(firstNamePath);
}
string lastNamePath = doc.Root.Element("name").GetAttributeString("lastname", "");
if (lastNamePath != "")
{
lastNamePath = lastNamePath.Replace("[GENDER]", (this.gender == Gender.Female) ? "female" : "male");
lastNamePath = lastNamePath.Replace("[GENDER]", (Head.gender == Gender.Female) ? "female" : "male");
if (Name != "") Name += " ";
Name += ToolBox.GetRandomLine(lastNamePath);
}
@@ -333,16 +477,16 @@ namespace Barotrauma
idCounter++;
Name = element.GetAttributeString("name", "unnamed");
string genderStr = element.GetAttributeString("gender", "male").ToLowerInvariant();
gender = (genderStr == "male") ? Gender.Male : Gender.Female;
Enum.TryParse(element.GetAttributeString("race", "white"), true, out race);
Head.gender = (genderStr == "male") ? Gender.Male : Gender.Female;
Enum.TryParse(element.GetAttributeString("race", "white"), true, out Head.race);
File = element.GetAttributeString("file", "");
SourceElement = GetConfig(File).Root;
Salary = element.GetAttributeInt("salary", 1000);
headSpriteId = element.GetAttributeInt("headspriteid", 1);
HairIndex = element.GetAttributeInt("hairindex", -1);
BeardIndex = element.GetAttributeInt("beardindex", -1);
MoustacheIndex = element.GetAttributeInt("moustacheindex", -1);
FaceAttachmentIndex = element.GetAttributeInt("faceattachmentindex", -1);
Head.HeadSpriteId = element.GetAttributeInt("headspriteid", 1);
Head.HairIndex = element.GetAttributeInt("hairindex", -1);
Head.BeardIndex = element.GetAttributeInt("beardindex", -1);
Head.MoustacheIndex = element.GetAttributeInt("moustacheindex", -1);
Head.FaceAttachmentIndex = element.GetAttributeInt("faceattachmentindex", -1);
StartItemsGiven = element.GetAttributeBool("startitemsgiven", false);
string personalityName = element.GetAttributeString("personality", "");
ragdollFileName = element.GetAttributeString("ragdoll", string.Empty);
@@ -369,8 +513,8 @@ namespace Barotrauma
string spritePath = spriteElement.Attribute("texture").Value;
spritePath = spritePath.Replace("[GENDER]", (gender == Gender.Female) ? "female" : "male");
spritePath = spritePath.Replace("[RACE]", race.ToString().ToLowerInvariant());
spritePath = spritePath.Replace("[GENDER]", (Head.gender == Gender.Female) ? "female" : "male");
spritePath = spritePath.Replace("[RACE]", Head.race.ToString().ToLowerInvariant());
spritePath = spritePath.Replace("[HEADID]", HeadSpriteId.ToString());
string fileName = Path.GetFileNameWithoutExtension(spritePath);
@@ -386,8 +530,8 @@ namespace Barotrauma
fileWithoutTags = fileWithoutTags.Split('[', ']').First();
if (fileWithoutTags != fileName) continue;
headSprite = new Sprite(spriteElement, "", file);
portrait = new Sprite(spriteElement, "", file) { RelativeOrigin = Vector2.Zero };
HeadSprite = new Sprite(spriteElement, "", file);
Portrait = new Sprite(spriteElement, "", file) { RelativeOrigin = Vector2.Zero };
//extract the tags out of the filename
SpriteTags = file.Split('[', ']').Skip(1).ToList();
@@ -416,22 +560,11 @@ namespace Barotrauma
public Gender SetRandomGender() => Gender = GetRandomGender();
public Race SetRandomRace() => Race = GetRandomRace();
public int SetRandomHead() => HeadSpriteId = SetRandomHeadID();
public int SetRandomHead() => HeadSpriteId = GetRandomHeadID();
public Gender GetRandomGender() => (Rand.Range(0.0f, 1.0f, Rand.RandSync.Server) < SourceElement.GetAttributeFloat("femaleratio", 0.5f)) ? Gender.Female : Gender.Male;
public Race GetRandomRace() => new Race[] { Race.White, Race.Black, Race.Asian }.GetRandom(Rand.RandSync.Server);
private int SetRandomHeadID()
{
if (headSpriteRange != Vector2.Zero)
{
headSpriteId = Rand.Range((int)headSpriteRange.X, (int)headSpriteRange.Y + 1, Rand.RandSync.Server);
}
else
{
headSpriteId = 0;
}
return headSpriteId;
}
public int GetRandomHeadID() => Head.headSpriteRange != Vector2.Zero ? Rand.Range((int)Head.headSpriteRange.X, (int)Head.headSpriteRange.Y + 1, Rand.RandSync.Server) : 0;
private List<XElement> hairs;
private List<XElement> beards;
@@ -459,27 +592,27 @@ namespace Barotrauma
{
if (elements == null) { return elements; }
return elements.Where(w =>
Enum.TryParse(w.GetAttributeString("gender", "male"), true, out Gender g) && g == gender &&
Enum.TryParse(w.GetAttributeString("race", "None"), true, out Race r) && r == race);
Enum.TryParse(w.GetAttributeString("gender", "male"), true, out Gender g) && g == Head.gender &&
Enum.TryParse(w.GetAttributeString("race", "None"), true, out Race r) && r == Head.race);
}
private void CalculateHeadSpriteRange()
{
if (SourceElement == null) { return; }
headSpriteRange = SourceElement.GetAttributeVector2("headidrange", Vector2.Zero);
if (headSpriteRange == Vector2.Zero)
Head.headSpriteRange = SourceElement.GetAttributeVector2("headidrange", Vector2.Zero);
if (Head.headSpriteRange == Vector2.Zero)
{
// If range is defined, we use it as it is
// Else we calculate the range from the wearables.
var wearables = FilterElementsByGenderAndRace(Wearables);
if (wearables == null)
{
headSpriteRange = Vector2.Zero;
Head.headSpriteRange = Vector2.Zero;
return;
}
if (wearables.None())
{
DebugConsole.ThrowError($"[CharacterInfo] No headidrange defined and no wearables matching the gender {gender} and the race {race} could be found. Total wearables found: {Wearables.Count()}.");
DebugConsole.ThrowError($"[CharacterInfo] No headidrange defined and no wearables matching the gender {Head.gender} and the race {Head.race} could be found. Total wearables found: {Wearables.Count()}.");
return;
}
else
@@ -492,7 +625,7 @@ namespace Barotrauma
return;
}
ids = ids.OrderBy(id => id);
headSpriteRange = new Vector2(ids.First(), ids.Last());
Head.headSpriteRange = new Vector2(ids.First(), ids.Last());
}
}
}
@@ -521,41 +654,41 @@ namespace Barotrauma
faceAttachments = AddEmpty(FilterByTypeAndHeadID(FilterElementsByGenderAndRace(wearables), WearableType.FaceAttachment), WearableType.FaceAttachment);
}
if (IsValidIndex(HairIndex, hairs))
if (IsValidIndex(Head.HairIndex, hairs))
{
HairElement = hairs[HairIndex];
Head.HairElement = hairs[Head.HairIndex];
}
else
{
HairElement = GetRandomElement(hairs);
HairIndex = hairs.IndexOf(HairElement);
Head.HairElement = GetRandomElement(hairs);
Head.HairIndex = hairs.IndexOf(Head.HairElement);
}
if (IsValidIndex(BeardIndex, beards))
if (IsValidIndex(Head.BeardIndex, beards))
{
BeardElement = beards[BeardIndex];
Head.BeardElement = beards[Head.BeardIndex];
}
else
{
BeardElement = GetRandomElement(beards);
BeardIndex = beards.IndexOf(BeardElement);
Head.BeardElement = GetRandomElement(beards);
Head.BeardIndex = beards.IndexOf(Head.BeardElement);
}
if (IsValidIndex(MoustacheIndex, moustaches))
if (IsValidIndex(Head.MoustacheIndex, moustaches))
{
MoustacheElement = moustaches[MoustacheIndex];
Head.MoustacheElement = moustaches[Head.MoustacheIndex];
}
else
{
MoustacheElement = GetRandomElement(moustaches);
MoustacheIndex = moustaches.IndexOf(MoustacheElement);
Head.MoustacheElement = GetRandomElement(moustaches);
Head.MoustacheIndex = moustaches.IndexOf(Head.MoustacheElement);
}
if (IsValidIndex(FaceAttachmentIndex, faceAttachments))
if (IsValidIndex(Head.FaceAttachmentIndex, faceAttachments))
{
FaceAttachment = faceAttachments[FaceAttachmentIndex];
Head.FaceAttachment = faceAttachments[Head.FaceAttachmentIndex];
}
else
{
FaceAttachment = GetRandomElement(faceAttachments);
FaceAttachmentIndex = faceAttachments.IndexOf(FaceAttachment);
Head.FaceAttachment = GetRandomElement(faceAttachments);
Head.FaceAttachmentIndex = faceAttachments.IndexOf(Head.FaceAttachment);
}
List<XElement> AddEmpty(IEnumerable<XElement> elements, WearableType type)
@@ -583,14 +716,14 @@ namespace Barotrauma
if (Enum.TryParse(e.GetAttributeString("type", ""), true, out WearableType type) && type != targetType) { return false; }
int headId = e.GetAttributeInt("headid", -1);
// if the head id is less than 1, the id is not valid and the condition is ignored.
return headId < 1 || headId == headSpriteId;
return headId < 1 || headId == Head.HeadSpriteId;
});
}
bool IsWearableAllowed(XElement element)
{
string spriteName = element.Element("sprite").GetAttributeString("name", string.Empty);
return IsAllowed(HairElement, spriteName) && IsAllowed(BeardElement, spriteName) && IsAllowed(MoustacheElement, spriteName) && IsAllowed(FaceAttachment, spriteName);
return IsAllowed(Head.HairElement, spriteName) && IsAllowed(Head.BeardElement, spriteName) && IsAllowed(Head.MoustacheElement, spriteName) && IsAllowed(Head.FaceAttachment, spriteName);
}
bool IsAllowed(XElement element, string spriteName)
@@ -671,8 +804,8 @@ namespace Barotrauma
charElement.Add(
new XAttribute("name", Name),
new XAttribute("file", File),
new XAttribute("gender", gender == Gender.Male ? "male" : "female"),
new XAttribute("race", race.ToString()),
new XAttribute("gender", Head.gender == Gender.Male ? "male" : "female"),
new XAttribute("race", Head.race.ToString()),
new XAttribute("salary", Salary),
new XAttribute("headspriteid", HeadSpriteId),
new XAttribute("hairindex", HairIndex),
@@ -735,10 +868,10 @@ namespace Barotrauma
msg.Write(Gender == Gender.Female);
msg.Write((byte)Race);
msg.Write((byte)HeadSpriteId);
msg.Write((byte)HairIndex);
msg.Write((byte)BeardIndex);
msg.Write((byte)MoustacheIndex);
msg.Write((byte)FaceAttachmentIndex);
msg.Write((byte)Head.HairIndex);
msg.Write((byte)Head.BeardIndex);
msg.Write((byte)Head.MoustacheIndex);
msg.Write((byte)Head.FaceAttachmentIndex);
msg.Write(ragdollFileName);
if (Job != null)
@@ -791,13 +924,13 @@ namespace Barotrauma
CharacterInfo ch = new CharacterInfo(configPath, newName, isFemale ? Gender.Female : Gender.Male, jobPrefab, ragdollFile)
{
ID = infoID,
race = (Race)race,
headSpriteId = headSpriteID,
HairIndex = hairIndex,
BeardIndex = beardIndex,
MoustacheIndex = moustacheIndex,
FaceAttachmentIndex = faceAttachmentIndex
};
ch.Head.race = (Race)race;
ch.Head.HeadSpriteId = headSpriteID;
ch.HairIndex = hairIndex;
ch.BeardIndex = beardIndex;
ch.MoustacheIndex = moustacheIndex;
ch.FaceAttachmentIndex = faceAttachmentIndex;
ch.CalculateHeadSpriteRange();
ch.ReloadHeadAttachments();
@@ -832,10 +965,7 @@ namespace Barotrauma
private void ResetAttachmentIndices()
{
HairIndex = -1;
BeardIndex = -1;
MoustacheIndex = -1;
FaceAttachmentIndex = -1;
Head.ResetAttachmentIndices();
}
private void ResetLoadedAttachments()
@@ -849,26 +979,10 @@ namespace Barotrauma
public void Remove()
{
Character = null;
if (headSprite != null)
{
headSprite.Remove();
headSprite = null;
}
if (portrait != null)
{
portrait.Remove();
portrait = null;
}
if (portraitBackground != null)
{
portraitBackground.Remove();
portraitBackground = null;
}
if (attachmentSprites != null)
{
attachmentSprites.ForEach(a => a.Sprite.Remove());
attachmentSprites = null;
}
HeadSprite = null;
Portrait = null;
PortraitBackground = null;
AttachmentSprites = null;
}
}
}