more for Activity
This commit is contained in:
@@ -1,51 +1,41 @@
|
|||||||
#region Copyright & License Information
|
using System;
|
||||||
/*
|
using System.Collections.Generic;
|
||||||
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
|
using System.Linq;
|
||||||
* This file is part of OpenRA, which is free software. It is made
|
using System.Text;
|
||||||
* available to you under the terms of the GNU General Public License
|
|
||||||
* as published by the Free Software Foundation. For more information,
|
namespace OpenRA.Traits.Activities
|
||||||
* see COPYING.
|
{
|
||||||
*/
|
public class Activity
|
||||||
#endregion
|
{
|
||||||
|
public Activity NextActivity { get; set; }
|
||||||
using System;
|
protected bool IsCanceled { get; private set; }
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
public virtual Activity Tick( Actor self )
|
||||||
using System.Text;
|
{
|
||||||
|
return this;
|
||||||
namespace OpenRA.Traits.Activities
|
}
|
||||||
{
|
protected virtual bool OnCancel( Actor self ) { return true; }
|
||||||
public class Activity
|
|
||||||
{
|
public virtual void Cancel( Actor self )
|
||||||
public Activity NextActivity { get; set; }
|
{
|
||||||
protected bool IsCanceled { get; private set; }
|
IsCanceled = OnCancel( self );
|
||||||
|
if( IsCanceled )
|
||||||
public virtual Activity Tick( Actor self )
|
NextActivity = null;
|
||||||
{
|
else if (NextActivity != null)
|
||||||
return this;
|
NextActivity.Cancel( self );
|
||||||
}
|
}
|
||||||
protected virtual bool OnCancel( Actor self ) { return true; }
|
|
||||||
|
public virtual void Queue( Activity activity )
|
||||||
public void Cancel( Actor self )
|
{
|
||||||
{
|
if( NextActivity != null )
|
||||||
IsCanceled = OnCancel( self );
|
NextActivity.Queue( activity );
|
||||||
if( IsCanceled )
|
else
|
||||||
NextActivity = null;
|
NextActivity = activity;
|
||||||
else if (NextActivity != null)
|
}
|
||||||
NextActivity.Cancel( self );
|
|
||||||
}
|
public virtual IEnumerable<Target> GetTargetQueue( Actor self )
|
||||||
|
{
|
||||||
public virtual void Queue( Activity activity )
|
yield break;
|
||||||
{
|
}
|
||||||
if( NextActivity != null )
|
}
|
||||||
NextActivity.Queue( activity );
|
}
|
||||||
else
|
|
||||||
NextActivity = activity;
|
|
||||||
}
|
|
||||||
|
|
||||||
public virtual IEnumerable<Target> GetTargetQueue( Actor self )
|
|
||||||
{
|
|
||||||
yield break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,38 +1,38 @@
|
|||||||
#region Copyright & License Information
|
#region Copyright & License Information
|
||||||
/*
|
/*
|
||||||
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
|
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
|
||||||
* This file is part of OpenRA, which is free software. It is made
|
* This file is part of OpenRA, which is free software. It is made
|
||||||
* available to you under the terms of the GNU General Public License
|
* available to you under the terms of the GNU General Public License
|
||||||
* as published by the Free Software Foundation. For more information,
|
* as published by the Free Software Foundation. For more information,
|
||||||
* see COPYING.
|
* see COPYING.
|
||||||
*/
|
*/
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using OpenRA.Traits;
|
using OpenRA.Traits;
|
||||||
using OpenRA.Traits.Activities;
|
using OpenRA.Traits.Activities;
|
||||||
|
|
||||||
namespace OpenRA.Mods.RA.Air
|
namespace OpenRA.Mods.RA.Air
|
||||||
{
|
{
|
||||||
public class FlyCircle : Activity
|
public class FlyCircle : Activity
|
||||||
{
|
{
|
||||||
public override Activity Tick(Actor self)
|
public override Activity Tick(Actor self)
|
||||||
{
|
{
|
||||||
var cruiseAltitude = self.Info.Traits.Get<PlaneInfo>().CruiseAltitude;
|
var cruiseAltitude = self.Info.Traits.Get<PlaneInfo>().CruiseAltitude;
|
||||||
|
|
||||||
if (IsCanceled) return NextActivity;
|
if (IsCanceled) return NextActivity;
|
||||||
|
|
||||||
var aircraft = self.Trait<Aircraft>();
|
var aircraft = self.Trait<Aircraft>();
|
||||||
|
|
||||||
var desiredFacing = aircraft.Facing + 64; // we can't possibly turn this fast.
|
var desiredFacing = aircraft.Facing + 64; // we can't possibly turn this fast.
|
||||||
if (aircraft.Altitude == cruiseAltitude)
|
if (aircraft.Altitude == cruiseAltitude)
|
||||||
aircraft.Facing = Util.TickFacing(aircraft.Facing, desiredFacing, aircraft.ROT);
|
aircraft.Facing = Util.TickFacing(aircraft.Facing, desiredFacing, aircraft.ROT);
|
||||||
|
|
||||||
if (aircraft.Altitude < cruiseAltitude)
|
if (aircraft.Altitude < cruiseAltitude)
|
||||||
++aircraft.Altitude;
|
++aircraft.Altitude;
|
||||||
|
|
||||||
FlyUtil.Fly(self, cruiseAltitude);
|
FlyUtil.Fly(self, cruiseAltitude);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user