Unstable 0.17.0.0

This commit is contained in:
Markus Isberg
2022-02-26 02:43:01 +09:00
parent a83f375681
commit 3974067915
913 changed files with 32472 additions and 32364 deletions
@@ -37,7 +37,8 @@ namespace Barotrauma
targetPos = attackWorldPos;
}
targetPos.Y = -targetPos.Y;
GUI.DrawLine(spriteBatch, pos, targetPos, GUI.Style.Red * 0.5f, 0, 4);
GUI.DrawLine(spriteBatch, pos, targetPos, GUIStyle.Red * 0.5f, 0, 4);
if (wallTarget != null)
{
Vector2 wallTargetPos = wallTarget.Position;
@@ -46,19 +47,19 @@ namespace Barotrauma
GUI.DrawRectangle(spriteBatch, wallTargetPos - new Vector2(10.0f, 10.0f), new Vector2(20.0f, 20.0f), Color.Orange, false);
GUI.DrawLine(spriteBatch, pos, wallTargetPos, Color.Orange * 0.5f, 0, 5);
}
GUI.DrawString(spriteBatch, pos - Vector2.UnitY * 60.0f, $"{SelectedAiTarget.Entity} ({GetTargetMemory(SelectedAiTarget, false)?.Priority.FormatZeroDecimal()})", GUI.Style.Red, Color.Black);
GUI.DrawString(spriteBatch, pos - Vector2.UnitY * 40.0f, $"({targetValue.FormatZeroDecimal()})", GUI.Style.Red, Color.Black);
GUI.DrawString(spriteBatch, pos - Vector2.UnitY * 60.0f, $"{SelectedAiTarget.Entity} ({GetTargetMemory(SelectedAiTarget, false)?.Priority.FormatZeroDecimal()})", GUIStyle.Red, Color.Black);
GUI.DrawString(spriteBatch, pos - Vector2.UnitY * 40.0f, $"({targetValue.FormatZeroDecimal()})", GUIStyle.Red, Color.Black);
}
/*GUI.Font.DrawString(spriteBatch, targetValue.ToString(), pos - Vector2.UnitY * 80.0f, GUI.Style.Red);
GUI.Font.DrawString(spriteBatch, "updatetargets: " + MathUtils.Round(updateTargetsTimer, 0.1f), pos - Vector2.UnitY * 100.0f, GUI.Style.Red);
GUI.Font.DrawString(spriteBatch, "cooldown: " + MathUtils.Round(coolDownTimer, 0.1f), pos - Vector2.UnitY * 120.0f, GUI.Style.Red);*/
/*GUIStyle.Font.DrawString(spriteBatch, targetValue.ToString(), pos - Vector2.UnitY * 80.0f, GUIStyle.Red);
GUIStyle.Font.DrawString(spriteBatch, "updatetargets: " + MathUtils.Round(updateTargetsTimer, 0.1f), pos - Vector2.UnitY * 100.0f, GUIStyle.Red);
GUIStyle.Font.DrawString(spriteBatch, "cooldown: " + MathUtils.Round(coolDownTimer, 0.1f), pos - Vector2.UnitY * 120.0f, GUIStyle.Red);*/
Color stateColor = Color.White;
switch (State)
{
case AIState.Attack:
stateColor = IsCoolDownRunning ? Color.Orange : GUI.Style.Red;
stateColor = IsCoolDownRunning ? Color.Orange : GUIStyle.Red;
break;
case AIState.Escape:
stateColor = Color.LightBlue;
@@ -78,13 +79,13 @@ namespace Barotrauma
{
GUI.DrawLine(spriteBatch,
ConvertUnits.ToDisplayUnits(new Vector2(attachJoint.WorldAnchorA.X, -attachJoint.WorldAnchorA.Y)),
ConvertUnits.ToDisplayUnits(new Vector2(attachJoint.WorldAnchorB.X, -attachJoint.WorldAnchorB.Y)), GUI.Style.Green, 0, 4);
ConvertUnits.ToDisplayUnits(new Vector2(attachJoint.WorldAnchorB.X, -attachJoint.WorldAnchorB.Y)), GUIStyle.Green, 0, 4);
}
if (LatchOntoAI.AttachPos.HasValue)
{
GUI.DrawLine(spriteBatch, pos,
ConvertUnits.ToDisplayUnits(new Vector2(LatchOntoAI.AttachPos.Value.X, -LatchOntoAI.AttachPos.Value.Y)), GUI.Style.Green, 0, 3);
ConvertUnits.ToDisplayUnits(new Vector2(LatchOntoAI.AttachPos.Value.X, -LatchOntoAI.AttachPos.Value.Y)), GUIStyle.Green, 0, 3);
}
}
@@ -108,12 +109,12 @@ namespace Barotrauma
GUI.DrawLine(spriteBatch,
new Vector2(currentNode.DrawPosition.X, -currentNode.DrawPosition.Y),
new Vector2(previousNode.DrawPosition.X, -previousNode.DrawPosition.Y),
GUI.Style.Red * 0.5f, 0, 3);
GUIStyle.Red * 0.5f, 0, 3);
GUI.SmallFont.DrawString(spriteBatch,
GUIStyle.SmallFont.DrawString(spriteBatch,
currentNode.ID.ToString(),
new Vector2(currentNode.DrawPosition.X - 10, -currentNode.DrawPosition.Y - 30),
GUI.Style.Red);
GUIStyle.Red);
}
}
}
@@ -124,7 +125,7 @@ namespace Barotrauma
Vector2 hitPos = ConvertUnits.ToDisplayUnits(steeringManager.AvoidRayCastHitPosition);
hitPos.Y = -hitPos.Y;
GUI.DrawLine(spriteBatch, hitPos, hitPos + new Vector2(steeringManager.AvoidDir.X, -steeringManager.AvoidDir.Y) * 100, GUI.Style.Red, width: 5);
GUI.DrawLine(spriteBatch, hitPos, hitPos + new Vector2(steeringManager.AvoidDir.X, -steeringManager.AvoidDir.Y) * 100, GUIStyle.Red, width: 5);
//GUI.DrawLine(spriteBatch, pos, ConvertUnits.ToDisplayUnits(steeringManager.AvoidLookAheadPos.X, -steeringManager.AvoidLookAheadPos.Y), Color.Orange, width: 4);
}
}
@@ -18,7 +18,7 @@ namespace Barotrauma
if (SelectedAiTarget?.Entity != null)
{
//GUI.DrawLine(spriteBatch, pos, new Vector2(SelectedAiTarget.WorldPosition.X, -SelectedAiTarget.WorldPosition.Y), GUI.Style.Red);
//GUI.DrawLine(spriteBatch, pos, new Vector2(SelectedAiTarget.WorldPosition.X, -SelectedAiTarget.WorldPosition.Y), GUIStyle.Red);
//GUI.DrawString(spriteBatch, pos + textOffset, $"AI TARGET: {SelectedAiTarget.Entity.ToString()}", Color.White, Color.Black);
}
@@ -87,7 +87,7 @@ namespace Barotrauma
new Vector2(previousNode.DrawPosition.X, -previousNode.DrawPosition.Y),
Color.Blue * 0.5f, 0, 3);
GUI.SmallFont.DrawString(spriteBatch,
GUIStyle.SmallFont.DrawString(spriteBatch,
currentNode.ID.ToString(),
new Vector2(currentNode.DrawPosition.X - 10, -currentNode.DrawPosition.Y - 30),
Color.Blue);
@@ -6,16 +6,16 @@ namespace Barotrauma
{
public static Color ObjectiveIconColor => Color.LightGray;
public static Sprite GetSprite(string identifier, string option, Entity targetEntity)
public static Sprite GetSprite(Identifier identifier, Identifier option, Entity targetEntity)
{
if (string.IsNullOrEmpty(identifier))
if (identifier == Identifier.Empty)
{
return null;
}
identifier = identifier.RemoveWhitespace();
if (Order.Prefabs.TryGetValue(identifier, out Order orderPrefab))
if (OrderPrefab.Prefabs.ContainsKey(identifier))
{
if (!string.IsNullOrEmpty(option) && orderPrefab.OptionSprites.TryGetValue(option, out var optionSprite))
OrderPrefab orderPrefab = OrderPrefab.Prefabs[identifier];
if (option != Identifier.Empty && orderPrefab.OptionSprites.TryGetValue(option, out var optionSprite))
{
return optionSprite;
}
@@ -25,7 +25,7 @@ namespace Barotrauma
}
return orderPrefab.SymbolSprite;
}
return GUI.Style.GetComponentStyle($"{identifier}objectiveicon")?.GetDefaultSprite();
return GUIStyle.GetComponentStyle($"{identifier}objectiveicon")?.GetDefaultSprite();
}
public Sprite GetSprite()
@@ -28,13 +28,13 @@ namespace Barotrauma
{
if (item.Prefab.BrokenSprites.None())
{
Color c = item.prefab.SpriteColor;
Color c = item.Prefab.SpriteColor;
item.SpriteColor = new Color(c.R / 255f * m, c.G / 255f * m, c.B / 255f * m, c.A / 255f);
}
}
foreach (var structure in thalamusStructures)
{
Color c = structure.prefab.SpriteColor;
Color c = structure.Prefab.SpriteColor;
structure.SpriteColor = new Color(c.R / 255f * m, c.G / 255f * m, c.B / 255f * m, c.A / 255f);
}
yield return CoroutineStatus.Running;
@@ -469,7 +469,7 @@ namespace Barotrauma
Color? color = null;
if (character.ExternalHighlight)
{
color = Color.Lerp(Color.White, GUI.Style.Orange, (float)Math.Sin(Timing.TotalTime * 3.5f));
color = Color.Lerp(Color.White, GUIStyle.Orange, (float)Math.Sin(Timing.TotalTime * 3.5f));
}
float depthOffset = GetDepthOffset();
@@ -564,7 +564,7 @@ namespace Barotrauma
Vector2 pos = ConvertUnits.ToDisplayUnits(limb.PullJointWorldAnchorB);
if (currentHull?.Submarine != null) pos += currentHull.Submarine.DrawPosition;
pos.Y = -pos.Y;
GUI.DrawRectangle(spriteBatch, new Rectangle((int)pos.X, (int)pos.Y, 5, 5), GUI.Style.Red, true, 0.01f);
GUI.DrawRectangle(spriteBatch, new Rectangle((int)pos.X, (int)pos.Y, 5, 5), GUIStyle.Red, true, 0.01f);
pos = ConvertUnits.ToDisplayUnits(limb.PullJointWorldAnchorA);
if (currentHull?.Submarine != null) pos += currentHull.Submarine.DrawPosition;
@@ -575,8 +575,8 @@ namespace Barotrauma
limb.body.DebugDraw(spriteBatch, inWater ? (currentHull == null ? Color.Blue : Color.Cyan) : Color.White);
}
Collider.DebugDraw(spriteBatch, frozen ? GUI.Style.Red : (inWater ? Color.SkyBlue : Color.Gray));
GUI.Font.DrawString(spriteBatch, Collider.LinearVelocity.X.FormatSingleDecimal(), new Vector2(Collider.DrawPosition.X, -Collider.DrawPosition.Y), Color.Orange);
Collider.DebugDraw(spriteBatch, frozen ? GUIStyle.Red : (inWater ? Color.SkyBlue : Color.Gray));
GUIStyle.Font.DrawString(spriteBatch, Collider.LinearVelocity.X.FormatSingleDecimal(), new Vector2(Collider.DrawPosition.X, -Collider.DrawPosition.Y), Color.Orange);
foreach (var joint in LimbJoints)
{
@@ -607,10 +607,10 @@ namespace Barotrauma
{
Vector2 pos = ConvertUnits.ToDisplayUnits(humanoid.RightHandIKPos);
if (humanoid.character.Submarine != null) { pos += humanoid.character.Submarine.DrawPosition; }
GUI.DrawRectangle(spriteBatch, new Rectangle((int)pos.X, (int)-pos.Y, 4, 4), GUI.Style.Green, true);
GUI.DrawRectangle(spriteBatch, new Rectangle((int)pos.X, (int)-pos.Y, 4, 4), GUIStyle.Green, true);
pos = ConvertUnits.ToDisplayUnits(humanoid.LeftHandIKPos);
if (humanoid.character.Submarine != null) { pos += humanoid.character.Submarine.DrawPosition; }
GUI.DrawRectangle(spriteBatch, new Rectangle((int)pos.X, (int)-pos.Y, 4, 4), GUI.Style.Green, true);
GUI.DrawRectangle(spriteBatch, new Rectangle((int)pos.X, (int)-pos.Y, 4, 4), GUIStyle.Green, true);
Vector2 aimPos = humanoid.AimSourceWorldPos;
aimPos.Y = -aimPos.Y;
@@ -6,14 +6,14 @@ namespace Barotrauma
{
partial class Attack
{
[Serialize("StructureBlunt", true), Editable()]
[Serialize("StructureBlunt", IsPropertySaveable.Yes), Editable()]
public string StructureSoundType { get; private set; }
private RoundSound sound;
private ParticleEmitter particleEmitter;
partial void InitProjSpecific(XElement element)
partial void InitProjSpecific(ContentXElement element)
{
if (element.Attribute("sound") != null)
{
@@ -21,7 +21,7 @@ namespace Barotrauma
return;
}
foreach (XElement subElement in element.Elements())
foreach (var subElement in element.Elements())
{
switch (subElement.Name.ToString().ToLowerInvariant())
{
@@ -29,7 +29,7 @@ namespace Barotrauma
particleEmitter = new ParticleEmitter(subElement);
break;
case "sound":
sound = Submarine.LoadRoundSound(subElement);
sound = RoundSound.Load(subElement);
break;
}
@@ -131,7 +131,7 @@ namespace Barotrauma
private class GUIMessage
{
public string RawText;
public string Identifier;
public Identifier Identifier;
public string Text;
private int _value;
@@ -142,7 +142,7 @@ namespace Barotrauma
{
_value = value;
Text = RawText.Replace("[value]", _value.ToString());
Size = GUI.Font.MeasureString(Text);
Size = GUIStyle.Font.MeasureString(Text);
}
}
@@ -154,7 +154,7 @@ namespace Barotrauma
public bool PlaySound;
public GUIMessage(string rawText, Color color, float delay, string identifier = null, int? value = null, float lifeTime = 3.0f)
public GUIMessage(string rawText, Color color, float delay, Identifier identifier = default, int? value = null, float lifeTime = 3.0f)
{
RawText = Text = rawText;
if (value.HasValue)
@@ -163,7 +163,7 @@ namespace Barotrauma
Value = value.Value;
}
Timer = -delay;
Size = GUI.Font.MeasureString(Text);
Size = GUIStyle.Font.MeasureString(Text);
Color = color;
Identifier = identifier;
Lifetime = lifeTime;
@@ -202,14 +202,14 @@ namespace Barotrauma
get { return activeObjectiveEntities; }
}
partial void InitProjSpecific(XElement mainElement)
partial void InitProjSpecific(ContentXElement mainElement)
{
soundTimer = Rand.Range(0.0f, Params.SoundInterval);
sounds = new List<CharacterSound>();
Params.Sounds.ForEach(s => sounds.Add(new CharacterSound(s)));
foreach (XElement subElement in mainElement.Elements())
foreach (var subElement in mainElement.Elements())
{
switch (subElement.Name.ToString().ToLowerInvariant())
{
@@ -267,11 +267,11 @@ namespace Barotrauma
//and the fire key is the same as Select or Use, reset the key to prevent accidentally selecting/using items
if (wasFiring && !keys[(int)InputType.Shoot].Held)
{
if (GameMain.Config.KeyBind(InputType.Shoot).Equals(GameMain.Config.KeyBind(InputType.Select)))
if (GameSettings.CurrentConfig.KeyMap.Bindings[InputType.Shoot] == GameSettings.CurrentConfig.KeyMap.Bindings[InputType.Select])
{
keys[(int)InputType.Select].Reset();
}
if (GameMain.Config.KeyBind(InputType.Shoot).Equals(GameMain.Config.KeyBind(InputType.Use)))
if (GameSettings.CurrentConfig.KeyMap.Bindings[InputType.Shoot] == GameSettings.CurrentConfig.KeyMap.Bindings[InputType.Use])
{
keys[(int)InputType.Use].Reset();
}
@@ -331,7 +331,7 @@ namespace Barotrauma
Position +
PlayerInput.MouseSpeed.ClampLength(10.0f); //apply a little bit of movement to the cursor pos to prevent AFK kicking
}
else if (!GameMain.Config.EnableMouseLook)
else if (!GameSettings.CurrentConfig.EnableMouseLook)
{
cam.OffsetAmount = targetOffsetAmount = 0.0f;
}
@@ -446,15 +446,15 @@ namespace Barotrauma
if (GameMain.NetworkMember != null && controlled == this)
{
string chatMessage = CauseOfDeath.Type == CauseOfDeathType.Affliction ?
LocalizedString chatMessage = CauseOfDeath.Type == CauseOfDeathType.Affliction ?
CauseOfDeath.Affliction.SelfCauseOfDeathDescription :
TextManager.Get("Self_CauseOfDeathDescription." + CauseOfDeath.Type.ToString(), fallBackTag: "Self_CauseOfDeathDescription.Damage");
TextManager.Get("Self_CauseOfDeathDescription." + CauseOfDeath.Type.ToString(), "Self_CauseOfDeathDescription.Damage");
if (GameMain.Client != null) { chatMessage += " " + TextManager.Get("DeathChatNotification"); }
GameMain.NetworkMember.RespawnManager?.ShowRespawnPromptIfNeeded();
GameMain.NetworkMember.AddChatMessage(chatMessage, ChatMessageType.Dead);
GameMain.NetworkMember.AddChatMessage(chatMessage.Value, ChatMessageType.Dead);
GameMain.LightManager.LosEnabled = false;
controlled = null;
if (!(Screen.Selected?.Cam is null))
@@ -726,9 +726,9 @@ namespace Barotrauma
}
}
partial void SetOrderProjSpecific(Order order, string orderOption, int priority)
partial void SetOrderProjSpecific(Order order)
{
GameMain.GameSession?.CrewManager?.AddCurrentOrderIcon(this, order, orderOption, priority);
GameMain.GameSession?.CrewManager?.AddCurrentOrderIcon(this, order);
}
public static void AddAllToGUIUpdateList()
@@ -812,7 +812,7 @@ namespace Barotrauma
Controlled != this &&
Submarine != null &&
Controlled.Submarine == Submarine &&
GameMain.Config.LosMode != LosMode.None)
GameSettings.CurrentConfig.Graphics.LosMode != LosMode.None)
{
float yPos = Controlled.AnimController.FloorY - 1.5f;
@@ -854,7 +854,7 @@ namespace Barotrauma
if (speechBubbleTimer > 0.0f)
{
GUI.SpeechBubbleIcon.Draw(spriteBatch, pos - Vector2.UnitY * 5,
GUIStyle.SpeechBubbleIcon.Value.Sprite.Draw(spriteBatch, pos - Vector2.UnitY * 5,
speechBubbleColor * Math.Min(speechBubbleTimer, 1.0f), 0.0f,
Math.Min(speechBubbleTimer, 1.0f));
}
@@ -880,7 +880,7 @@ namespace Barotrauma
GUI.DrawLine(spriteBatch,
cursorPos,
new Vector2(item.DrawPosition.X, -item.DrawPosition.Y),
ToolBox.GradientLerp(dist, GUI.Style.Red, GUI.Style.Orange, GUI.Style.Green), width: 2);
ToolBox.GradientLerp(dist, GUIStyle.Red, GUIStyle.Orange, GUIStyle.Green), width: 2);
}
}
return;
@@ -899,10 +899,10 @@ namespace Barotrauma
{
if (info != null)
{
string name = Info.DisplayName;
LocalizedString name = Info.DisplayName;
if (controlled == null && name != Info.Name) { name += " " + TextManager.Get("Disguised"); }
Vector2 nameSize = GUI.Font.MeasureString(name);
Vector2 nameSize = GUIStyle.Font.MeasureString(name);
Vector2 namePos = new Vector2(pos.X, pos.Y - 10.0f - (5.0f / cam.Zoom)) - nameSize * 0.5f / cam.Zoom;
Color nameColor = GetNameColor();
@@ -916,7 +916,7 @@ namespace Barotrauma
if (CampaignInteractionType != CampaignMode.InteractionType.None && AllowCustomInteract)
{
var iconStyle = GUI.Style.GetComponentStyle("CampaignInteractionBubble." + CampaignInteractionType);
var iconStyle = GUIStyle.GetComponentStyle("CampaignInteractionBubble." + CampaignInteractionType);
if (iconStyle != null)
{
Vector2 headPos = AnimController.GetLimb(LimbType.Head)?.body?.DrawPosition ?? DrawPosition + Vector2.UnitY * 100.0f;
@@ -929,11 +929,11 @@ namespace Barotrauma
}
}
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 * hudInfoAlpha, 0.0f, Vector2.Zero, 1.0f / cam.Zoom, SpriteEffects.None, 0.0f);
GUIStyle.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);
GUIStyle.Font.DrawString(spriteBatch, name, namePos, nameColor * hudInfoAlpha, 0.0f, Vector2.Zero, 1.0f / cam.Zoom, SpriteEffects.None, 0.0f);
if (GameMain.DebugDraw)
{
GUI.Font.DrawString(spriteBatch, ID.ToString(), namePos - new Vector2(0.0f, 20.0f), Color.White);
GUIStyle.Font.DrawString(spriteBatch, ID.ToString(), namePos - new Vector2(0.0f, 20.0f), Color.White);
}
}
@@ -941,7 +941,7 @@ namespace Barotrauma
if (petBehavior != null && !IsDead && !IsUnconscious)
{
var petStatus = petBehavior.GetCurrentStatusIndicatorType();
var iconStyle = GUI.Style.GetComponentStyle("PetIcon." + petStatus);
var iconStyle = GUIStyle.GetComponentStyle("PetIcon." + petStatus);
if (iconStyle != null)
{
Vector2 headPos = AnimController.GetLimb(LimbType.Head)?.body?.DrawPosition ?? DrawPosition + Vector2.UnitY * 100.0f;
@@ -963,7 +963,7 @@ namespace Barotrauma
Vector2 healthBarPos = new Vector2(pos.X - 50, -pos.Y);
GUI.DrawProgressBar(spriteBatch, healthBarPos, new Vector2(100.0f, 15.0f),
CharacterHealth.DisplayedVitality / MaxVitality,
Color.Lerp(GUI.Style.Red, GUI.Style.Green, CharacterHealth.DisplayedVitality / MaxVitality) * 0.8f * hudInfoAlpha,
Color.Lerp(GUIStyle.Red, GUIStyle.Green, CharacterHealth.DisplayedVitality / MaxVitality) * 0.8f * hudInfoAlpha,
new Color(0.5f, 0.57f, 0.6f, 1.0f) * hudInfoAlpha);
}
}
@@ -987,7 +987,7 @@ namespace Barotrauma
}
}
Color nameColor = GUI.Style.TextColor;
Color nameColor = GUIStyle.TextColorNormal;
if (Controlled != null && team != Controlled.TeamID)
{
if (TeamID == CharacterTeamType.FriendlyNPC)
@@ -996,13 +996,13 @@ namespace Barotrauma
}
else
{
nameColor = GUI.Style.Red;
nameColor = GUIStyle.Red;
}
}
return nameColor;
}
public void AddMessage(string rawText, Color color, bool playSound, string identifier = null, int? value = null, float lifetime = 3.0f)
public void AddMessage(string rawText, Color color, bool playSound, Identifier identifier = default, int? value = null, float lifetime = 3.0f)
{
GUIMessage existingMessage = null;
@@ -1089,12 +1089,12 @@ namespace Barotrauma
matchingSounds.Clear();
foreach (var s in sounds)
{
if (s.Type == soundType && (s.Gender == Gender.None || (info != null && info.Gender == s.Gender)))
if (s.Type == soundType && (s.TagSet.None() || (info != null && s.TagSet.IsSubsetOf(info.Head.Preset.TagSet))))
{
matchingSounds.Add(s);
}
}
var selectedSound = matchingSounds.GetRandom();
var selectedSound = matchingSounds.GetRandomUnsynced();
if (selectedSound?.Sound == null) { return; }
soundChannel = SoundPlayer.PlaySound(selectedSound.Sound, AnimController.WorldPosition, selectedSound.Volume, selectedSound.Range, hullGuess: CurrentHull, ignoreMuffling: selectedSound.IgnoreMuffling);
soundTimer = Params.SoundInterval;
@@ -1117,7 +1117,7 @@ namespace Barotrauma
/// <summary>
/// Note that when a predicate is provided, the random option uses Linq.Where() extension method, which creates a new collection.
/// </summary>
public CharacterSound GetSound(Func<CharacterSound, bool> predicate = null, bool random = false) => random ? sounds.GetRandom(predicate) : sounds.FirstOrDefault(predicate);
public CharacterSound GetSound(Func<CharacterSound, bool> predicate = null, bool random = false) => random ? sounds.GetRandomUnsynced(predicate) : sounds.FirstOrDefault(predicate);
partial void ImplodeFX()
{
@@ -1156,14 +1156,14 @@ namespace Barotrauma
if (newAmount > prevAmount)
{
int increase = newAmount - prevAmount;
AddMessage("+" + TextManager.GetWithVariable("currencyformat", "[credits]", "[value]"),
GUI.Style.Yellow, playSound: this == Controlled, "money", increase);
AddMessage("+" + TextManager.GetWithVariable("currencyformat", "[credits]", "[value]").Value,
GUIStyle.Yellow, playSound: this == Controlled, "money".ToIdentifier(), increase);
}
}
partial void OnTalentGiven(TalentPrefab talentPrefab)
{
AddMessage(TextManager.Get("talentname." + talentPrefab.Identifier), GUI.Style.Yellow, playSound: this == Controlled);
AddMessage(TextManager.Get("talentname." + talentPrefab.Identifier).Value, GUIStyle.Yellow, playSound: this == Controlled);
}
}
}
@@ -35,23 +35,23 @@ namespace Barotrauma
MinSize = new Point(100, 50),
RelativeOffset = new Vector2(0.0f, 0.01f)
}, isHorizontal: false, childAnchor: Anchor.TopCenter);
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.4f), TopContainer.RectTransform), character.DisplayName, textAlignment: Alignment.Center, textColor: GUI.Style.Red);
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.4f), TopContainer.RectTransform), character.DisplayName, textAlignment: Alignment.Center, textColor: GUIStyle.Red);
TopHealthBar = new GUIProgressBar(new RectTransform(new Vector2(1.0f, 0.6f), TopContainer.RectTransform)
{
MinSize = new Point(100, HUDLayoutSettings.HealthBarArea.Size.Y)
}, barSize: 0.0f, style: "CharacterHealthBarCentered")
{
Color = GUI.Style.Red
Color = GUIStyle.Red
};
SideContainer = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.05f), bossHealthContainer.RectTransform)
{
MinSize = new Point(80, 60)
}, isHorizontal: false, childAnchor: Anchor.TopRight);
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.3f), SideContainer.RectTransform), character.DisplayName, textAlignment: Alignment.CenterRight, textColor: GUI.Style.Red);
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.3f), SideContainer.RectTransform), character.DisplayName, textAlignment: Alignment.CenterRight, textColor: GUIStyle.Red);
SideHealthBar = new GUIProgressBar(new RectTransform(new Vector2(1.0f, 0.7f), SideContainer.RectTransform), barSize: 0.0f, style: "CharacterHealthBar")
{
Color = GUI.Style.Red
Color = GUIStyle.Red
};
TopContainer.Visible = SideContainer.Visible = false;
@@ -72,7 +72,7 @@ namespace Barotrauma
private static readonly List<BossHealthBar> bossHealthBars = new List<BossHealthBar>();
private static readonly Dictionary<string, string> cachedHudTexts = new Dictionary<string, string>();
private static readonly Dictionary<Identifier, LocalizedString> cachedHudTexts = new Dictionary<Identifier, LocalizedString>();
private static GUILayoutGroup bossHealthContainer;
@@ -119,14 +119,12 @@ namespace Barotrauma
!ConversationAction.FadeScreenToBlack;
}
public static string GetCachedHudText(string textTag, string keyBind)
public static LocalizedString GetCachedHudText(string textTag, InputType keyBind)
{
if (cachedHudTexts.TryGetValue(textTag + keyBind, out string text))
{
return text;
}
text = TextManager.GetWithVariable(textTag, "[key]", keyBind);
cachedHudTexts.Add(textTag + keyBind, text);
Identifier key = (textTag + keyBind).ToIdentifier();
if (cachedHudTexts.TryGetValue(key, out LocalizedString text)) { return text; }
text = TextManager.GetWithVariable(textTag, "[key]", GameSettings.CurrentConfig.KeyMap.KeyBindText(keyBind)).Value;
cachedHudTexts.Add(key, text);
return text;
}
@@ -256,24 +254,24 @@ namespace Barotrauma
if (GameMain.GameSession?.CrewManager != null)
{
orderIndicatorCount.Clear();
foreach (Pair<Order, float?> activeOrder in GameMain.GameSession.CrewManager.ActiveOrders)
foreach (CrewManager.ActiveOrder activeOrder in GameMain.GameSession.CrewManager.ActiveOrders)
{
if (!DrawIcon(activeOrder.First)) { continue; }
if (!DrawIcon(activeOrder.Order)) { continue; }
if (activeOrder.Second.HasValue)
if (activeOrder.FadeOutTime.HasValue)
{
DrawOrderIndicator(spriteBatch, cam, character, activeOrder.First, iconAlpha: MathHelper.Clamp(activeOrder.Second.Value / 10.0f, 0.2f, 1.0f));
DrawOrderIndicator(spriteBatch, cam, character, activeOrder.Order, iconAlpha: MathHelper.Clamp(activeOrder.FadeOutTime.Value / 10.0f, 0.2f, 1.0f));
}
else
{
float iconAlpha = GetDistanceBasedIconAlpha(activeOrder.First.TargetSpatialEntity, maxDistance: 450.0f);
float iconAlpha = GetDistanceBasedIconAlpha(activeOrder.Order.TargetSpatialEntity, maxDistance: 450.0f);
if (iconAlpha <= 0.0f) { continue; }
DrawOrderIndicator(spriteBatch, cam, character, activeOrder.First,
DrawOrderIndicator(spriteBatch, cam, character, activeOrder.Order,
iconAlpha: iconAlpha, createOffset: false, scaleMultiplier: 0.5f, overrideAlpha: true);
}
}
if (character.GetCurrentOrderWithTopPriority()?.Order is Order currentOrder && DrawIcon(currentOrder))
if (character.GetCurrentOrderWithTopPriority() is Order currentOrder && DrawIcon(currentOrder))
{
DrawOrderIndicator(spriteBatch, cam, character, currentOrder, 1.0f);
}
@@ -310,8 +308,8 @@ namespace Barotrauma
if (!brokenItem.IsInteractable(character)) { continue; }
float alpha = GetDistanceBasedIconAlpha(brokenItem);
if (alpha <= 0.0f) continue;
GUI.DrawIndicator(spriteBatch, brokenItem.DrawPosition, cam, 100.0f, GUI.BrokenIcon,
Color.Lerp(GUI.Style.Red, GUI.Style.Orange * 0.5f, brokenItem.Condition / brokenItem.MaxCondition) * alpha);
GUI.DrawIndicator(spriteBatch, brokenItem.DrawPosition, cam, 100.0f, GUIStyle.BrokenIcon.Value.Sprite,
Color.Lerp(GUIStyle.Red, GUIStyle.Orange * 0.5f, brokenItem.Condition / brokenItem.MaxCondition) * alpha);
}
float GetDistanceBasedIconAlpha(ISpatialEntity target, float maxDistance = 1000.0f)
@@ -344,12 +342,12 @@ namespace Barotrauma
circleSize = MathHelper.Clamp(circleSize, 45.0f, 100.0f) * Math.Min((focusedItemOverlayTimer - 1.0f) * 5.0f, 1.0f);
if (circleSize > 0.0f)
{
Vector2 scale = new Vector2(circleSize / GUI.Style.FocusIndicator.FrameSize.X);
GUI.Style.FocusIndicator.Draw(spriteBatch,
(int)((focusedItemOverlayTimer - 1.0f) * GUI.Style.FocusIndicator.FrameCount * 3.0f),
Vector2 scale = new Vector2(circleSize / GUIStyle.FocusIndicator.FrameSize.X);
GUIStyle.FocusIndicator.Draw(spriteBatch,
(int)((focusedItemOverlayTimer - 1.0f) * GUIStyle.FocusIndicator.FrameCount * 3.0f),
circlePos,
Color.LightBlue * 0.3f,
origin: GUI.Style.FocusIndicator.FrameSize.ToVector2() / 2,
origin: GUIStyle.FocusIndicator.FrameSize.ToVector2() / 2,
rotate: (float)Timing.TotalTime,
scale: scale);
}
@@ -367,8 +365,8 @@ namespace Barotrauma
int dir = Math.Sign(focusedItem.WorldPosition.X - character.WorldPosition.X);
Vector2 textSize = GUI.Font.MeasureString(hudTexts.First().Text);
Vector2 largeTextSize = GUI.SubHeadingFont.MeasureString(hudTexts.First().Text);
Vector2 textSize = GUIStyle.Font.MeasureString(hudTexts.First().Text);
Vector2 largeTextSize = GUIStyle.SubHeadingFont.MeasureString(hudTexts.First().Text);
Vector2 startPos = cam.WorldToScreen(focusedItem.DrawPosition);
startPos.Y -= (hudTexts.Count + 1) * textSize.Y;
@@ -383,14 +381,14 @@ namespace Barotrauma
float alpha = MathHelper.Clamp((focusedItemOverlayTimer - ItemOverlayDelay) * 2.0f, 0.0f, 1.0f);
GUI.DrawString(spriteBatch, textPos, hudTexts.First().Text, hudTexts.First().Color * alpha, Color.Black * alpha * 0.7f, 2, font: GUI.SubHeadingFont);
GUI.DrawString(spriteBatch, textPos, hudTexts.First().Text, hudTexts.First().Color * alpha, Color.Black * alpha * 0.7f, 2, font: GUIStyle.SubHeadingFont, ForceUpperCase.No);
startPos.X += dir * 10.0f * GUI.Scale;
textPos.X += dir * 10.0f * GUI.Scale;
textPos.Y += largeTextSize.Y;
foreach (ColoredText coloredText in hudTexts.Skip(1))
{
if (dir == -1) textPos.X = (int)(startPos.X - GUI.SmallFont.MeasureString(coloredText.Text).X);
GUI.DrawString(spriteBatch, textPos, coloredText.Text, coloredText.Color * alpha, Color.Black * alpha * 0.7f, 2, GUI.SmallFont);
if (dir == -1) textPos.X = (int)(startPos.X - GUIStyle.SmallFont.MeasureString(coloredText.Text).X);
GUI.DrawString(spriteBatch, textPos, coloredText.Text, coloredText.Color * alpha, Color.Black * alpha * 0.7f, 2, GUIStyle.SmallFont);
textPos.Y += textSize.Y;
}
}
@@ -405,7 +403,7 @@ namespace Barotrauma
{
if (npc.CampaignInteractionType == CampaignMode.InteractionType.None || npc.Submarine != character.Submarine || npc.IsDead || npc.IsIncapacitated) { continue; }
var iconStyle = GUI.Style.GetComponentStyle("CampaignInteractionIcon." + npc.CampaignInteractionType);
var iconStyle = GUIStyle.GetComponentStyle("CampaignInteractionIcon." + npc.CampaignInteractionType);
if (iconStyle == null) { continue; }
Range<float> visibleRange = new Range<float>(npc.CurrentHull == Character.Controlled.CurrentHull ? 500.0f : 100.0f, float.PositiveInfinity);
if (npc.CampaignInteractionType == CampaignMode.InteractionType.Examine)
@@ -491,7 +489,7 @@ namespace Barotrauma
mouseOnPortrait = HUDLayoutSettings.BottomRightInfoArea.Contains(PlayerInput.MousePosition) && !character.ShouldLockHud();
if (mouseOnPortrait)
{
GUI.UIGlow.Draw(spriteBatch, HUDLayoutSettings.BottomRightInfoArea, GUI.Style.Green * 0.5f);
GUIStyle.UIGlow.Draw(spriteBatch, HUDLayoutSettings.BottomRightInfoArea, GUIStyle.Green * 0.5f);
}
}
if (ShouldDrawInventory(character))
@@ -555,28 +553,28 @@ namespace Barotrauma
string focusName = character.FocusedCharacter.Info == null ? character.FocusedCharacter.DisplayName : character.FocusedCharacter.Info.DisplayName;
Vector2 textPos = startPos;
Vector2 textSize = GUI.Font.MeasureString(focusName);
Vector2 largeTextSize = GUI.SubHeadingFont.MeasureString(focusName);
Vector2 textSize = GUIStyle.Font.MeasureString(focusName);
Vector2 largeTextSize = GUIStyle.SubHeadingFont.MeasureString(focusName);
textPos -= new Vector2(textSize.X / 2, textSize.Y);
Color nameColor = character.FocusedCharacter.GetNameColor();
GUI.DrawString(spriteBatch, textPos, focusName, nameColor, Color.Black * 0.7f, 2, GUI.SubHeadingFont);
GUI.DrawString(spriteBatch, textPos, focusName, nameColor, Color.Black * 0.7f, 2, GUIStyle.SubHeadingFont, ForceUpperCase.No);
textPos.X += 10.0f * GUI.Scale;
textPos.Y += GUI.SubHeadingFont.MeasureString(focusName).Y;
textPos.Y += GUIStyle.SubHeadingFont.MeasureString(focusName).Y;
if (!character.FocusedCharacter.IsIncapacitated && character.FocusedCharacter.IsPet)
{
GUI.DrawString(spriteBatch, textPos, GetCachedHudText("PlayHint", GameMain.Config.KeyBindText(InputType.Use)),
GUI.Style.Green, Color.Black, 2, GUI.SmallFont);
GUI.DrawString(spriteBatch, textPos, GetCachedHudText("PlayHint", InputType.Use),
GUIStyle.Green, Color.Black, 2, GUIStyle.SmallFont);
textPos.Y += largeTextSize.Y;
}
if (character.FocusedCharacter.CanBeDragged)
{
string text = character.CanEat ? "EatHint" : "GrabHint";
GUI.DrawString(spriteBatch, textPos, GetCachedHudText(text, GameMain.Config.KeyBindText(InputType.Grab)),
GUI.Style.Green, Color.Black, 2, GUI.SmallFont);
GUI.DrawString(spriteBatch, textPos, GetCachedHudText(text, InputType.Grab),
GUIStyle.Green, Color.Black, 2, GUIStyle.SmallFont);
textPos.Y += largeTextSize.Y;
}
@@ -585,13 +583,13 @@ namespace Barotrauma
character.FocusedCharacter.CharacterHealth.UseHealthWindow &&
character.CanInteractWith(character.FocusedCharacter, 160f, false))
{
GUI.DrawString(spriteBatch, textPos, GetCachedHudText("HealHint", GameMain.Config.KeyBindText(InputType.Health)),
GUI.Style.Green, Color.Black, 2, GUI.SmallFont);
GUI.DrawString(spriteBatch, textPos, GetCachedHudText("HealHint", InputType.Health),
GUIStyle.Green, Color.Black, 2, GUIStyle.SmallFont);
textPos.Y += textSize.Y;
}
if (!string.IsNullOrEmpty(character.FocusedCharacter.customInteractHUDText) && character.FocusedCharacter.AllowCustomInteract)
if (!character.FocusedCharacter.CustomInteractHUDText.IsNullOrEmpty() && character.FocusedCharacter.AllowCustomInteract)
{
GUI.DrawString(spriteBatch, textPos, character.FocusedCharacter.customInteractHUDText, GUI.Style.Green, Color.Black, 2, GUI.SmallFont);
GUI.DrawString(spriteBatch, textPos, character.FocusedCharacter.CustomInteractHUDText, GUIStyle.Green, Color.Black, 2, GUIStyle.SmallFont);
textPos.Y += textSize.Y;
}
}
@@ -8,6 +8,7 @@ using Microsoft.Xna.Framework.Graphics;
using System.Xml.Linq;
using Barotrauma.IO;
using Barotrauma.Items.Components;
using System.Collections.Immutable;
namespace Barotrauma
{
@@ -34,17 +35,17 @@ namespace Barotrauma
public static void Init()
{
infoAreaPortraitBG = GUI.Style.GetComponentStyle("InfoAreaPortraitBG")?.GetDefaultSprite();
infoAreaPortraitBG = GUIStyle.GetComponentStyle("InfoAreaPortraitBG")?.GetDefaultSprite();
new Sprite("Content/UI/InventoryUIAtlas.png", new Rectangle(833, 298, 142, 98), null, 0);
}
partial void LoadHeadSpriteProjectSpecific(XElement limbElement)
partial void LoadHeadSpriteProjectSpecific(ContentXElement limbElement)
{
XElement maskElement = limbElement.Element("tintmask");
ContentXElement maskElement = limbElement.GetChildElement("tintmask");
if (maskElement != null)
{
string tintMaskPath = maskElement.GetAttributeString("texture", "");
if (!string.IsNullOrWhiteSpace(tintMaskPath))
ContentPath tintMaskPath = maskElement.GetAttributeContentPath("texture");
if (!tintMaskPath.IsNullOrEmpty())
{
tintMask = new Sprite(maskElement, file: Limb.GetSpritePath(tintMaskPath, this));
tintHighlightThreshold = maskElement.GetAttributeFloat("highlightthreshold", 0.6f);
@@ -66,7 +67,7 @@ namespace Barotrauma
new GUICustomComponent(new RectTransform(new Vector2(0.425f, 1.0f), headerArea.RectTransform),
onDraw: (sb, component) => DrawInfoFrameCharacterIcon(sb, component.Rect));
ScalableFont font = paddedFrame.Rect.Width < 280 ? GUI.SmallFont : GUI.Font;
GUIFont font = paddedFrame.Rect.Width < 280 ? GUIStyle.SmallFont : GUIStyle.Font;
var headerTextArea = new GUILayoutGroup(new RectTransform(new Vector2(0.575f, 1.0f), headerArea.RectTransform))
{
@@ -77,9 +78,9 @@ namespace Barotrauma
Color? nameColor = null;
if (Job != null) { nameColor = Job.Prefab.UIColor; }
GUITextBlock characterNameBlock = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), headerTextArea.RectTransform), ToolBox.LimitString(Name, GUI.Font, headerTextArea.Rect.Width), textColor: nameColor, font: GUI.Font)
GUITextBlock characterNameBlock = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), headerTextArea.RectTransform), ToolBox.LimitString(Name, GUIStyle.Font, headerTextArea.Rect.Width), textColor: nameColor, font: GUIStyle.Font)
{
ForceUpperCase = true,
ForceUpperCase = ForceUpperCase.Yes,
Padding = Vector4.Zero
};
@@ -98,9 +99,11 @@ namespace Barotrauma
};
}
if (personalityTrait != null)
if (PersonalityTrait != null)
{
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), headerTextArea.RectTransform), TextManager.AddPunctuation(':', TextManager.Get("PersonalityTrait"), TextManager.Get("personalitytrait." + personalityTrait.Name.Replace(" ", ""))), font: font)
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), headerTextArea.RectTransform),
TextManager.AddPunctuation(':', TextManager.Get("PersonalityTrait"), TextManager.Get("personalitytrait." + PersonalityTrait.Name.Replace(" ".ToIdentifier(), "".ToIdentifier()))),
font: font)
{
Padding = Vector4.Zero
};
@@ -148,10 +151,10 @@ namespace Barotrauma
Stretch = true
};
string deadDescription = TextManager.AddPunctuation(':', TextManager.Get("deceased") + "\n" + Character.CauseOfDeath.Affliction?.CauseOfDeathDescription ??
LocalizedString deadDescription = TextManager.AddPunctuation(':', TextManager.Get("deceased") + "\n" + Character.CauseOfDeath.Affliction?.CauseOfDeathDescription ??
TextManager.AddPunctuation(':', TextManager.Get("CauseOfDeath"), TextManager.Get("CauseOfDeath." + Character.CauseOfDeath.Type.ToString())));
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), deadArea.RectTransform), deadDescription, textColor: GUI.Style.Red, font: font, textAlignment: Alignment.TopLeft) { Padding = Vector4.Zero };
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), deadArea.RectTransform), deadDescription, textColor: GUIStyle.Red, font: font, textAlignment: Alignment.TopLeft) { Padding = Vector4.Zero };
}
if (returnParent)
@@ -182,13 +185,13 @@ namespace Barotrauma
Color? textColor = null;
if (Job != null) { textColor = Job.Prefab.UIColor; }
GUITextBlock textBlock = new GUITextBlock(new RectTransform(Vector2.One, frame.RectTransform, Anchor.CenterLeft) { AbsoluteOffset = new Point(40, 0) }, text, textColor: textColor, font: GUI.SmallFont);
GUITextBlock textBlock = new GUITextBlock(new RectTransform(Vector2.One, frame.RectTransform, Anchor.CenterLeft) { AbsoluteOffset = new Point(40, 0) }, text, textColor: textColor, font: GUIStyle.SmallFont);
new GUICustomComponent(new RectTransform(new Point(frame.Rect.Height, frame.Rect.Height), frame.RectTransform, Anchor.CenterLeft) { IsFixedSize = false },
onDraw: (sb, component) => DrawIcon(sb, component.Rect.Center.ToVector2(), targetAreaSize: component.Rect.Size.ToVector2()));
return frame;
}
partial void OnSkillChanged(string skillIdentifier, float prevLevel, float newLevel)
partial void OnSkillChanged(Identifier skillIdentifier, float prevLevel, float newLevel)
{
if (TeamID == CharacterTeamType.FriendlyNPC) { return; }
if (Character.Controlled != null && Character.Controlled.TeamID != TeamID) { return; }
@@ -199,9 +202,10 @@ namespace Barotrauma
if ((int)newLevel > (int)prevLevel)
{
int increase = Math.Max((int)newLevel - (int)prevLevel, 1);
Character?.AddMessage(
"+[value] "+ TextManager.Get("SkillName." + skillIdentifier),
specialIncrease ? GUI.Style.Orange : GUI.Style.Green,
"+[value] "+ TextManager.Get("SkillName." + skillIdentifier).Value,
specialIncrease ? GUIStyle.Orange : GUIStyle.Green,
playSound: Character == Character.Controlled, skillIdentifier, increase);
}
}
@@ -216,8 +220,8 @@ namespace Barotrauma
{
int increase = newAmount - prevAmount;
Character?.AddMessage(
"+[value] " + TextManager.Get("experienceshort"),
GUI.Style.Blue, playSound: Character == Character.Controlled, "exp", increase);
"+[value] " + TextManager.Get("experienceshort").Value,
GUIStyle.Blue, playSound: Character == Character.Controlled, "exp".ToIdentifier(), increase);
}
}
@@ -227,9 +231,13 @@ namespace Barotrauma
if (idCard.StoredOwnerAppearance.JobPrefab == null || idCard.StoredOwnerAppearance.Portrait == null)
{
string[] readTags = idCard.Item.Tags.Split(',');
var readTags = idCard.Item.Tags.Split(',')
.Where(s => s.Contains(':'))
.Select(s => s.Split(':'))
.Select(s => (s[0].ToIdentifier(),s[1]))
.ToImmutableDictionary();
if (readTags.Length == 0) { return; }
if (readTags.None()) { return; }
if (idCard.StoredOwnerAppearance.JobPrefab == null)
{
@@ -238,7 +246,7 @@ namespace Barotrauma
if (idCard.StoredOwnerAppearance.Portrait == null)
{
idCard.StoredOwnerAppearance.ExtractAppearance(this, readTags);
idCard.StoredOwnerAppearance.ExtractAppearance(this, idCard);
}
}
@@ -267,17 +275,17 @@ namespace Barotrauma
{
LoadHeadAttachments();
}
FaceAttachment?.Elements("sprite").ForEach(s => attachmentSprites.Add(new WearableSprite(s, WearableType.FaceAttachment)));
BeardElement?.Elements("sprite").ForEach(s => attachmentSprites.Add(new WearableSprite(s, WearableType.Beard)));
MoustacheElement?.Elements("sprite").ForEach(s => attachmentSprites.Add(new WearableSprite(s, WearableType.Moustache)));
HairElement?.Elements("sprite").ForEach(s => attachmentSprites.Add(new WearableSprite(s, WearableType.Hair)));
Head.FaceAttachment?.GetChildElements("sprite").ForEach(s => attachmentSprites.Add(new WearableSprite(s, WearableType.FaceAttachment)));
Head.BeardElement?.GetChildElements("sprite").ForEach(s => attachmentSprites.Add(new WearableSprite(s, WearableType.Beard)));
Head.MoustacheElement?.GetChildElements("sprite").ForEach(s => attachmentSprites.Add(new WearableSprite(s, WearableType.Moustache)));
Head.HairElement?.GetChildElements("sprite").ForEach(s => attachmentSprites.Add(new WearableSprite(s, WearableType.Hair)));
if (omitJob)
{
JobPrefab.NoJobElement?.Element("PortraitClothing")?.Elements("sprite").ForEach(s => attachmentSprites.Add(new WearableSprite(s, WearableType.JobIndicator)));
JobPrefab.NoJobElement?.GetChildElement("PortraitClothing")?.GetChildElements("sprite").ForEach(s => attachmentSprites.Add(new WearableSprite(s, WearableType.JobIndicator)));
}
else
{
Job?.Prefab.ClothingElement?.Elements("sprite").ForEach(s => attachmentSprites.Add(new WearableSprite(s, WearableType.JobIndicator)));
Job?.Prefab.ClothingElement?.GetChildElements("sprite").ForEach(s => attachmentSprites.Add(new WearableSprite(s, WearableType.JobIndicator)));
}
}
@@ -288,7 +296,7 @@ namespace Barotrauma
{
if (sprite == null) { return; }
if (Head.SheetIndex == null) { return; }
Point location = CalculateOffset(sprite, Head.SheetIndex.Value.ToPoint());
Point location = CalculateOffset(sprite, Head.SheetIndex.ToPoint());
sprite.SourceRect = new Rectangle(location, sprite.SourceRect.Size);
}
@@ -414,19 +422,16 @@ namespace Barotrauma
{
var currEffect = spriteBatch.GetCurrentEffect();
float scale = Math.Min(targetAreaSize.X / headSprite.size.X, targetAreaSize.Y / headSprite.size.Y);
if (Head.SheetIndex.HasValue)
{
headSprite.SourceRect = new Rectangle(CalculateOffset(headSprite, Head.SheetIndex.Value.ToPoint()), headSprite.SourceRect.Size);
}
headSprite.SourceRect = new Rectangle(CalculateOffset(headSprite, Head.SheetIndex.ToPoint()), headSprite.SourceRect.Size);
SetHeadEffect(spriteBatch);
headSprite.Draw(spriteBatch, screenPos, scale: scale, color: SkinColor);
headSprite.Draw(spriteBatch, screenPos, scale: scale, color: Head.SkinColor);
if (AttachmentSprites != null)
{
float depthStep = 0.000001f;
foreach (var attachment in AttachmentSprites)
{
SetAttachmentEffect(spriteBatch, attachment);
DrawAttachmentSprite(spriteBatch, attachment, headSprite, Head.SheetIndex, screenPos, scale, depthStep, GetAttachmentColor(attachment, HairColor, FacialHairColor));
DrawAttachmentSprite(spriteBatch, attachment, headSprite, Head.SheetIndex, screenPos, scale, depthStep, GetAttachmentColor(attachment, Head.HairColor, Head.FacialHairColor));
depthStep += depthStep;
}
}
@@ -479,14 +484,17 @@ namespace Barotrauma
attachment.Sprite.Draw(spriteBatch, drawPos, color ?? Color.White, origin, rotate: 0, scale: scale, depth: depth, spriteEffect: spriteEffects);
}
public static CharacterInfo ClientRead(string speciesName, IReadMessage inc)
public static CharacterInfo ClientRead(Identifier speciesName, IReadMessage inc)
{
ushort infoID = inc.ReadUInt16();
string newName = inc.ReadString();
string originalName = inc.ReadString();
int gender = inc.ReadByte();
int race = inc.ReadByte();
int headSpriteID = inc.ReadByte();
int tagCount = inc.ReadByte();
HashSet<Identifier> tagSet = new HashSet<Identifier>();
for (int i = 0; i < tagCount; i++)
{
tagSet.Add(inc.ReadIdentifier());
}
int hairIndex = inc.ReadByte();
int beardIndex = inc.ReadByte();
int moustacheIndex = inc.ReadByte();
@@ -500,14 +508,14 @@ namespace Barotrauma
int variant = inc.ReadByte();
JobPrefab jobPrefab = null;
Dictionary<string, float> skillLevels = new Dictionary<string, float>();
Dictionary<Identifier, float> skillLevels = new Dictionary<Identifier, float>();
if (!string.IsNullOrEmpty(jobIdentifier))
{
jobPrefab = JobPrefab.Get(jobIdentifier);
byte skillCount = inc.ReadByte();
for (int i = 0; i < skillCount; i++)
{
string skillIdentifier = inc.ReadString();
Identifier skillIdentifier = inc.ReadIdentifier();
float skillLevel = inc.ReadSingle();
skillLevels.Add(skillIdentifier, skillLevel);
}
@@ -518,14 +526,14 @@ namespace Barotrauma
{
ID = infoID,
};
ch.RecreateHead(headSpriteID,(Race)race, (Gender)gender, hairIndex, beardIndex, moustacheIndex, faceAttachmentIndex);
ch.SkinColor = skinColor;
ch.HairColor = hairColor;
ch.FacialHairColor = facialHairColor;
ch.RecreateHead(tagSet.ToImmutableHashSet(), hairIndex, beardIndex, moustacheIndex, faceAttachmentIndex);
ch.Head.SkinColor = skinColor;
ch.Head.HairColor = hairColor;
ch.Head.FacialHairColor = facialHairColor;
ch.SetPersonalityTrait();
if (ch.Job != null)
{
foreach (KeyValuePair<string, float> skill in skillLevels)
foreach (KeyValuePair<Identifier, float> skill in skillLevels)
{
Skill matchingSkill = ch.Job.Skills.Find(s => s.Identifier == skill.Key);
if (matchingSkill == null)
@@ -538,17 +546,8 @@ namespace Barotrauma
ch.Job.Skills.RemoveAll(s => !skillLevels.ContainsKey(s.Identifier));
}
byte savedStatValueCount = inc.ReadByte();
for (int i = 0; i < savedStatValueCount; i++)
{
int statType = inc.ReadByte();
string statIdentifier = inc.ReadString();
float statValue = inc.ReadSingle();
bool removeOnDeath = inc.ReadBoolean();
ch.ChangeSavedStatValue((StatTypes)statType, statValue, statIdentifier, removeOnDeath);
}
ch.ExperiencePoints = inc.ReadUInt16();
ch.AdditionalTalentPoints = inc.ReadUInt16();
ch.AdditionalTalentPoints = inc.ReadRangedInteger(0, MaxAdditionalTalentPoints);
return ch;
}
@@ -605,12 +604,12 @@ namespace Barotrauma
{ RelativeOffset = new Vector2(-0.01f, 0.0f) });
}
RectTransform createItemRectTransform(string labelTag, float width = 0.6f)
RectTransform createItemRectTransform(Identifier labelTag, float width = 0.6f)
{
var layoutGroup = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.166f), content.RectTransform));
var label = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.5f), layoutGroup.RectTransform),
TextManager.Get(labelTag), font: GUI.SubHeadingFont);
TextManager.Get(labelTag), font: GUIStyle.SubHeadingFont);
var bottomItem = new GUIFrame(new RectTransform(new Vector2(1.0f, 0.5f), layoutGroup.RectTransform),
style: null);
@@ -618,43 +617,40 @@ namespace Barotrauma
return new RectTransform(new Vector2(width, 1.0f), bottomItem.RectTransform, Anchor.Center);
}
RectTransform genderItemRT = createItemRectTransform("Gender", 1.0f);
RectTransform menuCategoryRT = createItemRectTransform(info.Prefab.MenuCategoryVar, 1.0f);
GUILayoutGroup genderContainer =
new GUILayoutGroup(genderItemRT, isHorizontal: true)
GUILayoutGroup menuCategoryContainer =
new GUILayoutGroup(menuCategoryRT, isHorizontal: true)
{
Stretch = true,
RelativeSpacing = 0.05f
};
void createGenderButton(Gender gender)
void createMenuCategoryButton(Identifier tag)
{
new GUIButton(new RectTransform(new Vector2(1.0f, 1.0f), genderContainer.RectTransform),
TextManager.Get(gender.ToString()), style: "ListBoxElement")
new GUIButton(new RectTransform(new Vector2(1.0f, 1.0f), menuCategoryContainer.RectTransform),
TextManager.Get(tag), style: "ListBoxElement")
{
UserData = gender,
UserData = tag,
OnClicked = OpenHeadSelection,
Selected = info.Gender == gender
Selected = info.Head.Preset.TagSet.Contains(tag)
};
}
createGenderButton(Gender.Male);
createGenderButton(Gender.Female);
int countAttachmentsOfType(WearableType wearableType)
=> info.FilterByTypeAndHeadID(
info.FilterElementsByGenderAndRace(info.Wearables, info.Head.gender, info.Head.race),
wearableType, info.HeadSpriteId).Count();
foreach (var tag in info.Prefab.VarTags[info.Prefab.MenuCategoryVar].OrderBy(t => t.Value).Reverse())
{
createMenuCategoryButton(tag);
}
List<GUIScrollBar> attachmentSliders = new List<GUIScrollBar>();
void createAttachmentSlider(int initialValue, WearableType wearableType)
{
int attachmentCount = countAttachmentsOfType(wearableType);
int attachmentCount = info.CountValidAttachmentsOfType(wearableType);
if (attachmentCount > 0)
{
var labelTag = wearableType == WearableType.FaceAttachment
? "FaceAttachment.Accessories"
: $"FaceAttachment.{wearableType}";
? "FaceAttachment.Accessories".ToIdentifier()
: $"FaceAttachment.{wearableType}".ToIdentifier();
var sliderItemRT = createItemRectTransform(labelTag);
var slider =
new GUIScrollBar(sliderItemRT, style: "GUISlider")
@@ -670,12 +666,12 @@ namespace Barotrauma
}
}
createAttachmentSlider(info.HairIndex, WearableType.Hair);
createAttachmentSlider(info.BeardIndex, WearableType.Beard);
createAttachmentSlider(info.MoustacheIndex, WearableType.Moustache);
createAttachmentSlider(info.FaceAttachmentIndex, WearableType.FaceAttachment);
createAttachmentSlider(info.Head.HairIndex, WearableType.Hair);
createAttachmentSlider(info.Head.BeardIndex, WearableType.Beard);
createAttachmentSlider(info.Head.MoustacheIndex, WearableType.Moustache);
createAttachmentSlider(info.Head.FaceAttachmentIndex, WearableType.FaceAttachment);
void createColorSelector(string labelTag, IEnumerable<(Color Color, float Commonness)> options, Func<Color> getter,
void createColorSelector(Identifier labelTag, IEnumerable<(Color Color, float Commonness)> options, Func<Color> getter,
Action<Color> setter)
{
var selectorItemRT = createItemRectTransform(labelTag, 0.4f);
@@ -757,21 +753,21 @@ namespace Barotrauma
};
}
if (countAttachmentsOfType(WearableType.Hair) > 0)
if (info.CountValidAttachmentsOfType(WearableType.Hair) > 0)
{
createColorSelector($"Customization.{nameof(info.HairColor)}", info.HairColors,
() => info.HairColor, (color) => info.HairColor = color);
createColorSelector($"Customization.{nameof(info.Head.HairColor)}".ToIdentifier(), info.HairColors,
() => info.Head.HairColor, (color) => info.Head.HairColor = color);
}
if (countAttachmentsOfType(WearableType.Moustache) > 0 ||
countAttachmentsOfType(WearableType.Beard) > 0)
if (info.CountValidAttachmentsOfType(WearableType.Moustache) > 0 ||
info.CountValidAttachmentsOfType(WearableType.Beard) > 0)
{
createColorSelector($"Customization.{nameof(info.FacialHairColor)}", info.FacialHairColors,
() => info.FacialHairColor, (color) => info.FacialHairColor = color);
createColorSelector($"Customization.{nameof(info.Head.FacialHairColor)}".ToIdentifier(), info.FacialHairColors,
() => info.Head.FacialHairColor, (color) => info.Head.FacialHairColor = color);
}
createColorSelector($"Customization.{nameof(info.SkinColor)}", info.SkinColors, () => info.SkinColor,
(color) => info.SkinColor = color);
createColorSelector($"Customization.{nameof(info.Head.SkinColor)}".ToIdentifier(), info.SkinColors, () => info.Head.SkinColor,
(color) => info.Head.SkinColor = color);
RandomizeButton = new GUIButton(new RectTransform(Vector2.One * 0.12f,
parentComponent.RectTransform,
@@ -780,10 +776,11 @@ namespace Barotrauma
{
OnClicked = (button, o) =>
{
info.Head = new HeadInfo();
info.SetGenderAndRace(Rand.RandSync.Unsynced);
info.SetColors();
var headPreset = info.Prefab.Heads.GetRandom(Rand.RandSync.Unsynced);
info.Head = new HeadInfo(info, headPreset);
info.SetAttachments(Rand.RandSync.Unsynced);
info.SetColors(Rand.RandSync.Unsynced);
RecreateFrameContents();
info.RefreshHead();
OnHeadSwitch?.Invoke(this);
@@ -801,7 +798,7 @@ namespace Barotrauma
private bool OpenHeadSelection(GUIButton button, object userData)
{
Gender selectedGender = (Gender)userData;
Identifier selectedCategory = (Identifier)userData;
var info = CharacterInfo;
@@ -842,36 +839,27 @@ namespace Barotrauma
GUILayoutGroup row = null;
int itemsInRow = 0;
XElement headElement = info.Ragdoll.MainElement.Elements().FirstOrDefault(e =>
ContentXElement headElement = info.Ragdoll.MainElement.Elements().FirstOrDefault(e =>
e.GetAttributeString("type", "").Equals("head", StringComparison.OrdinalIgnoreCase));
XElement headSpriteElement = headElement.Element("sprite");
ContentXElement headSpriteElement = headElement.GetChildElement("sprite");
string spritePathWithTags = headSpriteElement.Attribute("texture").Value;
var characterConfigElement = info.CharacterConfigElement;
var heads = info.Heads;
var heads = info.Prefab.Heads;
if (heads != null)
{
row = null;
itemsInRow = 0;
foreach (var kvp in heads.Where(kv => kv.Key.Gender == selectedGender))
foreach (var head in heads.Where(h => h.TagSet.Contains(selectedCategory)))
{
var headPreset = kvp.Key;
Race race = headPreset.Race;
int headIndex = headPreset.ID;
string spritePath = info.Prefab.ReplaceVars(spritePathWithTags, head);
string spritePath = spritePathWithTags
.Replace("[GENDER]", selectedGender.ToString().ToLowerInvariant())
.Replace("[RACE]", race.ToString().ToLowerInvariant());
if (!File.Exists(spritePath))
{
continue;
}
if (!File.Exists(spritePath)) { continue; }
Sprite headSprite = new Sprite(headSpriteElement, "", spritePath);
headSprite.SourceRect =
new Rectangle(CalculateOffset(headSprite, kvp.Value.ToPoint()),
new Rectangle(CharacterInfo.CalculateOffset(headSprite, head.SheetIndex.ToPoint()),
headSprite.SourceRect.Size);
characterSprites.Add(headSprite);
@@ -881,7 +869,7 @@ namespace Barotrauma
new RectTransform(new Vector2(1.0f, 0.333f), HeadSelectionList.Content.RectTransform),
true)
{
UserData = selectedGender,
UserData = head.MenuCategory,
Visible = true
};
itemsInRow = 0;
@@ -892,9 +880,9 @@ namespace Barotrauma
{
OutlineColor = Color.White * 0.5f,
PressedColor = Color.White * 0.5f,
UserData = new Tuple<Gender, Race, int>(selectedGender, race, headIndex),
UserData = head,
OnClicked = SwitchHead,
Selected = selectedGender == info.Gender && race == info.Race && headIndex == info.HeadSpriteId,
Selected = info.Head.Preset == head,
Visible = true
};
@@ -909,12 +897,18 @@ namespace Barotrauma
private bool SwitchHead(GUIButton button, object obj)
{
var info = CharacterInfo;
Gender gender = ((Tuple<Gender, Race, int>)obj).Item1;
Race race = ((Tuple<Gender, Race, int>)obj).Item2;
int id = ((Tuple<Gender, Race, int>)obj).Item3;
info.Gender = gender;
info.Race = race;
info.Head.HeadSpriteId = id;
var headPreset = obj as HeadPreset;
if (info.Head.Preset != headPreset)
{
info.Head = new HeadInfo(info, headPreset)
{
SkinColor = info.Head.SkinColor,
HairColor = info.Head.HairColor,
FacialHairColor = info.Head.FacialHairColor
};
info.ReloadHeadAttachments();
}
RecreateFrameContents();
OnHeadSwitch?.Invoke(this);
return true;
@@ -927,16 +921,16 @@ namespace Barotrauma
switch (type)
{
case WearableType.Beard:
info.BeardIndex = index;
info.Head.BeardIndex = index;
break;
case WearableType.FaceAttachment:
info.FaceAttachmentIndex = index;
info.Head.FaceAttachmentIndex = index;
break;
case WearableType.Hair:
info.HairIndex = index;
info.Head.HairIndex = index;
break;
case WearableType.Moustache:
info.MoustacheIndex = index;
info.Head.MoustacheIndex = index;
break;
default:
DebugConsole.ThrowError($"Wearable type not implemented: {type}");
@@ -134,7 +134,7 @@ namespace Barotrauma
msg.Write((ushort)characterTalents.Count);
foreach (var unlockedTalent in characterTalents)
{
msg.Write(unlockedTalent.Prefab.UIntIdentifier);
msg.Write(unlockedTalent.Prefab.UintIdentifier);
}
break;
}
@@ -307,7 +307,7 @@ namespace Barotrauma
{
string errorMsg = "Received an inventory update message for an entity with no inventory ([name], removed: " + Removed + ")";
DebugConsole.ThrowError(errorMsg.Replace("[name]", Name));
GameAnalyticsManager.AddErrorEventOnce("CharacterNetworking.ClientRead:NoInventory" + ID, GameAnalyticsManager.ErrorSeverity.Error, errorMsg.Replace("[name]", SpeciesName));
GameAnalyticsManager.AddErrorEventOnce("CharacterNetworking.ClientRead:NoInventory" + ID, GameAnalyticsManager.ErrorSeverity.Error, errorMsg.Replace("[name]", SpeciesName.Value));
//read anyway to prevent messing up reading the rest of the message
_ = msg.ReadUInt16();
@@ -357,7 +357,7 @@ namespace Barotrauma
int skillCount = msg.ReadByte();
for (int i = 0; i < skillCount; i++)
{
string skillIdentifier = msg.ReadString();
Identifier skillIdentifier = msg.ReadIdentifier();
float skillLevel = msg.ReadSingle();
info?.SetSkillLevel(skillIdentifier, skillLevel);
}
@@ -419,9 +419,9 @@ namespace Barotrauma
if (!validData) { break; }
if (msgType == 1)
{
int orderIndex = msg.ReadRangedInteger(0, Order.PrefabList.Count);
var orderPrefab = Order.PrefabList[orderIndex];
string option = null;
UInt32 orderPrefabUintIdentifier = msg.ReadUInt32();
var orderPrefab = OrderPrefab.Prefabs.Find(p => p.UintIdentifier == orderPrefabUintIdentifier);
Identifier option = Identifier.Empty;
if (orderPrefab.HasOptions)
{
int optionIndex = msg.ReadRangedInteger(-1, orderPrefab.AllOptions.Length);
@@ -434,8 +434,8 @@ namespace Barotrauma
}
else if (msgType == 2)
{
string identifier = msg.ReadString();
string option = msg.ReadString();
Identifier identifier = msg.ReadIdentifier();
Identifier option = msg.ReadIdentifier();
ushort objectiveTargetEntityId = msg.ReadUInt16();
var objectiveTargetEntity = FindEntityByID(objectiveTargetEntityId);
GameMain.GameSession?.CrewManager?.CreateObjectiveIcon(this, identifier, option, objectiveTargetEntity);
@@ -486,8 +486,8 @@ namespace Barotrauma
break;
case 13: //NetEntityEvent.Type.UpdatePermanentStats:
byte savedStatValueCount = msg.ReadByte();
StatTypes statType = (StatTypes)msg.ReadByte();
info?.ClearSavedStatValues(statType);
StatTypes statType = (StatTypes)msg.ReadByte();
info?.ClearSavedStatValues(statType);
for (int i = 0; i < savedStatValueCount; i++)
{
string statIdentifier = msg.ReadString();
@@ -544,7 +544,7 @@ namespace Barotrauma
int ownerId = hasOwner ? inc.ReadByte() : -1;
byte teamID = inc.ReadByte();
bool hasAi = inc.ReadBoolean();
string infoSpeciesName = inc.ReadString();
Identifier infoSpeciesName = inc.ReadIdentifier();
CharacterInfo info = CharacterInfo.ClientRead(infoSpeciesName, inc);
try
@@ -567,7 +567,7 @@ namespace Barotrauma
int orderCount = inc.ReadByte();
for (int i = 0; i < orderCount; i++)
{
int orderPrefabIndex = inc.ReadByte();
UInt32 orderPrefabUintIdentifier = inc.ReadUInt32();
Entity targetEntity = FindEntityByID(inc.ReadUInt16());
Character orderGiver = inc.ReadBoolean() ? FindEntityByID(inc.ReadUInt16()) as Character : null;
int orderOptionIndex = inc.ReadByte();
@@ -581,18 +581,23 @@ namespace Barotrauma
targetPosition = new OrderTarget(new Vector2(x, y), hull, creatingFromExistingData: true);
}
if (orderPrefabIndex >= 0 && orderPrefabIndex < Order.PrefabList.Count)
OrderPrefab orderPrefab =
OrderPrefab.Prefabs.Find(p => p.UintIdentifier == orderPrefabUintIdentifier);
if (orderPrefab != null)
{
var orderPrefab = Order.PrefabList[orderPrefabIndex];
var component = orderPrefab.GetTargetItemComponent(targetEntity as Item);
if (!orderPrefab.MustSetTarget || (targetEntity != null && component != null) || targetPosition != null)
{
var order = targetPosition == null ?
new Order(orderPrefab, targetEntity, component, orderGiver: orderGiver) :
new Order(orderPrefab, targetPosition, orderGiver: orderGiver);
character.SetOrder(order,
orderOptionIndex >= 0 && orderOptionIndex < orderPrefab.Options.Length ? orderPrefab.Options[orderOptionIndex] : null,
orderPriority, orderGiver, speak: false, force: true);
order = order.WithOption(
orderOptionIndex >= 0 && orderOptionIndex < orderPrefab.Options.Length
? orderPrefab.Options[orderOptionIndex]
: Identifier.Empty)
.WithManualPriority(orderPriority)
.WithOrderGiver(orderGiver);
character.SetOrder(order, speak: false, force: true);
}
else
{
@@ -601,7 +606,7 @@ namespace Barotrauma
}
else
{
DebugConsole.ThrowError("Invalid order prefab index - index (" + orderPrefabIndex + ") out of bounds.");
DebugConsole.ThrowError("Invalid order prefab index - index (" + orderPrefabUintIdentifier + ") out of bounds.");
}
}
@@ -1,4 +1,5 @@
using Barotrauma.Sounds;
using System.Collections.Immutable;
namespace Barotrauma
{
@@ -13,20 +14,17 @@ namespace Barotrauma
public readonly CharacterParams.SoundParams Params;
public SoundType Type => Params.State;
public Gender Gender => Params.Gender;
public ImmutableHashSet<Identifier> TagSet => Params.TagSet;
public float Volume => roundSound == null ? 0.0f : roundSound.Volume;
public float Range => roundSound == null ? 0.0f : roundSound.Range;
public Sound Sound => roundSound?.Sound;
public bool IgnoreMuffling
{
get { return roundSound?.IgnoreMuffling ?? false; }
}
public bool IgnoreMuffling => roundSound?.IgnoreMuffling ?? false;
public CharacterSound(CharacterParams.SoundParams soundParams)
{
Params = soundParams;
roundSound = Submarine.LoadRoundSound(soundParams.Element);
roundSound = RoundSound.Load(soundParams.Element);
}
}
}
@@ -39,7 +39,7 @@ namespace Barotrauma
public Vector2 Size;
private readonly Submarine parentSub;
public string Text
public LocalizedString Text
{
get;
private set;
@@ -58,7 +58,7 @@ namespace Barotrauma
}
public HUDProgressBar(Vector2 worldPosition, string textTag, Submarine parentSubmarine = null)
: this(worldPosition, parentSubmarine, GUI.Style.Red, GUI.Style.Green, textTag)
: this(worldPosition, parentSubmarine, GUIStyle.Red, GUIStyle.Green, textTag)
{
}
@@ -73,7 +73,7 @@ namespace Barotrauma
if (!string.IsNullOrEmpty(textTag))
{
this.textTag = textTag;
Text = TextManager.Get(textTag);
Text = TextManager.Get(textTag).Fallback(textTag);
}
}
@@ -101,12 +101,12 @@ namespace Barotrauma
color * a,
Color.White * a * 0.8f);
if (!string.IsNullOrEmpty(Text))
if (!Text.IsNullOrEmpty())
{
Vector2 textSize = GUI.SmallFont.MeasureString(Text);
Vector2 textSize = GUIStyle.SmallFont.MeasureString(Text);
Vector2 textPos = new Vector2(pos.X + (Size.X - textSize.X) / 2, pos.Y - textSize.Y * 1.2f);
GUI.DrawString(spriteBatch, textPos - Vector2.One, Text, Color.Black * a, font: GUI.SmallFont);
GUI.DrawString(spriteBatch, textPos, Text, Color.White * a, font: GUI.SmallFont);
GUI.DrawString(spriteBatch, textPos - Vector2.One, Text, Color.Black * a, font: GUIStyle.SmallFont);
GUI.DrawString(spriteBatch, textPos, Text, Color.White * a, font: GUIStyle.SmallFont);
}
}
@@ -16,15 +16,15 @@
{
return;
}
GUI.AddMessage(TextManager.Get("HuskDormant"), GUI.Style.Red);
GUI.AddMessage(TextManager.Get("HuskDormant"), GUIStyle.Red);
break;
case InfectionState.Transition:
GUI.AddMessage(TextManager.Get("HuskCantSpeak"), GUI.Style.Red);
GUI.AddMessage(TextManager.Get("HuskCantSpeak"), GUIStyle.Red);
break;
case InfectionState.Active:
if (character.Params.UseHuskAppendage)
{
GUI.AddMessage(TextManager.GetWithVariable("HuskActivate", "[Attack]", GameMain.Config.KeyBindText(InputType.Attack)), GUI.Style.Red);
GUI.AddMessage(TextManager.GetWithVariable("HuskActivate", "[Attack]", GameSettings.CurrentConfig.KeyMap.KeyBindText(InputType.Attack)), GUIStyle.Red);
}
break;
case InfectionState.Final:
@@ -75,7 +75,7 @@ namespace Barotrauma
case FloodType.Minor:
currentFloodState += deltaTime;
//lerp the water surface in all hulls 15 units above the floor within 10 seconds
foreach (Hull hull in Hull.hullList)
foreach (Hull hull in Hull.HullList)
{
for (int i = hull.FakeFireSources.Count - 1; i >= 0; i--)
{
@@ -87,7 +87,7 @@ namespace Barotrauma
case FloodType.Major:
currentFloodState += deltaTime;
//create a full flood in 10 seconds
foreach (Hull hull in Hull.hullList)
foreach (Hull hull in Hull.HullList)
{
for (int i = hull.FakeFireSources.Count - 1; i >= 0; i--)
{
@@ -98,7 +98,7 @@ namespace Barotrauma
break;
case FloodType.HideFlooding:
//hide water inside hulls (the player can't see which hulls are flooded)
foreach (Hull hull in Hull.hullList)
foreach (Hull hull in Hull.HullList)
{
hull.DrawSurface = hull.Rect.Y - hull.Rect.Height;
}
@@ -140,7 +140,7 @@ namespace Barotrauma
character.Submarine != null &&
createFireSourceTimer > MathHelper.Lerp(MaxFakeFireSourceInterval, MinFakeFireSourceInterval, Strength / 100.0f))
{
Hull fireHull = Hull.hullList.GetRandom(h => h.Submarine == character.Submarine);
Hull fireHull = Hull.HullList.GetRandomUnsynced(h => h.Submarine == character.Submarine);
if (fireHull != null)
{
var fakeFire = new DummyFireSource(Vector2.One * 500.0f, new Vector2(Rand.Range(fireHull.WorldRect.X, fireHull.WorldRect.Right), fireHull.WorldPosition.Y + 1), fireHull, isNetworkMessage: true)
@@ -14,11 +14,31 @@ namespace Barotrauma
{
private static bool toggledThisFrame;
public static Sprite DamageOverlay;
public class DamageOverlayPrefab : Prefab
{
public readonly static PrefabSelector<DamageOverlayPrefab> Prefabs = new PrefabSelector<DamageOverlayPrefab>();
public static string DamageOverlayFile;
public readonly Sprite DamageOverlay;
private static string[] strengthTexts;
public DamageOverlayPrefab(ContentXElement element, AfflictionsFile file) : base(file, file.Path.Value.ToIdentifier())
{
DamageOverlay = new Sprite(element);
}
public override void Dispose()
{
DamageOverlay.Remove();
}
}
public static Sprite DamageOverlay => DamageOverlayPrefab.Prefabs.ActivePrefab.DamageOverlay;
private readonly static LocalizedString[] strengthTexts = new LocalizedString[]
{
TextManager.Get("AfflictionStrengthLow"),
TextManager.Get("AfflictionStrengthMedium"),
TextManager.Get("AfflictionStrengthHigh")
};
private Point screenResolution;
@@ -134,7 +154,7 @@ namespace Barotrauma
Character.Controlled.ResetInteract = true;
if (openHealthWindow != null)
{
if (value.Character.Info == null || value.Character == Character.Controlled || Character.Controlled.HasEquippedItem("healthscanner"))
if (value.Character.Info == null || value.Character == Character.Controlled || Character.Controlled.HasEquippedItem("healthscanner".ToIdentifier()))
{
openHealthWindow.characterName.Text = value.Character.Name;
}
@@ -173,20 +193,10 @@ namespace Barotrauma
private GUIFrame healthBarHolder;
partial void InitProjSpecific(XElement element, Character character)
partial void InitProjSpecific(ContentXElement element, Character character)
{
DisplayedVitality = MaxVitality;
if (strengthTexts == null)
{
strengthTexts = new string[]
{
TextManager.Get("AfflictionStrengthLow"),
TextManager.Get("AfflictionStrengthMedium"),
TextManager.Get("AfflictionStrengthHigh")
};
}
character.OnAttacked += OnAttacked;
healthWindow = new GUIFrame(new RectTransform(new Vector2(0.35f, 0.6f), GUI.Canvas, anchor: Anchor.Center, scaleBasis: ScaleBasis.Smallest), style: "GUIFrameListBox");
@@ -200,13 +210,13 @@ namespace Barotrauma
{
Stretch = true
};
new GUICustomComponent(new RectTransform(new Vector2(0.2f, 1.0f), nameContainer.RectTransform, Anchor.CenterLeft),
onDraw: (spriteBatch, component) =>
{
character.Info?.DrawPortrait(spriteBatch, new Vector2(component.Rect.X, component.Rect.Center.Y - component.Rect.Width / 2), Vector2.Zero, component.Rect.Width, false, character != Character.Controlled);
});
characterName = new GUITextBlock(new RectTransform(new Vector2(0.6f, 1.0f), nameContainer.RectTransform), "", textAlignment: Alignment.CenterLeft, font: GUI.SubHeadingFont)
characterName = new GUITextBlock(new RectTransform(new Vector2(0.6f, 1.0f), nameContainer.RectTransform), "", textAlignment: Alignment.CenterLeft, font: GUIStyle.SubHeadingFont)
{
AutoScaleHorizontal = true
};
@@ -220,12 +230,12 @@ namespace Barotrauma
var healthBarContainer = new GUIFrame(new RectTransform(new Vector2(1.0f, 0.07f), healthWindowVerticalLayout.RectTransform), style: null);
var healthBarIcon = new GUIFrame(new RectTransform(new Vector2(0.095f, 1.0f), healthBarContainer.RectTransform), style: "GUIHealthBarIcon");
healthWindowHealthBarShadow = new GUIProgressBar(new RectTransform(new Vector2(0.91f, 1.0f), healthBarContainer.RectTransform, Anchor.CenterRight),
barSize: 1.0f, color: GUI.Style.Green, style: "GUIHealthBar")
barSize: 1.0f, color: GUIStyle.Green, style: "GUIHealthBar")
{
IsHorizontal = true
};
healthWindowHealthBar = new GUIProgressBar(new RectTransform(new Vector2(0.91f, 1.0f), healthBarContainer.RectTransform, Anchor.CenterRight),
barSize: 1.0f, color: GUI.Style.Green, style: "GUIHealthBar")
barSize: 1.0f, color: GUIStyle.Green, style: "GUIHealthBar")
{
IsHorizontal = true
};
@@ -311,7 +321,7 @@ namespace Barotrauma
}
);
deadIndicator = new GUITextBlock(new RectTransform(new Vector2(0.9f, 0.1f), limbSelection.RectTransform, Anchor.Center),
text: TextManager.Get("Deceased"), font: GUI.LargeFont, textAlignment: Alignment.Center, style: "GUIToolTip")
text: TextManager.Get("Deceased"), font: GUIStyle.LargeFont, textAlignment: Alignment.Center, style: "GUIToolTip")
{
Visible = false,
CanBeFocused = false
@@ -328,7 +338,7 @@ namespace Barotrauma
afflictionIconContainer = new GUIListBox(new RectTransform(new Vector2(0.25f, 1.0f), characterIndicatorArea.RectTransform), style: null);
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.1f), healthWindowVerticalLayout.RectTransform),
TextManager.Get("SuitableTreatments"), font: GUI.SubHeadingFont, textAlignment: Alignment.BottomCenter);
TextManager.Get("SuitableTreatments"), font: GUIStyle.SubHeadingFont, textAlignment: Alignment.BottomCenter);
treatmentLayout = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.15f), healthWindowVerticalLayout.RectTransform), true)
{
@@ -366,10 +376,10 @@ namespace Barotrauma
healthShadowSize = 1.0f;
healthBar = new GUIProgressBar(new RectTransform(Vector2.One, healthBarHolder.RectTransform, Anchor.BottomRight),
barSize: 1.0f, color: GUI.Style.HealthBarColorHigh, style: "CharacterHealthBar")
barSize: 1.0f, color: GUIStyle.HealthBarColorHigh, style: "CharacterHealthBar")
{
HoverCursor = CursorState.Hand,
ToolTip = TextManager.GetWithVariable("hudbutton.healthinterface", "[key]", GameMain.Config.KeyBindText(InputType.Health)),
ToolTip = TextManager.GetWithVariable("hudbutton.healthinterface", "[key]", GameSettings.CurrentConfig.KeyMap.KeyBindText(InputType.Health)),
Enabled = true
};
@@ -406,7 +416,7 @@ namespace Barotrauma
if (element != null)
{
foreach (XElement subElement in element.Elements())
foreach (var subElement in element.Elements())
{
switch (subElement.Name.ToString().ToLowerInvariant())
{
@@ -501,7 +511,17 @@ namespace Barotrauma
{
if (prevOxygen > 0.0f && OxygenAmount <= 0.0f && Character.Controlled == Character)
{
SoundPlayer.PlaySound(Character.Info != null && Character.Info.Gender == Gender.Female ? "drownfemale" : "drownmale");
string soundName;
if (Character.Info != null)
{
soundName = Character.Info.ReplaceVars($"drown[{Character.Info.Prefab.MenuCategoryVar}]");
}
else
{
var charInfoPrefab = CharacterPrefab.HumanPrefab.CharacterInfoPrefab;
soundName = charInfoPrefab.ReplaceVars($"drown[{charInfoPrefab.MenuCategoryVar}]", charInfoPrefab.Heads.First());
}
SoundPlayer.PlaySound(soundName);
}
if (Character == Character.Controlled && !IsUnconscious && !Character.IsDead && OxygenAmount < LowOxygenThreshold)
@@ -715,11 +735,11 @@ namespace Barotrauma
if (!(afflictionIcon.UserData is Affliction affliction)) { continue; }
if (affliction.AppliedAsFailedTreatmentTime > Timing.TotalTime - 1.0 && afflictionIcon.FlashTimer <= 0.0f)
{
afflictionIcon.Flash(GUI.Style.Red);
afflictionIcon.Flash(GUIStyle.Red);
}
else if (affliction.AppliedAsSuccessfulTreatmentTime > Timing.TotalTime - 1.0 && afflictionIcon.FlashTimer <= 0.0f)
{
afflictionIcon.Flash(GUI.Style.Green);
afflictionIcon.Flash(GUIStyle.Green);
}
}
@@ -754,7 +774,7 @@ namespace Barotrauma
var labelContainer = afflictionTooltip.Content.GetChildByUserData("label");
labelContainer.RectTransform.Resize(new Point(labelContainer.Rect.Width, (int)(GUI.LargeFont.Size * 1.5f)));
labelContainer.RectTransform.Resize(new Point(labelContainer.Rect.Width, (int)(GUIStyle.LargeFont.Size * 1.5f)));
}
}
else
@@ -799,7 +819,7 @@ namespace Barotrauma
{
var treatmentButton = component.GetChild<GUIButton>();
if (!(treatmentButton?.UserData is ItemPrefab itemPrefab)) { continue; }
var matchingItem = Character.Controlled.Inventory.FindItem(it => it.prefab == itemPrefab, recursive: true);
var matchingItem = Character.Controlled.Inventory.FindItem(it => it.Prefab == itemPrefab, recursive: true);
treatmentButton.Enabled = matchingItem != null;
if (treatmentButton.Enabled && treatmentButton.State == GUIComponent.ComponentState.Hover)
{
@@ -809,16 +829,18 @@ namespace Barotrauma
if (Character.Controlled.Inventory.visualSlots != null && index > -1 && index < Character.Controlled.Inventory.visualSlots.Length &&
Character.Controlled.Inventory.visualSlots[index].HighlightTimer <= 0.0f)
{
Character.Controlled.Inventory.visualSlots[index].ShowBorderHighlight(GUI.Style.Green, 0.5f, 0.5f);
Character.Controlled.Inventory.visualSlots[index].ShowBorderHighlight(GUIStyle.Green, 0.5f, 0.5f);
}
}
if (matchingItem != null && !string.IsNullOrEmpty(treatmentButton.ToolTip)) { continue; }
treatmentButton.ToolTip = $"‖color:255,255,255,255‖{itemPrefab.Name}‖color:end‖" + '\n' + itemPrefab.Description;
if (matchingItem != null && !treatmentButton.ToolTip.IsNullOrEmpty()) { continue; }
treatmentButton.ToolTip = RichString.Rich($"‖color:255,255,255,255‖{itemPrefab.Name}‖color:end‖" + '\n' + itemPrefab.Description);
if (treatmentButton.Enabled)
{
treatmentButton.ToolTip =
$"‖color:gui.green‖[{TextManager.Get(PlayerInput.MouseButtonsSwapped() ? "input.rightmouse" : "input.leftmouse")}] {TextManager.Get("quickuseaction.usetreatment")}‖color:end‖" + '\n'
+ treatmentButton.RawToolTip;
RichString.Rich(
$"‖color:gui.green‖[{TextManager.Get(PlayerInput.MouseButtonsSwapped() ? "input.rightmouse" : "input.leftmouse")}] "
+ $"{TextManager.Get("quickuseaction.usetreatment")}‖color:end‖" + '\n'
+ treatmentButton.ToolTip.NestedStr);
}
foreach (GUIComponent child in treatmentButton.Children)
{
@@ -834,7 +856,7 @@ namespace Barotrauma
}
else
{
healthBar.Color = healthWindowHealthBar.Color = ToolBox.GradientLerp(DisplayedVitality / MaxVitality, GUI.Style.HealthBarColorLow, GUI.Style.HealthBarColorMedium, GUI.Style.HealthBarColorHigh);
healthBar.Color = healthWindowHealthBar.Color = ToolBox.GradientLerp(DisplayedVitality / MaxVitality, GUIStyle.HealthBarColorLow, GUIStyle.HealthBarColorMedium, GUIStyle.HealthBarColorHigh);
healthBar.HoverColor = healthWindowHealthBar.HoverColor = healthBar.Color * 2.0f;
healthBar.BarSize = healthWindowHealthBar.BarSize =
(DisplayedVitality > 0.0f) ?
@@ -1007,14 +1029,14 @@ namespace Barotrauma
DrawStatusHUD(spriteBatch);
}
private (Affliction affliction, string text)? highlightedAfflictionIcon;
private (Affliction Affliction, LocalizedString NameToolTip)? highlightedAfflictionIcon = null;
public void DrawStatusHUD(SpriteBatch spriteBatch)
{
highlightedAfflictionIcon = null;
//Rectangle interactArea = healthBar.Rect;
if (Character.Controlled?.SelectedCharacter == null && openHealthWindow == null)
{
List<(Affliction affliction, string text)> statusIcons = new List<(Affliction affliction, string text)>();
var statusIcons = new List<(Affliction Affliction, LocalizedString Warning)>();
if (Character.InPressure)
{
statusIcons.Add((pressureAffliction, TextManager.Get("PressureHUDWarning")));
@@ -1045,7 +1067,7 @@ namespace Barotrauma
foreach (var statusIcon in statusIcons)
{
Affliction affliction = statusIcon.affliction;
Affliction affliction = statusIcon.Affliction;
AfflictionPrefab afflictionPrefab = affliction.Prefab;
Rectangle afflictionIconRect = new Rectangle(pos, new Point(iconSize));
@@ -1059,10 +1081,10 @@ namespace Barotrauma
{
Rectangle glowRect = afflictionIconRect;
glowRect.Inflate((int)(20 * GUI.Scale), (int)(20 * GUI.Scale));
var glow = GUI.Style.GetComponentStyle("OuterGlowCircular");
var glow = GUIStyle.GetComponentStyle("OuterGlowCircular");
glow.Sprites[GUIComponent.ComponentState.None][0].Draw(
spriteBatch, glowRect,
GUI.Style.Red * (float)((Math.Sin(affliction.DamagePerSecondTimer * MathHelper.TwoPi - MathHelper.PiOver2) + 1.0f) * 0.5f));
GUIStyle.Red * (float)((Math.Sin(affliction.DamagePerSecondTimer * MathHelper.TwoPi - MathHelper.PiOver2) + 1.0f) * 0.5f));
}
float alphaMultiplier = highlightedAfflictionIcon == statusIcon ? 1f : 0.8f;
@@ -1082,8 +1104,8 @@ namespace Barotrauma
if (highlightedAfflictionIcon != null)
{
string nameTooltip = highlightedAfflictionIcon.Value.text;
Vector2 offset = GUI.Font.MeasureString(nameTooltip);
LocalizedString nameTooltip = highlightedAfflictionIcon.Value.NameToolTip;
Vector2 offset = GUIStyle.Font.MeasureString(nameTooltip);
GUI.DrawString(spriteBatch,
alignment == Alignment.Left ? highlightedIconPos + offset : highlightedIconPos - offset,
@@ -1096,7 +1118,7 @@ namespace Barotrauma
float currHealth = healthBar.BarSize;
Color prevColor = healthBar.Color;
healthBarShadow.BarSize = healthShadowSize;
healthBarShadow.Color = Color.Lerp(GUI.Style.Red, Color.Black, 0.5f);
healthBarShadow.Color = Color.Lerp(GUIStyle.Red, Color.Black, 0.5f);
healthBarShadow.Visible = true;
healthBar.BarSize = currHealth;
healthBar.Color = prevColor;
@@ -1113,7 +1135,7 @@ namespace Barotrauma
float currHealth = healthWindowHealthBar.BarSize;
Color prevColor = healthWindowHealthBar.Color;
healthWindowHealthBarShadow.BarSize = healthShadowSize;
healthWindowHealthBarShadow.Color = GUI.Style.Red;
healthWindowHealthBarShadow.Color = GUIStyle.Red;
healthWindowHealthBarShadow.Visible = true;
healthWindowHealthBar.BarSize = currHealth;
healthWindowHealthBar.Color = prevColor;
@@ -1137,10 +1159,10 @@ namespace Barotrauma
{
if (prefab.IsBuff)
{
return ToolBox.GradientLerp(afflictionStrength / prefab.MaxStrength, GUI.Style.BuffColorLow, GUI.Style.BuffColorMedium, GUI.Style.BuffColorHigh);
return ToolBox.GradientLerp(afflictionStrength / prefab.MaxStrength, GUIStyle.BuffColorLow, GUIStyle.BuffColorMedium, GUIStyle.BuffColorHigh);
}
return ToolBox.GradientLerp(afflictionStrength / prefab.MaxStrength, GUI.Style.DebuffColorLow, GUI.Style.DebuffColorMedium, GUI.Style.DebuffColorHigh);
return ToolBox.GradientLerp(afflictionStrength / prefab.MaxStrength, GUIStyle.DebuffColorLow, GUIStyle.DebuffColorMedium, GUIStyle.DebuffColorHigh);
}
return ToolBox.GradientLerp(afflictionStrength / prefab.MaxStrength, prefab.IconColors);
@@ -1213,7 +1235,7 @@ namespace Barotrauma
CanBeFocused = false
};
var progressbarBg = new GUIProgressBar(new RectTransform(new Vector2(1.0f, 0.18f), content.RectTransform), 0.0f, GUI.Style.Green, style: "GUIAfflictionBar")
var progressbarBg = new GUIProgressBar(new RectTransform(new Vector2(1.0f, 0.18f), content.RectTransform), 0.0f, GUIStyle.Green, style: "GUIAfflictionBar")
{
UserData = "afflictionstrengthprediction",
CanBeFocused = false
@@ -1240,9 +1262,9 @@ namespace Barotrauma
afflictionIcon.PressedColor = afflictionIcon.Color;
afflictionIcon.HoverColor = Color.Lerp(afflictionIcon.Color, Color.White, 0.6f);
afflictionIcon.SelectedColor = Color.Lerp(afflictionIcon.Color, Color.White, 0.5f);
var nameText = new GUITextBlock(new RectTransform(new Vector2(1.1f, 0.0f), content.RectTransform),
affliction.Prefab.Name, font: GUI.SmallFont, textAlignment: Alignment.BottomCenter)
affliction.Prefab.Name, font: GUIStyle.SmallFont, textAlignment: Alignment.BottomCenter)
{
CanBeFocused = false
};
@@ -1274,13 +1296,13 @@ namespace Barotrauma
//key = item identifier
//float = suitability
Dictionary<string, float> treatmentSuitability = new Dictionary<string, float>();
Dictionary<Identifier, float> treatmentSuitability = new Dictionary<Identifier, float>();
GetSuitableTreatments(treatmentSuitability,
normalize: true,
ignoreHiddenAfflictions: true,
limb: selectedLimbIndex == -1 ? null : Character.AnimController.Limbs.Find(l => l.HealthIndex == selectedLimbIndex));
foreach (string treatment in treatmentSuitability.Keys.ToList())
foreach (Identifier treatment in treatmentSuitability.Keys.ToList())
{
//prefer suggestions for items the player has
if (Character.Controlled.Inventory.FindItemByIdentifier(treatment, recursive: true) != null)
@@ -1304,10 +1326,10 @@ namespace Barotrauma
recommendedTreatmentContainer.AutoHideScrollBar = true;
}
List<KeyValuePair<string, float>> treatmentSuitabilities = treatmentSuitability.OrderByDescending(t => t.Value).ToList();
List<KeyValuePair<Identifier, float>> treatmentSuitabilities = treatmentSuitability.OrderByDescending(t => t.Value).ToList();
int count = 0;
foreach (KeyValuePair<string, float> treatment in treatmentSuitabilities)
foreach (KeyValuePair<Identifier, float> treatment in treatmentSuitabilities)
{
count++;
if (count > 5) { break; }
@@ -1326,7 +1348,7 @@ namespace Barotrauma
OnClicked = (btn, userdata) =>
{
if (!(userdata is ItemPrefab itemPrefab)) { return false; }
var item = Character.Controlled.Inventory.FindItem(it => it.prefab == itemPrefab, recursive: true);
var item = Character.Controlled.Inventory.FindItem(it => it.Prefab == itemPrefab, recursive: true);
if (item == null) { return false; }
Limb targetLimb = Character.AnimController.Limbs.FirstOrDefault(l => l.HealthIndex == selectedLimbIndex);
item.ApplyTreatment(Character.Controlled, Character, targetLimb);
@@ -1337,15 +1359,15 @@ namespace Barotrauma
new GUIImage(new RectTransform(Vector2.One, innerFrame.RectTransform, Anchor.Center), style: "TalentBackgroundGlow")
{
CanBeFocused = false,
Color = GUI.Style.Green,
Color = GUIStyle.Green,
HoverColor = Color.White,
PressedColor = Color.DarkGray,
SelectedColor = Color.Transparent,
DisabledColor = Color.Transparent
};
Sprite itemSprite = item.InventoryIcon ?? item.sprite;
Color itemColor = itemSprite == item.sprite ? item.SpriteColor : item.InventoryIconColor;
Sprite itemSprite = item.InventoryIcon ?? item.Sprite;
Color itemColor = itemSprite == item.Sprite ? item.SpriteColor : item.InventoryIconColor;
var itemIcon = new GUIImage(new RectTransform(new Vector2(0.8f, 0.8f), innerFrame.RectTransform, Anchor.Center),
itemSprite, scaleToFit: true)
{
@@ -1397,12 +1419,12 @@ namespace Barotrauma
CanBeFocused = false
};
var afflictionName = new GUITextBlock(new RectTransform(new Vector2(0.65f, 1.0f), labelContainer.RectTransform), affliction.Prefab.Name, textAlignment: Alignment.CenterLeft, font: GUI.LargeFont)
var afflictionName = new GUITextBlock(new RectTransform(new Vector2(0.65f, 1.0f), labelContainer.RectTransform), affliction.Prefab.Name, textAlignment: Alignment.CenterLeft, font: GUIStyle.LargeFont)
{
CanBeFocused = false,
AutoScaleHorizontal = true
};
var afflictionStrength = new GUITextBlock(new RectTransform(new Vector2(0.35f, 0.6f), labelContainer.RectTransform), "", textAlignment: Alignment.TopRight, font: GUI.SubHeadingFont)
var afflictionStrength = new GUITextBlock(new RectTransform(new Vector2(0.35f, 0.6f), labelContainer.RectTransform), "", textAlignment: Alignment.TopRight, font: GUIStyle.SubHeadingFont)
{
UserData = "strength",
CanBeFocused = false
@@ -1423,21 +1445,21 @@ namespace Barotrauma
if (description.Font.MeasureString(description.WrappedText).Y > description.Rect.Height)
{
description.Font = GUI.SmallFont;
description.Font = GUIStyle.SmallFont;
}
Point nameDims = new Point(afflictionName.Rect.Width, (int)(GUI.LargeFont.Size * 1.5f));
Point nameDims = new Point(afflictionName.Rect.Width, (int)(GUIStyle.LargeFont.Size * 1.5f));
afflictionStrength.Text = strengthTexts[
MathHelper.Clamp((int)Math.Floor((affliction.Strength / affliction.Prefab.MaxStrength) * strengthTexts.Length), 0, strengthTexts.Length - 1)];
Vector2 strengthDims = GUI.SubHeadingFont.MeasureString(afflictionStrength.Text);
Vector2 strengthDims = GUIStyle.SubHeadingFont.MeasureString(afflictionStrength.Text);
labelContainer.RectTransform.Resize(new Point(labelContainer.Rect.Width, nameDims.Y));
afflictionName.RectTransform.Resize(new Point((int)(labelContainer.Rect.Width - strengthDims.X * 0.99f), nameDims.Y));
afflictionStrength.RectTransform.Resize(new Point(labelContainer.Rect.Width - afflictionName.Rect.Width, nameDims.Y));
afflictionStrength.TextColor = Color.Lerp(GUI.Style.Orange, GUI.Style.Red,
afflictionStrength.TextColor = Color.Lerp(GUIStyle.Orange, GUIStyle.Red,
affliction.Strength / affliction.Prefab.MaxStrength);
description.RectTransform.Resize(new Point(description.Rect.Width, (int)(description.TextSize.Y + 10)));
@@ -1451,8 +1473,8 @@ namespace Barotrauma
{
vitality.Visible = true;
vitality.Text = TextManager.Get("Vitality") + " -" + vitalityDecrease;
vitality.TextColor = vitalityDecrease <= 0 ? GUI.Style.Green :
Color.Lerp(GUI.Style.Orange, GUI.Style.Red, affliction.Strength / affliction.Prefab.MaxStrength);
vitality.TextColor = vitalityDecrease <= 0 ? GUIStyle.Green :
Color.Lerp(GUIStyle.Orange, GUIStyle.Red, affliction.Strength / affliction.Prefab.MaxStrength);
}
vitality.AutoDraw = true;
@@ -1478,7 +1500,7 @@ namespace Barotrauma
var potentialTreatment = Inventory.DraggingItems.FirstOrDefault();
if (potentialTreatment == null && GUI.MouseOn?.UserData is ItemPrefab itemPrefab)
{
potentialTreatment = Character.Controlled.Inventory.FindItem(it => it.prefab == itemPrefab, recursive: true);
potentialTreatment = Character.Controlled.Inventory.FindItem(it => it.Prefab == itemPrefab, recursive: true);
}
potentialTreatment ??= Inventory.SelectedSlot?.Item;
@@ -1488,11 +1510,11 @@ namespace Barotrauma
Color afflictionEffectColor = Color.White;
if (afflictionVitalityDecrease > 0.0f)
{
afflictionEffectColor = GUI.Style.Red;
afflictionEffectColor = GUIStyle.Red;
}
else if (afflictionVitalityDecrease < 0.0f)
{
afflictionEffectColor = GUI.Style.Green;
afflictionEffectColor = GUIStyle.Green;
}
var child = afflictionIconContainer.Content.FindChild(affliction);
@@ -1510,7 +1532,7 @@ namespace Barotrauma
if (afflictionStrengthPrediction < affliction.Strength)
{
afflictionStrengthBar.Color = afflictionEffectColor;
afflictionStrengthPredictionBar.Color = GUI.Style.Blue * t;
afflictionStrengthPredictionBar.Color = GUIStyle.Blue * t;
afflictionStrengthPredictionBar.BarSize = afflictionStrengthBar.BarSize;
afflictionStrengthBar.BarSize = afflictionStrengthPrediction / affliction.Prefab.MaxStrength;
}
@@ -1541,8 +1563,8 @@ namespace Barotrauma
{
foreach (var reduceAffliction in effect.ReduceAffliction)
{
if (reduceAffliction.affliction != affliction.Identifier && reduceAffliction.affliction != affliction.Prefab.AfflictionType) { continue; }
strength -= reduceAffliction.amount * (effect.Duration > 0 ? effect.Duration : 1.0f);
if (reduceAffliction.AfflictionIdentifier != affliction.Identifier && reduceAffliction.AfflictionIdentifier != affliction.Prefab.AfflictionType) { continue; }
strength -= reduceAffliction.ReduceAmount * (effect.Duration > 0 ? effect.Duration : 1.0f);
}
foreach (var addAffliction in effect.Afflictions)
{
@@ -1563,7 +1585,7 @@ namespace Barotrauma
strengthText.Text = strengthTexts[
MathHelper.Clamp((int)Math.Floor((affliction.Strength / affliction.Prefab.MaxStrength) * strengthTexts.Length), 0, strengthTexts.Length - 1)];
strengthText.TextColor = Color.Lerp(GUI.Style.Orange, GUI.Style.Red,
strengthText.TextColor = Color.Lerp(GUIStyle.Orange, GUIStyle.Red,
affliction.Strength / affliction.Prefab.MaxStrength);
var vitalityText = labelContainer.GetChildByUserData("vitality") as GUITextBlock;
@@ -1576,8 +1598,8 @@ namespace Barotrauma
{
vitalityText.Visible = true;
vitalityText.Text = TextManager.Get("Vitality") + " -" + vitalityDecrease;
vitalityText.TextColor = vitalityDecrease <= 0 ? GUI.Style.Green :
Color.Lerp(GUI.Style.Orange, GUI.Style.Red, affliction.Strength / affliction.Prefab.MaxStrength);
vitalityText.TextColor = vitalityDecrease <= 0 ? GUIStyle.Green :
Color.Lerp(GUIStyle.Orange, GUIStyle.Red, affliction.Strength / affliction.Prefab.MaxStrength);
}
}
@@ -1807,9 +1829,9 @@ namespace Barotrauma
if (afflictionsDisplayedOnLimb.Count() > 1)
{
string additionalAfflictionCount = $"+{afflictionsDisplayedOnLimb.Count() - 1}";
Vector2 displace = GUI.SubHeadingFont.MeasureString(additionalAfflictionCount);
GUI.SubHeadingFont.DrawString(spriteBatch, additionalAfflictionCount, iconPos + new Vector2(displace.X * 1.1f, -displace.Y * 0.45f), Color.Black * 0.75f);
GUI.SubHeadingFont.DrawString(spriteBatch, additionalAfflictionCount, iconPos + new Vector2(displace.X, -displace.Y * 0.5f), Color.White);
Vector2 displace = GUIStyle.SubHeadingFont.MeasureString(additionalAfflictionCount);
GUIStyle.SubHeadingFont.DrawString(spriteBatch, additionalAfflictionCount, iconPos + new Vector2(displace.X * 1.1f, -displace.Y * 0.45f), Color.Black * 0.75f);
GUIStyle.SubHeadingFont.DrawString(spriteBatch, additionalAfflictionCount, iconPos + new Vector2(displace.X, -displace.Y * 0.5f), Color.White);
}
i++;
@@ -1885,7 +1907,7 @@ namespace Barotrauma
for (int i = 0; i < afflictionCount; i++)
{
uint afflictionID = inc.ReadUInt32();
AfflictionPrefab afflictionPrefab = AfflictionPrefab.Prefabs.Find(p => p.UIntIdentifier == afflictionID);
AfflictionPrefab afflictionPrefab = AfflictionPrefab.Prefabs.Find(p => p.UintIdentifier == afflictionID);
if (afflictionPrefab == null)
{
DebugConsole.ThrowError("Error while reading character health data: affliction with the uint ID " + afflictionID + " not found.");
@@ -1913,7 +1935,7 @@ namespace Barotrauma
{
int limbIndex = inc.ReadRangedInteger(0, limbHealths.Count - 1);
uint afflictionID = inc.ReadUInt32();
AfflictionPrefab afflictionPrefab = AfflictionPrefab.Prefabs.Find(p => p.UIntIdentifier == afflictionID);
AfflictionPrefab afflictionPrefab = AfflictionPrefab.Prefabs.Find(p => p.UintIdentifier == afflictionID);
if (afflictionPrefab == null)
{
DebugConsole.ThrowError("Error while reading character health data: affliction with the uint ID " + afflictionID + " not found.");
@@ -2,14 +2,14 @@
{
partial class DamageModifier
{
[Serialize("", false), Editable]
[Serialize("", IsPropertySaveable.No), Editable]
public string DamageSound
{
get;
private set;
}
[Serialize("", false), Editable]
[Serialize("", IsPropertySaveable.No), Editable]
public string DamageParticle
{
get;
@@ -6,7 +6,7 @@ using System.Collections.Generic;
namespace Barotrauma
{
partial class JobPrefab : IPrefab, IDisposable
partial class JobPrefab : PrefabWithUintIdentifier
{
public GUIButton CreateInfoFrame(out GUIComponent buttonContainer)
{
@@ -18,20 +18,20 @@ namespace Barotrauma
GUIFrame frame = new GUIFrame(new RectTransform(new Point(width, height), frameHolder.RectTransform, Anchor.Center));
GUIFrame paddedFrame = new GUIFrame(new RectTransform(new Vector2(0.9f, 0.9f), frame.RectTransform, Anchor.Center), style: null);
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.1f), paddedFrame.RectTransform), Name, font: GUI.LargeFont);
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.1f), paddedFrame.RectTransform), Name, font: GUIStyle.LargeFont);
var descriptionBlock = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), paddedFrame.RectTransform) { RelativeOffset = new Vector2(0.0f, 0.15f) },
Description, font: GUI.SmallFont, wrap: true);
Description, font: GUIStyle.SmallFont, wrap: true);
var skillContainer = new GUILayoutGroup(new RectTransform(new Vector2(0.45f, 0.5f), paddedFrame.RectTransform)
{ RelativeOffset = new Vector2(0.0f, 0.2f + descriptionBlock.RectTransform.RelativeSize.Y) });
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), skillContainer.RectTransform),
TextManager.Get("Skills"), font: GUI.LargeFont);
TextManager.Get("Skills"), font: GUIStyle.LargeFont);
foreach (SkillPrefab skill in Skills)
{
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), skillContainer.RectTransform),
" - " + TextManager.AddPunctuation(':', TextManager.Get("SkillName." + skill.Identifier), (int)skill.LevelRange.Start + " - " + (int)skill.LevelRange.End),
font: GUI.SmallFont);
font: GUIStyle.SmallFont);
}
buttonContainer = paddedFrame;
@@ -43,14 +43,14 @@ namespace Barotrauma
Stretch = true
};
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), itemContainer.RectTransform),
TextManager.Get("Items", fallBackTag: "mapentitycategory.equipment"), font: GUI.LargeFont);
TextManager.Get("Items", "mapentitycategory.equipment"), font: GUIStyle.LargeFont);
foreach (string identifier in itemIdentifiers.Distinct())
{
if (!(MapEntityPrefab.Find(name: null, identifier: identifier) is ItemPrefab itemPrefab)) { continue; }
int count = itemIdentifiers.Count(i => i == identifier);
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), itemContainer.RectTransform),
" - " + (count == 1 ? itemPrefab.Name : itemPrefab.Name + " x" + count),
font: GUI.SmallFont);
font: GUIStyle.SmallFont);
}*/
return frameHolder;
@@ -76,12 +76,12 @@ namespace Barotrauma
}
}
public List<OutfitPreview> GetJobOutfitSprites(Gender gender, bool useInventoryIcon, out Vector2 maxDimensions)
public List<OutfitPreview> GetJobOutfitSprites(CharacterInfoPrefab charInfoPrefab, bool useInventoryIcon, out Vector2 maxDimensions)
{
List<OutfitPreview> outfitPreviews = new List<OutfitPreview>();
maxDimensions = Vector2.One;
var equipIdentifiers = Element.GetChildElements("ItemSet").Elements().Where(e => e.GetAttributeBool("outfit", false)).Select(e => e.GetAttributeString("identifier", ""));
var equipIdentifiers = Element.GetChildElements("ItemSet").Elements().Where(e => e.GetAttributeBool("outfit", false)).Select(e => e.GetAttributeIdentifier("identifier", ""));
List<ItemPrefab> outfitPrefabs = new List<ItemPrefab>();
foreach (var equipIdentifier in equipIdentifiers)
@@ -114,8 +114,8 @@ namespace Barotrauma
var children = previewElement.Elements().ToList();
for (int n = 0; n < children.Count; n++)
{
XElement spriteElement = children[n];
string spriteTexture = spriteElement.GetAttributeString("texture", "").Replace("[GENDER]", (gender == Gender.Female) ? "female" : "male");
var spriteElement = children[n];
string spriteTexture = charInfoPrefab.ReplaceVars(spriteElement.GetAttributeString("texture", ""), charInfoPrefab.Heads.First());
var sprite = new Sprite(spriteElement, file: spriteTexture);
sprite.size = new Vector2(sprite.SourceRect.Width, sprite.SourceRect.Height);
outfitPreview.AddSprite(sprite, children[n].GetAttributeVector2("offset", Vector2.Zero));
@@ -78,7 +78,7 @@ namespace Barotrauma
//{
// var pos = ConvertUnits.ToDisplayUnits(mouthPos.Value);
// pos.Y = -pos.Y;
// ShapeExtensions.DrawPoint(spriteBatch, pos, GUI.Style.Red, size: 5);
// ShapeExtensions.DrawPoint(spriteBatch, pos, GUIStyle.Red, size: 5);
//}
// A debug visualisation on the bezier curve between limbs.
@@ -95,7 +95,7 @@ namespace Barotrauma
GUI.DrawLine(spriteBatch, start, end, Color.White);
GUI.DrawLine(spriteBatch, start, control, Color.Black);
GUI.DrawLine(spriteBatch, control, end, Color.Black);
GUI.DrawBezierWithDots(spriteBatch, start, end, control, 1000, GUI.Style.Red);*/
GUI.DrawBezierWithDots(spriteBatch, start, end, control, 1000, GUIStyle.Red);*/
}
}
@@ -274,7 +274,7 @@ namespace Barotrauma
}
}
partial void InitProjSpecific(XElement element)
partial void InitProjSpecific(ContentXElement element)
{
for (int i = 0; i < Params.decorativeSpriteParams.Count; i++)
{
@@ -290,7 +290,7 @@ namespace Barotrauma
spriteAnimState.Add(decorativeSprite, new SpriteState());
}
TintMask = null;
foreach (XElement subElement in element.Elements())
foreach (var subElement in element.Elements())
{
switch (subElement.Name.ToString().ToLowerInvariant())
{
@@ -317,7 +317,7 @@ namespace Barotrauma
NonConditionalDeformations.AddRange(deformations);
break;
case "randomcolor":
randomColor = subElement.GetAttributeColorArray("colors", null)?.GetRandom();
randomColor = subElement.GetAttributeColorArray("colors", null)?.GetRandomUnsynced();
if (randomColor.HasValue)
{
Params.GetSprite().Color = randomColor.Value;
@@ -337,8 +337,8 @@ namespace Barotrauma
InitialLightSpriteAlpha = LightSource.OverrideLightSpriteAlpha;
break;
case "tintmask":
string tintMaskPath = subElement.GetAttributeString("texture", "");
if (!string.IsNullOrWhiteSpace(tintMaskPath))
ContentPath tintMaskPath = subElement.GetAttributeContentPath("texture");
if (!tintMaskPath.IsNullOrWhiteSpace())
{
TintMask = new Sprite(subElement, file: GetSpritePath(tintMaskPath));
TintHighlightThreshold = subElement.GetAttributeFloat("highlightthreshold", 0.6f);
@@ -346,8 +346,8 @@ namespace Barotrauma
}
break;
case "huskmask":
string huskMaskPath = subElement.GetAttributeString("texture", "");
if (!string.IsNullOrWhiteSpace(huskMaskPath))
ContentPath huskMaskPath = subElement.GetAttributeContentPath("texture");
if (!huskMaskPath.IsNullOrWhiteSpace())
{
HuskMask = new Sprite(subElement, file: GetSpritePath(huskMaskPath));
}
@@ -387,7 +387,7 @@ namespace Barotrauma
}
if (deformation == null)
{
deformation = SpriteDeformation.Load(animationElement, character.SpeciesName);
deformation = SpriteDeformation.Load(animationElement, character.SpeciesName.Value);
if (deformation != null)
{
ragdoll.SpriteDeformations.Add(deformation);
@@ -472,19 +472,23 @@ namespace Barotrauma
}
private string _texturePath;
private string GetSpritePath(XElement element, SpriteParams spriteParams)
private string GetSpritePath(ContentXElement element, SpriteParams spriteParams)
{
if (_texturePath == null)
{
if (spriteParams != null)
{
string texturePath = character.Params.VariantFile?.Root?.GetAttributeString("texture", null) ?? spriteParams.GetTexturePath();
ContentPath texturePath =
character.Params.VariantFile?.Root?.GetAttributeContentPath("texture", character.Prefab.ContentPackage)
?? ContentPath.FromRaw(character.Prefab.ContentPackage, spriteParams.GetTexturePath());
_texturePath = GetSpritePath(texturePath);
}
else
{
string texturePath = element.GetAttributeString("texture", null);
texturePath = string.IsNullOrWhiteSpace(texturePath) ? ragdoll.RagdollParams.Texture : texturePath;
ContentPath texturePath = element.GetAttributeContentPath("texture");
texturePath = texturePath.IsNullOrWhiteSpace()
? ContentPath.FromRaw(character.Prefab.ContentPackage, ragdoll.RagdollParams.Texture)
: texturePath;
_texturePath = GetSpritePath(texturePath);
}
}
@@ -494,20 +498,18 @@ namespace Barotrauma
/// <summary>
/// Get the full path of a limb sprite, taking into account tags, gender and head id
/// </summary>
public static string GetSpritePath(string texturePath, CharacterInfo characterInfo)
public static string GetSpritePath(ContentPath texturePath, CharacterInfo characterInfo)
{
string spritePath = texturePath;
string spritePath = texturePath.Value;
string spritePathWithTags = spritePath;
if (characterInfo != null)
{
spritePath = spritePath.Replace("[GENDER]", (characterInfo.Gender == Gender.Female) ? "female" : "male");
spritePath = spritePath.Replace("[RACE]", characterInfo.Race.ToString().ToLowerInvariant());
spritePath = spritePath.Replace("[HEADID]", characterInfo.HeadSpriteId.ToString());
spritePath = characterInfo.ReplaceVars(spritePath);
if (characterInfo.HeadSprite != null && characterInfo.SpriteTags.Any())
{
string tags = "";
characterInfo.SpriteTags.ForEach(tag => tags += "[" + tag + "]");
characterInfo.SpriteTags.ForEach(tag => tags += $"[{tag}]");
spritePathWithTags = Path.Combine(
Path.GetDirectoryName(spritePath),
@@ -518,9 +520,9 @@ namespace Barotrauma
}
private string GetSpritePath(string texturePath)
private string GetSpritePath(ContentPath texturePath)
{
if (!character.IsHumanoid) { return texturePath; }
if (!character.IsHumanoid) { return texturePath.Value; }
return GetSpritePath(texturePath, character?.Info);
}
@@ -696,7 +698,7 @@ namespace Barotrauma
clr = clr.Multiply(ragdoll.RagdollParams.Color);
if (character.Info != null)
{
clr = clr.Multiply(character.Info.SkinColor);
clr = clr.Multiply(character.Info.Head.SkinColor);
}
if (character.CharacterHealth.FaceTint.A > 0 && type == LimbType.Head)
{
@@ -929,7 +931,7 @@ namespace Barotrauma
if (pullJoint != null)
{
Vector2 pos = ConvertUnits.ToDisplayUnits(pullJoint.WorldAnchorB);
GUI.DrawRectangle(spriteBatch, new Rectangle((int)pos.X, (int)-pos.Y, 5, 5), GUI.Style.Red, true);
GUI.DrawRectangle(spriteBatch, new Rectangle((int)pos.X, (int)-pos.Y, 5, 5), GUIStyle.Red, true);
}
var bodyDrawPos = body.DrawPosition;
bodyDrawPos.Y = -bodyDrawPos.Y;
@@ -943,11 +945,11 @@ namespace Barotrauma
var front = ConvertUnits.ToDisplayUnits(body.FarseerBody.GetWorldPoint(localFront));
front.Y = -front.Y;
GUI.DrawLine(spriteBatch, bodyDrawPos, front, Color.Yellow, width: 2);
GUI.DrawLine(spriteBatch, from, to, GUI.Style.Red, width: 1);
GUI.DrawLine(spriteBatch, from, to, GUIStyle.Red, width: 1);
GUI.DrawRectangle(spriteBatch, new Rectangle((int)from.X, (int)from.Y, 12, 12), Color.White, true);
GUI.DrawRectangle(spriteBatch, new Rectangle((int)to.X, (int)to.Y, 12, 12), Color.White, true);
GUI.DrawRectangle(spriteBatch, new Rectangle((int)from.X, (int)from.Y, 10, 10), Color.Blue, true);
GUI.DrawRectangle(spriteBatch, new Rectangle((int)to.X, (int)to.Y, 10, 10), GUI.Style.Red, true);
GUI.DrawRectangle(spriteBatch, new Rectangle((int)to.X, (int)to.Y, 10, 10), GUIStyle.Red, true);
GUI.DrawRectangle(spriteBatch, new Rectangle((int)front.X, (int)front.Y, 10, 10), Color.Yellow, true);
//Vector2 mainLimbFront = ConvertUnits.ToDisplayUnits(ragdoll.MainLimb.body.FarseerBody.GetWorldPoint(ragdoll.MainLimb.body.GetFrontLocal(MathHelper.ToRadians(limbParams.Orientation))));
@@ -1046,8 +1048,8 @@ namespace Barotrauma
//{
// width = (int)Math.Round(width / cam.Zoom);
//}
//GUI.DrawLine(spriteBatch, startPos, startPos + Vector2.Normalize(up) * size, GUI.Style.Red, width: width);
Color color = modifier.DamageMultiplier > 1 ? GUI.Style.Red : GUI.Style.Green;
//GUI.DrawLine(spriteBatch, startPos, startPos + Vector2.Normalize(up) * size, GUIStyle.Red, width: width);
Color color = modifier.DamageMultiplier > 1 ? GUIStyle.Red : GUIStyle.Green;
float size = ConvertUnits.ToDisplayUnits(body.GetSize().Length() / 2);
if (isScreenSpace)
{
@@ -1078,9 +1080,9 @@ namespace Barotrauma
{
wearable.Sprite.SourceRect = new Rectangle(CharacterInfo.CalculateOffset(sprite, wearable.SheetIndex.Value), sprite.SourceRect.Size);
}
else if (type == LimbType.Head && character.Info != null && character.Info.Head.SheetIndex.HasValue)
else if (type == LimbType.Head && character.Info != null)
{
wearable.Sprite.SourceRect = new Rectangle(CharacterInfo.CalculateOffset(sprite, character.Info.Head.SheetIndex.Value.ToPoint()), sprite.SourceRect.Size);
wearable.Sprite.SourceRect = new Rectangle(CharacterInfo.CalculateOffset(sprite, character.Info.Head.SheetIndex.ToPoint()), sprite.SourceRect.Size);
}
else
{
@@ -1134,11 +1136,11 @@ namespace Barotrauma
{
if (wearable.Type == WearableType.Hair)
{
wearableColor = character.Info.HairColor;
wearableColor = character.Info.Head.HairColor;
}
else if (wearable.Type == WearableType.Beard || wearable.Type == WearableType.Moustache)
{
wearableColor = character.Info.FacialHairColor;
wearableColor = character.Info.Head.FacialHairColor;
}
}
float scale = wearable.Scale;
@@ -1164,22 +1166,22 @@ namespace Barotrauma
wearable.Sprite.Draw(spriteBatch, new Vector2(body.DrawPosition.X, -body.DrawPosition.Y), finalColor, origin, rotation, scale, spriteEffect, depth);
}
private WearableSprite GetWearableSprite(WearableType type, bool random = false)
private WearableSprite GetWearableSprite(WearableType type)//, bool random = false)
{
var info = character.Info;
if (info == null) { return null; }
XElement element;
if (random)
ContentXElement element;
/*if (random)
{
element = info.FilterByTypeAndHeadID(info.FilterElementsByGenderAndRace(info.Wearables, info.Gender, info.Race), type, info.Head.HeadSpriteId)?.GetRandom(Rand.RandSync.ClientOnly);
element = info.FilterElements(info.Wearables, info.Head.Preset.TagSet)?.GetRandom(Rand.RandSync.ClientOnly);
}
else
{
element = info.FilterByTypeAndHeadID(info.FilterElementsByGenderAndRace(info.Wearables, info.Gender, info.Race), type, info.Head.HeadSpriteId)?.FirstOrDefault();
}
{*/
element = info.FilterElements(info.Wearables, info.Head.Preset.TagSet, type)?.FirstOrDefault();
//}
if (element != null)
{
return new WearableSprite(element.Element("sprite"), type);
return new WearableSprite(element.GetChildElement("sprite"), type);
}
return null;
}