Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -253,5 +253,11 @@ public List<NpcContainer> GetVisibleNpcs()

return visibleNpcs;
}

public IEnumerable<NpcContainer> GetAllNpcContainers()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function is never called. Remove if unused (Especially as it can be a performance bottleneck).

{
for (var i = 0; i < _count; i++)
yield return _loaders[i].Container;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,10 @@ public List<NpcContainer> GetVisibleNpcs()
{
return _npcDomain.GetVisibleNpcs();
}

public IEnumerable<NpcContainer> GetAllNpcContainers()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function is never called. Remove if unused (Especially as it can be a performance bottleneck).

{
return _npcDomain.GetAllNpcContainers();
}
}
}
18 changes: 18 additions & 0 deletions Assets/Gothic-Core/Scripts/Services/Npc/NpcRoutineService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,25 @@ public bool CalculateCurrentRoutine(NpcInstance npc)
}
npcProps.RoutineCurrent = newRoutine;

if (changed)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing line of code. Good finding. :-)

_npcMeshCullingService.NotifyNpcRoutineChanged(npc.GetUserData());

return changed;
}

/// <summary>
/// Re-evaluates the time-based routine for all NPCs. Culled NPCs whose routine changed
/// will have their culling sphere moved to the new waypoint via NotifyNpcRoutineChanged.
/// Call this after a time skip so off-screen NPCs appear at their correct schedule position.
/// </summary>
public void RecalculateAllNpcRoutines()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function is never called. Remove if unused (Especially as it can be a performance bottleneck).

{
foreach (var container in _npcMeshCullingService.GetAllNpcContainers())
{
if (container?.Props?.Routines == null || container.Props.Routines.Count == 0)
continue;
CalculateCurrentRoutine(container.Instance);
}
}
}
}