Skip to content

Commit c97ab51

Browse files
authored
fix(2121): hide guild name if name hidden, cleanup code (AscensionGameDev#2139)
1 parent 6a3b52e commit c97ab51

File tree

3 files changed

+29
-52
lines changed

3 files changed

+29
-52
lines changed

Intersect.Client/Entities/Entity.cs

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ public virtual int SpriteFrames
337337
}
338338
}
339339

340-
public IMapInstance MapInstance => Maps.MapInstance.Get(MapId);
340+
public IMapInstance? MapInstance => Maps.MapInstance.Get(MapId);
341341

342342
public virtual Guid MapId { get; set; }
343343

@@ -922,26 +922,7 @@ public virtual int CalculateAttackTime()
922922
/// <summary>
923923
/// Returns whether this entity is Stealthed or not.
924924
/// </summary>
925-
public virtual bool IsStealthed
926-
{
927-
get
928-
{
929-
if (this == Globals.Me)
930-
{
931-
return false;
932-
}
933-
934-
for (var n = 0; n < Status.Count; n++)
935-
{
936-
if (Status[n].Type == SpellEffect.Stealth)
937-
{
938-
return true;
939-
}
940-
}
941-
942-
return false;
943-
}
944-
}
925+
public virtual bool IsStealthed => this != Globals.Me && Status.Any(t => t.Type == SpellEffect.Stealth);
945926

946927
/// <summary>
947928
/// Returns whether this entity should be drawn.

Intersect.Client/Entities/Player.cs

Lines changed: 23 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2468,58 +2468,52 @@ private void DrawNameAndLabels(Color textColor, Color borderColor, Color backgro
24682468
DrawGuildName(textColor, borderColor, backgroundColor);
24692469
}
24702470

2471-
public virtual void DrawGuildName(Color textColor, Color borderColor = null, Color backgroundColor = null)
2471+
public virtual void DrawGuildName(Color textColor, Color? borderColor = default, Color? backgroundColor = default)
24722472
{
2473-
if (HideName || Guild == null || Guild.Trim().Length == 0 || !Options.Instance.Guild.ShowGuildNameTagsOverMembers)
2473+
var guildLabel = Guild?.Trim();
2474+
if (!ShouldDrawName || string.IsNullOrWhiteSpace(guildLabel) || !Options.Instance.Guild.ShowGuildNameTagsOverMembers)
24742475
{
24752476
return;
24762477
}
24772478

2478-
if (borderColor == null)
2479+
if (IsStealthed && !IsInMyParty(Globals.Me))
24792480
{
2480-
borderColor = Color.Transparent;
2481-
}
2482-
2483-
if (backgroundColor == null)
2484-
{
2485-
backgroundColor = Color.Transparent;
2486-
}
2487-
2488-
//Check for stealth amoungst status effects.
2489-
for (var n = 0; n < Status.Count; n++)
2490-
{
2491-
//If unit is stealthed, don't render unless the entity is the player.
2492-
if (Status[n].Type == SpellEffect.Stealth)
2493-
{
2494-
if (this != Globals.Me && !(this is Player player && Globals.Me.IsInMyParty(player)))
2495-
{
2496-
return;
2497-
}
2498-
}
2481+
// Do not render if the party is stealthed and not in the local player's party
2482+
return;
24992483
}
25002484

2501-
var map = MapInstance;
2502-
if (map == null)
2485+
if (MapInstance == default)
25032486
{
25042487
return;
25052488
}
25062489

2507-
var textSize = Graphics.Renderer.MeasureText(Guild, Graphics.EntityNameFont, 1);
2490+
var textSize = Graphics.Renderer.MeasureText(guildLabel, Graphics.EntityNameFont, 1);
25082491

25092492
var x = (int)Math.Ceiling(Origin.X);
25102493
var y = GetLabelLocation(LabelType.Guild);
25112494

2495+
backgroundColor ??= Color.Transparent;
25122496
if (backgroundColor != Color.Transparent)
25132497
{
25142498
Graphics.DrawGameTexture(
2515-
Graphics.Renderer.GetWhiteTexture(), new FloatRect(0, 0, 1, 1),
2516-
new FloatRect(x - textSize.X / 2f - 4, y, textSize.X + 8, textSize.Y), backgroundColor
2499+
Graphics.Renderer.GetWhiteTexture(),
2500+
new FloatRect(0, 0, 1, 1),
2501+
new FloatRect(x - textSize.X / 2f - 4, y, textSize.X + 8, textSize.Y),
2502+
backgroundColor
25172503
);
25182504
}
25192505

2506+
borderColor ??= Color.Transparent;
25202507
Graphics.Renderer.DrawString(
2521-
Guild, Graphics.EntityNameFont, x - (int)Math.Ceiling(textSize.X / 2f), (int)y, 1,
2522-
Color.FromArgb(textColor.ToArgb()), true, null, Color.FromArgb(borderColor.ToArgb())
2508+
guildLabel,
2509+
Graphics.EntityNameFont,
2510+
x - (int)Math.Ceiling(textSize.X / 2f),
2511+
(int)y,
2512+
1,
2513+
Color.FromArgb(textColor.ToArgb()),
2514+
true,
2515+
default,
2516+
Color.FromArgb(borderColor.ToArgb())
25232517
);
25242518
}
25252519

Intersect.sln.DotSettings

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,7 @@
55
<s:Boolean x:Key="/Default/UserDictionary/Words/=Migratable/@EntryIndexedValue">True</s:Boolean>
66
<s:Boolean x:Key="/Default/UserDictionary/Words/=Paperdoll/@EntryIndexedValue">True</s:Boolean>
77
<s:Boolean x:Key="/Default/UserDictionary/Words/=plaindata/@EntryIndexedValue">True</s:Boolean>
8-
<s:Boolean x:Key="/Default/UserDictionary/Words/=randomblob/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
9-
8+
<s:Boolean x:Key="/Default/UserDictionary/Words/=pname/@EntryIndexedValue">True</s:Boolean>
9+
<s:Boolean x:Key="/Default/UserDictionary/Words/=randomblob/@EntryIndexedValue">True</s:Boolean>
10+
<s:Boolean x:Key="/Default/UserDictionary/Words/=Renderable/@EntryIndexedValue">True</s:Boolean>
11+
<s:Boolean x:Key="/Default/UserDictionary/Words/=stealthed/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>

0 commit comments

Comments
 (0)