move CancelableActivity into its own file
This commit is contained in:
@@ -221,6 +221,7 @@
|
|||||||
<Compile Include="ObjectCreator.cs" />
|
<Compile Include="ObjectCreator.cs" />
|
||||||
<Compile Include="Network\SyncReport.cs" />
|
<Compile Include="Network\SyncReport.cs" />
|
||||||
<Compile Include="TraitDictionary.cs" />
|
<Compile Include="TraitDictionary.cs" />
|
||||||
|
<Compile Include="Traits\Activities\CancelableActivity.cs" />
|
||||||
<Compile Include="Traits\SharesCell.cs" />
|
<Compile Include="Traits\SharesCell.cs" />
|
||||||
<Compile Include="Traits\Valued.cs" />
|
<Compile Include="Traits\Valued.cs" />
|
||||||
<Compile Include="Traits\World\BibLayer.cs" />
|
<Compile Include="Traits\World\BibLayer.cs" />
|
||||||
|
|||||||
38
OpenRA.Game/Traits/Activities/CancelableActivity.cs
Executable file
38
OpenRA.Game/Traits/Activities/CancelableActivity.cs
Executable file
@@ -0,0 +1,38 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace OpenRA.Traits
|
||||||
|
{
|
||||||
|
public abstract class CancelableActivity : IActivity
|
||||||
|
{
|
||||||
|
protected IActivity NextActivity { get; private set; }
|
||||||
|
protected bool IsCanceled { get; private set; }
|
||||||
|
|
||||||
|
public abstract IActivity Tick( Actor self );
|
||||||
|
protected virtual bool OnCancel( Actor self ) { return true; }
|
||||||
|
|
||||||
|
public void Cancel( Actor self )
|
||||||
|
{
|
||||||
|
IsCanceled = OnCancel( self );
|
||||||
|
if( IsCanceled )
|
||||||
|
NextActivity = null;
|
||||||
|
else if (NextActivity != null)
|
||||||
|
NextActivity.Cancel( self );
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Queue( IActivity activity )
|
||||||
|
{
|
||||||
|
if( NextActivity != null )
|
||||||
|
NextActivity.Queue( activity );
|
||||||
|
else
|
||||||
|
NextActivity = activity;
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual IEnumerable<float2> GetCurrentPath()
|
||||||
|
{
|
||||||
|
yield break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -180,37 +180,6 @@ namespace OpenRA.Traits
|
|||||||
IEnumerable<float2> GetCurrentPath();
|
IEnumerable<float2> GetCurrentPath();
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract class CancelableActivity : IActivity
|
|
||||||
{
|
|
||||||
protected IActivity NextActivity { get; private set; }
|
|
||||||
protected bool IsCanceled { get; private set; }
|
|
||||||
|
|
||||||
public abstract IActivity Tick( Actor self );
|
|
||||||
protected virtual bool OnCancel( Actor self ) { return true; }
|
|
||||||
|
|
||||||
public void Cancel( Actor self )
|
|
||||||
{
|
|
||||||
IsCanceled = OnCancel( self );
|
|
||||||
if( IsCanceled )
|
|
||||||
NextActivity = null;
|
|
||||||
else if (NextActivity != null)
|
|
||||||
NextActivity.Cancel( self );
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Queue( IActivity activity )
|
|
||||||
{
|
|
||||||
if( NextActivity != null )
|
|
||||||
NextActivity.Queue( activity );
|
|
||||||
else
|
|
||||||
NextActivity = activity;
|
|
||||||
}
|
|
||||||
|
|
||||||
public virtual IEnumerable<float2> GetCurrentPath()
|
|
||||||
{
|
|
||||||
yield break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public interface IRenderOverlay { void Render( WorldRenderer wr ); }
|
public interface IRenderOverlay { void Render( WorldRenderer wr ); }
|
||||||
public interface INotifyIdle { void Idle(Actor self); }
|
public interface INotifyIdle { void Idle(Actor self); }
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user