QueuedActivity's Insert is broken
This commit is contained in:
@@ -31,7 +31,7 @@ namespace OpenRA
|
||||
[Sync]
|
||||
public Player Owner;
|
||||
|
||||
private IActivity currentActivity;
|
||||
private Activity currentActivity;
|
||||
public Group Group;
|
||||
|
||||
internal Actor(World world, string name, TypeDictionary initDict )
|
||||
@@ -121,7 +121,14 @@ namespace OpenRA
|
||||
|
||||
public bool IsInWorld { get; internal set; }
|
||||
|
||||
public void QueueActivity( IActivity nextActivity )
|
||||
public void QueueActivity( bool queued, Activity nextActivity )
|
||||
{
|
||||
if( !queued )
|
||||
CancelActivity();
|
||||
QueueActivity( nextActivity );
|
||||
}
|
||||
|
||||
public void QueueActivity( Activity nextActivity )
|
||||
{
|
||||
if( currentActivity == null )
|
||||
currentActivity = nextActivity;
|
||||
@@ -135,7 +142,7 @@ namespace OpenRA
|
||||
currentActivity.Cancel( this );
|
||||
}
|
||||
|
||||
public IActivity GetCurrentActivity()
|
||||
public Activity GetCurrentActivity()
|
||||
{
|
||||
return currentActivity;
|
||||
}
|
||||
|
||||
@@ -15,12 +15,15 @@ using System.Text;
|
||||
|
||||
namespace OpenRA.Traits.Activities
|
||||
{
|
||||
public abstract class CancelableActivity : IActivity
|
||||
public class Activity
|
||||
{
|
||||
protected IActivity NextActivity { get; private set; }
|
||||
public Activity NextActivity { get; set; }
|
||||
protected bool IsCanceled { get; private set; }
|
||||
|
||||
public abstract IActivity Tick( Actor self );
|
||||
public virtual Activity Tick( Actor self )
|
||||
{
|
||||
return this;
|
||||
}
|
||||
protected virtual bool OnCancel( Actor self ) { return true; }
|
||||
|
||||
public void Cancel( Actor self )
|
||||
@@ -32,7 +35,7 @@ namespace OpenRA.Traits.Activities
|
||||
NextActivity.Cancel( self );
|
||||
}
|
||||
|
||||
public void Queue( IActivity activity )
|
||||
public virtual void Queue( Activity activity )
|
||||
{
|
||||
if( NextActivity != null )
|
||||
NextActivity.Queue( activity );
|
||||
@@ -40,9 +43,9 @@ namespace OpenRA.Traits.Activities
|
||||
NextActivity = activity;
|
||||
}
|
||||
|
||||
public virtual IEnumerable<float2> GetCurrentPath()
|
||||
public virtual IEnumerable<Target> GetTargetQueue( Actor self )
|
||||
{
|
||||
yield break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -237,12 +237,12 @@ namespace OpenRA.Traits
|
||||
if (activity != null && mobile != null)
|
||||
{
|
||||
var alt = new float2(0, -mobile.Altitude);
|
||||
var path = activity.GetCurrentPath();
|
||||
var targets = activity.GetTargetQueue(self);
|
||||
var start = self.CenterLocation + alt;
|
||||
|
||||
var c = Color.Green;
|
||||
|
||||
foreach (var step in path)
|
||||
foreach (var step in targets.Select(p => p.CenterLocation))
|
||||
{
|
||||
var stp = step + alt;
|
||||
Game.Renderer.LineRenderer.DrawLine(stp + new float2(-1, -1), stp + new float2(-1, 1), c, c);
|
||||
|
||||
@@ -12,6 +12,8 @@ namespace OpenRA.Traits
|
||||
{
|
||||
public struct Target // a target: either an actor, or a fixed location.
|
||||
{
|
||||
public static Target[] NoTargets = {};
|
||||
|
||||
Actor actor;
|
||||
Player owner;
|
||||
int2 pos;
|
||||
|
||||
@@ -203,14 +203,6 @@ namespace OpenRA.Traits
|
||||
IBotInfo Info { get; }
|
||||
}
|
||||
|
||||
public interface IActivity
|
||||
{
|
||||
IActivity Tick(Actor self);
|
||||
void Cancel(Actor self);
|
||||
void Queue(IActivity activity);
|
||||
IEnumerable<float2> GetCurrentPath();
|
||||
}
|
||||
|
||||
public interface IRenderOverlay { void Render(WorldRenderer wr); }
|
||||
public interface INotifyIdle { void TickIdle(Actor self); }
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@ using System.Linq;
|
||||
using OpenRA.Graphics;
|
||||
using OpenRA.Support;
|
||||
using System.Collections.Generic;
|
||||
using OpenRA.Traits.Activities;
|
||||
|
||||
namespace OpenRA.Traits
|
||||
{
|
||||
@@ -103,13 +104,13 @@ namespace OpenRA.Traits
|
||||
return new Renderable(s, loc.Round(), pal, (int)self.CenterLocation.Y);
|
||||
}
|
||||
|
||||
public static IActivity SequenceActivities(params IActivity[] acts)
|
||||
public static Activity SequenceActivities(params Activity[] acts)
|
||||
{
|
||||
return acts.Reverse().Aggregate(
|
||||
(next, a) => { a.Queue( next ); return a; });
|
||||
}
|
||||
|
||||
public static IActivity RunActivity( Actor self, IActivity act )
|
||||
public static Activity RunActivity( Actor self, Activity act )
|
||||
{
|
||||
while( act != null )
|
||||
{
|
||||
|
||||
@@ -19,7 +19,7 @@ using System;
|
||||
|
||||
namespace OpenRA.Mods.Cnc
|
||||
{
|
||||
public class HarvesterDockSequence : IActivity
|
||||
public class HarvesterDockSequence : Activity
|
||||
{
|
||||
enum State
|
||||
{
|
||||
@@ -49,9 +49,7 @@ namespace OpenRA.Mods.Cnc
|
||||
endDock = proc.Trait<IHasLocation>().PxPosition + new int2(-15,8);
|
||||
}
|
||||
|
||||
IActivity NextActivity { get; set; }
|
||||
|
||||
public IActivity Tick(Actor self)
|
||||
public override Activity Tick(Actor self)
|
||||
{
|
||||
switch (state)
|
||||
{
|
||||
@@ -82,22 +80,15 @@ namespace OpenRA.Mods.Cnc
|
||||
throw new InvalidOperationException("Invalid harvester dock state");
|
||||
}
|
||||
|
||||
public void Cancel(Actor self)
|
||||
protected override bool OnCancel(Actor self)
|
||||
{
|
||||
state = State.Undock;
|
||||
return true;
|
||||
}
|
||||
|
||||
public void Queue( IActivity activity )
|
||||
public override IEnumerable<Target> GetTargetQueue( Actor self )
|
||||
{
|
||||
if( NextActivity != null )
|
||||
NextActivity.Queue( activity );
|
||||
else
|
||||
NextActivity = activity;
|
||||
}
|
||||
|
||||
public IEnumerable<float2> GetCurrentPath()
|
||||
{
|
||||
yield break;
|
||||
yield return Target.FromActor(proc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -116,7 +116,7 @@ namespace OpenRA.Mods.Cnc
|
||||
}
|
||||
}
|
||||
|
||||
public override IActivity GetAttackActivity(Actor self, Target newTarget, bool allowMove)
|
||||
public override Activity GetAttackActivity(Actor self, Target newTarget, bool allowMove)
|
||||
{
|
||||
return new AttackActivity( newTarget );
|
||||
}
|
||||
@@ -137,12 +137,12 @@ namespace OpenRA.Mods.Cnc
|
||||
return State == PopupState.Closed ? Info.ClosedDamageMultiplier : 1f;
|
||||
}
|
||||
|
||||
class AttackActivity : CancelableActivity
|
||||
class AttackActivity : Activity
|
||||
{
|
||||
readonly Target target;
|
||||
public AttackActivity( Target newTarget ) { this.target = newTarget; }
|
||||
|
||||
public override IActivity Tick( Actor self )
|
||||
public override Activity Tick( Actor self )
|
||||
{
|
||||
if( IsCanceled || !target.IsValid ) return NextActivity;
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace OpenRA.Mods.Cnc
|
||||
public TiberiumRefinery(Actor self, TiberiumRefineryInfo info)
|
||||
: base(self, info as OreRefineryInfo) {}
|
||||
|
||||
public override IActivity DockSequence(Actor harv, Actor self)
|
||||
public override Activity DockSequence(Actor harv, Actor self)
|
||||
{
|
||||
return new HarvesterDockSequence(harv, self);
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ using OpenRA.Mods.RA.Move;
|
||||
namespace OpenRA.Mods.RA.Activities
|
||||
{
|
||||
/* non-turreted attack */
|
||||
public class Attack : CancelableActivity
|
||||
public class Attack : Activity
|
||||
{
|
||||
protected Target Target;
|
||||
ITargetable targetable;
|
||||
@@ -40,7 +40,7 @@ namespace OpenRA.Mods.RA.Activities
|
||||
|
||||
public Attack(Target target, int range) : this(target, range, true) {}
|
||||
|
||||
public override IActivity Tick( Actor self )
|
||||
public override Activity Tick( Actor self )
|
||||
{
|
||||
var attack = self.Trait<AttackBase>();
|
||||
|
||||
@@ -49,7 +49,7 @@ namespace OpenRA.Mods.RA.Activities
|
||||
return ret;
|
||||
}
|
||||
|
||||
protected virtual IActivity InnerTick( Actor self, AttackBase attack )
|
||||
protected virtual Activity InnerTick( Actor self, AttackBase attack )
|
||||
{
|
||||
if (IsCanceled) return NextActivity;
|
||||
var facing = self.Trait<IFacing>();
|
||||
|
||||
@@ -11,10 +11,11 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using OpenRA.Traits;
|
||||
using OpenRA.Traits.Activities;
|
||||
|
||||
namespace OpenRA.Mods.RA.Activities
|
||||
{
|
||||
public class CallFunc : IActivity
|
||||
public class CallFunc : Activity
|
||||
{
|
||||
public CallFunc(Action a) { this.a = a; }
|
||||
public CallFunc(Action a, bool interruptable)
|
||||
@@ -25,33 +26,30 @@ namespace OpenRA.Mods.RA.Activities
|
||||
|
||||
Action a;
|
||||
bool interruptable;
|
||||
IActivity NextActivity { get; set; }
|
||||
|
||||
public IActivity Tick(Actor self)
|
||||
public override Activity Tick(Actor self)
|
||||
{
|
||||
if (a != null) a();
|
||||
return NextActivity;
|
||||
}
|
||||
|
||||
public void Cancel(Actor self)
|
||||
protected override bool OnCancel(Actor self)
|
||||
{
|
||||
if (!interruptable)
|
||||
return;
|
||||
return false;
|
||||
|
||||
a = null;
|
||||
NextActivity = null;
|
||||
return true;
|
||||
}
|
||||
|
||||
public void Queue( IActivity activity )
|
||||
public override IEnumerable<Target> GetTargetQueue( Actor self )
|
||||
{
|
||||
if( NextActivity != null )
|
||||
NextActivity.Queue( activity );
|
||||
else
|
||||
NextActivity = activity;
|
||||
}
|
||||
if (NextActivity != null)
|
||||
foreach (var target in NextActivity.GetTargetQueue(self))
|
||||
{
|
||||
yield return target;
|
||||
}
|
||||
|
||||
public IEnumerable<float2> GetCurrentPath()
|
||||
{
|
||||
yield break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,13 +14,13 @@ using OpenRA.Traits.Activities;
|
||||
|
||||
namespace OpenRA.Mods.RA.Activities
|
||||
{
|
||||
class CaptureActor : CancelableActivity
|
||||
class CaptureActor : Activity
|
||||
{
|
||||
Actor target;
|
||||
|
||||
public CaptureActor(Actor target) { this.target = target; }
|
||||
|
||||
public override IActivity Tick(Actor self)
|
||||
public override Activity Tick(Actor self)
|
||||
{
|
||||
if (IsCanceled) return NextActivity;
|
||||
if (target == null || !target.IsInWorld || target.IsDead()) return NextActivity;
|
||||
|
||||
@@ -15,15 +15,13 @@ using OpenRA.Mods.RA.Move;
|
||||
|
||||
namespace OpenRA.Mods.RA.Activities
|
||||
{
|
||||
public class DeliverResources : IActivity
|
||||
public class DeliverResources : Activity
|
||||
{
|
||||
IActivity NextActivity { get; set; }
|
||||
|
||||
bool isDocking;
|
||||
|
||||
public DeliverResources() { }
|
||||
|
||||
public IActivity Tick( Actor self )
|
||||
public override Activity Tick( Actor self )
|
||||
{
|
||||
if( NextActivity != null )
|
||||
return NextActivity;
|
||||
@@ -51,21 +49,20 @@ namespace OpenRA.Mods.RA.Activities
|
||||
return Util.SequenceActivities( new Wait(10), this );
|
||||
}
|
||||
|
||||
public void Cancel(Actor self)
|
||||
protected override bool OnCancel(Actor self)
|
||||
{
|
||||
// TODO: allow canceling of deliver orders?
|
||||
return false;
|
||||
}
|
||||
|
||||
public void Queue( IActivity activity )
|
||||
public override IEnumerable<Target> GetTargetQueue( Actor self )
|
||||
{
|
||||
if( NextActivity != null )
|
||||
NextActivity.Queue( activity );
|
||||
else
|
||||
NextActivity = activity;
|
||||
}
|
||||
if (NextActivity != null)
|
||||
foreach (var target in NextActivity.GetTargetQueue(self))
|
||||
{
|
||||
yield return target;
|
||||
}
|
||||
|
||||
public IEnumerable<float2> GetCurrentPath()
|
||||
{
|
||||
yield break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ using OpenRA.Traits.Activities;
|
||||
|
||||
namespace OpenRA.Mods.RA.Activities
|
||||
{
|
||||
class Demolish : CancelableActivity
|
||||
class Demolish : Activity
|
||||
{
|
||||
Actor target;
|
||||
int delay;
|
||||
@@ -26,7 +26,7 @@ namespace OpenRA.Mods.RA.Activities
|
||||
this.delay = delay;
|
||||
}
|
||||
|
||||
public override IActivity Tick(Actor self)
|
||||
public override Activity Tick(Actor self)
|
||||
{
|
||||
if (IsCanceled) return NextActivity;
|
||||
if (target == null || !target.IsInWorld || target.IsDead()) return NextActivity;
|
||||
|
||||
@@ -15,7 +15,7 @@ using OpenRA.Mods.RA.Effects;
|
||||
|
||||
namespace OpenRA.Mods.RA.Activities
|
||||
{
|
||||
class DonateSupplies : CancelableActivity
|
||||
class DonateSupplies : Activity
|
||||
{
|
||||
Actor target;
|
||||
int payload;
|
||||
@@ -26,7 +26,7 @@ namespace OpenRA.Mods.RA.Activities
|
||||
this.payload = payload;
|
||||
}
|
||||
|
||||
public override IActivity Tick(Actor self)
|
||||
public override Activity Tick(Actor self)
|
||||
{
|
||||
if (IsCanceled) return NextActivity;
|
||||
if (target == null || !target.IsInWorld || target.IsDead()) return NextActivity;
|
||||
|
||||
@@ -17,12 +17,12 @@ using OpenRA.Mods.RA.Move;
|
||||
|
||||
namespace OpenRA.Mods.RA.Activities
|
||||
{
|
||||
public class Enter : CancelableActivity
|
||||
public class Enter : Activity
|
||||
{
|
||||
readonly Actor target;
|
||||
public Enter( Actor target ) { this.target = target; }
|
||||
|
||||
public override IActivity Tick( Actor self )
|
||||
public override Activity Tick( Actor self )
|
||||
{
|
||||
if( IsCanceled || target.Destroyed || !target.IsInWorld )
|
||||
return NextActivity;
|
||||
|
||||
@@ -13,7 +13,7 @@ using OpenRA.Traits.Activities;
|
||||
|
||||
namespace OpenRA.Mods.RA.Activities
|
||||
{
|
||||
class EnterTransport : CancelableActivity
|
||||
class EnterTransport : Activity
|
||||
{
|
||||
public Actor transport;
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace OpenRA.Mods.RA.Activities
|
||||
this.transport = transport;
|
||||
}
|
||||
|
||||
public override IActivity Tick(Actor self)
|
||||
public override Activity Tick(Actor self)
|
||||
{
|
||||
if (IsCanceled) return NextActivity;
|
||||
if (transport == null || !transport.IsInWorld) return NextActivity;
|
||||
|
||||
@@ -14,7 +14,7 @@ using OpenRA.Mods.RA.Move;
|
||||
|
||||
namespace OpenRA.Mods.RA.Activities
|
||||
{
|
||||
public class Follow : CancelableActivity
|
||||
public class Follow : Activity
|
||||
{
|
||||
Target Target;
|
||||
int Range;
|
||||
@@ -29,7 +29,7 @@ namespace OpenRA.Mods.RA.Activities
|
||||
Range = range;
|
||||
}
|
||||
|
||||
public override IActivity Tick( Actor self )
|
||||
public override Activity Tick( Actor self )
|
||||
{
|
||||
if (IsCanceled) return NextActivity;
|
||||
if (!Target.IsValid) return NextActivity;
|
||||
|
||||
@@ -13,14 +13,15 @@ using OpenRA.Mods.RA.Render;
|
||||
using OpenRA.Traits;
|
||||
using OpenRA.Traits.Activities;
|
||||
using OpenRA.Mods.RA.Move;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace OpenRA.Mods.RA.Activities
|
||||
{
|
||||
public class Harvest : CancelableActivity
|
||||
public class Harvest : Activity
|
||||
{
|
||||
bool isHarvesting = false;
|
||||
|
||||
public override IActivity Tick( Actor self )
|
||||
public override Activity Tick( Actor self )
|
||||
{
|
||||
if( isHarvesting ) return this;
|
||||
if( IsCanceled ) return NextActivity;
|
||||
@@ -74,5 +75,10 @@ namespace OpenRA.Mods.RA.Activities
|
||||
}));
|
||||
self.QueueActivity(new Harvest());
|
||||
}
|
||||
|
||||
public override IEnumerable<Target> GetTargetQueue( Actor self )
|
||||
{
|
||||
yield return Target.FromPos(self.Location);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace OpenRA.Mods.RA.Activities
|
||||
public Heal(Target target, int range, bool allowMovement)
|
||||
: base(target, range, allowMovement) {}
|
||||
|
||||
protected override IActivity InnerTick( Actor self, AttackBase attack )
|
||||
protected override Activity InnerTick( Actor self, AttackBase attack )
|
||||
{
|
||||
if (Target.IsActor && Target.Actor.GetDamageState() == DamageState.Undamaged)
|
||||
return NextActivity;
|
||||
|
||||
@@ -14,12 +14,12 @@ using OpenRA.Traits.Activities;
|
||||
|
||||
namespace OpenRA.Mods.RA.Activities
|
||||
{
|
||||
class Infiltrate : CancelableActivity
|
||||
class Infiltrate : Activity
|
||||
{
|
||||
Actor target;
|
||||
public Infiltrate(Actor target) { this.target = target; }
|
||||
|
||||
public override IActivity Tick(Actor self)
|
||||
public override Activity Tick(Actor self)
|
||||
{
|
||||
if (IsCanceled) return NextActivity;
|
||||
if (target == null || !target.IsInWorld || target.IsDead()) return NextActivity;
|
||||
|
||||
@@ -18,9 +18,9 @@ namespace OpenRA.Mods.RA.Activities
|
||||
{
|
||||
// assumes you have Minelayer on that unit
|
||||
|
||||
class LayMines : CancelableActivity
|
||||
class LayMines : Activity
|
||||
{
|
||||
public override IActivity Tick( Actor self )
|
||||
public override Activity Tick( Actor self )
|
||||
{
|
||||
if (IsCanceled) return NextActivity;
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ using OpenRA.Traits.Activities;
|
||||
|
||||
namespace OpenRA.Mods.RA.Activities
|
||||
{
|
||||
class Leap : CancelableActivity
|
||||
class Leap : Activity
|
||||
{
|
||||
Target target;
|
||||
int2 initialLocation;
|
||||
@@ -33,7 +33,7 @@ namespace OpenRA.Mods.RA.Activities
|
||||
Sound.Play("dogg5p.aud", self.CenterLocation);
|
||||
}
|
||||
|
||||
public override IActivity Tick(Actor self)
|
||||
public override Activity Tick(Actor self)
|
||||
{
|
||||
if( moveFraction == 0 && IsCanceled ) return NextActivity;
|
||||
if (!target.IsValid) return NextActivity;
|
||||
|
||||
@@ -16,7 +16,7 @@ using OpenRA.Traits.Activities;
|
||||
|
||||
namespace OpenRA.Mods.RA.Activities
|
||||
{
|
||||
class MakeAnimation : CancelableActivity
|
||||
class MakeAnimation : Activity
|
||||
{
|
||||
readonly bool Reversed;
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace OpenRA.Mods.RA.Activities
|
||||
|
||||
bool complete = false;
|
||||
bool started = false;
|
||||
public override IActivity Tick( Actor self )
|
||||
public override Activity Tick( Actor self )
|
||||
{
|
||||
if (IsCanceled) return NextActivity;
|
||||
if (!started)
|
||||
|
||||
@@ -14,7 +14,7 @@ using OpenRA.Traits.Activities;
|
||||
|
||||
namespace OpenRA.Mods.RA.Activities
|
||||
{
|
||||
public class MoveAdjacentTo : CancelableActivity
|
||||
public class MoveAdjacentTo : Activity
|
||||
{
|
||||
readonly Actor target;
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace OpenRA.Mods.RA.Activities
|
||||
this.target = target;
|
||||
}
|
||||
|
||||
public override IActivity Tick( Actor self )
|
||||
public override Activity Tick( Actor self )
|
||||
{
|
||||
if( IsCanceled || target.Destroyed || !target.IsInWorld) return NextActivity;
|
||||
|
||||
|
||||
@@ -11,26 +11,24 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using OpenRA.Traits;
|
||||
using OpenRA.Traits.Activities;
|
||||
|
||||
namespace OpenRA.Mods.RA.Activities
|
||||
{
|
||||
public class QueuedActivity : IActivity
|
||||
public class QueuedActivity : Activity
|
||||
{
|
||||
public QueuedActivity(Action<QueuedActivity> a) { this.a = a; }
|
||||
|
||||
public QueuedActivity(Action<QueuedActivity> a, bool interruptable)
|
||||
{
|
||||
this.a = a;
|
||||
this.interruptable = interruptable;
|
||||
}
|
||||
|
||||
Action<QueuedActivity> a;
|
||||
private bool interruptable = true;
|
||||
public IActivity NextActivity { get; set; }
|
||||
|
||||
public IActivity Tick(Actor self) { return Run(self); }
|
||||
public override Activity Tick(Actor self) { return Run(self); }
|
||||
|
||||
public IActivity Run(Actor self)
|
||||
public Activity Run(Actor self)
|
||||
{
|
||||
if (a != null)
|
||||
a(this);
|
||||
@@ -38,7 +36,7 @@ namespace OpenRA.Mods.RA.Activities
|
||||
return NextActivity;
|
||||
}
|
||||
|
||||
public void Insert(IActivity activity)
|
||||
public void Insert( Activity activity )
|
||||
{
|
||||
if (activity == null)
|
||||
return;
|
||||
@@ -46,29 +44,12 @@ namespace OpenRA.Mods.RA.Activities
|
||||
NextActivity = activity;
|
||||
}
|
||||
|
||||
public void Cancel(Actor self)
|
||||
{
|
||||
if (!interruptable)
|
||||
return;
|
||||
|
||||
a = null;
|
||||
NextActivity = null;
|
||||
}
|
||||
|
||||
public void Queue( IActivity activity )
|
||||
{
|
||||
if( NextActivity != null )
|
||||
NextActivity.Queue( activity );
|
||||
else
|
||||
NextActivity = activity;
|
||||
}
|
||||
|
||||
public IEnumerable<float2> GetCurrentPath()
|
||||
public override IEnumerable<Target> GetTargetQueue( Actor self )
|
||||
{
|
||||
if (NextActivity != null)
|
||||
foreach (var path in NextActivity.GetCurrentPath())
|
||||
foreach (var target in NextActivity.GetTargetQueue(self))
|
||||
{
|
||||
yield return path;
|
||||
yield return target;
|
||||
}
|
||||
|
||||
yield break;
|
||||
|
||||
@@ -18,7 +18,7 @@ using System;
|
||||
|
||||
namespace OpenRA.Mods.RA
|
||||
{
|
||||
public class RAHarvesterDockSequence : IActivity
|
||||
public class RAHarvesterDockSequence : Activity
|
||||
{
|
||||
enum State
|
||||
{
|
||||
@@ -42,10 +42,8 @@ namespace OpenRA.Mods.RA
|
||||
harv = self.Trait<Harvester>();
|
||||
ru = self.Trait<RenderUnit>();
|
||||
}
|
||||
|
||||
IActivity NextActivity { get; set; }
|
||||
|
||||
public IActivity Tick(Actor self)
|
||||
|
||||
public override Activity Tick(Actor self)
|
||||
{
|
||||
switch (state)
|
||||
{
|
||||
@@ -72,22 +70,15 @@ namespace OpenRA.Mods.RA
|
||||
throw new InvalidOperationException("Invalid harvester dock state");
|
||||
}
|
||||
|
||||
public void Cancel(Actor self)
|
||||
protected override bool OnCancel(Actor self)
|
||||
{
|
||||
state = State.Undock;
|
||||
return true;
|
||||
}
|
||||
|
||||
public void Queue( IActivity activity )
|
||||
public override IEnumerable<Target> GetTargetQueue( Actor self )
|
||||
{
|
||||
if( NextActivity != null )
|
||||
NextActivity.Queue( activity );
|
||||
else
|
||||
NextActivity = activity;
|
||||
}
|
||||
|
||||
public IEnumerable<float2> GetCurrentPath()
|
||||
{
|
||||
yield break;
|
||||
yield return Target.FromActor(proc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,13 +15,13 @@ using OpenRA.Traits.Activities;
|
||||
|
||||
namespace OpenRA.Mods.RA.Activities
|
||||
{
|
||||
public class Rearm : CancelableActivity
|
||||
public class Rearm : Activity
|
||||
{
|
||||
int remainingTicks = ticksPerPip;
|
||||
|
||||
const int ticksPerPip = 25 * 2;
|
||||
|
||||
public override IActivity Tick(Actor self)
|
||||
public override Activity Tick(Actor self)
|
||||
{
|
||||
if (IsCanceled) return NextActivity;
|
||||
var limitedAmmo = self.TraitOrDefault<LimitedAmmo>();
|
||||
|
||||
@@ -13,9 +13,9 @@ using OpenRA.Traits.Activities;
|
||||
|
||||
namespace OpenRA.Mods.RA.Activities
|
||||
{
|
||||
public class RemoveSelf : CancelableActivity
|
||||
public class RemoveSelf : Activity
|
||||
{
|
||||
public override IActivity Tick(Actor self)
|
||||
public override Activity Tick(Actor self)
|
||||
{
|
||||
if (IsCanceled) return NextActivity;
|
||||
self.Destroy();
|
||||
|
||||
@@ -15,14 +15,14 @@ using OpenRA.Traits.Activities;
|
||||
|
||||
namespace OpenRA.Mods.RA.Activities
|
||||
{
|
||||
public class Repair : CancelableActivity
|
||||
public class Repair : Activity
|
||||
{
|
||||
int remainingTicks;
|
||||
Actor host;
|
||||
|
||||
public Repair(Actor host) { this.host = host; }
|
||||
|
||||
public override IActivity Tick(Actor self)
|
||||
public override Activity Tick(Actor self)
|
||||
{
|
||||
if (IsCanceled) return NextActivity;
|
||||
if (host != null && !host.IsInWorld) return NextActivity;
|
||||
|
||||
@@ -14,13 +14,13 @@ using OpenRA.Traits.Activities;
|
||||
|
||||
namespace OpenRA.Mods.RA.Activities
|
||||
{
|
||||
class RepairBuilding : CancelableActivity
|
||||
class RepairBuilding : Activity
|
||||
{
|
||||
Actor target;
|
||||
|
||||
public RepairBuilding(Actor target) { this.target = target; }
|
||||
|
||||
public override IActivity Tick(Actor self)
|
||||
public override Activity Tick(Actor self)
|
||||
{
|
||||
if (IsCanceled) return NextActivity;
|
||||
if (target == null || !target.IsInWorld || target.IsDead()) return NextActivity;
|
||||
|
||||
@@ -16,9 +16,9 @@ using OpenRA.Mods.RA.Buildings;
|
||||
|
||||
namespace OpenRA.Mods.RA.Activities
|
||||
{
|
||||
class Sell : CancelableActivity
|
||||
class Sell : Activity
|
||||
{
|
||||
public override IActivity Tick(Actor self)
|
||||
public override Activity Tick(Actor self)
|
||||
{
|
||||
var h = self.TraitOrDefault<Health>();
|
||||
var si = self.Info.Traits.Get<SellableInfo>();
|
||||
|
||||
@@ -14,7 +14,7 @@ using OpenRA.Traits.Activities;
|
||||
|
||||
namespace OpenRA.Mods.RA.Activities
|
||||
{
|
||||
public class Teleport : CancelableActivity
|
||||
public class Teleport : Activity
|
||||
{
|
||||
int2 destination;
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace OpenRA.Mods.RA.Activities
|
||||
this.destination = destination;
|
||||
}
|
||||
|
||||
public override IActivity Tick(Actor self)
|
||||
public override Activity Tick(Actor self)
|
||||
{
|
||||
self.TraitsImplementing<ITeleportable>().FirstOrDefault().SetPosition(self, destination);
|
||||
return NextActivity;
|
||||
|
||||
@@ -16,7 +16,7 @@ using OpenRA.Traits.Activities;
|
||||
|
||||
namespace OpenRA.Mods.RA.Activities
|
||||
{
|
||||
class Transform : CancelableActivity
|
||||
class Transform : Activity
|
||||
{
|
||||
public readonly string ToActor = null;
|
||||
public int2 Offset = new int2(0,0);
|
||||
@@ -29,7 +29,7 @@ namespace OpenRA.Mods.RA.Activities
|
||||
this.ToActor = toActor;
|
||||
}
|
||||
|
||||
public override IActivity Tick( Actor self )
|
||||
public override Activity Tick( Actor self )
|
||||
{
|
||||
if (IsCanceled) return NextActivity;
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ using OpenRA.Traits.Activities;
|
||||
|
||||
namespace OpenRA.Mods.RA.Activities
|
||||
{
|
||||
public class Turn : CancelableActivity
|
||||
public class Turn : Activity
|
||||
{
|
||||
int desiredFacing;
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace OpenRA.Mods.RA.Activities
|
||||
this.desiredFacing = desiredFacing;
|
||||
}
|
||||
|
||||
public override IActivity Tick( Actor self )
|
||||
public override Activity Tick( Actor self )
|
||||
{
|
||||
if (IsCanceled) return NextActivity;
|
||||
var facing = self.Trait<IFacing>();
|
||||
|
||||
@@ -17,7 +17,7 @@ using OpenRA.Mods.RA.Move;
|
||||
|
||||
namespace OpenRA.Mods.RA.Activities
|
||||
{
|
||||
public class UnloadCargo : CancelableActivity
|
||||
public class UnloadCargo : Activity
|
||||
{
|
||||
int2? ChooseExitTile(Actor self, Actor cargo)
|
||||
{
|
||||
@@ -36,7 +36,7 @@ namespace OpenRA.Mods.RA.Activities
|
||||
return null;
|
||||
}
|
||||
|
||||
public override IActivity Tick(Actor self)
|
||||
public override Activity Tick(Actor self)
|
||||
{
|
||||
if (IsCanceled) return NextActivity;
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ using OpenRA.Traits.Activities;
|
||||
|
||||
namespace OpenRA.Mods.RA.Activities
|
||||
{
|
||||
public class Wait : CancelableActivity
|
||||
public class Wait : Activity
|
||||
{
|
||||
int remainingTicks;
|
||||
bool interruptable = true;
|
||||
@@ -25,7 +25,7 @@ namespace OpenRA.Mods.RA.Activities
|
||||
this.interruptable = interruptable;
|
||||
}
|
||||
|
||||
public override IActivity Tick(Actor self)
|
||||
public override Activity Tick(Actor self)
|
||||
{
|
||||
if (remainingTicks-- == 0) return NextActivity;
|
||||
return this;
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
|
||||
using OpenRA.Mods.RA.Activities;
|
||||
using OpenRA.Traits;
|
||||
using OpenRA.Traits.Activities;
|
||||
|
||||
namespace OpenRA.Mods.RA.Air
|
||||
{
|
||||
@@ -22,7 +23,7 @@ namespace OpenRA.Mods.RA.Air
|
||||
{
|
||||
public AttackHeli(Actor self, AttackHeliInfo info) : base(self, info) { }
|
||||
|
||||
public override IActivity GetAttackActivity(Actor self, Target newTarget, bool allowMove)
|
||||
public override Activity GetAttackActivity(Actor self, Target newTarget, bool allowMove)
|
||||
{
|
||||
return new HeliAttack( newTarget );
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
|
||||
using OpenRA.Mods.RA.Activities;
|
||||
using OpenRA.Traits;
|
||||
using OpenRA.Traits.Activities;
|
||||
|
||||
namespace OpenRA.Mods.RA.Air
|
||||
{
|
||||
@@ -22,7 +23,7 @@ namespace OpenRA.Mods.RA.Air
|
||||
{
|
||||
public AttackPlane(Actor self, AttackPlaneInfo info) : base(self, info) { }
|
||||
|
||||
public override IActivity GetAttackActivity(Actor self, Target newTarget, bool allowMove)
|
||||
public override Activity GetAttackActivity(Actor self, Target newTarget, bool allowMove)
|
||||
{
|
||||
return new FlyAttack( newTarget );
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ namespace OpenRA.Mods.RA.Air
|
||||
}
|
||||
}
|
||||
|
||||
class FallToEarth : CancelableActivity
|
||||
class FallToEarth : Activity
|
||||
{
|
||||
int acceleration = 0;
|
||||
int spin = 0;
|
||||
@@ -47,7 +47,7 @@ namespace OpenRA.Mods.RA.Air
|
||||
acceleration = self.World.SharedRandom.Next(2) * 2 - 1;
|
||||
}
|
||||
|
||||
public override IActivity Tick(Actor self)
|
||||
public override Activity Tick(Actor self)
|
||||
{
|
||||
var aircraft = self.Trait<Aircraft>();
|
||||
if (aircraft.Altitude <= 0)
|
||||
|
||||
@@ -15,7 +15,7 @@ using OpenRA.Traits.Activities;
|
||||
|
||||
namespace OpenRA.Mods.RA.Air
|
||||
{
|
||||
public class Fly : CancelableActivity
|
||||
public class Fly : Activity
|
||||
{
|
||||
public readonly int2 Pos;
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace OpenRA.Mods.RA.Air
|
||||
public static Fly ToPx( int2 px ) { return new Fly( px ); }
|
||||
public static Fly ToCell( int2 pos ) { return new Fly( Util.CenterOfCell( pos ) ); }
|
||||
|
||||
public override IActivity Tick(Actor self)
|
||||
public override Activity Tick(Actor self)
|
||||
{
|
||||
var cruiseAltitude = self.Info.Traits.Get<PlaneInfo>().CruiseAltitude;
|
||||
|
||||
@@ -47,9 +47,9 @@ namespace OpenRA.Mods.RA.Air
|
||||
return this;
|
||||
}
|
||||
|
||||
public override IEnumerable<float2> GetCurrentPath()
|
||||
public override IEnumerable<Target> GetTargetQueue( Actor self )
|
||||
{
|
||||
yield return Pos;
|
||||
yield return Target.FromPos(Pos);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -13,14 +13,14 @@ using OpenRA.Traits.Activities;
|
||||
|
||||
namespace OpenRA.Mods.RA.Air
|
||||
{
|
||||
public class FlyAttack : CancelableActivity
|
||||
public class FlyAttack : Activity
|
||||
{
|
||||
readonly Target Target;
|
||||
IActivity inner;
|
||||
Activity inner;
|
||||
|
||||
public FlyAttack(Target target) { Target = target; }
|
||||
|
||||
public override IActivity Tick(Actor self)
|
||||
public override Activity Tick(Actor self)
|
||||
{
|
||||
if( !Target.IsValid )
|
||||
Cancel( self );
|
||||
@@ -52,13 +52,13 @@ namespace OpenRA.Mods.RA.Air
|
||||
}
|
||||
}
|
||||
|
||||
public class FlyAttackLoop : CancelableActivity
|
||||
public class FlyAttackLoop : Activity
|
||||
{
|
||||
int2 Target;
|
||||
|
||||
public FlyAttackLoop(int2 target) { Target = target; }
|
||||
|
||||
public override IActivity Tick(Actor self)
|
||||
public override Activity Tick(Actor self)
|
||||
{
|
||||
if( IsCanceled ) return NextActivity;
|
||||
|
||||
|
||||
@@ -14,9 +14,9 @@ using OpenRA.Traits.Activities;
|
||||
|
||||
namespace OpenRA.Mods.RA.Air
|
||||
{
|
||||
public class FlyCircle : CancelableActivity
|
||||
public class FlyCircle : Activity
|
||||
{
|
||||
public override IActivity Tick(Actor self)
|
||||
public override Activity Tick(Actor self)
|
||||
{
|
||||
var cruiseAltitude = self.Info.Traits.Get<PlaneInfo>().CruiseAltitude;
|
||||
|
||||
@@ -34,10 +34,5 @@ namespace OpenRA.Mods.RA.Air
|
||||
FlyUtil.Fly(self, cruiseAltitude);
|
||||
return this;
|
||||
}
|
||||
|
||||
public override IEnumerable<float2> GetCurrentPath()
|
||||
{
|
||||
yield break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,13 +13,13 @@ using OpenRA.Traits.Activities;
|
||||
|
||||
namespace OpenRA.Mods.RA.Air
|
||||
{
|
||||
public class FlyTimed : CancelableActivity
|
||||
public class FlyTimed : Activity
|
||||
{
|
||||
int remainingTicks;
|
||||
|
||||
public FlyTimed(int ticks) { remainingTicks = ticks; }
|
||||
|
||||
public override IActivity Tick(Actor self)
|
||||
public override Activity Tick(Actor self)
|
||||
{
|
||||
if( IsCanceled ) return NextActivity;
|
||||
var targetAltitude = self.Info.Traits.Get<PlaneInfo>().CruiseAltitude;
|
||||
@@ -29,11 +29,11 @@ namespace OpenRA.Mods.RA.Air
|
||||
}
|
||||
}
|
||||
|
||||
public class FlyOffMap : CancelableActivity
|
||||
public class FlyOffMap : Activity
|
||||
{
|
||||
public bool Interruptible = true;
|
||||
|
||||
public override IActivity Tick(Actor self)
|
||||
public override Activity Tick(Actor self)
|
||||
{
|
||||
var targetAltitude = self.Info.Traits.Get<PlaneInfo>().CruiseAltitude;
|
||||
if (IsCanceled || !self.World.Map.IsInMap(self.Location)) return NextActivity;
|
||||
|
||||
@@ -15,12 +15,12 @@ using OpenRA.Traits.Activities;
|
||||
|
||||
namespace OpenRA.Mods.RA.Air
|
||||
{
|
||||
public class HeliAttack : CancelableActivity
|
||||
public class HeliAttack : Activity
|
||||
{
|
||||
Target target;
|
||||
public HeliAttack( Target target ) { this.target = target; }
|
||||
|
||||
public override IActivity Tick(Actor self)
|
||||
public override Activity Tick(Actor self)
|
||||
{
|
||||
if (IsCanceled) return NextActivity;
|
||||
if (!target.IsValid) return NextActivity;
|
||||
|
||||
@@ -15,7 +15,7 @@ using OpenRA.Traits.Activities;
|
||||
|
||||
namespace OpenRA.Mods.RA.Air
|
||||
{
|
||||
class HeliFly : CancelableActivity
|
||||
class HeliFly : Activity
|
||||
{
|
||||
public readonly int2 Dest;
|
||||
public HeliFly(int2 dest)
|
||||
@@ -23,7 +23,7 @@ namespace OpenRA.Mods.RA.Air
|
||||
Dest = dest;
|
||||
}
|
||||
|
||||
public override IActivity Tick(Actor self)
|
||||
public override Activity Tick(Actor self)
|
||||
{
|
||||
if (IsCanceled) return NextActivity;
|
||||
|
||||
@@ -50,9 +50,9 @@ namespace OpenRA.Mods.RA.Air
|
||||
return this;
|
||||
}
|
||||
|
||||
public override IEnumerable<float2> GetCurrentPath()
|
||||
public override IEnumerable<Target> GetTargetQueue( Actor self )
|
||||
{
|
||||
yield return Dest;
|
||||
yield return Target.FromPos(Dest);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,13 +13,13 @@ using OpenRA.Traits.Activities;
|
||||
|
||||
namespace OpenRA.Mods.RA.Air
|
||||
{
|
||||
class HeliLand : CancelableActivity
|
||||
class HeliLand : Activity
|
||||
{
|
||||
public HeliLand(bool requireSpace) { this.requireSpace = requireSpace; }
|
||||
|
||||
bool requireSpace;
|
||||
|
||||
public override IActivity Tick(Actor self)
|
||||
public override Activity Tick(Actor self)
|
||||
{
|
||||
if (IsCanceled) return NextActivity;
|
||||
var aircraft = self.Trait<Aircraft>();
|
||||
|
||||
@@ -15,7 +15,7 @@ using OpenRA.Mods.RA.Activities;
|
||||
|
||||
namespace OpenRA.Mods.RA.Air
|
||||
{
|
||||
public class HeliReturn : CancelableActivity
|
||||
public class HeliReturn : Activity
|
||||
{
|
||||
static Actor ChooseHelipad(Actor self)
|
||||
{
|
||||
@@ -25,7 +25,7 @@ namespace OpenRA.Mods.RA.Air
|
||||
!Reservable.IsReserved(a));
|
||||
}
|
||||
|
||||
public override IActivity Tick(Actor self)
|
||||
public override Activity Tick(Actor self)
|
||||
{
|
||||
if (IsCanceled) return NextActivity;
|
||||
var dest = ChooseHelipad(self);
|
||||
|
||||
@@ -15,13 +15,13 @@ using OpenRA.Traits.Activities;
|
||||
|
||||
namespace OpenRA.Mods.RA.Air
|
||||
{
|
||||
public class Land : CancelableActivity
|
||||
public class Land : Activity
|
||||
{
|
||||
Target Target;
|
||||
|
||||
public Land(Target t) { Target = t; }
|
||||
|
||||
public override IActivity Tick(Actor self)
|
||||
public override Activity Tick(Actor self)
|
||||
{
|
||||
if (!Target.IsValid)
|
||||
Cancel(self);
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using OpenRA.Traits;
|
||||
using OpenRA.Traits.Activities;
|
||||
|
||||
namespace OpenRA.Mods.RA.Air
|
||||
{
|
||||
|
||||
@@ -16,7 +16,7 @@ using OpenRA.Mods.RA.Buildings;
|
||||
|
||||
namespace OpenRA.Mods.RA.Air
|
||||
{
|
||||
public class ReturnToBase : CancelableActivity
|
||||
public class ReturnToBase : Activity
|
||||
{
|
||||
bool isCalculated;
|
||||
Actor dest;
|
||||
@@ -90,7 +90,7 @@ namespace OpenRA.Mods.RA.Air
|
||||
this.dest = dest;
|
||||
}
|
||||
|
||||
public override IActivity Tick(Actor self)
|
||||
public override Activity Tick(Actor self)
|
||||
{
|
||||
if (IsCanceled) return NextActivity;
|
||||
if (!isCalculated)
|
||||
|
||||
@@ -14,6 +14,7 @@ using System.Drawing;
|
||||
using System.Linq;
|
||||
using OpenRA.FileFormats;
|
||||
using OpenRA.Traits;
|
||||
using OpenRA.Traits.Activities;
|
||||
|
||||
namespace OpenRA.Mods.RA
|
||||
{
|
||||
@@ -172,7 +173,7 @@ namespace OpenRA.Mods.RA
|
||||
return (order.OrderString == "Attack" || order.OrderString == "AttackHold") ? "Attack" : null;
|
||||
}
|
||||
|
||||
public abstract IActivity GetAttackActivity(Actor self, Target newTarget, bool allowMove);
|
||||
public abstract Activity GetAttackActivity(Actor self, Target newTarget, bool allowMove);
|
||||
|
||||
public bool HasAnyValidWeapons(Target t) { return Weapons.Any(w => w.IsValidAgainst(self.World, t)); }
|
||||
public float GetMaximumRange() { return Weapons.Max(w => w.Info.Range); }
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
|
||||
using System;
|
||||
using OpenRA.Traits;
|
||||
using OpenRA.Traits.Activities;
|
||||
|
||||
namespace OpenRA.Mods.RA
|
||||
{
|
||||
@@ -40,7 +41,7 @@ namespace OpenRA.Mods.RA
|
||||
return true;
|
||||
}
|
||||
|
||||
public override IActivity GetAttackActivity(Actor self, Target newTarget, bool allowMove)
|
||||
public override Activity GetAttackActivity(Actor self, Target newTarget, bool allowMove)
|
||||
{
|
||||
var weapon = ChooseWeaponForTarget(newTarget);
|
||||
if( weapon == null )
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
using System;
|
||||
using OpenRA.Mods.RA.Activities;
|
||||
using OpenRA.Traits;
|
||||
using OpenRA.Traits.Activities;
|
||||
|
||||
namespace OpenRA.Mods.RA
|
||||
{
|
||||
@@ -37,7 +38,7 @@ namespace OpenRA.Mods.RA
|
||||
self.QueueActivity(new Leap(self, target));
|
||||
}
|
||||
|
||||
public override IActivity GetAttackActivity(Actor self, Target newTarget, bool allowMove)
|
||||
public override Activity GetAttackActivity(Actor self, Target newTarget, bool allowMove)
|
||||
{
|
||||
var weapon = ChooseWeaponForTarget(newTarget);
|
||||
if( weapon == null )
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
|
||||
using System;
|
||||
using OpenRA.Traits;
|
||||
using OpenRA.Traits.Activities;
|
||||
|
||||
namespace OpenRA.Mods.RA
|
||||
{
|
||||
@@ -23,7 +24,7 @@ namespace OpenRA.Mods.RA
|
||||
public AttackMedic(Actor self, AttackMedicInfo info)
|
||||
: base( self, info ) {}
|
||||
|
||||
public override IActivity GetAttackActivity(Actor self, Target newTarget, bool allowMove)
|
||||
public override Activity GetAttackActivity(Actor self, Target newTarget, bool allowMove)
|
||||
{
|
||||
var weapon = ChooseWeaponForTarget(newTarget);
|
||||
if( weapon == null )
|
||||
|
||||
@@ -73,12 +73,12 @@ namespace OpenRA.Mods.RA
|
||||
}
|
||||
}
|
||||
|
||||
class AttackMoveActivity : CancelableActivity
|
||||
class AttackMoveActivity : Activity
|
||||
{
|
||||
IActivity inner;
|
||||
public AttackMoveActivity( IActivity inner ) { this.inner = inner; }
|
||||
Activity inner;
|
||||
public AttackMoveActivity( Activity inner ) { this.inner = inner; }
|
||||
|
||||
public override IActivity Tick( Actor self )
|
||||
public override Activity Tick( Actor self )
|
||||
{
|
||||
self.Trait<AutoTarget>().ScanAndAttack(self, true, false);
|
||||
|
||||
|
||||
@@ -32,17 +32,17 @@ namespace OpenRA.Mods.RA
|
||||
return base.CanAttack( self, target ) && !isBuilding;
|
||||
}
|
||||
|
||||
public override IActivity GetAttackActivity(Actor self, Target newTarget, bool allowMove)
|
||||
public override Activity GetAttackActivity(Actor self, Target newTarget, bool allowMove)
|
||||
{
|
||||
return new SetTarget( newTarget );
|
||||
}
|
||||
|
||||
class SetTarget : CancelableActivity
|
||||
class SetTarget : Activity
|
||||
{
|
||||
readonly Target target;
|
||||
public SetTarget( Target target ) { this.target = target; }
|
||||
|
||||
public override IActivity Tick( Actor self )
|
||||
public override Activity Tick( Actor self )
|
||||
{
|
||||
if( IsCanceled || !target.IsValid )
|
||||
return NextActivity;
|
||||
|
||||
@@ -47,17 +47,17 @@ namespace OpenRA.Mods.RA
|
||||
timeToRecharge = self.Info.Traits.Get<AttackTeslaInfo>().ReloadTime;
|
||||
}
|
||||
|
||||
public override IActivity GetAttackActivity( Actor self, Target newTarget, bool allowMove )
|
||||
public override Activity GetAttackActivity( Actor self, Target newTarget, bool allowMove )
|
||||
{
|
||||
return new TeslaAttack( newTarget );
|
||||
}
|
||||
|
||||
class TeslaAttack : CancelableActivity
|
||||
class TeslaAttack : Activity
|
||||
{
|
||||
readonly Target target;
|
||||
public TeslaAttack( Target target ) { this.target = target; }
|
||||
|
||||
public override IActivity Tick( Actor self )
|
||||
public override Activity Tick( Actor self )
|
||||
{
|
||||
if( IsCanceled || !target.IsValid ) return NextActivity;
|
||||
|
||||
@@ -70,12 +70,12 @@ namespace OpenRA.Mods.RA
|
||||
}
|
||||
}
|
||||
|
||||
class TeslaZap : CancelableActivity
|
||||
class TeslaZap : Activity
|
||||
{
|
||||
readonly Target target;
|
||||
public TeslaZap( Target target ) { this.target = target; }
|
||||
|
||||
public override IActivity Tick( Actor self )
|
||||
public override Activity Tick( Actor self )
|
||||
{
|
||||
if( IsCanceled || !target.IsValid ) return NextActivity;
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ namespace OpenRA.Mods.RA
|
||||
DoAttack( self, target );
|
||||
}
|
||||
|
||||
public override IActivity GetAttackActivity(Actor self, Target newTarget, bool allowMove)
|
||||
public override Activity GetAttackActivity(Actor self, Target newTarget, bool allowMove)
|
||||
{
|
||||
return new AttackActivity( newTarget );
|
||||
}
|
||||
@@ -64,12 +64,12 @@ namespace OpenRA.Mods.RA
|
||||
bool buildComplete = false;
|
||||
public void BuildingComplete(Actor self) { buildComplete = true; }
|
||||
|
||||
class AttackActivity : CancelableActivity
|
||||
class AttackActivity : Activity
|
||||
{
|
||||
readonly Target target;
|
||||
public AttackActivity( Target newTarget ) { this.target = newTarget; }
|
||||
|
||||
public override IActivity Tick( Actor self )
|
||||
public override Activity Tick( Actor self )
|
||||
{
|
||||
if( IsCanceled || !target.IsValid ) return NextActivity;
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
|
||||
using OpenRA.FileFormats;
|
||||
using OpenRA.Traits;
|
||||
using OpenRA.Traits.Activities;
|
||||
|
||||
namespace OpenRA.Mods.RA
|
||||
{
|
||||
@@ -39,7 +40,7 @@ namespace OpenRA.Mods.RA
|
||||
});
|
||||
|
||||
if (info.InitialActivity != null)
|
||||
a.QueueActivity(Game.CreateObject<IActivity>(info.InitialActivity));
|
||||
a.QueueActivity(Game.CreateObject<Activity>(info.InitialActivity));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,13 +10,12 @@
|
||||
|
||||
using System.Collections.Generic;
|
||||
using OpenRA.Traits;
|
||||
using OpenRA.Traits.Activities;
|
||||
|
||||
namespace OpenRA.Mods.RA.Move
|
||||
{
|
||||
public class Drag : IActivity
|
||||
public class Drag : Activity
|
||||
{
|
||||
IActivity NextActivity { get; set; }
|
||||
|
||||
int2 endLocation;
|
||||
int2 startLocation;
|
||||
int length;
|
||||
@@ -29,7 +28,7 @@ namespace OpenRA.Mods.RA.Move
|
||||
}
|
||||
|
||||
int ticks = 0;
|
||||
public IActivity Tick( Actor self )
|
||||
public override Activity Tick( Actor self )
|
||||
{
|
||||
var mobile = self.Trait<Mobile>();
|
||||
mobile.PxPosition = int2.Lerp(startLocation, endLocation, ticks, length - 1);
|
||||
@@ -43,19 +42,14 @@ namespace OpenRA.Mods.RA.Move
|
||||
return this;
|
||||
}
|
||||
|
||||
public void Cancel(Actor self) { }
|
||||
|
||||
public void Queue( IActivity activity )
|
||||
{
|
||||
if( NextActivity != null )
|
||||
NextActivity.Queue( activity );
|
||||
else
|
||||
NextActivity = activity;
|
||||
protected override bool OnCancel(Actor self)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public IEnumerable<float2> GetCurrentPath()
|
||||
public override IEnumerable<Target> GetTargetQueue( Actor self )
|
||||
{
|
||||
yield return endLocation;
|
||||
yield return Target.FromPos(endLocation);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -457,11 +457,11 @@ namespace OpenRA.Mods.RA.Move
|
||||
}
|
||||
}
|
||||
|
||||
public IActivity ScriptedMove(int2 cell) { return new Move(cell); }
|
||||
public IActivity MoveTo(int2 cell, int nearEnough) { return new Move(cell, nearEnough); }
|
||||
public IActivity MoveTo(int2 cell, Actor ignoredActor) { return new Move(cell, ignoredActor); }
|
||||
public IActivity MoveWithinRange(Actor target, int range) { return new Move(target, range); }
|
||||
public IActivity MoveWithinRange(Target target, int range) { return new Move(target, range); }
|
||||
public IActivity MoveTo(Func<List<int2>> pathFunc) { return new Move(pathFunc); }
|
||||
public Activity ScriptedMove(int2 cell) { return new Move(cell); }
|
||||
public Activity MoveTo(int2 cell, int nearEnough) { return new Move(cell, nearEnough); }
|
||||
public Activity MoveTo(int2 cell, Actor ignoredActor) { return new Move(cell, ignoredActor); }
|
||||
public Activity MoveWithinRange(Actor target, int range) { return new Move(target, range); }
|
||||
public Activity MoveWithinRange(Target target, int range) { return new Move(target, range); }
|
||||
public Activity MoveTo(Func<List<int2>> pathFunc) { return new Move(pathFunc); }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ using OpenRA.FileFormats;
|
||||
|
||||
namespace OpenRA.Mods.RA.Move
|
||||
{
|
||||
class Move : CancelableActivity
|
||||
class Move : Activity
|
||||
{
|
||||
int2? destination;
|
||||
int nearEnough;
|
||||
@@ -102,7 +102,7 @@ namespace OpenRA.Mods.RA.Move
|
||||
return path;
|
||||
}
|
||||
|
||||
public override IActivity Tick( Actor self )
|
||||
public override Activity Tick( Actor self )
|
||||
{
|
||||
var mobile = self.Trait<Mobile>();
|
||||
|
||||
@@ -239,16 +239,16 @@ namespace OpenRA.Mods.RA.Move
|
||||
return true;
|
||||
}
|
||||
|
||||
public override IEnumerable<float2> GetCurrentPath()
|
||||
public override IEnumerable<Target> GetTargetQueue( Actor self )
|
||||
{
|
||||
if( path != null )
|
||||
return Enumerable.Reverse(path).Select( c => (float2)Util.CenterOfCell(c) );
|
||||
return Enumerable.Reverse(path).Select( c => Target.FromCell(c) );
|
||||
if( destination != null )
|
||||
return new float2[] { destination.Value };
|
||||
return new float2[ 0 ];
|
||||
return new Target[] { Target.FromPos(destination.Value) };
|
||||
return Target.NoTargets;
|
||||
}
|
||||
|
||||
abstract class MovePart : IActivity
|
||||
abstract class MovePart : Activity
|
||||
{
|
||||
public readonly Move move;
|
||||
public readonly int2 from, to;
|
||||
@@ -267,17 +267,17 @@ namespace OpenRA.Mods.RA.Move
|
||||
this.moveFractionTotal = ( ( to - from ) * 3 ).Length;
|
||||
}
|
||||
|
||||
public void Cancel( Actor self )
|
||||
protected override bool OnCancel( Actor self )
|
||||
{
|
||||
move.Cancel( self );
|
||||
return move.OnCancel( self );
|
||||
}
|
||||
|
||||
public void Queue( IActivity activity )
|
||||
public override void Queue( Activity activity )
|
||||
{
|
||||
move.Queue( activity );
|
||||
}
|
||||
|
||||
public IActivity Tick( Actor self )
|
||||
public override Activity Tick( Actor self )
|
||||
{
|
||||
var mobile = self.Trait<Mobile>();
|
||||
var ret = InnerTick( self, mobile );
|
||||
@@ -290,7 +290,7 @@ namespace OpenRA.Mods.RA.Move
|
||||
return ret;
|
||||
}
|
||||
|
||||
IActivity InnerTick( Actor self, Mobile mobile )
|
||||
Activity InnerTick( Actor self, Mobile mobile )
|
||||
{
|
||||
moveFraction += mobile.MovementSpeedForCell(self, mobile.toCell);
|
||||
if( moveFraction <= moveFractionTotal )
|
||||
@@ -315,9 +315,9 @@ namespace OpenRA.Mods.RA.Move
|
||||
|
||||
protected abstract MovePart OnComplete( Actor self, Mobile mobile, Move parent );
|
||||
|
||||
public IEnumerable<float2> GetCurrentPath()
|
||||
public override IEnumerable<Target> GetTargetQueue( Actor self )
|
||||
{
|
||||
return move.GetCurrentPath();
|
||||
return move.GetTargetQueue(self);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@ using OpenRA.Mods.RA.Effects;
|
||||
using OpenRA.Mods.RA.Move;
|
||||
using OpenRA.Mods.RA.Render;
|
||||
using OpenRA.Traits;
|
||||
using OpenRA.Traits.Activities;
|
||||
|
||||
namespace OpenRA.Mods.RA
|
||||
{
|
||||
@@ -51,7 +52,7 @@ namespace OpenRA.Mods.RA
|
||||
bool preventDock = false;
|
||||
|
||||
public int2 DeliverOffset { get { return Info.DockOffset; } }
|
||||
public virtual IActivity DockSequence(Actor harv, Actor self)
|
||||
public virtual Activity DockSequence(Actor harv, Actor self)
|
||||
{
|
||||
return new RAHarvesterDockSequence(harv, self);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user