FIX works
This commit is contained in:
@@ -162,6 +162,7 @@ namespace OpenRa.Game
|
||||
else
|
||||
return Cursor.MoveBlocked;
|
||||
case "Enter": return Cursor.Enter;
|
||||
case "Infiltrate": return Cursor.Enter;
|
||||
case "Capture": return Cursor.Capture;
|
||||
case "Harvest": return Cursor.Attack; // TODO: special harvest cursor?
|
||||
default:
|
||||
|
||||
@@ -198,6 +198,7 @@
|
||||
<Compile Include="Traits\MineImmune.cs" />
|
||||
<Compile Include="Traits\Minelayer.cs" />
|
||||
<Compile Include="Traits\LimitedAmmo.cs" />
|
||||
<Compile Include="Traits\Repairable.cs" />
|
||||
<Compile Include="Traits\Reservable.cs" />
|
||||
<Compile Include="Traits\SquishByTank.cs" />
|
||||
<Compile Include="Traits\Plane.cs" />
|
||||
|
||||
@@ -49,7 +49,7 @@ namespace OpenRa.Game
|
||||
}
|
||||
}
|
||||
|
||||
Func<int2, bool> AvoidUnitsNear(int2 p, int dist)
|
||||
public Func<int2, bool> AvoidUnitsNear(int2 p, int dist)
|
||||
{
|
||||
return q =>
|
||||
p != q &&
|
||||
|
||||
@@ -15,6 +15,7 @@ namespace OpenRa.Game
|
||||
Func<int2, bool> customBlock;
|
||||
public bool checkForBlocked;
|
||||
public bool ignoreTerrain;
|
||||
public Actor ignoreBuilding;
|
||||
|
||||
public PathSearch()
|
||||
{
|
||||
@@ -28,6 +29,12 @@ namespace OpenRa.Game
|
||||
return this;
|
||||
}
|
||||
|
||||
public PathSearch WithIgnoredBuilding(Actor b)
|
||||
{
|
||||
ignoreBuilding = b;
|
||||
return this;
|
||||
}
|
||||
|
||||
public int2 Expand( float[][ , ] passableCost )
|
||||
{
|
||||
var p = queue.Pop();
|
||||
@@ -49,7 +56,8 @@ namespace OpenRa.Game
|
||||
{
|
||||
if (passableCost[(int)umt][newHere.X, newHere.Y] == float.PositiveInfinity)
|
||||
continue;
|
||||
if (!Game.BuildingInfluence.CanMoveHere(newHere))
|
||||
if (!Game.BuildingInfluence.CanMoveHere(newHere) &&
|
||||
Game.BuildingInfluence.GetBuildingAt(newHere) != ignoreBuilding)
|
||||
continue;
|
||||
if (Rules.Map.IsOverlaySolid(newHere))
|
||||
continue;
|
||||
|
||||
@@ -14,6 +14,7 @@ namespace OpenRa.Game.Traits.Activities
|
||||
int nearEnough;
|
||||
public List<int2> path;
|
||||
Func<Actor, Mobile, List<int2>> getPath;
|
||||
public Actor ignoreBuilding;
|
||||
|
||||
MovePart move;
|
||||
|
||||
@@ -26,6 +27,18 @@ namespace OpenRa.Game.Traits.Activities
|
||||
this.nearEnough = nearEnough;
|
||||
}
|
||||
|
||||
public Move(int2 destination, Actor ignoreBuilding)
|
||||
{
|
||||
this.getPath = (self, mobile) =>
|
||||
Game.PathFinder.FindPath(
|
||||
PathSearch.FromPoint( self.Location, destination, mobile.GetMovementType(), false )
|
||||
.WithCustomBlocker( Game.PathFinder.AvoidUnitsNear( self.Location, 4 )).WithIgnoredBuilding( ignoreBuilding ));
|
||||
|
||||
this.destination = destination;
|
||||
this.nearEnough = 0;
|
||||
this.ignoreBuilding = ignoreBuilding;
|
||||
}
|
||||
|
||||
public Move( Actor target, int range )
|
||||
{
|
||||
this.getPath = ( self, mobile ) => Game.PathFinder.FindUnitPathToRange(
|
||||
@@ -42,9 +55,11 @@ namespace OpenRa.Game.Traits.Activities
|
||||
this.nearEnough = 0;
|
||||
}
|
||||
|
||||
static bool CanEnterCell( int2 c, Actor self )
|
||||
bool CanEnterCell( int2 c, Actor self )
|
||||
{
|
||||
if (!Game.BuildingInfluence.CanMoveHere(c)) return false;
|
||||
if (!Game.BuildingInfluence.CanMoveHere(c)
|
||||
&& Game.BuildingInfluence.GetBuildingAt(c) != ignoreBuilding)
|
||||
return false;
|
||||
|
||||
// Cannot enter a cell if any unit inside is uncrushable
|
||||
// This will need to be updated for multiple-infantry-in-a-cell
|
||||
|
||||
@@ -16,13 +16,13 @@ namespace OpenRa.Game.Traits
|
||||
|
||||
// todo: other bits
|
||||
|
||||
return new Order(underCursor.Health <= EngineerDamage ? "Capture" : "Enter",
|
||||
return new Order(underCursor.Health <= EngineerDamage ? "Capture" : "Infiltrate",
|
||||
self, underCursor, int2.Zero, null);
|
||||
}
|
||||
|
||||
public void ResolveOrder(Actor self, Order order)
|
||||
{
|
||||
if (order.OrderString == "Enter" || order.OrderString == "Capture")
|
||||
if (order.OrderString == "Infiltrate" || order.OrderString == "Capture")
|
||||
{
|
||||
self.CancelActivity();
|
||||
self.QueueActivity(new Move(order.TargetActor, 1));
|
||||
|
||||
50
OpenRa.Game/Traits/Repairable.cs
Normal file
50
OpenRa.Game/Traits/Repairable.cs
Normal file
@@ -0,0 +1,50 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using OpenRa.Game.Traits.Activities;
|
||||
|
||||
namespace OpenRa.Game.Traits
|
||||
{
|
||||
class Repairable : IOrder
|
||||
{
|
||||
IDisposable reservation;
|
||||
public Repairable(Actor self) { }
|
||||
|
||||
public Order IssueOrder(Actor self, int2 xy, MouseInput mi, Actor underCursor)
|
||||
{
|
||||
if (mi.Button != MouseButton.Right) return null;
|
||||
if (underCursor == null) return null;
|
||||
|
||||
if (underCursor.Info == Rules.UnitInfo["FIX"]
|
||||
&& underCursor.Owner == self.Owner
|
||||
&& !Reservable.IsReserved(underCursor))
|
||||
return new Order("Enter", self, underCursor, int2.Zero, null);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public void ResolveOrder(Actor self, Order order)
|
||||
{
|
||||
if (reservation != null)
|
||||
{
|
||||
reservation.Dispose();
|
||||
reservation = null;
|
||||
}
|
||||
|
||||
if (order.OrderString == "Enter")
|
||||
{
|
||||
if (Reservable.IsReserved(order.TargetActor))
|
||||
return;
|
||||
|
||||
var res = order.TargetActor.traits.GetOrDefault<Reservable>();
|
||||
if (res != null) reservation = res.Reserve(self);
|
||||
|
||||
self.CancelActivity();
|
||||
self.QueueActivity(new Move(((1 / 24f) * order.TargetActor.CenterLocation).ToInt2(), order.TargetActor));
|
||||
self.QueueActivity(new Rearm());
|
||||
self.QueueActivity(new Repair());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user