Implements identity system! If your mask hides your face (e.g. oxygen mask, clown mask and diving suit), the game will either use the name of the ID card owner in your ID card slot or will give you a "?" name.

This only affects "DisplayName". The reason why I can't completely override the .Name for the client from server is due to how crew manifest and CharacterInfo classes are handled - it would require a major rework of many Character-related systems and interactions to truly make this "hack-proof".
Server hosts will have to stay on their toes I guess.
This commit is contained in:
Alex Noir
2017-12-16 19:52:25 +03:00
parent eb92242a8c
commit bd646fb23e
9 changed files with 74 additions and 12 deletions

View File

@@ -298,15 +298,16 @@ namespace Barotrauma
if (info != null)
{
Vector2 namePos = new Vector2(pos.X, pos.Y - 110.0f - (5.0f / cam.Zoom)) - GUI.Font.MeasureString(Info.Name) * 0.5f / cam.Zoom;
string name = Info.DisplayName;
Vector2 namePos = new Vector2(pos.X, pos.Y - 110.0f - (5.0f / cam.Zoom)) - GUI.Font.MeasureString(name) * 0.5f / cam.Zoom;
Color nameColor = Color.White;
if (Character.Controlled != null && TeamID != Character.Controlled.TeamID)
{
nameColor = Color.Red;
}
GUI.Font.DrawString(spriteBatch, Info.Name, namePos + new Vector2(1.0f / cam.Zoom, 1.0f / cam.Zoom), Color.Black, 0.0f, Vector2.Zero, 1.0f / cam.Zoom, SpriteEffects.None, 0.001f);
GUI.Font.DrawString(spriteBatch, Info.Name, namePos, nameColor, 0.0f, Vector2.Zero, 1.0f / cam.Zoom, SpriteEffects.None, 0.0f);
GUI.Font.DrawString(spriteBatch, name, namePos + new Vector2(1.0f / cam.Zoom, 1.0f / cam.Zoom), Color.Black, 0.0f, Vector2.Zero, 1.0f / cam.Zoom, SpriteEffects.None, 0.001f);
GUI.Font.DrawString(spriteBatch, name, namePos, nameColor, 0.0f, Vector2.Zero, 1.0f / cam.Zoom, SpriteEffects.None, 0.0f);
if (GameMain.DebugDraw)
{

View File

@@ -208,7 +208,7 @@ namespace Barotrauma
string focusName = character.FocusedCharacter.SpeciesName;
if (character.FocusedCharacter.Info != null)
{
focusName = character.FocusedCharacter.Info.Name;
focusName = character.FocusedCharacter.Info.DisplayName;
}
Vector2 textPos = startPos;
textPos -= new Vector2(GUI.Font.MeasureString(focusName).X / 2, 20);

View File

@@ -296,9 +296,26 @@ namespace Barotrauma
}
else
{
toolTip = string.IsNullOrEmpty(Items[i].Description) ?
string description = Items[i].Description;
if (Items[i].Name == "ID Card")
{
string[] readTags = Items[i].Tags.Split(',');
string idName = null;
string idJob = null;
foreach (string tag in readTags)
{
string[] s = tag.Split(':');
if (s[0] == "name")
idName = s[1];
if (s[0] == "job")
idJob = s[1];
}
if (idName != null)
description = "This belongs to " + idName + (idJob != null ? ", the " + idJob + ".\n" : ".\n") + description;
}
toolTip = string.IsNullOrEmpty(description) ?
Items[i].Name :
Items[i].Name + '\n' + Items[i].Description;
Items[i].Name + '\n' + description;
}
DrawToolTip(spriteBatch, toolTip, slots[i].Rect);

View File

@@ -41,7 +41,7 @@
<Wearable limbtype="Head" slots="Any,Face">
<sprite texture="DivingMask.png" limb="Head" sourcerect="1,1,37,38"/>
<StatusEffect type="OnWearing" target="Character" ObstructVision="true" setvalue="true" disabledeltatime="true"/>
<StatusEffect type="OnWearing" target="Character" HideFace="true" ObstructVision="true" setvalue="true" disabledeltatime="true"/>
<StatusEffect type="OnWearing" target="Contained,Character" OxygenAvailable="1000.0" Condition="-0.5">
<RequiredItem type="Contained" name="Oxygen Tank"/>
</StatusEffect>
@@ -92,7 +92,7 @@
<sprite texture="DivingSuit.png" limb="RightFoot" sourcerect="30,100,20,25" origin="0.5,0.5" depth="0.13" inheritlimbdepth="false" hidelimb="true"/>
<sprite texture="DivingSuit.png" limb="LeftFoot" sourcerect="30,100,20,25" origin="0.5,0.5" depth="0.13" inheritlimbdepth="false" hidelimb="true"/>
<StatusEffect type="OnWearing" target="Character" ObstructVision="true" PressureProtection="100.0" SpeedMultiplier="0.6" LowPassMultiplier="0.2" setvalue="true" disabledeltatime="true"/>
<StatusEffect type="OnWearing" target="Character" HideFace="true" ObstructVision="true" PressureProtection="100.0" SpeedMultiplier="0.6" LowPassMultiplier="0.2" setvalue="true" disabledeltatime="true"/>
<StatusEffect type="OnWearing" target="Contained,Character" OxygenAvailable="1000.0" Condition="-0.5">
<RequiredItem type="Contained" name="Oxygen Tank"/>
</StatusEffect>

View File

@@ -38,6 +38,7 @@
<Wearable limbtype="Head" slots="Any,Face">
<sprite texture="clownmask.png" limb="Head" origin="0.5,0.5"/>
<StatusEffect type="OnWearing" target="Character" HideFace="true"/>
</Wearable>
</Item>

View File

@@ -197,8 +197,8 @@
<Body width="60" height="10" density="50"/>
<MeleeWeapon slots="Any,RightHand,LeftHand"
aimpos="50,0" handle1="-5,0" holdangle="30" reload="1.8">
<Attack damage="15" stun="0.4" damagetype="Blunt" sound="Content/Items/Weapons/smack.ogg"/>
aimpos="50,0" handle1="-5,0" holdangle="30" reload="1.7">
<Attack damage="10" stun="0.4" damagetype="Blunt" sound="Content/Items/Weapons/smack.ogg"/>
</MeleeWeapon>
</Item>

View File

@@ -139,6 +139,19 @@ namespace Barotrauma
}
}
private float hideFaceTimer;
public bool HideFace
{
get
{
return hideFaceTimer > 0.0f;
}
set
{
hideFaceTimer = MathHelper.Clamp(hideFaceTimer + (value ? 1.0f : -0.5f), 0.0f, 10.0f);
}
}
public string ConfigPath
{
get;
@@ -1406,6 +1419,8 @@ namespace Barotrauma
item.Submarine = Submarine;
}
}
HideFace = false;
if (isDead) return;

View File

@@ -12,7 +12,34 @@ namespace Barotrauma
partial class CharacterInfo
{
public string Name;
public string DisplayName
{
get {
string disguiseName = "?";
if (Character != null && Character.HideFace)
{
if (Character.Inventory != null)
{
var idCard = Character.Inventory.FindItem("ID Card");
if (idCard != null && Character.Inventory.IsInLimbSlot(idCard, InvSlotType.Card)) //Disguise as the ID card name if it's equipped
{
string[] readTags = idCard.Tags.Split(',');
foreach (string tag in readTags)
{
string[] s = tag.Split(':');
if (s[0] == "name")
{
disguiseName = s[1];
break;
}
}
}
}
return disguiseName;
}
return Name;
}
}
public Character Character;
public readonly string File;

View File

@@ -130,7 +130,8 @@ namespace Barotrauma
{
item.AddTag(s);
}
item.Description = "This belongs to " + character.Name + ", the " + Name + ".";
item.AddTag("name:" + character.Name);
item.AddTag("job:" + Name);
}
if (parentItem != null) parentItem.Combine(item);