Class ClientNameplateDisplay
Decides which overhead nameplates are up without being targeted: every NPC and every
other player inside their own chosen ranges, and the player's own. Driven from
Client.Update.
public sealed class ClientNameplateDisplay
- Inheritance
-
ClientNameplateDisplay
- Inherited Members
Remarks
Why this is not part of the nameplate layer. UITKNameplateLayer
answers rendering questions — how far, how many, is it behind a wall. Whether a character
deserves a nameplate at all is a gameplay question about who the viewer is and who they are
looking at, and it has to be asked of every character in view, including the ones whose
plates are currently hidden. That is this class, walking
BaseCharacter.ClientCharacters.
Ownership of a plate's visibility is split three ways, and the split is what keeps the three from fighting:
- UITKTarget turns the current target's plate on, and asks ShouldStayVisible(ICharacter) before turning it off again on clear. Without that ask, untargeting an NPC standing next to the player blinked its nameplate off for one sweep interval before this class put it back.
- UITKPetControl turns the player's own pet's plate on; the rule here agrees (an owned character that is not the player is always kept), so a sweep never undoes it.
- This class owns everything else: NPCs and other players by their two ranges, the local player by the own-name toggle. Any further "keep this name up" rule — party members, guild mates — belongs in Decide(bool, bool, bool, bool, float, float, float, bool) rather than in a second writer that would have to be reconciled with it.
Cost. One dictionary walk every SweepIntervalSeconds, a squared distance per NPC, a standing colour per visible plate, and a visibility flip only on a transition. The walk is deliberately not per frame: a nameplate appearing a fifth of a second after the player crosses the range is invisible, and the walk touches every character in view. Distances use a small hysteresis (ExitRangeMultiplier) so a character idling exactly on the boundary does not toggle every sweep.
Fields
ExitRangeMultiplier
A nameplate that is already up stays up until the character is this many times the range away. Five percent: a metre and a half at the default range, enough to absorb the jitter of two characters standing on the line and small enough to be unnoticed.
public const float ExitRangeMultiplier = 1.05
Field Value
SweepIntervalSeconds
Seconds between sweeps of the client character registry.
public const float SweepIntervalSeconds = 0.2
Field Value
Methods
ApplyGuildRowColor(ICharacter)
Colours a player's guild row: the friendly colour when they are in the local player's guild (the local player's own row included), the style's grey otherwise.
public static void ApplyGuildRowColor(ICharacter character)
Parameters
characterICharacterThe player whose plate to colour; pets are left alone, their row names an owner.
Remarks
Rewriting a row with the values it already has is a no-op on the plate, so the sweep can call this freely.
Decide(bool, bool, bool, bool, float, float, float, bool)
The visibility rule, as arithmetic on facts about one character.
public static bool Decide(bool isPlayer, bool isOwner, bool isTargeted, bool wasVisible, float sqrDistance, float npcRange, float playerRange, bool showOwnName)
Parameters
isPlayerboolWhether the character is a player character.
isOwnerboolWhether this client owns the character: the local player, or their pet.
isTargetedboolWhether the character is the local player's current target — hovered, or pinned to the target frame.
wasVisibleboolWhether the plate is currently up, which selects the exit distance.
sqrDistancefloatSquared distance from the local player, in metres squared.
npcRangefloatThe NPC nameplate range, in metres; zero or less means target only.
playerRangefloatThe other-player nameplate range, in metres; zero or less means target only.
showOwnNameboolWhether the player's own nameplate stays up.
Returns
- bool
True when the nameplate should be up.
Remarks
Static and free of Unity types so the truth table can be pinned by a plain unit test.
Initialize()
Subscribes to world entry and settings changes. Call during client startup.
public void Initialize()
MarkFor(FactionAllianceLevel)
The mark for a displayed standing.
public static NameplateMark MarkFor(FactionAllianceLevel level)
Parameters
levelFactionAllianceLevel
Returns
SameGuild(ICharacter, ICharacter)
Whether two characters belong to the same guild; no guild (ID 0) is nobody's guild.
public static bool SameGuild(ICharacter a, ICharacter b)
Parameters
aICharacterbICharacter
Returns
ShouldStayVisible(ICharacter)
Whether a character's nameplate should stay up when the target frame stops framing it.
public static bool ShouldStayVisible(ICharacter character)
Parameters
characterICharacterThe character being untargeted.
Returns
- bool
True to leave the plate up; false to let the target frame take it down.
Remarks
Answered from the same rule the sweep applies, so the target frame and the sweep can never disagree about a character that is both untargeted and in range. Without a live display the answer falls back to the pre-range behaviour: the player's own plate stays, everything else goes.
Shutdown()
Unsubscribes. Call during client teardown.
public void Shutdown()
Standing(ICharacter, ICharacter, out Color)
The standing colour and mark a viewer gives a character: one rule for the overhead plate and both target cards.
public static NameplateMark Standing(ICharacter viewer, ICharacter character, out Color tint)
Parameters
viewerICharacterThe local player.
characterICharacterThe character being drawn.
tintColorThe standing colour; white when either side has no faction.
Returns
- NameplateMark
The mark to draw, or None.
Remarks
The player's OWN standing is how a stranger sees them: red with crossed swords while their aggression is on (anyone outside their party and guild may fight them), the neutral colour and no mark while it is off. Their own PET acts under them (HarmRule.Principal), so it is red with crossed swords while their aggression is on — it may be fought too — and otherwise carries the friendly shield: it is on their side. Everyone else is the viewer's displayed standing toward them.
Tick()
Runs one sweep when the interval has elapsed. Call once per frame.
public void Tick()