diff --git a/OpenRa.Game/Traits/Helicopter.cs b/OpenRa.Game/Traits/Helicopter.cs index 38bd07f0c5..1361571a91 100644 --- a/OpenRa.Game/Traits/Helicopter.cs +++ b/OpenRa.Game/Traits/Helicopter.cs @@ -9,6 +9,14 @@ namespace OpenRa.Game.Traits public IDisposable reservation; public Helicopter(Actor self) {} + // todo: push into data! + static bool HeliCanEnter(Actor a) + { + if (a.Info == Rules.UnitInfo["HPAD"]) return true; + if (a.Info == Rules.UnitInfo["FIX"]) return true; + return false; + } + public Order IssueOrder(Actor self, int2 xy, MouseInput mi, Actor underCursor) { if (mi.Button == MouseButton.Left) return null; @@ -16,7 +24,7 @@ namespace OpenRa.Game.Traits if (underCursor == null) return new Order("Move", self, null, xy, null); - if (underCursor.Info == Rules.UnitInfo["HPAD"] + if (HeliCanEnter(underCursor) && underCursor.Owner == self.Owner && !Reservable.IsReserved(underCursor)) return new Order("Enter", self, underCursor, int2.Zero, null); @@ -54,7 +62,8 @@ namespace OpenRa.Game.Traits self.QueueActivity(new HeliFly(order.TargetActor.CenterLocation + offsetVec)); self.QueueActivity(new Turn(self.Info.InitialFacing)); self.QueueActivity(new HeliLand(false)); - self.QueueActivity(new Rearm()); + self.QueueActivity(order.TargetActor.Info == Rules.UnitInfo["HPAD"] + ? (IActivity)new Rearm() : new Repair()); } } diff --git a/OpenRa.Game/Traits/Plane.cs b/OpenRa.Game/Traits/Plane.cs index f00bbe54d5..f01c38e76b 100644 --- a/OpenRa.Game/Traits/Plane.cs +++ b/OpenRa.Game/Traits/Plane.cs @@ -12,13 +12,21 @@ namespace OpenRa.Game.Traits public Plane(Actor self) {} + // todo: push into data! + static bool PlaneCanEnter(Actor a) + { + if (a.Info == Rules.UnitInfo["AFLD"]) return true; + if (a.Info == Rules.UnitInfo["FIX"]) return true; + return false; + } + public Order IssueOrder(Actor self, int2 xy, MouseInput mi, Actor underCursor) { if (mi.Button == MouseButton.Left) return null; if (underCursor == null) return new Order("Move", self, null, xy, null); - if (underCursor.Info == Rules.UnitInfo["AFLD"] + if (PlaneCanEnter(underCursor) && underCursor.Owner == self.Owner && !Reservable.IsReserved(underCursor)) return new Order("Enter", self, underCursor, int2.Zero, null); @@ -51,18 +59,12 @@ namespace OpenRa.Game.Traits self.CancelActivity(); self.QueueActivity(new ReturnToBase(self, order.TargetActor)); - self.QueueActivity(new Rearm()); /* todo: something else when it's FIX rather than AFLD */ + self.QueueActivity(order.TargetActor.Info == Rules.UnitInfo["AFLD"] + ? (IActivity)new Rearm() : new Repair()); } } - public UnitMovementType GetMovementType() - { - return UnitMovementType.Fly; - } - - public bool CanEnterCell(int2 location) - { - return true; // Planes can go anywhere (?) - } + public UnitMovementType GetMovementType() { return UnitMovementType.Fly; } + public bool CanEnterCell(int2 location) { return true; } } }