Add following to IMove.
This commit is contained in:
@@ -153,6 +153,7 @@ namespace OpenRA.Traits
|
||||
Activity MoveTo(CPos cell, int nearEnough);
|
||||
Activity MoveTo(CPos cell, Actor ignoredActor);
|
||||
Activity MoveWithinRange(Target target, WRange range);
|
||||
Activity MoveFollow(Actor self, Target target, WRange range);
|
||||
CPos NearestMoveableCell(CPos target);
|
||||
}
|
||||
|
||||
|
||||
44
OpenRA.Mods.RA/Activities/FlyFollow.cs
Normal file
44
OpenRA.Mods.RA/Activities/FlyFollow.cs
Normal file
@@ -0,0 +1,44 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2014 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 COPYING.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using OpenRA.Mods.RA.Air;
|
||||
using OpenRA.Mods.RA.Move;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.RA.Activities
|
||||
{
|
||||
public class FlyFollow : Activity
|
||||
{
|
||||
Target target;
|
||||
Plane plane;
|
||||
WRange range;
|
||||
|
||||
public FlyFollow(Actor self, Target target, WRange range)
|
||||
{
|
||||
this.target = target;
|
||||
plane = self.Trait<Plane>();
|
||||
this.range = range;
|
||||
}
|
||||
|
||||
public override Activity Tick(Actor self)
|
||||
{
|
||||
if (IsCanceled || !target.IsValidFor(self))
|
||||
return NextActivity;
|
||||
|
||||
if (target.IsInRange(self.CenterPosition, range))
|
||||
{
|
||||
Fly.FlyToward(self, plane, plane.Facing, plane.Info.CruiseAltitude);
|
||||
return this;
|
||||
}
|
||||
|
||||
return Util.SequenceActivities(new Fly(self, target, WRange.Zero, range), this);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -156,6 +156,7 @@ namespace OpenRA.Mods.RA.Air
|
||||
public Activity MoveTo(CPos cell, Actor ignoredActor) { return new HeliFly(self, Target.FromCell(cell)); }
|
||||
public Activity MoveWithinRange(Target target, WRange range) { return new HeliFly(self, target, WRange.Zero, range); }
|
||||
public Activity MoveWithinRange(Target target, WRange minRange, WRange maxRange) { return new HeliFly(self, target, minRange, maxRange); }
|
||||
public Activity MoveFollow(Actor self, Target target, WRange range) { return new Follow(self, target, range); }
|
||||
public CPos NearestMoveableCell(CPos cell) { return cell; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#endregion
|
||||
|
||||
using System.Drawing;
|
||||
using OpenRA.Mods.RA.Activities;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.RA.Air
|
||||
@@ -96,6 +97,7 @@ namespace OpenRA.Mods.RA.Air
|
||||
public Activity MoveTo(CPos cell, Actor ignoredActor) { return Util.SequenceActivities(new Fly(self, Target.FromCell(cell)), new FlyCircle()); }
|
||||
public Activity MoveWithinRange(Target target, WRange range) { return Util.SequenceActivities(new Fly(self, target, WRange.Zero, range), new FlyCircle()); }
|
||||
public Activity MoveWithinRange(Target target, WRange minRange, WRange maxRange) { return Util.SequenceActivities(new Fly(self, target, minRange, maxRange), new FlyCircle()); }
|
||||
public Activity MoveFollow(Actor self, Target target, WRange range) { return new FlyFollow(self, target, range); }
|
||||
public CPos NearestMoveableCell(CPos cell) { return cell; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -99,8 +99,10 @@ namespace OpenRA.Mods.RA
|
||||
var range = WRange.FromCells(Math.Max(0, weapon.Weapon.Range.Range / 1024 - RangeTolerance));
|
||||
|
||||
attack.Target = target;
|
||||
if (allowMove && self.HasTrait<Mobile>() && !self.Info.Traits.Get<MobileInfo>().OnRails)
|
||||
return Util.SequenceActivities(new Follow(self, target, range), this);
|
||||
var mobile = self.TraitOrDefault<Mobile>();
|
||||
|
||||
if (allowMove && mobile != null && !mobile.Info.OnRails)
|
||||
return Util.SequenceActivities(mobile.MoveFollow(self, target, range), this);
|
||||
}
|
||||
|
||||
return NextActivity;
|
||||
|
||||
@@ -30,8 +30,7 @@ namespace OpenRA.Mods.RA
|
||||
self.SetTargetLine(target, Color.Yellow);
|
||||
|
||||
var range = WRange.FromCells(target.Actor.Info.Traits.Get<GuardableInfo>().Range);
|
||||
self.QueueActivity(false, new AttackMove.AttackMoveActivity(self,
|
||||
new Follow(self, target, range)));
|
||||
self.QueueActivity(false, new AttackMove.AttackMoveActivity(self, self.Trait<IMove>().MoveFollow(self, target, range)));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -540,6 +540,7 @@ namespace OpenRA.Mods.RA.Move
|
||||
public Activity MoveTo(CPos cell, int nearEnough) { return new Move(cell, nearEnough); }
|
||||
public Activity MoveTo(CPos cell, Actor ignoredActor) { return new Move(cell, ignoredActor); }
|
||||
public Activity MoveWithinRange(Target target, WRange range) { return new Move(target, range); }
|
||||
public Activity MoveFollow(Actor self, Target target, WRange range) { return new Follow(self, target, range); }
|
||||
public Activity MoveTo(Func<List<CPos>> pathFunc) { return new Move(pathFunc); }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -488,6 +488,7 @@
|
||||
<Compile Include="Render\WithCrateBody.cs" />
|
||||
<Compile Include="Buildings\Demolishable.cs" />
|
||||
<Compile Include="Widgets\Logic\DisconnectWatcherLogic.cs" />
|
||||
<Compile Include="Activities\FlyFollow.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\OpenRA.FileFormats\OpenRA.FileFormats.csproj">
|
||||
|
||||
Reference in New Issue
Block a user