fix weird crap in ConstructionYard (badly named: just undeploys)
This commit is contained in:
@@ -18,79 +18,32 @@
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using OpenRA.GameRules;
|
||||
using OpenRA.Traits.Activities;
|
||||
|
||||
namespace OpenRA.Traits
|
||||
{
|
||||
class ConstructionYardInfo : ITraitInfo
|
||||
class ConstructionYardInfo : TraitInfo<ConstructionYard> { }
|
||||
|
||||
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<ConstructionYardInfo>().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<IMovement>().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<BuildingInfluence>().CanMoveHere(a)) return false;
|
||||
|
||||
var crushable = true;
|
||||
foreach (Actor actor in self.World.WorldActor.traits.Get<UnitInfluence>().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 */
|
||||
|
||||
Reference in New Issue
Block a user