FIX works
This commit is contained in:
@@ -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