From cf5cb80c6131aa38f01572e1dd776f56f897ade7 Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Mon, 2 Aug 2010 23:57:19 +1200 Subject: [PATCH] Restore cnc helicopters (reservable etc changes deferred) --- OpenRA.Mods.RA/ProducesHelicopters.cs | 48 ++++++++++++++------------- mods/cnc/structures.yaml | 1 + 2 files changed, 26 insertions(+), 23 deletions(-) diff --git a/OpenRA.Mods.RA/ProducesHelicopters.cs b/OpenRA.Mods.RA/ProducesHelicopters.cs index 5bf8f5044e..0b8a57d77d 100644 --- a/OpenRA.Mods.RA/ProducesHelicopters.cs +++ b/OpenRA.Mods.RA/ProducesHelicopters.cs @@ -24,46 +24,48 @@ namespace OpenRA.Mods.RA { public ProducesHelicopters(ProducesHelicoptersInfo info) : base(info) {} - /* + // Hack around visibility bullshit in Production public override bool Produce( Actor self, ActorInfo producee ) { - var location = CreationLocation( self, producee ); - if( location == null || self.World.WorldActor.traits.Get().GetUnitsAt( location.Value ).Any() ) - return false; + // Pick an exit that we can move to + var exit = int2.Zero; + var spawn = float2.Zero; + var success = false; - var pi = self.Info.Traits.Get(); + // Pick a spawn/exit point + // Todo: Reorder in a synced random way + foreach (var s in Spawns) + { + exit = self.Location + s.Value; + spawn = self.CenterLocation + s.Key; + if (!self.World.WorldActor.traits.Get().GetUnitsAt( exit ).Any()) + { + success = true; + break; + } + } + + // Todo: Once Helicopter supports it, update UIM if its docked/landed var newUnit = self.World.CreateActor( producee.Name, new TypeDictionary { - new LocationInit( location.Value ), + new LocationInit( exit ), new OwnerInit( self.Owner ), - new FacingInit( pi.ProductionFacing ), }); - + newUnit.CenterLocation = spawn; + var rp = self.traits.GetOrDefault(); - if( rp != null || pi.ExitOffset != null) + if( rp != null ) { - if( newUnit.traits.Contains() ) - { - if (pi.ExitOffset != null) - newUnit.QueueActivity(new Activities.HeliFly(Util.CenterOfCell(ExitLocation( self, producee ).Value))); - - if (rp != null) - newUnit.QueueActivity( new Activities.HeliFly( Util.CenterOfCell(rp.rallyPoint)) ); - } + newUnit.QueueActivity( new Activities.HeliFly( Util.CenterOfCell(rp.rallyPoint)) ); } - if (pi != null && pi.SpawnOffset != null) - newUnit.CenterLocation = self.CenterLocation - + new float2(pi.SpawnOffset[0], pi.SpawnOffset[1]); - foreach (var t in self.traits.WithInterface()) t.UnitProduced(self, newUnit); Log.Write("debug", "{0} #{1} produced by {2} #{3}", newUnit.Info.Name, newUnit.ActorID, self.Info.Name, self.ActorID); return true; - } - */ + } } } diff --git a/mods/cnc/structures.yaml b/mods/cnc/structures.yaml index 8dbc1b4aa3..3c3a3d5fef 100644 --- a/mods/cnc/structures.yaml +++ b/mods/cnc/structures.yaml @@ -340,6 +340,7 @@ HPAD: Bib: ProducesHelicopters: SpawnOffsets: 0,-4 + ExitCells: 0,0 Produces: Plane BelowUnits: Reservable: