ActorInitializer, in preparation for next change (bob)
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user