Make INotifyIdle and INotifyBecomingIdle require explicit implementation
This commit is contained in:
committed by
Matthias Mailänder
parent
ddfed13db4
commit
761a4f29ab
@@ -318,7 +318,10 @@ namespace OpenRA.Traits
|
||||
}
|
||||
|
||||
public interface IRenderOverlay { void Render(WorldRenderer wr); }
|
||||
|
||||
[RequireExplicitImplementation]
|
||||
public interface INotifyBecomingIdle { void OnBecomingIdle(Actor self); }
|
||||
[RequireExplicitImplementation]
|
||||
public interface INotifyIdle { void TickIdle(Actor self); }
|
||||
|
||||
public interface IRenderAboveWorld { void RenderAboveWorld(Actor self, WorldRenderer wr); }
|
||||
|
||||
@@ -87,7 +87,7 @@ namespace OpenRA.Mods.Common.Scripting
|
||||
return Triggerables(trigger).Count > 0;
|
||||
}
|
||||
|
||||
public void TickIdle(Actor self)
|
||||
void INotifyIdle.TickIdle(Actor self)
|
||||
{
|
||||
if (world.Disposing)
|
||||
return;
|
||||
|
||||
@@ -19,7 +19,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
class FlyAwayOnIdle : INotifyIdle
|
||||
{
|
||||
public void TickIdle(Actor self)
|
||||
void INotifyIdle.TickIdle(Actor self)
|
||||
{
|
||||
self.QueueActivity(new FlyOffMap(self));
|
||||
self.QueueActivity(new RemoveSelf());
|
||||
|
||||
@@ -30,7 +30,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
aircraftInfo = self.Info.TraitInfo<AircraftInfo>();
|
||||
}
|
||||
|
||||
public void TickIdle(Actor self)
|
||||
void INotifyIdle.TickIdle(Actor self)
|
||||
{
|
||||
// We're on the ground, let's stay there.
|
||||
if (self.World.Map.DistanceAboveTerrain(self.CenterPosition).Length < aircraftInfo.MinAirborneAltitude)
|
||||
|
||||
@@ -92,7 +92,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
self.QueueActivity(new AttackMoveActivity(self, move.MoveTo(TargetLocation.Value, 1)));
|
||||
}
|
||||
|
||||
public void TickIdle(Actor self)
|
||||
void INotifyIdle.TickIdle(Actor self)
|
||||
{
|
||||
// This might cause the actor to be stuck if the target location is unreachable
|
||||
if (TargetLocation.HasValue && self.Location != TargetLocation.Value)
|
||||
|
||||
@@ -188,7 +188,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
Attack(self, Aggressor, allowMove);
|
||||
}
|
||||
|
||||
public void TickIdle(Actor self)
|
||||
void INotifyIdle.TickIdle(Actor self)
|
||||
{
|
||||
if (IsTraitDisabled || Stance < UnitStance.Defend)
|
||||
return;
|
||||
|
||||
@@ -57,12 +57,17 @@ namespace OpenRA.Mods.Common.Traits
|
||||
base.Created(self);
|
||||
}
|
||||
|
||||
public virtual void OnBecomingIdle(Actor self)
|
||||
protected virtual void OnBecomingIdle(Actor self)
|
||||
{
|
||||
countdown = self.World.SharedRandom.Next(info.MinMoveDelay, info.MaxMoveDelay);
|
||||
}
|
||||
|
||||
public virtual void TickIdle(Actor self)
|
||||
void INotifyBecomingIdle.OnBecomingIdle(Actor self)
|
||||
{
|
||||
OnBecomingIdle(self);
|
||||
}
|
||||
|
||||
protected virtual void TickIdle(Actor self)
|
||||
{
|
||||
if (IsTraitDisabled)
|
||||
return;
|
||||
@@ -83,6 +88,11 @@ namespace OpenRA.Mods.Common.Traits
|
||||
DoAction(self, targetCell);
|
||||
}
|
||||
|
||||
void INotifyIdle.TickIdle(Actor self)
|
||||
{
|
||||
TickIdle(self);
|
||||
}
|
||||
|
||||
CPos PickTargetLocation()
|
||||
{
|
||||
var target = self.CenterPosition + new WVec(0, -1024 * effectiveMoveRadius, 0).Rotate(WRot.FromFacing(self.World.SharedRandom.Next(255)));
|
||||
|
||||
Reference in New Issue
Block a user