new heli movement
This commit is contained in:
32
OpenRa.Game/Traits/Activities/HeliLand.cs
Normal file
32
OpenRa.Game/Traits/Activities/HeliLand.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace OpenRa.Game.Traits.Activities
|
||||
{
|
||||
class HeliLand : IActivity
|
||||
{
|
||||
public HeliLand(bool requireSpace) { this.requireSpace = requireSpace; }
|
||||
|
||||
bool requireSpace;
|
||||
bool isCanceled;
|
||||
public IActivity NextActivity { get; set; }
|
||||
|
||||
public IActivity Tick(Actor self)
|
||||
{
|
||||
if (isCanceled) return NextActivity;
|
||||
var unit = self.traits.Get<Unit>();
|
||||
if (unit.Altitude == 0)
|
||||
return NextActivity;
|
||||
|
||||
if (requireSpace && !Game.IsCellBuildable(self.Location, UnitMovementType.Foot))
|
||||
return this; // fail to land if no space
|
||||
|
||||
--unit.Altitude;
|
||||
return this;
|
||||
}
|
||||
|
||||
public void Cancel(Actor self) { isCanceled = true; NextActivity = null; }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user