Allow sub makers to alter the ID Card's description property on spawn points

This commit is contained in:
Alex Noir
2017-12-16 21:30:18 +03:00
parent 9a91480256
commit 8ab97af456
5 changed files with 38 additions and 3 deletions
@@ -297,7 +297,7 @@ namespace Barotrauma
else
{
string description = Items[i].Description;
if (Items[i].Name == "ID Card")
if (Items[i].Prefab.Name == "ID Card")
{
string[] readTags = Items[i].Tags.Split(',');
string idName = null;
@@ -106,6 +106,16 @@ namespace Barotrauma
return true;
}
private bool EnterIDCardDesc(GUITextBox textBox, string text)
{
IdCardDesc = text;
textBox.Text = text;
textBox.Color = Color.Green;
textBox.Deselect();
return true;
}
private bool EnterIDCardTags(GUITextBox textBox, string text)
{
IdCardTags = text.Split(',');
@@ -172,8 +182,16 @@ namespace Barotrauma
y = 40 + 20;
new GUITextBlock(new Rectangle(0, y, 100, 20), "ID Card tags:", Color.Transparent, Color.White, Alignment.TopLeft, null, editingHUD);
new GUITextBlock(new Rectangle(0, y, 100, 20), "ID Card description:", Color.Transparent, Color.White, Alignment.TopLeft, null, editingHUD);
GUITextBox propertyBox = new GUITextBox(new Rectangle(100, y, 200, 20), "", editingHUD);
propertyBox.Text = idCardDesc;
propertyBox.OnEnterPressed = EnterIDCardDesc;
propertyBox.OnTextChanged = TextBoxChanged;
propertyBox.ToolTip = "Characters spawning at this spawnpoint will have the specified description added to their ID card. This can be used to describe additional access levels their card has on the sub.";
y = y + 30;
new GUITextBlock(new Rectangle(0, y, 100, 20), "ID Card tags:", Color.Transparent, Color.White, Alignment.TopLeft, null, editingHUD);
propertyBox.Text = string.Join(", ", idCardTags);
propertyBox.OnEnterPressed = EnterIDCardTags;
propertyBox.OnTextChanged = TextBoxChanged;
@@ -132,6 +132,8 @@ namespace Barotrauma
}
item.AddTag("name:" + character.Name);
item.AddTag("job:" + Name);
if (!string.IsNullOrWhiteSpace(spawnPoint.IdCardDesc))
item.Description = spawnPoint.IdCardDesc;
}
if (parentItem != null) parentItem.Combine(item);
@@ -21,6 +21,7 @@ namespace Barotrauma
protected SpawnType spawnType;
//characters spawning at the waypoint will be given an ID card with these tags
private string idCardDesc;
private string[] idCardTags;
//only characters with this job will be spawned at the waypoint
@@ -57,6 +58,11 @@ namespace Barotrauma
}
}
public string IdCardDesc
{
get { return idCardDesc; }
private set { idCardDesc = value; }
}
public string[] IdCardTags
{
get { return idCardTags; }
@@ -113,6 +119,7 @@ namespace Barotrauma
public override MapEntity Clone()
{
var clone = new WayPoint(rect, Submarine);
clone.idCardDesc = idCardDesc;
clone.idCardTags = idCardTags;
clone.spawnType = spawnType;
clone.assignedJob = assignedJob;
@@ -570,6 +577,11 @@ namespace Barotrauma
Enum.TryParse<SpawnType>(element.GetAttributeString("spawn", "Path"), out w.spawnType);
string idCardDescString = element.GetAttributeString("idcarddesc", "");
if (!string.IsNullOrWhiteSpace(idCardDescString))
{
w.IdCardDesc = idCardDescString;
}
string idCardTagString = element.GetAttributeString("idcardtags", "");
if (!string.IsNullOrWhiteSpace(idCardTagString))
{
@@ -604,6 +616,7 @@ namespace Barotrauma
new XAttribute("y", (int)(rect.Y - Submarine.HiddenSubPosition.Y)),
new XAttribute("spawn", spawnType));
if (idCardDesc != null) element.Add(new XAttribute("idcarddesc", idCardDesc));
if (idCardTags.Length > 0)
{
element.Add(new XAttribute("idcardtags", string.Join(",", idCardTags)));
@@ -533,7 +533,9 @@ namespace Barotrauma.Networking
foreach (string s in shuttleSpawnPoints[i].IdCardTags)
{
item.AddTag(s);
}
}
if (!string.IsNullOrWhiteSpace(shuttleSpawnPoints[i].IdCardDesc))
item.Description = shuttleSpawnPoints[i].IdCardDesc;
}
#if CLIENT
GameMain.GameSession.CrewManager.AddCharacter(character);