v1.7.7.0 (Winter Update 2024)
This commit is contained in:
@@ -11,17 +11,15 @@ namespace Barotrauma
|
||||
{
|
||||
partial class CharacterHUD
|
||||
{
|
||||
const float BossHealthBarDuration = 120.0f;
|
||||
|
||||
abstract class BossProgressBar
|
||||
abstract class ProgressBar
|
||||
{
|
||||
public float FadeTimer;
|
||||
|
||||
public readonly GUIComponent TopContainer;
|
||||
public readonly GUIComponent SideContainer;
|
||||
|
||||
public readonly GUIProgressBar TopHealthBar;
|
||||
public readonly GUIProgressBar SideHealthBar;
|
||||
public readonly GUIProgressBar TopBar;
|
||||
public readonly GUIProgressBar SideBar;
|
||||
|
||||
public abstract bool Completed { get; }
|
||||
|
||||
@@ -33,9 +31,9 @@ namespace Barotrauma
|
||||
|
||||
public abstract Color Color { get; }
|
||||
|
||||
public BossProgressBar(LocalizedString label)
|
||||
public ProgressBar(LocalizedString label, float fadeTimer = 120.0f)
|
||||
{
|
||||
FadeTimer = BossHealthBarDuration;
|
||||
FadeTimer = fadeTimer;
|
||||
|
||||
TopContainer = new GUILayoutGroup(new RectTransform(new Vector2(0.18f, 0.03f), HUDFrame.RectTransform, Anchor.TopCenter)
|
||||
{
|
||||
@@ -43,25 +41,25 @@ namespace Barotrauma
|
||||
RelativeOffset = new Vector2(0.0f, 0.01f)
|
||||
}, isHorizontal: false, childAnchor: Anchor.TopCenter);
|
||||
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.4f), TopContainer.RectTransform), label, textAlignment: Alignment.Center, textColor: GUIStyle.Red);
|
||||
TopHealthBar = new GUIProgressBar(new RectTransform(new Vector2(1.0f, 0.6f), TopContainer.RectTransform)
|
||||
TopBar = 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 = GUIStyle.Red
|
||||
};
|
||||
CreateNumberText(TopHealthBar);
|
||||
CreateNumberText(TopBar);
|
||||
|
||||
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), label, textAlignment: Alignment.CenterRight, textColor: GUIStyle.Red);
|
||||
SideHealthBar = new GUIProgressBar(new RectTransform(new Vector2(1.0f, 0.7f), SideContainer.RectTransform), barSize: 0.0f, style: "CharacterHealthBar")
|
||||
SideBar = new GUIProgressBar(new RectTransform(new Vector2(1.0f, 0.7f), SideContainer.RectTransform), barSize: 0.0f, style: "CharacterHealthBar")
|
||||
{
|
||||
Color = GUIStyle.Red
|
||||
};
|
||||
CreateNumberText(SideHealthBar);
|
||||
CreateNumberText(SideBar);
|
||||
|
||||
TopContainer.Visible = SideContainer.Visible = false;
|
||||
TopContainer.CanBeFocused = false;
|
||||
@@ -88,7 +86,7 @@ namespace Barotrauma
|
||||
public abstract bool IsDuplicate(object targetObject);
|
||||
}
|
||||
|
||||
class BossHealthBar : BossProgressBar
|
||||
class HealthBar : ProgressBar
|
||||
{
|
||||
public readonly Character Character;
|
||||
|
||||
@@ -104,7 +102,7 @@ namespace Barotrauma
|
||||
|
||||
public override string NumberToDisplay => string.Empty;
|
||||
|
||||
public BossHealthBar(Character character) : base(character.DisplayName)
|
||||
public HealthBar(Character character) : base(character.DisplayName)
|
||||
{
|
||||
Character = character;
|
||||
}
|
||||
@@ -115,7 +113,7 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
class MissionProgressBar : BossProgressBar
|
||||
class MissionProgressBar : ProgressBar
|
||||
{
|
||||
public readonly Mission Mission;
|
||||
|
||||
@@ -125,13 +123,13 @@ namespace Barotrauma
|
||||
|
||||
public override bool Interrupted => Mission.Failed || GameMain.GameSession?.Missions == null || !GameMain.GameSession.Missions.Contains(Mission);
|
||||
|
||||
public override Color Color => GUIStyle.Red;
|
||||
public override Color Color => Mission.Prefab.ProgressBarColor;
|
||||
|
||||
public override string NumberToDisplay => Mission.Prefab.ShowProgressInNumbers ?
|
||||
$"{Mission.State}/{Mission.Prefab.MaxProgressState}" :
|
||||
string.Empty;
|
||||
|
||||
public MissionProgressBar(Mission mission) : base(mission.Prefab.ProgressBarLabel)
|
||||
public MissionProgressBar(Mission mission) : base(mission.Prefab.ProgressBarLabel, fadeTimer: float.PositiveInfinity)
|
||||
{
|
||||
Mission = mission;
|
||||
}
|
||||
@@ -150,7 +148,7 @@ namespace Barotrauma
|
||||
private static readonly List<Item> brokenItems = new List<Item>();
|
||||
private static float brokenItemsCheckTimer;
|
||||
|
||||
private static readonly List<BossProgressBar> bossProgressBars = new List<BossProgressBar>();
|
||||
private static readonly List<ProgressBar> bossProgressBars = new List<ProgressBar>();
|
||||
|
||||
private static readonly Dictionary<Identifier, LocalizedString> cachedHudTexts = new Dictionary<Identifier, LocalizedString>();
|
||||
private static LanguageIdentifier cachedHudTextLanguage = LanguageIdentifier.None;
|
||||
@@ -564,7 +562,7 @@ namespace Barotrauma
|
||||
float alpha = MathHelper.Lerp(0.3f, 1.0f, distFactor);
|
||||
GUI.DrawIndicator(
|
||||
spriteBatch,
|
||||
entity.WorldPosition,
|
||||
entity.DrawPosition,
|
||||
cam,
|
||||
visibleRange,
|
||||
style.GetDefaultSprite(),
|
||||
@@ -592,7 +590,7 @@ namespace Barotrauma
|
||||
if (Vector2.DistanceSquared(character.Position, item.Position) > 500f * 500f) { continue; }
|
||||
var body = Submarine.CheckVisibility(character.SimPosition, item.SimPosition, ignoreLevel: true);
|
||||
if (body != null && body.UserData as Item != item) { continue; }
|
||||
GUI.DrawIndicator(spriteBatch, item.WorldPosition + new Vector2(0f, item.RectHeight * 0.65f), cam, new Range<float>(-100f, 500.0f), item.IconStyle.GetDefaultSprite(), item.IconStyle.Color, createOffset: false);
|
||||
GUI.DrawIndicator(spriteBatch, item.DrawPosition + new Vector2(0f, item.RectHeight * 0.65f), cam, new Range<float>(-100f, 500.0f), item.IconStyle.GetDefaultSprite(), item.IconStyle.Color, createOffset: false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -773,7 +771,7 @@ namespace Barotrauma
|
||||
GUIStyle.Green, Color.Black, 2, GUIStyle.SmallFont);
|
||||
textPos.Y += textSize.Y;
|
||||
}
|
||||
if (!character.FocusedCharacter.CustomInteractHUDText.IsNullOrEmpty() && character.FocusedCharacter.AllowCustomInteract)
|
||||
if (character.FocusedCharacter.ShouldShowCustomInteractText)
|
||||
{
|
||||
GUI.DrawString(spriteBatch, textPos, character.FocusedCharacter.CustomInteractHUDText, GUIStyle.Green, Color.Black, 2, GUIStyle.SmallFont);
|
||||
textPos.Y += textSize.Y;
|
||||
@@ -784,7 +782,7 @@ namespace Barotrauma
|
||||
{
|
||||
if (character == null || character.IsDead || character.Removed) { return; }
|
||||
if (bossProgressBars.Any(b => b.IsDuplicate(character))) { return; }
|
||||
AddBossProgressBar(new BossHealthBar(character));
|
||||
AddBossProgressBar(new HealthBar(character));
|
||||
}
|
||||
|
||||
public static void ShowMissionProgressBar(Mission mission)
|
||||
@@ -803,14 +801,14 @@ namespace Barotrauma
|
||||
bossProgressBars.Clear();
|
||||
}
|
||||
|
||||
private static void RemoveBossProgressBar(BossProgressBar progressBar)
|
||||
private static void RemoveBossProgressBar(ProgressBar progressBar)
|
||||
{
|
||||
progressBar.SideContainer.Parent?.RemoveChild(progressBar.SideContainer);
|
||||
progressBar.TopContainer.Parent?.RemoveChild(progressBar.TopContainer);
|
||||
bossProgressBars.Remove(progressBar);
|
||||
}
|
||||
|
||||
private static void AddBossProgressBar(BossProgressBar progressBar)
|
||||
private static void AddBossProgressBar(ProgressBar progressBar)
|
||||
{
|
||||
var healthBarMode = GameMain.NetworkMember?.ServerSettings.ShowEnemyHealthBars ?? GameSettings.CurrentConfig.ShowEnemyHealthBars;
|
||||
if (healthBarMode == EnemyHealthBarMode.HideAll)
|
||||
@@ -819,10 +817,10 @@ namespace Barotrauma
|
||||
}
|
||||
if (bossProgressBars.Count > 5)
|
||||
{
|
||||
BossProgressBar oldestHealthBar = bossProgressBars.First();
|
||||
ProgressBar oldestHealthBar = bossProgressBars.First();
|
||||
foreach (var bar in bossProgressBars)
|
||||
{
|
||||
if (bar.TopHealthBar.BarSize < oldestHealthBar.TopHealthBar.BarSize)
|
||||
if (bar.TopBar.BarSize < oldestHealthBar.TopBar.BarSize)
|
||||
{
|
||||
oldestHealthBar = bar;
|
||||
}
|
||||
@@ -850,7 +848,7 @@ namespace Barotrauma
|
||||
bossHealthBar.TopContainer.Visible = showTopBar;
|
||||
bossHealthBar.SideContainer.Visible = !bossHealthBar.TopContainer.Visible;
|
||||
|
||||
bossHealthBar.TopHealthBar.BarSize = bossHealthBar.SideHealthBar.BarSize = bossHealthBar.State;
|
||||
bossHealthBar.TopBar.BarSize = bossHealthBar.SideBar.BarSize = bossHealthBar.State;
|
||||
float alpha = Math.Min(bossHealthBar.FadeTimer, 1.0f);
|
||||
|
||||
if (bossHealthBar.TopContainer.Visible)
|
||||
@@ -862,7 +860,7 @@ namespace Barotrauma
|
||||
SetColor(bossHealthBar, bossHealthBar.SideContainer, alpha);
|
||||
}
|
||||
|
||||
static void SetColor(BossProgressBar bossHealthBar, GUIComponent container, float alpha)
|
||||
static void SetColor(ProgressBar bossHealthBar, GUIComponent container, float alpha)
|
||||
{
|
||||
foreach (var component in container.GetAllChildren())
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user