From 31cb2081c657c91921da10dba5478f57af2be5fa Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Fri, 23 Jul 2010 20:39:51 +1200 Subject: [PATCH] rude hack to make planes associate with the airfield which spawned them --- OpenRA.Mods.RA/Plane.cs | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/OpenRA.Mods.RA/Plane.cs b/OpenRA.Mods.RA/Plane.cs index 432f492d1e..d532474244 100644 --- a/OpenRA.Mods.RA/Plane.cs +++ b/OpenRA.Mods.RA/Plane.cs @@ -21,12 +21,30 @@ namespace OpenRA.Mods.RA public override object Create( ActorInitializer init ) { return new Plane( init ); } } - public class Plane : Aircraft, IIssueOrder, IResolveOrder, IOrderCursor, IOrderVoice + public class Plane : Aircraft, IIssueOrder, IResolveOrder, IOrderCursor, IOrderVoice, ITick { public IDisposable reservation; public Plane( ActorInitializer init ) : base( init ) { } + bool firstTick = true; + public void Tick(Actor self) + { + if (firstTick) + { + firstTick = false; + if (self.traits.Get().Altitude == 0) + { + /* not spawning in the air, so try to assoc. with our afld. this is a hack. */ + var res = self.World.FindUnits(self.CenterLocation, self.CenterLocation) + .Select( a => a.traits.GetOrDefault() ).FirstOrDefault( a => a != null ); + + if (res != null) + reservation = res.Reserve(self); + } + } + } + public Order IssueOrder(Actor self, int2 xy, MouseInput mi, Actor underCursor) { if (mi.Button == MouseButton.Left) return null;