Remove Do() and replace with foreach()

This commit is contained in:
tomas
2022-08-19 22:15:00 +02:00
committed by abcdefg30
parent 92478a219e
commit ac623d784a
6 changed files with 22 additions and 21 deletions

View File

@@ -172,13 +172,13 @@ namespace OpenRA.Mods.Common.Traits
if (health.DamageState == DamageState.Undamaged)
{
Repairers.Do(r =>
foreach (var repairer in Repairers)
{
if (r == self.Owner)
if (repairer == self.Owner)
return;
r.PlayerActor.TraitOrDefault<PlayerExperience>()?.GiveExperience(Info.PlayerExperience);
});
repairer.PlayerActor.TraitOrDefault<PlayerExperience>()?.GiveExperience(Info.PlayerExperience);
}
Repairers.Clear();
RepairActive = false;

View File

@@ -95,14 +95,16 @@ namespace OpenRA.Mods.Common.Traits
}
// Add buildables that have a build limit set and are not already in the list
player.World.ActorsWithTrait<Buildable>()
.Where(a =>
a.Actor.Owner == player &&
a.Actor.IsInWorld &&
!a.Actor.IsDead &&
!ret.ContainsKey(a.Actor.Info.Name) &&
a.Actor.Info.TraitInfo<BuildableInfo>().BuildLimit > 0)
.Do(b => ret[b.Actor.Info.Name].Add(b.Actor));
var buildables = player.World.ActorsWithTrait<Buildable>()
.Where(a =>
a.Actor.Owner == player &&
a.Actor.IsInWorld &&
!a.Actor.IsDead &&
!ret.ContainsKey(a.Actor.Info.Name) &&
a.Actor.Info.TraitInfo<BuildableInfo>().BuildLimit > 0);
foreach (var buildable in buildables)
ret[buildable.Actor.Info.Name].Add(buildable.Actor);
return ret;
}

View File

@@ -343,7 +343,9 @@ namespace OpenRA.Mods.Common.Widgets.Logic
text: "Delete all maps on this page?",
onConfirm: () =>
{
maps.Do(m => DeleteMap(m));
foreach (var map in maps)
DeleteMap(map);
after?.Invoke(Game.ModData.MapCache.ChooseInitialMap(null, Game.CosmeticRandom));
},
confirmText: "Delete",

View File

@@ -463,7 +463,9 @@ namespace OpenRA.Mods.Common.Widgets.Logic
text: $"Delete {list.Count} replays?",
onConfirm: () =>
{
list.ForEach(DeleteReplay);
foreach (var replayMetadata in list)
DeleteReplay(replayMetadata);
if (selectedReplay == null)
SelectFirstVisibleReplay();
},