move CancelableActivity into its own file

This commit is contained in:
Bob
2010-10-23 20:56:05 +13:00
committed by Chris Forbes
parent fece294cc6
commit 25582cb9f8
3 changed files with 39 additions and 31 deletions

View File

@@ -221,6 +221,7 @@
<Compile Include="ObjectCreator.cs" />
<Compile Include="Network\SyncReport.cs" />
<Compile Include="TraitDictionary.cs" />
<Compile Include="Traits\Activities\CancelableActivity.cs" />
<Compile Include="Traits\SharesCell.cs" />
<Compile Include="Traits\Valued.cs" />
<Compile Include="Traits\World\BibLayer.cs" />

View 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;
}
}
}

View File

@@ -180,37 +180,6 @@ namespace OpenRA.Traits
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 INotifyIdle { void Idle(Actor self); }