WorldRenderer, replace foreach ActorsWithTraits with ApplyToActorsWithTrait. #18798.

This commit is contained in:
Vapre
2021-07-23 22:20:00 +02:00
committed by abcdefg30
parent 00356b8bbd
commit 83357af14c
2 changed files with 23 additions and 17 deletions

View File

@@ -427,7 +427,7 @@ namespace OpenRA
foreach (var a in actors.Values)
a.Tick();
ApplyToActorsWithTraitTimed<ITick>((Actor actor, ITick trait) => trait.Tick(actor), "Trait");
ApplyToActorsWithTraitTimed<ITick>((actor, trait) => trait.Tick(actor), "Trait");
effects.DoTimed(e => e.Tick(this), "Effect");
}
@@ -439,7 +439,7 @@ namespace OpenRA
// For things that want to update their render state once per tick, ignoring pause state
public void TickRender(WorldRenderer wr)
{
ApplyToActorsWithTraitTimed<ITickRender>((Actor actor, ITickRender trait) => trait.TickRender(wr, actor), "Render");
ApplyToActorsWithTraitTimed<ITickRender>((actor, trait) => trait.TickRender(wr, actor), "Render");
ScreenMap.TickRender();
}
@@ -503,6 +503,11 @@ namespace OpenRA
TraitDict.ApplyToActorsWithTraitTimed<T>(action, text);
}
public void ApplyToActorsWithTrait<T>(Action<Actor, T> action)
{
TraitDict.ApplyToActorsWithTrait<T>(action);
}
public IEnumerable<Actor> ActorsHavingTrait<T>()
{
return TraitDict.ActorsHavingTrait<T>();