In RemoveCellsFromPlayerShroud, don't call RemoveSource unless required.

Since AddCellsToPlayerShroud only adds for players with a valid relationship, we can skip a dictionary lookup in RemoveSource by only attempting the remove if the relationship check passes as well.
This commit is contained in:
RoosterDragon
2024-10-02 19:32:03 +01:00
committed by Gustas
parent d010157611
commit 86b9227577
4 changed files with 36 additions and 10 deletions

View File

@@ -44,11 +44,19 @@ namespace OpenRA.Mods.Common.Effects
void AddCellsToPlayerShroud(Player p, PPos[] uv)
{
if (validStances.HasRelationship(player.RelationshipWith(p)))
p.Shroud.AddSource(this, sourceType, uv);
if (!validStances.HasRelationship(player.RelationshipWith(p)))
return;
p.Shroud.AddSource(this, sourceType, uv);
}
void RemoveCellsFromPlayerShroud(Player p) { p.Shroud.RemoveSource(this); }
void RemoveCellsFromPlayerShroud(Player p)
{
if (!validStances.HasRelationship(player.RelationshipWith(p)))
return;
p.Shroud.RemoveSource(this);
}
PPos[] ProjectedCells(World world)
{