Tidy up Activity.Cancel(), make Tick abstract

This commit is contained in:
Paul Chote
2011-04-16 13:18:22 +12:00
parent 0a67c68c45
commit 4f83e994d0
14 changed files with 47 additions and 54 deletions

View File

@@ -33,13 +33,10 @@ namespace OpenRA.Mods.RA.Activities
return NextActivity;
}
protected override bool OnCancel(Actor self)
public override void Cancel(Actor self)
{
if (!interruptable)
return false;
a = null;
return true;
if (interruptable)
base.Cancel(self);
}
}
}

View File

@@ -23,6 +23,7 @@ namespace OpenRA.Mods.RA.Activities
public override Activity Tick( Actor self )
{
// TODO: wtf is this?
if( NextActivity != null )
return NextActivity;
@@ -48,11 +49,8 @@ namespace OpenRA.Mods.RA.Activities
}
return Util.SequenceActivities( new Wait(10), this );
}
protected override bool OnCancel(Actor self)
{
// TODO: allow canceling of deliver orders?
return false;
}
// Cannot be cancelled
public override void Cancel(Actor self) { }
}
}

View File

@@ -30,7 +30,6 @@ namespace OpenRA.Mods.RA.Activities
bool started = false;
public override Activity Tick( Actor self )
{
if (IsCanceled) return NextActivity;
if (!started)
{
var rb = self.Trait<RenderBuilding>();
@@ -51,7 +50,7 @@ namespace OpenRA.Mods.RA.Activities
return complete ? NextActivity : this;
}
// Not actually cancellable
protected override bool OnCancel( Actor self ) { return false; }
// Cannot be cancelled
public override void Cancel( Actor self ) { }
}
}

View File

@@ -70,10 +70,10 @@ namespace OpenRA.Mods.RA
throw new InvalidOperationException("Invalid harvester dock state");
}
protected override bool OnCancel(Actor self)
public override void Cancel(Actor self)
{
state = State.Undock;
return true;
base.Cancel(self);
}
public override IEnumerable<Target> GetTargets( Actor self )

View File

@@ -40,7 +40,7 @@ namespace OpenRA.Mods.RA.Activities
return this;
}
// Not actually cancellable
protected override bool OnCancel( Actor self ) { return false; }
// Cannot be cancelled
public override void Cancel( Actor self ) { }
}
}

View File

@@ -27,15 +27,16 @@ namespace OpenRA.Mods.RA.Activities
public override Activity Tick(Actor self)
{
if (remainingTicks-- == 0) return NextActivity;
return this;
return (remainingTicks-- == 0) ? NextActivity: this;
}
protected override bool OnCancel( Actor self )
public override void Cancel( Actor self )
{
if( !interruptable ) return false;
if( !interruptable )
return;
remainingTicks = 0;
return true;
base.Cancel(self);
}
}
}