use new Enter activity for engy, spy, c4
This commit is contained in:
@@ -40,7 +40,7 @@ namespace OpenRA
|
||||
|
||||
public List<int2> FindUnitPath(int2 from, int2 target, Actor self)
|
||||
{
|
||||
using (new PerfSample("find_unit_path"))
|
||||
using (new PerfSample("Pathfinder"))
|
||||
{
|
||||
var cached = CachedPaths.FirstOrDefault(p => p.from == from && p.to == target && p.actor == self);
|
||||
if (cached != null)
|
||||
@@ -69,7 +69,7 @@ namespace OpenRA
|
||||
|
||||
public List<int2> FindUnitPathToRange( int2 src, int2 target, int range, Actor self )
|
||||
{
|
||||
using( new PerfSample( "find_unit_path_multiple_src" ) )
|
||||
using( new PerfSample( "Pathfinder" ) )
|
||||
{
|
||||
var mobileInfo = self.Info.Traits.Get<MobileInfo>();
|
||||
var tilesInRange = world.FindTilesInCircle(target, range)
|
||||
@@ -93,7 +93,7 @@ namespace OpenRA
|
||||
|
||||
public List<int2> FindPath( PathSearch search )
|
||||
{
|
||||
//using (new PerfSample("find_path_inner"))
|
||||
using (new PerfSample("Pathfinder"))
|
||||
{
|
||||
while (!search.queue.Empty)
|
||||
{
|
||||
@@ -127,9 +127,11 @@ namespace OpenRA
|
||||
|
||||
|
||||
|
||||
List<int2> FindBidiPath( /* searches from both ends toward each other */
|
||||
public List<int2> FindBidiPath( /* searches from both ends toward each other */
|
||||
PathSearch fromSrc,
|
||||
PathSearch fromDest)
|
||||
{
|
||||
using (new PerfSample("Pathfinder"))
|
||||
{
|
||||
while (!fromSrc.queue.Empty && !fromDest.queue.Empty)
|
||||
{
|
||||
@@ -148,6 +150,7 @@ namespace OpenRA
|
||||
|
||||
return new List<int2>();
|
||||
}
|
||||
}
|
||||
|
||||
static List<int2> MakeBidiPath(PathSearch a, PathSearch b, int2 p)
|
||||
{
|
||||
|
||||
@@ -72,7 +72,7 @@ namespace OpenRA
|
||||
|
||||
public PathSearch FromPoint(int2 from)
|
||||
{
|
||||
AddInitialCell( world, from );
|
||||
AddInitialCell( from );
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -155,7 +155,7 @@ namespace OpenRA
|
||||
new int2( 1, 1 ),
|
||||
};
|
||||
|
||||
public void AddInitialCell( World world, int2 location )
|
||||
public void AddInitialCell( int2 location )
|
||||
{
|
||||
if (!world.Map.IsInMap(location.X, location.Y))
|
||||
return;
|
||||
@@ -177,7 +177,7 @@ namespace OpenRA
|
||||
heuristic = DefaultEstimator( target ),
|
||||
checkForBlocked = checkForBlocked };
|
||||
|
||||
search.AddInitialCell( world, from );
|
||||
search.AddInitialCell( from );
|
||||
return search;
|
||||
}
|
||||
|
||||
@@ -190,7 +190,7 @@ namespace OpenRA
|
||||
};
|
||||
|
||||
foreach( var sl in froms )
|
||||
search.AddInitialCell(world, sl);
|
||||
search.AddInitialCell( sl );
|
||||
|
||||
return search;
|
||||
}
|
||||
|
||||
37
OpenRA.Mods.RA/Activities/Enter.cs
Executable file
37
OpenRA.Mods.RA/Activities/Enter.cs
Executable file
@@ -0,0 +1,37 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2010 The OpenRA Developers (see AUTHORS)
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* available to you under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation. For more information,
|
||||
* see LICENSE.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using OpenRA.Traits;
|
||||
using OpenRA.Traits.Activities;
|
||||
|
||||
namespace OpenRA.Mods.RA.Activities
|
||||
{
|
||||
public class Enter : CancelableActivity
|
||||
{
|
||||
readonly Actor target;
|
||||
public Enter( Actor target ) { this.target = target; }
|
||||
|
||||
public override IActivity Tick( Actor self )
|
||||
{
|
||||
if( IsCanceled || target.Destroyed || !target.IsInWorld )
|
||||
return NextActivity;
|
||||
|
||||
var mobile = self.Trait<Mobile>();
|
||||
var nearest = target.Trait<IOccupySpace>().NearestCellTo( mobile.toCell );
|
||||
if( ( nearest - mobile.toCell ).LengthSquared >= 2 )
|
||||
return Util.SequenceActivities( new MoveAdjacentTo( target ), this );
|
||||
|
||||
return Util.SequenceActivities( new Move( nearest, target ), NextActivity );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -35,7 +35,8 @@ namespace OpenRA.Mods.RA.Activities
|
||||
return new Wait(20);
|
||||
|
||||
return Util.SequenceActivities(
|
||||
new Move(Util.CellContaining(rearmTarget.CenterLocation), rearmTarget),
|
||||
new Enter(rearmTarget),
|
||||
//new Move(Util.CellContaining(rearmTarget.CenterLocation), rearmTarget),
|
||||
new Rearm(),
|
||||
new Repair(rearmTarget),
|
||||
this );
|
||||
|
||||
54
OpenRA.Mods.RA/Activities/MoveAdjacentTo.cs
Executable file
54
OpenRA.Mods.RA/Activities/MoveAdjacentTo.cs
Executable file
@@ -0,0 +1,54 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2010 The OpenRA Developers (see AUTHORS)
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* available to you under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation. For more information,
|
||||
* see LICENSE.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using OpenRA.Traits;
|
||||
using OpenRA.Traits.Activities;
|
||||
|
||||
namespace OpenRA.Mods.RA.Activities
|
||||
{
|
||||
public class MoveAdjacentTo : CancelableActivity
|
||||
{
|
||||
readonly Actor target;
|
||||
|
||||
public MoveAdjacentTo( Actor target )
|
||||
{
|
||||
this.target = target;
|
||||
}
|
||||
|
||||
public override IActivity Tick( Actor self )
|
||||
{
|
||||
if( IsCanceled || target.Destroyed || !target.IsInWorld) return NextActivity;
|
||||
|
||||
var mobile = self.Trait<Mobile>();
|
||||
var ps1 = new PathSearch( self.World, mobile.Info )
|
||||
{
|
||||
checkForBlocked = true,
|
||||
heuristic = location => 0,
|
||||
inReverse = true
|
||||
};
|
||||
foreach( var cell in target.Trait<IOccupySpace>().OccupiedCells() )
|
||||
{
|
||||
ps1.AddInitialCell( cell );
|
||||
if( ( mobile.toCell - cell ).LengthSquared <= 2 )
|
||||
return NextActivity;
|
||||
}
|
||||
ps1.heuristic = PathSearch.DefaultEstimator( mobile.toCell );
|
||||
|
||||
var ps2 = PathSearch.FromPoint( self.World, mobile.Info, mobile.toCell, target.Location, true );
|
||||
var ret = self.World.PathFinder.FindBidiPath( ps1, ps2 );
|
||||
if( ret.Count > 0 )
|
||||
ret.RemoveAt( 0 );
|
||||
return Util.SequenceActivities( new Move( () => ret ), this );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -54,7 +54,8 @@ namespace OpenRA.Mods.RA
|
||||
});
|
||||
|
||||
self.CancelActivity();
|
||||
self.QueueActivity(new Move(order.TargetActor.Location, order.TargetActor));
|
||||
self.QueueActivity(new Enter(order.TargetActor));
|
||||
//self.QueueActivity(new Move(order.TargetActor.Location, order.TargetActor));
|
||||
self.QueueActivity(new Demolish(order.TargetActor));
|
||||
self.QueueActivity(new Move(self.Location, 0));
|
||||
}
|
||||
|
||||
@@ -58,7 +58,8 @@ namespace OpenRA.Mods.RA
|
||||
});
|
||||
|
||||
self.CancelActivity();
|
||||
self.QueueActivity(new Move(order.TargetActor.Location, order.TargetActor));
|
||||
self.QueueActivity(new Enter(order.TargetActor));
|
||||
//self.QueueActivity(new Move(order.TargetActor.Location, order.TargetActor));
|
||||
self.QueueActivity(new CaptureBuilding(order.TargetActor));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,7 +57,8 @@ namespace OpenRA.Mods.RA
|
||||
});
|
||||
|
||||
self.CancelActivity();
|
||||
self.QueueActivity(new Move(order.TargetActor.Location, order.TargetActor));
|
||||
self.QueueActivity(new Enter(order.TargetActor));
|
||||
//self.QueueActivity(new Move(order.TargetActor.Location, order.TargetActor));
|
||||
self.QueueActivity(new RepairBuilding(order.TargetActor));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,6 +57,7 @@
|
||||
<Compile Include="Activities\CaptureBuilding.cs" />
|
||||
<Compile Include="Activities\DeliverOre.cs" />
|
||||
<Compile Include="Activities\Demolish.cs" />
|
||||
<Compile Include="Activities\Enter.cs" />
|
||||
<Compile Include="Activities\EnterTransport.cs" />
|
||||
<Compile Include="Activities\Fly.cs" />
|
||||
<Compile Include="Activities\FlyAttack.cs" />
|
||||
@@ -70,6 +71,7 @@
|
||||
<Compile Include="Activities\Land.cs" />
|
||||
<Compile Include="Activities\LayMines.cs" />
|
||||
<Compile Include="Activities\Leap.cs" />
|
||||
<Compile Include="Activities\MoveAdjacentTo.cs" />
|
||||
<Compile Include="Activities\Rearm.cs" />
|
||||
<Compile Include="Activities\Repair.cs" />
|
||||
<Compile Include="Activities\ReturnToBase.cs" />
|
||||
|
||||
@@ -39,7 +39,7 @@ namespace OpenRA.Mods.RA
|
||||
if (order.OrderString == "SpyInfiltrate")
|
||||
{
|
||||
self.CancelActivity();
|
||||
self.QueueActivity(new Move(order.TargetActor, 1));
|
||||
self.QueueActivity(new MoveAdjacentTo(order.TargetActor));
|
||||
if (self.Owner == self.World.LocalPlayer)
|
||||
self.World.AddFrameEndTask( w =>
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user