Remove Do() and replace with foreach()
This commit is contained in:
@@ -38,12 +38,6 @@ namespace OpenRA
|
|||||||
catch { return def; }
|
catch { return def; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Do<T>(this IEnumerable<T> e, Action<T> fn)
|
|
||||||
{
|
|
||||||
foreach (var ee in e)
|
|
||||||
fn(ee);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Lazy<T> Lazy<T>(Func<T> p) { return new Lazy<T>(p); }
|
public static Lazy<T> Lazy<T>(Func<T> p) { return new Lazy<T>(p); }
|
||||||
|
|
||||||
public static IEnumerable<string> GetNamespaces(this Assembly a)
|
public static IEnumerable<string> GetNamespaces(this Assembly a)
|
||||||
|
|||||||
@@ -85,7 +85,8 @@ namespace OpenRA.Mods.Cnc.Graphics
|
|||||||
if (!cache.Any() || length != cachedLength || pos != cachedPos)
|
if (!cache.Any() || length != cachedLength || pos != cachedPos)
|
||||||
cache = GenerateRenderables(wr);
|
cache = GenerateRenderables(wr);
|
||||||
|
|
||||||
cache.Do(c => c.Render(wr));
|
foreach (var renderable in cache)
|
||||||
|
renderable.Render(wr);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Rectangle ScreenBounds(WorldRenderer wr) { return Rectangle.Empty; }
|
public Rectangle ScreenBounds(WorldRenderer wr) { return Rectangle.Empty; }
|
||||||
|
|||||||
@@ -172,13 +172,13 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
|
|
||||||
if (health.DamageState == DamageState.Undamaged)
|
if (health.DamageState == DamageState.Undamaged)
|
||||||
{
|
{
|
||||||
Repairers.Do(r =>
|
foreach (var repairer in Repairers)
|
||||||
{
|
{
|
||||||
if (r == self.Owner)
|
if (repairer == self.Owner)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
r.PlayerActor.TraitOrDefault<PlayerExperience>()?.GiveExperience(Info.PlayerExperience);
|
repairer.PlayerActor.TraitOrDefault<PlayerExperience>()?.GiveExperience(Info.PlayerExperience);
|
||||||
});
|
}
|
||||||
|
|
||||||
Repairers.Clear();
|
Repairers.Clear();
|
||||||
RepairActive = false;
|
RepairActive = false;
|
||||||
|
|||||||
@@ -95,14 +95,16 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Add buildables that have a build limit set and are not already in the list
|
// Add buildables that have a build limit set and are not already in the list
|
||||||
player.World.ActorsWithTrait<Buildable>()
|
var buildables = player.World.ActorsWithTrait<Buildable>()
|
||||||
.Where(a =>
|
.Where(a =>
|
||||||
a.Actor.Owner == player &&
|
a.Actor.Owner == player &&
|
||||||
a.Actor.IsInWorld &&
|
a.Actor.IsInWorld &&
|
||||||
!a.Actor.IsDead &&
|
!a.Actor.IsDead &&
|
||||||
!ret.ContainsKey(a.Actor.Info.Name) &&
|
!ret.ContainsKey(a.Actor.Info.Name) &&
|
||||||
a.Actor.Info.TraitInfo<BuildableInfo>().BuildLimit > 0)
|
a.Actor.Info.TraitInfo<BuildableInfo>().BuildLimit > 0);
|
||||||
.Do(b => ret[b.Actor.Info.Name].Add(b.Actor));
|
|
||||||
|
foreach (var buildable in buildables)
|
||||||
|
ret[buildable.Actor.Info.Name].Add(buildable.Actor);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -343,7 +343,9 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
text: "Delete all maps on this page?",
|
text: "Delete all maps on this page?",
|
||||||
onConfirm: () =>
|
onConfirm: () =>
|
||||||
{
|
{
|
||||||
maps.Do(m => DeleteMap(m));
|
foreach (var map in maps)
|
||||||
|
DeleteMap(map);
|
||||||
|
|
||||||
after?.Invoke(Game.ModData.MapCache.ChooseInitialMap(null, Game.CosmeticRandom));
|
after?.Invoke(Game.ModData.MapCache.ChooseInitialMap(null, Game.CosmeticRandom));
|
||||||
},
|
},
|
||||||
confirmText: "Delete",
|
confirmText: "Delete",
|
||||||
|
|||||||
@@ -463,7 +463,9 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
text: $"Delete {list.Count} replays?",
|
text: $"Delete {list.Count} replays?",
|
||||||
onConfirm: () =>
|
onConfirm: () =>
|
||||||
{
|
{
|
||||||
list.ForEach(DeleteReplay);
|
foreach (var replayMetadata in list)
|
||||||
|
DeleteReplay(replayMetadata);
|
||||||
|
|
||||||
if (selectedReplay == null)
|
if (selectedReplay == null)
|
||||||
SelectFirstVisibleReplay();
|
SelectFirstVisibleReplay();
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user