diff --git a/OpenRA.FileFormats/Exts.cs b/OpenRA.FileFormats/Exts.cs index 8cc5ec979e..d7d6b499d9 100755 --- a/OpenRA.FileFormats/Exts.cs +++ b/OpenRA.FileFormats/Exts.cs @@ -35,6 +35,8 @@ namespace OpenRA fn(ee); } + public static Lazy Lazy(Func p) { return new Lazy(p); } + public static IEnumerable GetNamespaces(this Assembly a) { return a.GetTypes().Select(t => t.Namespace).Distinct().Where(n => n != null); diff --git a/OpenRA.FileFormats/OpenRA.FileFormats.csproj b/OpenRA.FileFormats/OpenRA.FileFormats.csproj index 180ff26069..a7c51d8e76 100644 --- a/OpenRA.FileFormats/OpenRA.FileFormats.csproj +++ b/OpenRA.FileFormats/OpenRA.FileFormats.csproj @@ -113,7 +113,6 @@ - diff --git a/OpenRA.FileFormats/Platform.cs b/OpenRA.FileFormats/Platform.cs index 16c7952df1..ba07eb512b 100644 --- a/OpenRA.FileFormats/Platform.cs +++ b/OpenRA.FileFormats/Platform.cs @@ -22,7 +22,7 @@ namespace OpenRA { public static PlatformType CurrentPlatform { get { return currentPlatform.Value; } } - static OpenRA.FileFormats.Lazy currentPlatform = Lazy.New((Func)GetCurrentPlatform); + static Lazy currentPlatform = new Lazy(GetCurrentPlatform); static PlatformType GetCurrentPlatform() { diff --git a/OpenRA.FileFormats/Primitives/Lazy.cs b/OpenRA.FileFormats/Primitives/Lazy.cs deleted file mode 100644 index c21343ff84..0000000000 --- a/OpenRA.FileFormats/Primitives/Lazy.cs +++ /dev/null @@ -1,48 +0,0 @@ -#region Copyright & License Information -/* - * Copyright 2007-2011 The OpenRA Developers (see AUTHORS) - * This file is part of OpenRA, which is free software. It is made - * available to you under the terms of the GNU General Public License - * as published by the Free Software Foundation. For more information, - * see COPYING. - */ -#endregion - -using System; - -namespace OpenRA.FileFormats -{ - public class Lazy - { - Func p; - T value; - - public Lazy(Func p) - { - if (p == null) - throw new ArgumentNullException(); - - this.p = p; - } - - public T Value - { - get - { - if (p == null) - return value; - - value = p(); - p = null; - return value; - } - } - - public T Force() { return Value; } - } - - public static class Lazy - { - public static Lazy New(Func p) { return new Lazy(p); } - } -} diff --git a/OpenRA.Game/Actor.cs b/OpenRA.Game/Actor.cs index b1ef111b33..0af70a2b15 100755 --- a/OpenRA.Game/Actor.cs +++ b/OpenRA.Game/Actor.cs @@ -24,12 +24,12 @@ namespace OpenRA public readonly World World; public readonly uint ActorID; - public OpenRA.FileFormats.Lazy Bounds; + public Lazy Bounds; - OpenRA.FileFormats.Lazy occupySpace; - OpenRA.FileFormats.Lazy facing; - OpenRA.FileFormats.Lazy health; - OpenRA.FileFormats.Lazy effectiveOwner; + Lazy occupySpace; + Lazy facing; + Lazy health; + Lazy effectiveOwner; public IOccupySpace OccupiesSpace { get { return occupySpace.Value; } } public IEffectiveOwner EffectiveOwner { get { return effectiveOwner.Value; } } @@ -62,7 +62,7 @@ namespace OpenRA if (initDict.Contains()) Owner = init.Get(); - occupySpace = Lazy.New(() => TraitOrDefault()); + occupySpace = Exts.Lazy(() => TraitOrDefault()); if (name != null) { @@ -74,14 +74,14 @@ namespace OpenRA AddTrait(trait.Create(init)); } - facing = Lazy.New(() => TraitOrDefault()); - health = Lazy.New(() => TraitOrDefault()); - effectiveOwner = Lazy.New(() => TraitOrDefault()); + facing = Exts.Lazy(() => TraitOrDefault()); + health = Exts.Lazy(() => TraitOrDefault()); + effectiveOwner = Exts.Lazy(() => TraitOrDefault()); applyIRender = (x, wr) => x.Render(this, wr); applyRenderModifier = (m, p, wr) => p.ModifyRender(this, wr, m); - Bounds = Lazy.New(() => + Bounds = Exts.Lazy(() => { var si = Info.Traits.GetOrDefault(); var size = (si != null && si.Bounds != null) ? new int2(si.Bounds[0], si.Bounds[1]) : diff --git a/OpenRA.Game/GameRules/SoundInfo.cs b/OpenRA.Game/GameRules/SoundInfo.cs index dcfde842ab..d7e923ec1d 100644 --- a/OpenRA.Game/GameRules/SoundInfo.cs +++ b/OpenRA.Game/GameRules/SoundInfo.cs @@ -8,6 +8,7 @@ */ #endregion +using System; using System.Collections.Generic; using System.Linq; using OpenRA.FileFormats; @@ -34,8 +35,8 @@ namespace OpenRA.GameRules : new Dictionary(); } - public readonly OpenRA.FileFormats.Lazy> VoicePools; - public readonly OpenRA.FileFormats.Lazy> NotificationsPools; + public readonly Lazy> VoicePools; + public readonly Lazy> NotificationsPools; public SoundInfo( MiniYaml y ) { @@ -45,8 +46,8 @@ namespace OpenRA.GameRules Voices = Load(y, "Voices"); Notifications = Load(y, "Notifications"); - VoicePools = Lazy.New(() => Voices.ToDictionary( a => a.Key, a => new SoundPool(a.Value) )); - NotificationsPools = Lazy.New(() => Notifications.ToDictionary( a => a.Key, a => new SoundPool(a.Value) )); + VoicePools = Exts.Lazy(() => Voices.ToDictionary(a => a.Key, a => new SoundPool(a.Value))); + NotificationsPools = Exts.Lazy(() => Notifications.ToDictionary( a => a.Key, a => new SoundPool(a.Value) )); } } diff --git a/OpenRA.Game/Graphics/WorldRenderer.cs b/OpenRA.Game/Graphics/WorldRenderer.cs index dbbf6389ab..d84b9a3841 100644 --- a/OpenRA.Game/Graphics/WorldRenderer.cs +++ b/OpenRA.Game/Graphics/WorldRenderer.cs @@ -39,7 +39,7 @@ namespace OpenRA.Graphics internal readonly TerrainRenderer terrainRenderer; internal readonly HardwarePalette palette; internal Cache palettes; - OpenRA.FileFormats.Lazy devTrait; + Lazy devTrait; internal WorldRenderer(World world) { @@ -56,7 +56,7 @@ namespace OpenRA.Graphics Theater = new Theater(world.TileSet); terrainRenderer = new TerrainRenderer(world, this); - devTrait = Lazy.New(() => world.LocalPlayer != null ? world.LocalPlayer.PlayerActor.Trait() : null); + devTrait = new Lazy(() => world.LocalPlayer != null ? world.LocalPlayer.PlayerActor.Trait() : null); } PaletteReference CreatePaletteReference(string name) diff --git a/OpenRA.Game/Map.cs b/OpenRA.Game/Map.cs index c1e5c76ac8..5ea4d855a5 100644 --- a/OpenRA.Game/Map.cs +++ b/OpenRA.Game/Map.cs @@ -84,7 +84,7 @@ namespace OpenRA return options; } - [FieldLoader.Ignore] public OpenRA.FileFormats.Lazy> Actors; + [FieldLoader.Ignore] public Lazy> Actors; public int PlayerCount { get { return Players.Count(p => p.Value.Playable); } } @@ -92,7 +92,7 @@ namespace OpenRA // Yaml map data [FieldLoader.Ignore] public Dictionary Players = new Dictionary(); - [FieldLoader.Ignore] public OpenRA.FileFormats.Lazy> Smudges; + [FieldLoader.Ignore] public Lazy> Smudges; [FieldLoader.Ignore] public List Rules = new List(); [FieldLoader.Ignore] public List Sequences = new List(); @@ -106,8 +106,8 @@ namespace OpenRA [FieldLoader.Ignore] public byte TileFormat = 1; public int2 MapSize; - [FieldLoader.Ignore] public OpenRA.FileFormats.Lazy[,]> MapTiles; - [FieldLoader.Ignore] public OpenRA.FileFormats.Lazy[,]> MapResources; + [FieldLoader.Ignore] public Lazy[,]> MapTiles; + [FieldLoader.Ignore] public Lazy[,]> MapResources; [FieldLoader.Ignore] public string[,] CustomTerrain; public static Map FromTileset(TileSet tileset) @@ -123,10 +123,10 @@ namespace OpenRA MapSize = new int2(1, 1), Tileset = tileset.Id, Options = new MapOptions(), - MapResources = Lazy.New(() => new TileReference[1, 1]), - MapTiles = Lazy.New(() => new TileReference[1, 1] { { tileRef } }), - Actors = Lazy.New(() => new Dictionary()), - Smudges = Lazy.New(() => new List()) + MapResources = Exts.Lazy(() => new TileReference[1, 1]), + MapTiles = Exts.Lazy(() => new TileReference[1, 1] { { tileRef } }), + Actors = Exts.Lazy(() => new Dictionary()), + Smudges = Exts.Lazy(() => new List()) }; return map; @@ -185,7 +185,7 @@ namespace OpenRA Players.Add(player.Name, player); } - Actors = Lazy.New(() => + Actors = Exts.Lazy(() => { var ret = new Dictionary(); foreach (var kv in yaml.NodesDict["Actors"].NodesDict) @@ -194,7 +194,7 @@ namespace OpenRA }); // Smudges - Smudges = Lazy.New(() => + Smudges = Exts.Lazy(() => { var ret = new List(); foreach (var kv in yaml.NodesDict["Smudges"].NodesDict) @@ -217,8 +217,8 @@ namespace OpenRA CustomTerrain = new string[MapSize.X, MapSize.Y]; - MapTiles = Lazy.New(() => LoadMapTiles()); - MapResources = Lazy.New(() => LoadResourceTiles()); + MapTiles = Exts.Lazy(() => LoadMapTiles()); + MapResources = Exts.Lazy(() => LoadResourceTiles()); // The Uid is calculated from the data on-disk, so // format changes must be flushed to disk. @@ -418,8 +418,8 @@ namespace OpenRA var oldMapTiles = MapTiles.Value; var oldMapResources = MapResources.Value; - MapTiles = Lazy.New(() => Exts.ResizeArray(oldMapTiles, oldMapTiles[0, 0], width, height)); - MapResources = Lazy.New(() => Exts.ResizeArray(oldMapResources, oldMapResources[0, 0], width, height)); + MapTiles = Exts.Lazy(() => Exts.ResizeArray(oldMapTiles, oldMapTiles[0, 0], width, height)); + MapResources = Exts.Lazy(() => Exts.ResizeArray(oldMapResources, oldMapResources[0, 0], width, height)); MapSize = new int2(width, height); } diff --git a/OpenRA.Game/Widgets/ButtonWidget.cs b/OpenRA.Game/Widgets/ButtonWidget.cs index e0a4bda47a..6c1820d461 100644 --- a/OpenRA.Game/Widgets/ButtonWidget.cs +++ b/OpenRA.Game/Widgets/ButtonWidget.cs @@ -43,7 +43,7 @@ namespace OpenRA.Widgets public Action OnMouseDown = _ => {}; public Action OnMouseUp = _ => {}; - OpenRA.FileFormats.Lazy tooltipContainer; + Lazy tooltipContainer; public readonly string TooltipContainer; public readonly string TooltipTemplate = "BUTTON_TOOLTIP"; public string TooltipText; @@ -63,7 +63,7 @@ namespace OpenRA.Widgets OnKeyPress = _ => OnClick(); IsDisabled = () => Disabled; IsHighlighted = () => Highlighted; - tooltipContainer = Lazy.New(() => + tooltipContainer = Exts.Lazy(() => Ui.Root.Get(TooltipContainer)); } @@ -95,7 +95,7 @@ namespace OpenRA.Widgets TooltipTemplate = other.TooltipTemplate; TooltipText = other.TooltipText; TooltipContainer = other.TooltipContainer; - tooltipContainer = Lazy.New(() => + tooltipContainer = Exts.Lazy(() => Ui.Root.Get(TooltipContainer)); } diff --git a/OpenRA.Game/Widgets/ClientTooltipRegionWidget.cs b/OpenRA.Game/Widgets/ClientTooltipRegionWidget.cs index 09d0a906bb..8531b6ab00 100644 --- a/OpenRA.Game/Widgets/ClientTooltipRegionWidget.cs +++ b/OpenRA.Game/Widgets/ClientTooltipRegionWidget.cs @@ -8,6 +8,7 @@ */ #endregion +using System; using OpenRA.FileFormats; using OpenRA.Network; @@ -23,7 +24,7 @@ namespace OpenRA.Widgets public ClientTooltipRegionWidget() { - tooltipContainer = Lazy.New(() => Ui.Root.Get(TooltipContainer)); + tooltipContainer = Exts.Lazy(() => Ui.Root.Get(TooltipContainer)); } protected ClientTooltipRegionWidget(ClientTooltipRegionWidget other) @@ -31,7 +32,7 @@ namespace OpenRA.Widgets { Template = other.Template; TooltipContainer = other.TooltipContainer; - tooltipContainer = Lazy.New(() => Ui.Root.Get(TooltipContainer)); + tooltipContainer = Exts.Lazy(() => Ui.Root.Get(TooltipContainer)); orderManager = other.orderManager; clientIndex = other.clientIndex; } diff --git a/OpenRA.Game/Widgets/MapPreviewWidget.cs b/OpenRA.Game/Widgets/MapPreviewWidget.cs index eef100e9f8..c1d6f69038 100644 --- a/OpenRA.Game/Widgets/MapPreviewWidget.cs +++ b/OpenRA.Game/Widgets/MapPreviewWidget.cs @@ -29,7 +29,7 @@ namespace OpenRA.Widgets public readonly string TooltipContainer; public readonly string TooltipTemplate = "SPAWN_TOOLTIP"; - OpenRA.FileFormats.Lazy tooltipContainer; + Lazy tooltipContainer; public int TooltipSpawnIndex = -1; Rectangle MapRect; @@ -37,7 +37,7 @@ namespace OpenRA.Widgets public MapPreviewWidget() { - tooltipContainer = Lazy.New(() => Ui.Root.Get(TooltipContainer)); + tooltipContainer = Exts.Lazy(() => Ui.Root.Get(TooltipContainer)); } protected MapPreviewWidget(MapPreviewWidget other) @@ -48,7 +48,7 @@ namespace OpenRA.Widgets ShowSpawnPoints = other.ShowSpawnPoints; TooltipTemplate = other.TooltipTemplate; TooltipContainer = other.TooltipContainer; - tooltipContainer = Lazy.New(() => Ui.Root.Get(TooltipContainer)); + tooltipContainer = Exts.Lazy(() => Ui.Root.Get(TooltipContainer)); } public override Widget Clone() { return new MapPreviewWidget(this); } diff --git a/OpenRA.Game/Widgets/ViewportControllerWidget.cs b/OpenRA.Game/Widgets/ViewportControllerWidget.cs index 9831ab6536..bb1eec757c 100644 --- a/OpenRA.Game/Widgets/ViewportControllerWidget.cs +++ b/OpenRA.Game/Widgets/ViewportControllerWidget.cs @@ -25,7 +25,7 @@ namespace OpenRA.Widgets { public readonly string TooltipTemplate = "WORLD_TOOLTIP"; public readonly string TooltipContainer; - OpenRA.FileFormats.Lazy tooltipContainer; + Lazy tooltipContainer; public WorldTooltipType TooltipType { get; private set; } public IToolTip ActorTooltip { get; private set; } @@ -64,7 +64,7 @@ namespace OpenRA.Widgets { this.world = world; this.worldRenderer = worldRenderer; - tooltipContainer = Lazy.New(() => + tooltipContainer = Exts.Lazy(() => Ui.Root.Get(TooltipContainer)); } diff --git a/OpenRA.Mods.Cnc/ProductionQueueFromSelection.cs b/OpenRA.Mods.Cnc/ProductionQueueFromSelection.cs index 8d2c4cb97e..9ce8c24f35 100644 --- a/OpenRA.Mods.Cnc/ProductionQueueFromSelection.cs +++ b/OpenRA.Mods.Cnc/ProductionQueueFromSelection.cs @@ -8,6 +8,7 @@ */ #endregion +using System; using System.Linq; using OpenRA.FileFormats; using OpenRA.Mods.RA; @@ -32,7 +33,7 @@ namespace OpenRA.Mods.Cnc.Widgets { this.world = world; - tabsWidget = Lazy.New(() => + tabsWidget = Exts.Lazy(() => Ui.Root.Get(info.ProductionTabsWidget)); } diff --git a/OpenRA.Mods.Cnc/Widgets/ProductionPaletteWidget.cs b/OpenRA.Mods.Cnc/Widgets/ProductionPaletteWidget.cs old mode 100755 new mode 100644 index 3e299090c8..ab594a290f --- a/OpenRA.Mods.Cnc/Widgets/ProductionPaletteWidget.cs +++ b/OpenRA.Mods.Cnc/Widgets/ProductionPaletteWidget.cs @@ -8,6 +8,7 @@ */ #endregion +using System; using System.Collections.Generic; using System.Drawing; using System.Linq; @@ -65,7 +66,7 @@ namespace OpenRA.Mods.Cnc.Widgets { this.World = world; this.worldRenderer = worldRenderer; - tooltipContainer = Lazy.New(() => + tooltipContainer = Exts.Lazy(() => Ui.Root.Get(TooltipContainer)); cantBuild = new Animation("clock"); diff --git a/OpenRA.Mods.Cnc/Widgets/ProductionTabsWidget.cs b/OpenRA.Mods.Cnc/Widgets/ProductionTabsWidget.cs index fd30767a51..b927360740 100644 --- a/OpenRA.Mods.Cnc/Widgets/ProductionTabsWidget.cs +++ b/OpenRA.Mods.Cnc/Widgets/ProductionTabsWidget.cs @@ -74,7 +74,7 @@ namespace OpenRA.Mods.Cnc.Widgets bool rightPressed = false; Rectangle leftButtonRect; Rectangle rightButtonRect; - OpenRA.FileFormats.Lazy paletteWidget; + Lazy paletteWidget; string queueGroup; [ObjectCreator.UseCtor] @@ -86,7 +86,7 @@ namespace OpenRA.Mods.Cnc.Widgets // Only visible if the production palette has icons to display IsVisible = () => queueGroup != null && Groups[queueGroup].Tabs.Count > 0; - paletteWidget = Lazy.New(() => Ui.Root.Get(PaletteWidget)); + paletteWidget = Exts.Lazy(() => Ui.Root.Get(PaletteWidget)); } public bool SelectNextTab(bool reverse) diff --git a/OpenRA.Mods.Cnc/Widgets/SupportPowersWidget.cs b/OpenRA.Mods.Cnc/Widgets/SupportPowersWidget.cs old mode 100755 new mode 100644 index 8bfcaf7ccc..e5551c989c --- a/OpenRA.Mods.Cnc/Widgets/SupportPowersWidget.cs +++ b/OpenRA.Mods.Cnc/Widgets/SupportPowersWidget.cs @@ -8,6 +8,7 @@ */ #endregion +using System; using System.Collections.Generic; using System.Drawing; using System.Linq; @@ -48,7 +49,7 @@ namespace OpenRA.Mods.Cnc.Widgets { this.worldRenderer = worldRenderer; spm = world.LocalPlayer.PlayerActor.Trait(); - tooltipContainer = Lazy.New(() => + tooltipContainer = Exts.Lazy(() => Ui.Root.Get(TooltipContainer)); icon = new Animation("icon"); diff --git a/OpenRA.Mods.RA/Armament.cs b/OpenRA.Mods.RA/Armament.cs index 001542af36..c60f1ce4d1 100644 --- a/OpenRA.Mods.RA/Armament.cs +++ b/OpenRA.Mods.RA/Armament.cs @@ -60,9 +60,9 @@ namespace OpenRA.Mods.RA public readonly Barrel[] Barrels; public readonly Actor self; - OpenRA.FileFormats.Lazy Turret; - OpenRA.FileFormats.Lazy Coords; - OpenRA.FileFormats.Lazy limitedAmmo; + Lazy Turret; + Lazy Coords; + Lazy limitedAmmo; List> delayedActions = new List>(); public WRange Recoil; @@ -75,9 +75,9 @@ namespace OpenRA.Mods.RA Info = info; // We can't resolve these until runtime - Turret = Lazy.New(() => self.TraitsImplementing().FirstOrDefault(t => t.Name == info.Turret)); - Coords = Lazy.New(() => self.Trait()); - limitedAmmo = Lazy.New(() => self.TraitOrDefault()); + Turret = Exts.Lazy(() => self.TraitsImplementing().FirstOrDefault(t => t.Name == info.Turret)); + Coords = Exts.Lazy(() => self.Trait()); + limitedAmmo = Exts.Lazy(() => self.TraitOrDefault()); Weapon = Rules.Weapons[info.Weapon.ToLowerInvariant()]; Burst = Weapon.Burst; diff --git a/OpenRA.Mods.RA/Attack/AttackBase.cs b/OpenRA.Mods.RA/Attack/AttackBase.cs index 0bc18b7cd7..7f12530398 100644 --- a/OpenRA.Mods.RA/Attack/AttackBase.cs +++ b/OpenRA.Mods.RA/Attack/AttackBase.cs @@ -33,8 +33,8 @@ namespace OpenRA.Mods.RA { [Sync] public bool IsAttacking { get; internal set; } public IEnumerable Armaments { get { return GetArmaments(); } } - protected OpenRA.FileFormats.Lazy facing; - protected OpenRA.FileFormats.Lazy building; + protected Lazy facing; + protected Lazy building; protected Func> GetArmaments; readonly Actor self; @@ -45,13 +45,13 @@ namespace OpenRA.Mods.RA this.self = self; this.info = info; - var armaments = Lazy.New(() => self.TraitsImplementing() + var armaments = Exts.Lazy(() => self.TraitsImplementing() .Where(a => info.Armaments.Contains(a.Info.Name))); GetArmaments = () => armaments.Value; - facing = Lazy.New(() => self.TraitOrDefault()); - building = Lazy.New(() => self.TraitOrDefault()); + facing = Exts.Lazy(() => self.TraitOrDefault()); + building = Exts.Lazy(() => self.TraitOrDefault()); } protected virtual bool CanAttack(Actor self, Target target) diff --git a/OpenRA.Mods.RA/Attack/AttackGarrisoned.cs b/OpenRA.Mods.RA/Attack/AttackGarrisoned.cs index aba46d4c99..66fab04cb1 100644 --- a/OpenRA.Mods.RA/Attack/AttackGarrisoned.cs +++ b/OpenRA.Mods.RA/Attack/AttackGarrisoned.cs @@ -46,7 +46,7 @@ namespace OpenRA.Mods.RA public readonly FirePort[] Ports; AttackGarrisonedInfo info; - OpenRA.FileFormats.Lazy coords; + Lazy coords; List armaments; List muzzles; Dictionary paxFacing; @@ -58,7 +58,7 @@ namespace OpenRA.Mods.RA : base(self, info) { this.info = info; - coords = Lazy.New(() => self.Trait()); + coords = Exts.Lazy(() => self.Trait()); armaments = new List(); muzzles = new List(); paxFacing = new Dictionary(); diff --git a/OpenRA.Mods.RA/CombatDebugOverlay.cs b/OpenRA.Mods.RA/CombatDebugOverlay.cs index b8bb74d926..3b6c930805 100644 --- a/OpenRA.Mods.RA/CombatDebugOverlay.cs +++ b/OpenRA.Mods.RA/CombatDebugOverlay.cs @@ -8,6 +8,7 @@ */ #endregion +using System; using System.Collections.Generic; using System.Drawing; using OpenRA.FileFormats; @@ -30,9 +31,9 @@ namespace OpenRA.Mods.RA public CombatDebugOverlay(Actor self) { - attack = Lazy.New(() => self.TraitOrDefault()); - coords = Lazy.New(() => self.Trait()); - health = Lazy.New(() => self.TraitOrDefault()); + attack = Exts.Lazy(() => self.TraitOrDefault()); + coords = Exts.Lazy(() => self.Trait()); + health = Exts.Lazy(() => self.TraitOrDefault()); var localPlayer = self.World.LocalPlayer; devMode = localPlayer != null ? localPlayer.PlayerActor.Trait() : null; diff --git a/OpenRA.Mods.RA/Effects/GpsDot.cs b/OpenRA.Mods.RA/Effects/GpsDot.cs index edbe4fc485..0a81ba268a 100644 --- a/OpenRA.Mods.RA/Effects/GpsDot.cs +++ b/OpenRA.Mods.RA/Effects/GpsDot.cs @@ -8,6 +8,7 @@ */ #endregion +using System; using System.Collections.Generic; using OpenRA.Effects; using OpenRA.FileFormats; @@ -51,10 +52,10 @@ namespace OpenRA.Mods.RA.Effects self.World.AddFrameEndTask(w => w.Add(this)); - huf = Lazy.New(() => self.TraitOrDefault()); - fuf = Lazy.New(() => self.TraitOrDefault()); - disguise = Lazy.New(() => self.TraitOrDefault()); - cloak = Lazy.New(() => self.TraitOrDefault()); + huf = Exts.Lazy(() => self.TraitOrDefault()); + fuf = Exts.Lazy(() => self.TraitOrDefault()); + disguise = Exts.Lazy(() => self.TraitOrDefault()); + cloak = Exts.Lazy(() => self.TraitOrDefault()); watcher = new Cache(p => p.PlayerActor.Trait()); frozen = new Cache(p => p.PlayerActor.Trait()); diff --git a/OpenRA.Mods.RA/Modifiers/FrozenUnderFog.cs b/OpenRA.Mods.RA/Modifiers/FrozenUnderFog.cs index 5c9ba0410b..3b149dd423 100644 --- a/OpenRA.Mods.RA/Modifiers/FrozenUnderFog.cs +++ b/OpenRA.Mods.RA/Modifiers/FrozenUnderFog.cs @@ -8,6 +8,7 @@ */ #endregion +using System; using System.Collections.Generic; using System.Linq; using OpenRA.FileFormats; @@ -41,9 +42,9 @@ namespace OpenRA.Mods.RA // Spawned actors (e.g. building husks) shouldn't be revealed startsRevealed = info.StartsRevealed && !init.Contains(); footprint = FootprintUtils.Tiles(init.self); - tooltip = Lazy.New(() => init.self.TraitsImplementing().FirstOrDefault()); - tooltip = Lazy.New(() => init.self.TraitsImplementing().FirstOrDefault()); - health = Lazy.New(() => init.self.TraitOrDefault()); + tooltip = Exts.Lazy(() => init.self.TraitsImplementing().FirstOrDefault()); + tooltip = Exts.Lazy(() => init.self.TraitsImplementing().FirstOrDefault()); + health = Exts.Lazy(() => init.self.TraitOrDefault()); frozen = new Dictionary(); visible = init.world.Players.ToDictionary(p => p, p => false); diff --git a/OpenRA.Mods.RA/SupportPowers/SupportPowerManager.cs b/OpenRA.Mods.RA/SupportPowers/SupportPowerManager.cs old mode 100755 new mode 100644 index 7369dfc21e..ad3fe1c4aa --- a/OpenRA.Mods.RA/SupportPowers/SupportPowerManager.cs +++ b/OpenRA.Mods.RA/SupportPowers/SupportPowerManager.cs @@ -8,6 +8,7 @@ */ #endregion +using System; using System.Collections.Generic; using System.Linq; using OpenRA.FileFormats; @@ -34,7 +35,7 @@ namespace OpenRA.Mods.RA { self = init.self; DevMode = init.self.Trait(); - RadarPings = Lazy.New(() => init.world.WorldActor.TraitOrDefault()); + RadarPings = Exts.Lazy(() => init.world.WorldActor.TraitOrDefault()); init.world.ActorAdded += ActorAdded; init.world.ActorRemoved += ActorRemoved; diff --git a/OpenRA.Mods.RA/Widgets/ResourceBarWidget.cs b/OpenRA.Mods.RA/Widgets/ResourceBarWidget.cs old mode 100755 new mode 100644 index 741f8552f8..2c9704c7a7 --- a/OpenRA.Mods.RA/Widgets/ResourceBarWidget.cs +++ b/OpenRA.Mods.RA/Widgets/ResourceBarWidget.cs @@ -22,7 +22,7 @@ namespace OpenRA.Mods.RA.Widgets { public readonly string TooltipTemplate; public readonly string TooltipContainer; - OpenRA.FileFormats.Lazy tooltipContainer; + Lazy tooltipContainer; public string TooltipFormat = ""; public ResourceBarOrientation Orientation = ResourceBarOrientation.Vertical; @@ -39,7 +39,7 @@ namespace OpenRA.Mods.RA.Widgets [ObjectCreator.UseCtor] public ResourceBarWidget(World world) { - tooltipContainer = Lazy.New(() => + tooltipContainer = Exts.Lazy(() => Ui.Root.Get(TooltipContainer)); } diff --git a/OpenRA.Utility/LegacyMapImporter.cs b/OpenRA.Utility/LegacyMapImporter.cs index aa0c0edf73..dbf4962d06 100644 --- a/OpenRA.Utility/LegacyMapImporter.cs +++ b/OpenRA.Utility/LegacyMapImporter.cs @@ -141,10 +141,10 @@ namespace OpenRA.Utility map.Bounds = Rectangle.FromLTRB(offsetX, offsetY, offsetX + width, offsetY + height); map.Selectable = true; - map.Smudges = Lazy.New(() => new List()); - map.Actors = Lazy.New(() => new Dictionary()); - map.MapResources = Lazy.New(() => new TileReference[mapSize, mapSize]); - map.MapTiles = Lazy.New(() => new TileReference[mapSize, mapSize]); + map.Smudges = Exts.Lazy(() => new List()); + map.Actors = Exts.Lazy(() => new Dictionary()); + map.MapResources = Exts.Lazy(() => new TileReference[mapSize, mapSize]); + map.MapTiles = Exts.Lazy(() => new TileReference[mapSize, mapSize]); map.Options = new MapOptions();