moving Actor.Location onto the appropriate traits (bob)

This commit is contained in:
Chris Forbes
2010-06-19 14:37:06 +12:00
parent db465e1fdd
commit 66adbee2a6
25 changed files with 218 additions and 103 deletions

View File

@@ -38,8 +38,7 @@ namespace OpenRA
public readonly World World;
public readonly uint ActorID;
[Sync]
public int2 Location;
public int2 Location { get { return traits.Get<IOccupySpace>().TopLeft; } }
[Sync]
public Player Owner;
[Sync]
@@ -52,11 +51,9 @@ namespace OpenRA
{
World = world;
ActorID = world.NextAID();
Location = location;
CenterLocation = Traits.Util.CenterOfCell(Location);
Owner = owner;
var init = new ActorInitializer( this );
var init = new ActorInitializer( this, location );
if (name != null)
{
@@ -70,6 +67,9 @@ namespace OpenRA
traits.Add(trait.Create(init));
}
if( CenterLocation == float2.Zero && traits.Contains<IOccupySpace>() )
CenterLocation = Traits.Util.CenterOfCell(Location);
Size = Lazy.New(() =>
{
var si = Info.Traits.GetOrDefault<SelectableInfo>();
@@ -262,10 +262,12 @@ namespace OpenRA
{
public readonly Actor self;
public World world { get { return self.World; } }
public readonly int2 location;
public ActorInitializer( Actor actor )
public ActorInitializer( Actor actor, int2 location )
{
this.self = actor;
this.location = location;
}
}
}