diff --git a/OpenRa.Game/Traits/Activities/Fly.cs b/OpenRa.Game/Traits/Activities/Fly.cs index f6f4e14414..c6dca04e80 100644 --- a/OpenRa.Game/Traits/Activities/Fly.cs +++ b/OpenRa.Game/Traits/Activities/Fly.cs @@ -8,7 +8,8 @@ namespace OpenRa.Traits.Activities bool isCanceled; public Fly(float2 pos) { Pos = pos; } - + public Fly(int2 pos) { Pos = Util.CenterOfCell(pos); } + public IActivity NextActivity { get; set; } const int CruiseAltitude = 20; diff --git a/OpenRa.Game/Traits/Activities/Land.cs b/OpenRa.Game/Traits/Activities/Land.cs index b517e0ae11..fc71f10e9f 100644 --- a/OpenRa.Game/Traits/Activities/Land.cs +++ b/OpenRa.Game/Traits/Activities/Land.cs @@ -5,7 +5,7 @@ using System.Text; namespace OpenRa.Traits.Activities { - class Land : IActivity + public class Land : IActivity { readonly float2 Pos; bool isCanceled; diff --git a/OpenRa.Game/Traits/Activities/UnloadCargo.cs b/OpenRa.Game/Traits/Activities/UnloadCargo.cs index 48b28464d6..fad697ab3f 100644 --- a/OpenRa.Game/Traits/Activities/UnloadCargo.cs +++ b/OpenRa.Game/Traits/Activities/UnloadCargo.cs @@ -5,7 +5,7 @@ using System.Text; namespace OpenRa.Traits.Activities { - class UnloadCargo : IActivity + public class UnloadCargo : IActivity { public IActivity NextActivity { get; set; } bool isCanceled; diff --git a/OpenRa.Game/Traits/Production.cs b/OpenRa.Game/Traits/Production.cs index cbfa7a493d..0ddf593bd9 100755 --- a/OpenRa.Game/Traits/Production.cs +++ b/OpenRa.Game/Traits/Production.cs @@ -4,7 +4,7 @@ using OpenRa.GameRules; namespace OpenRa.Traits { - class ProductionInfo : ITraitInfo + public class ProductionInfo : ITraitInfo { public readonly int[] SpawnOffset = null; public readonly string[] Produces = { }; @@ -12,7 +12,7 @@ namespace OpenRa.Traits public virtual object Create(Actor self) { return new Production(self); } } - class Production : IIssueOrder, IResolveOrder, IProducer, ITags + public class Production : IIssueOrder, IResolveOrder, IProducer, ITags { bool isPrimary = false; public bool IsPrimary { get { return isPrimary; } } @@ -29,7 +29,7 @@ namespace OpenRa.Traits return newUnit.Info.Traits.GetOrDefault().InitialFacing; } - public bool Produce( Actor self, ActorInfo producee ) + public virtual bool Produce( Actor self, ActorInfo producee ) { var location = CreationLocation( self, producee ); if( location == null || self.World.WorldActor.traits.Get().GetUnitsAt( location.Value ).Any() ) diff --git a/OpenRa.Game/Traits/RallyPoint.cs b/OpenRa.Game/Traits/RallyPoint.cs index 21b5348ad7..3978b98d48 100644 --- a/OpenRa.Game/Traits/RallyPoint.cs +++ b/OpenRa.Game/Traits/RallyPoint.cs @@ -11,7 +11,7 @@ namespace OpenRa.Traits public object Create(Actor self) { return new RallyPoint(self); } } - class RallyPoint : IRender, IIssueOrder, IResolveOrder, ITick + public class RallyPoint : IRender, IIssueOrder, IResolveOrder, ITick { [Sync] public int2 rallyPoint; diff --git a/OpenRa.Mods.RA/OpenRa.Mods.RA.csproj b/OpenRa.Mods.RA/OpenRa.Mods.RA.csproj index 4b5b5b0782..b5f469f36f 100644 --- a/OpenRa.Mods.RA/OpenRa.Mods.RA.csproj +++ b/OpenRa.Mods.RA/OpenRa.Mods.RA.csproj @@ -51,6 +51,7 @@ + diff --git a/OpenRa.Mods.RA/ProductionAirdrop.cs b/OpenRa.Mods.RA/ProductionAirdrop.cs new file mode 100644 index 0000000000..966e4089a8 --- /dev/null +++ b/OpenRa.Mods.RA/ProductionAirdrop.cs @@ -0,0 +1,60 @@ +using System.Collections.Generic; +using System.Linq; +using OpenRa.GameRules; +using OpenRa.Traits.Activities; +using OpenRa.Traits; + +namespace OpenRa.Mods.RA +{ + public class ProductionAirdropInfo : ProductionInfo + { + public override object Create(Actor self) { return new ProductionAirdrop(self); } + } + + class ProductionAirdrop : Production + { + public ProductionAirdrop(Actor self) : base(self) { } + + public override bool Produce( Actor self, ActorInfo producee ) + { + var location = CreationLocation(self, producee); + var owner = self.Owner; + + // Start at the edge of the map, to the right of the airfield + var startPos = new int2(owner.World.Map.XOffset + owner.World.Map.Width, self.Location.Y); + var endPos = new int2(owner.World.Map.XOffset, self.Location.Y); + var deployOffset = new float2(24f,0); + + var rp = self.traits.GetOrDefault(); + owner.World.AddFrameEndTask(w => + { + var a = w.CreateActor("C17", startPos, owner); + var cargo = a.traits.Get(); + + var newUnit = new Actor(self.World, producee.Name, new int2(0, 0), self.Owner); + cargo.Load(a, newUnit); + + a.CancelActivity(); + a.QueueActivity(new Land(self.CenterLocation+deployOffset)); + a.QueueActivity(new CallFunc(() => + { + var actor = cargo.Unload(self); + self.World.AddFrameEndTask(ww => + { + ww.Add(actor); + actor.traits.Get().TeleportTo(actor, self.Location); + actor.CancelActivity(); + actor.QueueActivity(new Move(rp.rallyPoint, 0)); + + foreach (var t in self.traits.WithInterface()) + t.UnitProduced(self, actor); + }); + })); + a.QueueActivity(new Fly(endPos)); + a.QueueActivity(new RemoveSelf()); + }); + + return true; + } + } +} diff --git a/mods/cnc/sequences-vehicles.xml b/mods/cnc/sequences-vehicles.xml index a5a55ba58c..a9e9b044ea 100644 --- a/mods/cnc/sequences-vehicles.xml +++ b/mods/cnc/sequences-vehicles.xml @@ -1,8 +1,12 @@  + + + + @@ -14,9 +18,16 @@ + + + + + + + diff --git a/mods/cnc/sequences.xml b/mods/cnc/sequences.xml index 3c03474e30..c19a91f0f0 100644 --- a/mods/cnc/sequences.xml +++ b/mods/cnc/sequences.xml @@ -955,7 +955,4 @@ - - - diff --git a/mods/cnc/structures.yaml b/mods/cnc/structures.yaml index d8bf52d8b5..b46c33fc0d 100644 --- a/mods/cnc/structures.yaml +++ b/mods/cnc/structures.yaml @@ -151,7 +151,8 @@ AFLD: Crewed: yes Sight: 5 RallyPoint: - Production: + BelowUnits: + ProductionAirdrop: Produces: Vehicle WEAP: diff --git a/mods/cnc/vehicles.yaml b/mods/cnc/vehicles.yaml index 6cedad9f0c..d1820af32d 100644 --- a/mods/cnc/vehicles.yaml +++ b/mods/cnc/vehicles.yaml @@ -67,3 +67,20 @@ BGGY: MuzzleFlash: yes RenderUnitTurreted: AutoTarget: + +C17: + ParaDrop: + LZRange: 1 + Inherits: ^Plane + Unit: + HP: 25 + Armor: light + ROT: 5 + Sight: 0 + Speed: 40 + Plane: + RenderUnit: + WithShadow: + Cargo: + Passengers: 10 + -Selectable: