Added FacingInit and AltitudeInit. Used in Mobile/Aircraft/Husks. Refactored Production, SpyPlane, Paratroopers and LeavesHusk

This commit is contained in:
alzeih
2010-08-02 00:49:26 +12:00
parent 2cc6e197fa
commit 4ea66ea309
8 changed files with 83 additions and 19 deletions

View File

@@ -11,6 +11,7 @@
using OpenRA.Mods.RA.Activities;
using OpenRA.Orders;
using OpenRA.Traits;
using OpenRA.FileFormats;
namespace OpenRA.Mods.RA
{
@@ -57,13 +58,17 @@ namespace OpenRA.Mods.RA
var startPos = owner.World.ChooseRandomEdgeCell();
owner.World.AddFrameEndTask(w =>
{
var flareType = (Info as ParatroopersPowerInfo).FlareType;
var flare = flareType != null ? w.CreateActor(flareType, p, owner) : null;
var a = w.CreateActor((Info as ParatroopersPowerInfo).UnitType, startPos, owner);
a.traits.Get<IFacing>().Facing = Util.GetFacing(p - startPos, 0);
a.traits.Get<IMove>().Altitude = a.Info.Traits.Get<PlaneInfo>().CruiseAltitude;
var info = (Info as ParatroopersPowerInfo);
var flare = info.FlareType != null ? w.CreateActor(info.FlareType, p, owner) : null;
var a = w.CreateActor(info.UnitType, new TypeDictionary
{
new LocationInit( startPos ),
new OwnerInit( owner ),
new FacingInit( Util.GetFacing(p - startPos, 0) ),
new AltitudeInit( Rules.Info[info.UnitType].Traits.Get<PlaneInfo>().CruiseAltitude ),
});
a.CancelActivity();
a.QueueActivity(new FlyCircle(p));
a.traits.Get<ParaDrop>().SetLZ(p, flare);

View File

@@ -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
{
@@ -45,9 +46,13 @@ namespace OpenRA.Mods.RA
var enterCell = self.World.ChooseRandomEdgeCell();
var plane = self.World.CreateActor("U2", enterCell, self.Owner);
plane.traits.Get<IMove>().Altitude = plane.Info.Traits.Get<PlaneInfo>().CruiseAltitude;
plane.traits.Get<IFacing>().Facing = Util.GetFacing(order.TargetLocation - enterCell, 0);
var plane = self.World.CreateActor("u2", new TypeDictionary
{
new LocationInit( enterCell ),
new OwnerInit( self.Owner ),
new FacingInit( Util.GetFacing(order.TargetLocation - enterCell, 0) ),
new AltitudeInit( Rules.Info["u2"].Traits.Get<PlaneInfo>().CruiseAltitude ),
});
plane.CancelActivity();
plane.QueueActivity(new Fly(Util.CenterOfCell(order.TargetLocation)));