diff --git a/OpenRA.Game/Traits/ConstructionYard.cs b/OpenRA.Game/Traits/ConstructionYard.cs index 32a03912c1..910df032df 100644 --- a/OpenRA.Game/Traits/ConstructionYard.cs +++ b/OpenRA.Game/Traits/ConstructionYard.cs @@ -18,79 +18,32 @@ */ #endregion -using OpenRA.GameRules; using OpenRA.Traits.Activities; namespace OpenRA.Traits { - class ConstructionYardInfo : ITraitInfo + class ConstructionYardInfo : TraitInfo { } + + public class ConstructionYard : IIssueOrder, IResolveOrder { - public readonly bool AllowUndeploy = true; - - public object Create(Actor self) { return new ConstructionYard(self); } - } - - public class ConstructionYard : IIssueOrder, IResolveOrder, IMovement - { - readonly Actor self; - - public ConstructionYard(Actor self) - { - this.self = self; - } - public Order IssueOrder(Actor self, int2 xy, MouseInput mi, Actor underCursor) { - if (!self.Info.Traits.Get().AllowUndeploy) return null; - if (mi.Button == MouseButton.Left) return null; - - if (underCursor != null) - { - // force-move - if (!mi.Modifiers.HasModifier(Modifiers.Alt)) return null; - if (!self.World.IsActorCrushableByActor(underCursor, self)) return null; - } - if (self.traits.GetOrDefault().CanEnterCell(xy)) - return new Order("Move", self, xy); - else - return null; + + if (underCursor == self) + return new Order("Deploy", self); + + return null; } public void ResolveOrder(Actor self, Order order) { - if (order.OrderString == "Move") + if (order.OrderString == "Deploy") { self.CancelActivity(); self.QueueActivity(new UndeployMcv()); } } - - // HACK: This should make reference to an MCV actor, and use of its Mobile trait - public UnitMovementType GetMovementType() { return UnitMovementType.Wheel; } - - public bool CanEnterCell(int2 a) - { - if (!self.World.WorldActor.traits.Get().CanMoveHere(a)) return false; - - var crushable = true; - foreach (Actor actor in self.World.WorldActor.traits.Get().GetUnitsAt(a)) - { - if (actor == self) continue; - - if (!self.World.IsActorCrushableByActor(actor, self)) - { - crushable = false; - break; - } - } - - if (!crushable) return false; - - return self.World.Map.IsInMap(a.X, a.Y) && - Rules.TerrainTypes[self.World.TileSet.GetTerrainType(self.World.Map.MapTiles[a.X, a.Y])] - .GetCost(GetMovementType()) < float.PositiveInfinity; - } } /* tag trait for "bases": mcv/fact */