Convert all CreateActor calls to use TypeDictionary
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -76,7 +76,9 @@ namespace OpenRA.Traits
|
||||
{
|
||||
this.self = init.self;
|
||||
this.Info = info;
|
||||
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;
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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 );
|
||||
|
||||
@@ -15,6 +15,7 @@ using OpenRA.Mods.RA;
|
||||
using OpenRA.Mods.RA.Activities;
|
||||
using OpenRA.Traits;
|
||||
using OpenRA.Traits.Activities;
|
||||
using OpenRA.FileFormats;
|
||||
|
||||
namespace OpenRA.Mods.Cnc
|
||||
{
|
||||
@@ -38,12 +39,17 @@ namespace OpenRA.Mods.Cnc
|
||||
var rp = self.traits.GetOrDefault<RallyPoint>();
|
||||
owner.World.AddFrameEndTask(w =>
|
||||
{
|
||||
var a = w.CreateActor("C17", startPos, owner);
|
||||
var cargo = a.traits.Get<Cargo>();
|
||||
a.traits.Get<IFacing>().Facing = 64;
|
||||
a.traits.Get<IMove>().Altitude = a.Info.Traits.Get<PlaneInfo>().CruiseAltitude;
|
||||
var a = w.CreateActor("C17", new TypeDictionary
|
||||
{
|
||||
new LocationInit( startPos ),
|
||||
new OwnerInit( owner ),
|
||||
new FacingInit( 64 ),
|
||||
new AltitudeInit( Rules.Info["c17"].Traits.Get<PlaneInfo>().CruiseAltitude ),
|
||||
});
|
||||
|
||||
var newUnit = self.World.CreateActor(false, producee.Name, new int2(0, 0), self.Owner);
|
||||
var cargo = a.traits.Get<Cargo>();
|
||||
|
||||
var newUnit = self.World.CreateActor(false, producee.Name, new TypeDictionary{ new OwnerInit( self.Owner ) });
|
||||
cargo.Load(a, newUnit);
|
||||
|
||||
a.CancelActivity();
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
using System.Linq;
|
||||
using OpenRA.Traits;
|
||||
using OpenRA.Traits.Activities;
|
||||
using OpenRA.FileFormats;
|
||||
|
||||
namespace OpenRA.Mods.RA.Activities
|
||||
{
|
||||
@@ -73,8 +74,11 @@ namespace OpenRA.Mods.RA.Activities
|
||||
if (limitedAmmo != null) limitedAmmo.Attacking(self);
|
||||
|
||||
self.World.AddFrameEndTask(
|
||||
w => w.CreateActor(
|
||||
self.Info.Traits.Get<MinelayerInfo>().Mine, self.Location, self.Owner));
|
||||
w => w.CreateActor(self.Info.Traits.Get<MinelayerInfo>().Mine, new TypeDictionary
|
||||
{
|
||||
new LocationInit( self.Location ),
|
||||
new OwnerInit( self.Owner ),
|
||||
}));
|
||||
}
|
||||
|
||||
public void Cancel( Actor self ) { canceled = true; NextActivity = null; }
|
||||
|
||||
@@ -13,6 +13,7 @@ using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
using OpenRA.Traits;
|
||||
using OpenRA.Mods.RA.Render;
|
||||
using OpenRA.FileFormats;
|
||||
|
||||
namespace OpenRA.Mods.RA.Activities
|
||||
{
|
||||
@@ -52,16 +53,17 @@ namespace OpenRA.Mods.RA.Activities
|
||||
foreach (var s in sounds)
|
||||
Sound.PlayToPlayer(self.Owner, s, self.CenterLocation);
|
||||
|
||||
var a = w.CreateActor(actor, self.Location + offset, self.Owner);
|
||||
var a = w.CreateActor( actor, new TypeDictionary
|
||||
{
|
||||
new LocationInit( self.Location + offset ),
|
||||
new OwnerInit( self.Owner ),
|
||||
new FacingInit( facing ),
|
||||
});
|
||||
var oldHealth = self.traits.GetOrDefault<Health>();
|
||||
var newHealth = a.traits.GetOrDefault<Health>();
|
||||
if (oldHealth != null && newHealth != null)
|
||||
newHealth.HPFraction = oldHealth.HPFraction;
|
||||
|
||||
var ifacing = a.traits.GetOrDefault<IFacing>();
|
||||
if (ifacing != null)
|
||||
ifacing.Facing = facing;
|
||||
|
||||
if (selected)
|
||||
w.Selection.Add(w, a);
|
||||
});
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using OpenRA.Traits;
|
||||
using OpenRA.FileFormats;
|
||||
|
||||
namespace OpenRA.Mods.RA
|
||||
{
|
||||
@@ -80,7 +81,12 @@ namespace OpenRA.Mods.RA
|
||||
var nj = j - image / template.Size.X;
|
||||
|
||||
// Create a new actor for this bridge and keep track of which subtiles this bridge includes
|
||||
var bridge = w.CreateActor(BridgeTypes[tile], new int2(ni, nj), w.WorldActor.Owner).traits.Get<Bridge>();
|
||||
var bridge = w.CreateActor(BridgeTypes[tile], new TypeDictionary
|
||||
{
|
||||
new LocationInit( new int2(ni, nj) ),
|
||||
new OwnerInit( w.WorldActor.Owner ),
|
||||
}).traits.Get<Bridge>();
|
||||
|
||||
Dictionary<int2, byte> subTiles = new Dictionary<int2, byte>();
|
||||
|
||||
// For each subtile in the template
|
||||
|
||||
@@ -49,7 +49,9 @@ namespace OpenRA.Mods.RA
|
||||
public Crate(ActorInitializer init, CrateInfo info)
|
||||
{
|
||||
this.self = init.self;
|
||||
if (init.Contains<LocationInit>())
|
||||
this.Location = init.Get<LocationInit,int2>();
|
||||
|
||||
this.Info = info;
|
||||
|
||||
self.World.WorldActor.traits.Get<UnitInfluence>().Add(self, this);
|
||||
|
||||
@@ -13,6 +13,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using OpenRA.Mods.RA.Activities;
|
||||
using OpenRA.Traits;
|
||||
using OpenRA.FileFormats;
|
||||
|
||||
namespace OpenRA.Mods.RA
|
||||
{
|
||||
@@ -67,13 +68,17 @@ namespace OpenRA.Mods.RA
|
||||
|
||||
self.World.AddFrameEndTask(w =>
|
||||
{
|
||||
var crate = w.CreateActor(false, "crate", new int2(0, 0), w.WorldActor.Owner);
|
||||
var crate = w.CreateActor(false, "crate", new TypeDictionary { new OwnerInit(w.WorldActor.Owner) });
|
||||
crates.Add(crate);
|
||||
|
||||
var startPos = w.ChooseRandomEdgeCell();
|
||||
var plane = w.CreateActor("BADR", startPos, w.WorldActor.Owner);
|
||||
var aircraft = plane.traits.Get<Aircraft>();
|
||||
aircraft.Facing = Util.GetFacing(p - startPos, 0);
|
||||
var plane = w.CreateActor("badr", new TypeDictionary
|
||||
{
|
||||
new LocationInit( startPos ),
|
||||
new OwnerInit( w.WorldActor.Owner),
|
||||
new FacingInit( Util.GetFacing(p - startPos, 0) ),
|
||||
new AltitudeInit( Rules.Info["badr"].Traits.Get<AircraftInfo>().CruiseAltitude ),
|
||||
});
|
||||
plane.CancelActivity();
|
||||
plane.QueueActivity(new FlyCircle(p));
|
||||
plane.traits.Get<ParaDrop>().SetLZ(p, null);
|
||||
|
||||
@@ -12,6 +12,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using OpenRA.Traits;
|
||||
using OpenRA.FileFormats;
|
||||
|
||||
namespace OpenRA.Mods.RA
|
||||
{
|
||||
@@ -65,7 +66,11 @@ namespace OpenRA.Mods.RA
|
||||
if (self.World.WorldActor.traits.Get<UnitInfluence>().GetUnitsAt(p).Any()) continue;
|
||||
|
||||
self.World.AddFrameEndTask(
|
||||
w => crates.Add(w.CreateActor("crate", p, self.World.WorldActor.Owner)));
|
||||
w => crates.Add(w.CreateActor("crate", new TypeDictionary
|
||||
{
|
||||
new LocationInit( p ),
|
||||
new OwnerInit( self.World.WorldActor.Owner ),
|
||||
})));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
|
||||
using System.Linq;
|
||||
using OpenRA.Traits;
|
||||
using OpenRA.FileFormats;
|
||||
|
||||
namespace OpenRA.Mods.RA.Crates
|
||||
{
|
||||
@@ -41,7 +42,11 @@ namespace OpenRA.Mods.RA.Crates
|
||||
var location = ChooseEmptyCellNear(collector);
|
||||
if (location != null)
|
||||
collector.World.AddFrameEndTask(
|
||||
w => w.CreateActor(Info.Unit, location.Value, collector.Owner));
|
||||
w => w.CreateActor(Info.Unit, new TypeDictionary
|
||||
{
|
||||
new LocationInit( location.Value ),
|
||||
new OwnerInit( collector.Owner )
|
||||
}));
|
||||
|
||||
base.Activate(collector);
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ using System;
|
||||
using System.Linq;
|
||||
using OpenRA.GameRules;
|
||||
using OpenRA.Traits;
|
||||
using OpenRA.FileFormats;
|
||||
|
||||
namespace OpenRA.Mods.RA
|
||||
{
|
||||
@@ -49,7 +50,11 @@ namespace OpenRA.Mods.RA
|
||||
eligibleLocations.Remove(loc);
|
||||
dudesValue -= at.Cost;
|
||||
|
||||
self.World.AddFrameEndTask(w => w.CreateActor(at.Name, loc, self.Owner));
|
||||
self.World.AddFrameEndTask(w => w.CreateActor(at.Name, new TypeDictionary
|
||||
{
|
||||
new LocationInit( loc ),
|
||||
new OwnerInit( self.Owner ),
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
|
||||
using System.Linq;
|
||||
using OpenRA.Traits;
|
||||
using OpenRA.FileFormats;
|
||||
|
||||
namespace OpenRA.Mods.RA
|
||||
{
|
||||
@@ -31,12 +32,12 @@ namespace OpenRA.Mods.RA
|
||||
self.World.AddFrameEndTask(
|
||||
w =>
|
||||
{
|
||||
var a = w.CreateActor(info.Actor, self.Location
|
||||
+ info.SpawnOffset, self.Owner);
|
||||
|
||||
var facing = a.traits.GetOrDefault<IFacing>();
|
||||
if (facing != null)
|
||||
facing.Facing = info.Facing;
|
||||
var a = w.CreateActor(info.Actor, new TypeDictionary
|
||||
{
|
||||
new LocationInit( self.Location + info.SpawnOffset ),
|
||||
new OwnerInit( self.Owner ),
|
||||
new FacingInit( info.Facing ),
|
||||
});
|
||||
|
||||
if (info.InitialActivity != null)
|
||||
a.QueueActivity(Game.CreateObject<IActivity>(info.InitialActivity));
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
using System.Linq;
|
||||
using OpenRA.GameRules;
|
||||
using OpenRA.Traits;
|
||||
using OpenRA.FileFormats;
|
||||
|
||||
namespace OpenRA.Mods.RA
|
||||
{
|
||||
@@ -28,8 +29,11 @@ namespace OpenRA.Mods.RA
|
||||
if( location == null || self.World.WorldActor.traits.Get<UnitInfluence>().GetUnitsAt( location.Value ).Any() )
|
||||
return false;
|
||||
|
||||
var newUnit = self.World.CreateActor( producee.Name, location.Value, self.Owner );
|
||||
newUnit.traits.Get<IFacing>().Facing = CreationFacing( self, newUnit ); ;
|
||||
var newUnit = self.World.CreateActor( producee.Name, new TypeDictionary
|
||||
{
|
||||
new LocationInit( location.Value ),
|
||||
new OwnerInit( self.Owner ),
|
||||
});
|
||||
|
||||
var pi = self.Info.Traits.Get<ProductionInfo>();
|
||||
var rp = self.traits.GetOrDefault<RallyPoint>();
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#endregion
|
||||
|
||||
using OpenRA.Traits;
|
||||
using OpenRA.FileFormats;
|
||||
|
||||
namespace OpenRA.Mods.RA
|
||||
{
|
||||
@@ -27,7 +28,11 @@ namespace OpenRA.Mods.RA
|
||||
self.World.AddFrameEndTask(w =>
|
||||
{
|
||||
w.Remove(self);
|
||||
w.CreateActor(info.Actor, self.Location, self.Owner);
|
||||
w.CreateActor(info.Actor, new TypeDictionary
|
||||
{
|
||||
new LocationInit( self.Location ),
|
||||
new OwnerInit( self.Owner ),
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,7 +41,11 @@ namespace OpenRA.Mods.RA
|
||||
|
||||
void SpawnUnitsForPlayer(Player p, int2 sp)
|
||||
{
|
||||
p.World.CreateActor("mcv", sp, p);
|
||||
p.World.CreateActor("mcv", new TypeDictionary
|
||||
{
|
||||
new LocationInit( sp ),
|
||||
new OwnerInit( p ),
|
||||
});
|
||||
|
||||
if (p == p.World.LocalPlayer || p.Stances[p.World.LocalPlayer] == Stance.Ally)
|
||||
p.World.WorldActor.traits.Get<Shroud>().Explore(p.World, sp,
|
||||
|
||||
@@ -12,6 +12,7 @@ using OpenRA.Mods.RA.Activities;
|
||||
using OpenRA.Orders;
|
||||
using OpenRA.Traits;
|
||||
using OpenRA.Traits.Activities;
|
||||
using OpenRA.FileFormats;
|
||||
|
||||
namespace OpenRA.Mods.RA
|
||||
{
|
||||
@@ -44,12 +45,20 @@ namespace OpenRA.Mods.RA
|
||||
|
||||
Owner.World.AddFrameEndTask(w =>
|
||||
{
|
||||
var flareType = (Info as AirstrikePowerInfo).FlareType;
|
||||
var flare = flareType != null ? w.CreateActor(flareType, order.TargetLocation, Owner) : null;
|
||||
var info = (Info as AirstrikePowerInfo);
|
||||
var flare = info.FlareType != null ? w.CreateActor(info.FlareType, new TypeDictionary
|
||||
{
|
||||
new LocationInit( order.TargetLocation ),
|
||||
new OwnerInit( Owner ),
|
||||
}) : null;
|
||||
|
||||
var a = w.CreateActor((Info as AirstrikePowerInfo).UnitType, startPos, Owner);
|
||||
a.traits.Get<IFacing>().Facing = Util.GetFacing(order.TargetLocation - startPos, 0);
|
||||
a.traits.Get<IMove>().Altitude = a.Info.Traits.Get<PlaneInfo>().CruiseAltitude;
|
||||
var a = w.CreateActor(info.UnitType, new TypeDictionary
|
||||
{
|
||||
new LocationInit( startPos ),
|
||||
new OwnerInit( Owner ),
|
||||
new FacingInit( Util.GetFacing(order.TargetLocation - startPos, 0) ),
|
||||
new AltitudeInit( Rules.Info[info.UnitType].Traits.Get<PlaneInfo>().CruiseAltitude ),
|
||||
});
|
||||
a.traits.Get<CarpetBomb>().SetTarget(order.TargetLocation);
|
||||
|
||||
a.CancelActivity();
|
||||
|
||||
@@ -59,7 +59,11 @@ namespace OpenRA.Mods.RA
|
||||
owner.World.AddFrameEndTask(w =>
|
||||
{
|
||||
var info = (Info as ParatroopersPowerInfo);
|
||||
var flare = info.FlareType != null ? w.CreateActor(info.FlareType, p, owner) : null;
|
||||
var flare = info.FlareType != null ? w.CreateActor(info.FlareType, new TypeDictionary
|
||||
{
|
||||
new LocationInit( p ),
|
||||
new OwnerInit( owner ),
|
||||
}) : null;
|
||||
|
||||
var a = w.CreateActor(info.UnitType, new TypeDictionary
|
||||
{
|
||||
@@ -75,8 +79,7 @@ namespace OpenRA.Mods.RA
|
||||
|
||||
var cargo = a.traits.Get<Cargo>();
|
||||
foreach (var i in items)
|
||||
cargo.Load(a, owner.World.CreateActor(false, i.ToLowerInvariant(),
|
||||
new int2(0,0), a.Owner));
|
||||
cargo.Load(a, owner.World.CreateActor(false, i.ToLowerInvariant(), new TypeDictionary { new OwnerInit( a.Owner ) }));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,7 +58,12 @@ namespace OpenRA.Mods.RA
|
||||
plane.QueueActivity(new Fly(Util.CenterOfCell(order.TargetLocation)));
|
||||
plane.QueueActivity(new CallFunc(() => plane.World.AddFrameEndTask( w =>
|
||||
{
|
||||
var camera = w.CreateActor("camera", order.TargetLocation, Owner);
|
||||
var camera = w.CreateActor("camera", new TypeDictionary
|
||||
{
|
||||
new LocationInit( order.TargetLocation ),
|
||||
new OwnerInit( Owner ),
|
||||
});
|
||||
|
||||
camera.QueueActivity(new Wait((int)(25 * 60 * (Info as SpyPlanePowerInfo).RevealTime)));
|
||||
camera.QueueActivity(new RemoveSelf());
|
||||
})));
|
||||
|
||||
Reference in New Issue
Block a user