Convert all CreateActor calls to use TypeDictionary

This commit is contained in:
alzeih
2010-08-02 01:28:07 +12:00
parent 4ea66ea309
commit 578d42614b
20 changed files with 131 additions and 63 deletions

View File

@@ -44,7 +44,7 @@ namespace OpenRA
World = world;
Shroud = new ShroudRenderer(this, world.Map);
PlayerActor = world.CreateActor("Player", new int2(int.MaxValue, int.MaxValue), this);
PlayerActor = world.CreateActor("Player", new TypeDictionary{ new OwnerInit( this ) });
Index = index;
Palette = "player"+index;
@@ -64,7 +64,7 @@ namespace OpenRA
World = world;
Shroud = new ShroudRenderer(this, world.Map);
PlayerActor = world.CreateActor("Player", new int2(int.MaxValue, int.MaxValue), this);
PlayerActor = world.CreateActor("Player", new TypeDictionary{ new OwnerInit( this ) });
Index = client.Index;
Palette = "player"+client.Index;

View File

@@ -76,7 +76,9 @@ namespace OpenRA.Traits
{
this.self = init.self;
this.Info = info;
this.__fromCell = this.__toCell = init.Get<LocationInit,int2>();
if (init.Contains<LocationInit>())
this.__fromCell = this.__toCell = init.Get<LocationInit,int2>();
this.Facing = init.Contains<FacingInit>() ? init.Get<FacingInit,int>() : info.InitialFacing;
this.Altitude = init.Contains<AltitudeInit>() ? init.Get<AltitudeInit,int>() : 0;

View File

@@ -11,6 +11,7 @@
using System.Linq;
using OpenRA.Effects;
using OpenRA.GameRules;
using OpenRA.FileFormats;
namespace OpenRA.Traits
{
@@ -40,7 +41,12 @@ namespace OpenRA.Traits
bool playSounds = true;
foreach (var t in LineBuildUtils.GetLineBuildCells(w, order.TargetLocation, order.TargetString, buildingInfo))
{
var building = w.CreateActor(order.TargetString, t, order.Player);
var building = w.CreateActor(order.TargetString, new TypeDictionary
{
new LocationInit( t ),
new OwnerInit( order.Player ),
});
if (playSounds)
foreach (var s in buildingInfo.BuildSounds)
Sound.PlayToPlayer(order.Player, s, building.CenterLocation);
@@ -49,7 +55,11 @@ namespace OpenRA.Traits
}
else
{
var building = w.CreateActor(order.TargetString, order.TargetLocation, order.Player);
var building = w.CreateActor(order.TargetString, new TypeDictionary
{
new LocationInit( order.TargetLocation ),
new OwnerInit( order.Player ),
});
foreach (var s in buildingInfo.BuildSounds)
Sound.PlayToPlayer(order.Player, s, building.CenterLocation);
}

View File

@@ -125,21 +125,6 @@ namespace OpenRA
Timer.Time( "----end World.ctor" );
}
public Actor CreateActor( string name, int2 location, Player owner )
{
return CreateActor( true, name, location, owner );
}
public Actor CreateActor( bool addToWorld, string name, int2 location, Player owner )
{
var initDict = new TypeDictionary
{
new LocationInit( location ),
new OwnerInit( owner ),
};
return CreateActor( addToWorld, name, initDict );
}
public Actor CreateActor( string name, TypeDictionary initDict )
{
return CreateActor( true, name, initDict );