Skip to content

Commit

Permalink
FIX: hide nameplates when leaving char select
Browse files Browse the repository at this point in the history
  • Loading branch information
shnok committed Nov 13, 2024
1 parent 2f7dea9 commit ecbab8c
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 6 deletions.
1 change: 1 addition & 0 deletions l2-unity-todo.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Nature renderer for deco layer

DONE

FIX: hide nameplates when leaving char select
chat window message limit, scroll limit, message filtering, message history
FIX: Bug in anim when no weapon equiped
FIX: if click to move during the FIRST attack animation after log-in or teleport, cant move
Expand Down
21 changes: 16 additions & 5 deletions l2-unity/Assets/Scripts/UI/Game/Nameplate/NameplatesManagerBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ protected bool ShouldCreateNameplateForEntity(ObjectData objectData)
protected void ProcessNameplateVisibility()
{
var nameplateIds = nameplates.Keys.ToList();
foreach (var id in nameplateIds)
foreach (int id in nameplateIds)
{
if (nameplates.TryGetValue(id, out var nameplate))
{
Expand All @@ -107,9 +107,20 @@ protected void ProcessNameplateVisibility()
}
}

protected void ClearNameplates()
{
foreach (int id in nameplates.Keys.ToList())
{
if (nameplates.TryGetValue(id, out var nameplate))
{
RemoveNameplate(id);
}
}
}

protected void UpdateNameplateSystem()
{
foreach (var nameplate in nameplates.Values)
foreach (Nameplate nameplate in nameplates.Values)
{
if (nameplate.Target == null) continue;

Expand Down Expand Up @@ -155,8 +166,8 @@ protected virtual bool IsNameplateVisible(Transform target)
// Factory methods for creating nameplates
protected Nameplate CreateNameplate(Entity entity)
{
var element = nameplateTemplate.Instantiate()[0];
var nameplate = new Nameplate(
VisualElement element = nameplateTemplate.Instantiate()[0];
Nameplate nameplate = new Nameplate(
element,
element.Q<Label>("EntityName"),
element.Q<Label>("EntityTitle"),
Expand All @@ -168,7 +179,7 @@ protected Nameplate CreateNameplate(Entity entity)

public void RemoveNameplate(int id)
{
if (nameplates.TryRemove(id, out var removed))
if (nameplates.TryRemove(id, out Nameplate removed))
{
rootElement.Remove(removed.NameplateEle);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,11 @@ private void Awake()

private void FixedUpdate()
{
if (!IsSystemReady()) return;
if (!IsSystemReady())
{
ClearNameplates();
return;
}

ScanForEntities();
ProcessNameplateVisibility();
Expand Down

0 comments on commit ecbab8c

Please sign in to comment.