ActorInitializer, in preparation for next change (bob)

This commit is contained in:
Chris Forbes
2010-06-19 14:28:30 +12:00
parent 572cdc9dbf
commit db465e1fdd
106 changed files with 174 additions and 227 deletions

View File

@@ -36,9 +36,9 @@ namespace OpenRA
public readonly ActorInfo Info;
public readonly World World;
public readonly uint ActorID;
[Sync]
public readonly uint ActorID;
[Sync]
public int2 Location;
[Sync]
public Player Owner;
@@ -49,13 +49,15 @@ namespace OpenRA
public Group Group;
public Actor(World world, string name, int2 location, Player owner)
{
{
World = world;
ActorID = world.NextAID();
Location = location;
CenterLocation = Traits.Util.CenterOfCell(Location);
Owner = owner;
var init = new ActorInitializer( this );
if (name != null)
{
if (!Rules.Info.ContainsKey(name.ToLowerInvariant()))
@@ -65,9 +67,9 @@ namespace OpenRA
Health = this.GetMaxHP();
foreach (var trait in Info.TraitsInConstructOrder())
traits.Add(trait.Create(this));
}
traits.Add(trait.Create(init));
}
Size = Lazy.New(() =>
{
var si = Info.Traits.GetOrDefault<SelectableInfo>();
@@ -254,5 +256,16 @@ namespace OpenRA
var o = obj as Actor;
return ( o != null && o.ActorID == ActorID );
}
}
public class ActorInitializer
{
public readonly Actor self;
public World world { get { return self.World; } }
public ActorInitializer( Actor actor )
{
this.self = actor;
}
}
}