v0.13.0.11
This commit is contained in:
@@ -153,6 +153,8 @@ namespace Barotrauma
|
||||
private static ushort idCounter;
|
||||
private const string disguiseName = "???";
|
||||
|
||||
public bool HasNickname => Name != OriginalName;
|
||||
public string OriginalName { get; private set; }
|
||||
public string Name;
|
||||
public string DisplayName
|
||||
{
|
||||
@@ -349,9 +351,9 @@ namespace Barotrauma
|
||||
|
||||
private readonly NPCPersonalityTrait personalityTrait;
|
||||
|
||||
public Order CurrentOrder { get; set; }
|
||||
public string CurrentOrderOption { get; set; }
|
||||
public bool IsDismissed => CurrentOrder == null || CurrentOrder.Identifier.Equals("dismissed", StringComparison.OrdinalIgnoreCase);
|
||||
public const int MaxCurrentOrders = 3;
|
||||
public static int HighestManualOrderPriority => MaxCurrentOrders;
|
||||
public List<OrderInfo> CurrentOrders { get; } = new List<OrderInfo>();
|
||||
|
||||
//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
|
||||
@@ -453,7 +455,7 @@ namespace Barotrauma
|
||||
public bool IsAttachmentsLoaded => HairIndex > -1 && BeardIndex > -1 && MoustacheIndex > -1 && FaceAttachmentIndex > -1;
|
||||
|
||||
// Used for creating the data
|
||||
public CharacterInfo(string speciesName, string name = "", JobPrefab jobPrefab = null, string ragdollFileName = null, int variant = 0, Rand.RandSync randSync = Rand.RandSync.Unsynced)
|
||||
public CharacterInfo(string speciesName, string name = "", string originalName = "", JobPrefab jobPrefab = null, string ragdollFileName = null, int variant = 0, Rand.RandSync randSync = Rand.RandSync.Unsynced)
|
||||
{
|
||||
if (speciesName.EndsWith(".xml", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
@@ -503,6 +505,7 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
}
|
||||
OriginalName = !string.IsNullOrEmpty(originalName) ? originalName : Name;
|
||||
personalityTrait = NPCPersonalityTrait.GetRandom(name + HeadSpriteId);
|
||||
Salary = CalculateSalary();
|
||||
if (ragdollFileName != null)
|
||||
@@ -518,6 +521,7 @@ namespace Barotrauma
|
||||
ID = idCounter;
|
||||
idCounter++;
|
||||
Name = infoElement.GetAttributeString("name", "");
|
||||
OriginalName = infoElement.GetAttributeString("originalname", null);
|
||||
string genderStr = infoElement.GetAttributeString("gender", "male").ToLowerInvariant();
|
||||
Salary = infoElement.GetAttributeInt("salary", 1000);
|
||||
Enum.TryParse(infoElement.GetAttributeString("race", "White"), true, out Race race);
|
||||
@@ -576,6 +580,11 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(OriginalName))
|
||||
{
|
||||
OriginalName = Name;
|
||||
}
|
||||
|
||||
StartItemsGiven = infoElement.GetAttributeBool("startitemsgiven", false);
|
||||
string personalityName = infoElement.GetAttributeString("personality", "");
|
||||
ragdollFileName = infoElement.GetAttributeString("ragdoll", string.Empty);
|
||||
@@ -622,7 +631,17 @@ namespace Barotrauma
|
||||
|
||||
public int GetIdentifier()
|
||||
{
|
||||
int id = ToolBox.StringToInt(Name);
|
||||
return GetIdentifier(Name);
|
||||
}
|
||||
|
||||
public int GetIdentifierUsingOriginalName()
|
||||
{
|
||||
return GetIdentifier(OriginalName);
|
||||
}
|
||||
|
||||
private int GetIdentifier(string name)
|
||||
{
|
||||
int id = ToolBox.StringToInt(name);
|
||||
id ^= HeadSpriteId;
|
||||
id ^= (int)Race << 6;
|
||||
id ^= HairIndex << 12;
|
||||
@@ -939,12 +958,38 @@ namespace Barotrauma
|
||||
|
||||
partial void OnSkillChanged(string skillIdentifier, float prevLevel, float newLevel, Vector2 textPopupPos);
|
||||
|
||||
public void Rename(string newName)
|
||||
{
|
||||
if (string.IsNullOrEmpty(newName)) { return; }
|
||||
// Replace the name tag of any existing id cards or duffel bags
|
||||
foreach (var item in Item.ItemList)
|
||||
{
|
||||
if (item.Prefab.Identifier != "idcard" && !item.Tags.Contains("despawncontainer")) { continue; }
|
||||
foreach (var tag in item.Tags.Split(','))
|
||||
{
|
||||
var splitTag = tag.Split(":");
|
||||
if (splitTag.Length < 2) { continue; }
|
||||
if (splitTag[0] != "name") { continue; }
|
||||
if (splitTag[1] != Name) { continue; }
|
||||
item.ReplaceTag(tag, $"name:{newName}");
|
||||
break;
|
||||
}
|
||||
}
|
||||
Name = newName;
|
||||
}
|
||||
|
||||
public void ResetName()
|
||||
{
|
||||
Name = OriginalName;
|
||||
}
|
||||
|
||||
public XElement Save(XElement parentElement)
|
||||
{
|
||||
XElement charElement = new XElement("Character");
|
||||
|
||||
charElement.Add(
|
||||
new XAttribute("name", Name),
|
||||
new XAttribute("originalname", OriginalName),
|
||||
new XAttribute("speciesname", SpeciesName),
|
||||
new XAttribute("gender", Head.gender == Gender.Male ? "male" : "female"),
|
||||
new XAttribute("race", Head.race.ToString()),
|
||||
@@ -957,7 +1002,7 @@ namespace Barotrauma
|
||||
new XAttribute("startitemsgiven", StartItemsGiven),
|
||||
new XAttribute("ragdoll", ragdollFileName),
|
||||
new XAttribute("personality", personalityTrait == null ? "" : personalityTrait.Name));
|
||||
|
||||
|
||||
// TODO: animations?
|
||||
|
||||
if (Character != null)
|
||||
@@ -1004,13 +1049,9 @@ namespace Barotrauma
|
||||
faceAttachments = null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reset order data so it doesn't carry into further rounds, as the AI is "recreated" always in between rounds anyway.
|
||||
/// </summary>
|
||||
public void ResetCurrentOrder()
|
||||
public void ClearCurrentOrders()
|
||||
{
|
||||
CurrentOrder = null;
|
||||
CurrentOrderOption = "";
|
||||
CurrentOrders.Clear();
|
||||
}
|
||||
|
||||
public void Remove()
|
||||
|
||||
Reference in New Issue
Block a user