Migrate to System.Lazy.

This commit is contained in:
Paul Chote
2014-03-12 22:48:47 +13:00
parent 67cd0645a4
commit 1b2a90c00c
25 changed files with 87 additions and 125 deletions

View File

@@ -24,12 +24,12 @@ namespace OpenRA
public readonly World World;
public readonly uint ActorID;
public OpenRA.FileFormats.Lazy<Rectangle> Bounds;
public Lazy<Rectangle> Bounds;
OpenRA.FileFormats.Lazy<IOccupySpace> occupySpace;
OpenRA.FileFormats.Lazy<IFacing> facing;
OpenRA.FileFormats.Lazy<Health> health;
OpenRA.FileFormats.Lazy<IEffectiveOwner> effectiveOwner;
Lazy<IOccupySpace> occupySpace;
Lazy<IFacing> facing;
Lazy<Health> health;
Lazy<IEffectiveOwner> effectiveOwner;
public IOccupySpace OccupiesSpace { get { return occupySpace.Value; } }
public IEffectiveOwner EffectiveOwner { get { return effectiveOwner.Value; } }
@@ -62,7 +62,7 @@ namespace OpenRA
if (initDict.Contains<OwnerInit>())
Owner = init.Get<OwnerInit, Player>();
occupySpace = Lazy.New(() => TraitOrDefault<IOccupySpace>());
occupySpace = Exts.Lazy(() => TraitOrDefault<IOccupySpace>());
if (name != null)
{
@@ -74,14 +74,14 @@ namespace OpenRA
AddTrait(trait.Create(init));
}
facing = Lazy.New(() => TraitOrDefault<IFacing>());
health = Lazy.New(() => TraitOrDefault<Health>());
effectiveOwner = Lazy.New(() => TraitOrDefault<IEffectiveOwner>());
facing = Exts.Lazy(() => TraitOrDefault<IFacing>());
health = Exts.Lazy(() => TraitOrDefault<Health>());
effectiveOwner = Exts.Lazy(() => TraitOrDefault<IEffectiveOwner>());
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<SelectableInfo>();
var size = (si != null && si.Bounds != null) ? new int2(si.Bounds[0], si.Bounds[1]) :