diff --git a/OpenRa.Game/Orders/ChronosphereSelectOrderGenerator.cs b/OpenRa.Game/Orders/ChronosphereSelectOrderGenerator.cs index ae7de0551f..4ff3de312d 100644 --- a/OpenRa.Game/Orders/ChronosphereSelectOrderGenerator.cs +++ b/OpenRa.Game/Orders/ChronosphereSelectOrderGenerator.cs @@ -24,7 +24,7 @@ namespace OpenRa.Game.Orders var loc = mi.Location + Game.viewport.Location; var underCursor = Game.FindUnits(loc, loc) .Where(a => a.Owner == Game.LocalPlayer - && a.traits.WithInterface().Any() + && a.traits.WithInterface().Any() && a.Info.Selectable).FirstOrDefault(); var unit = underCursor != null ? underCursor.Info as UnitInfo : null; diff --git a/OpenRa.Game/Traits/Chronoshiftable.cs b/OpenRa.Game/Traits/Chronoshiftable.cs index cd0fa8af1c..98dc29d28c 100644 --- a/OpenRa.Game/Traits/Chronoshiftable.cs +++ b/OpenRa.Game/Traits/Chronoshiftable.cs @@ -6,7 +6,7 @@ using System.Drawing; namespace OpenRa.Game.Traits { - class Chronoshiftable : IOrder, ISpeedModifier, ITick, IChronoshiftable + class Chronoshiftable : IOrder, ISpeedModifier, ITick { // Return-to-sender logic int2 chronoshiftOrigin; diff --git a/OpenRa.Game/Traits/DemoTruck.cs b/OpenRa.Game/Traits/DemoTruck.cs index add4849cff..b84bcdec27 100644 --- a/OpenRa.Game/Traits/DemoTruck.cs +++ b/OpenRa.Game/Traits/DemoTruck.cs @@ -6,29 +6,27 @@ using OpenRa.Game.Orders; namespace OpenRa.Game.Traits { - class DemoTruck : IOrder, ISpeedModifier, INotifyDamage, IChronoshiftable + class DemoTruck : Chronoshiftable, IOrder, INotifyDamage { readonly Actor self; public DemoTruck(Actor self) + : base(self) { this.self = self; } - - // Fire primary on Chronoshift - public Order IssueOrder(Actor self, int2 xy, MouseInput mi, Actor underCursor) + + public new void ResolveOrder(Actor self, Order order) { - return null; // Chronoshift order is issued through Chrome. - } - - public void ResolveOrder(Actor self, Order order) - { - if (order.OrderString == "ChronosphereSelect") - Game.controller.orderGenerator = new ChronoshiftDestinationOrderGenerator(self); - + // Override chronoshifting action to detonate vehicle var movement = self.traits.WithInterface().FirstOrDefault(); var chronosphere = Game.world.Actors.Where(a => a.Owner == order.Subject.Owner && a.traits.Contains()).FirstOrDefault(); if (order.OrderString == "Chronoshift" && movement.CanEnterCell(order.TargetLocation)) + { self.InflictDamage(chronosphere, self.Health, Rules.WarheadInfo["Super"]); + return; + } + + base.ResolveOrder(self, order); } // Fire primary on death @@ -49,11 +47,5 @@ namespace OpenRa.Game.Traits w => w.Add(new Bullet(self.Info.Primary, detonatedBy.Owner, detonatedBy, detonateLocation, detonateLocation, altitude, altitude))); } - - public float GetSpeedModifier() - { - // ARGH! You must not do this, it will desync! - return (Game.controller.orderGenerator is ChronoshiftDestinationOrderGenerator) ? 0f : 1f; - } } } diff --git a/OpenRa.Game/Traits/TraitsInterfaces.cs b/OpenRa.Game/Traits/TraitsInterfaces.cs index de5bc49c19..da3e3bb431 100644 --- a/OpenRa.Game/Traits/TraitsInterfaces.cs +++ b/OpenRa.Game/Traits/TraitsInterfaces.cs @@ -43,7 +43,6 @@ namespace OpenRa.Game.Traits bool IsCrushableBy(UnitMovementType umt, Player player); bool IsPathableCrush(UnitMovementType umt, Player player); } - interface IChronoshiftable{} struct Renderable { public readonly Sprite Sprite;