Implemented: Stances

Added: Basic stances (Aggressive, Guard (Hold Ground), Hold Fire, None (dummy), Return Fire)
Added: WorldCommandWidget (to be able to set said stances)
Added: WorldCommandWidget to ra (cnc will follow, later on)
Changed: Added support to AttackBase for firing with movement disabled + utility method ScanForTarget (used by stances)
Added: AssignUnitStance (attach this to unit-producing actors, together with what stances can be picked as 'default')
This commit is contained in:
geckosoft
2010-11-11 04:28:11 +01:00
committed by Bob
parent 6d67ab2240
commit 6b40abb58c
18 changed files with 640 additions and 29 deletions

View File

@@ -0,0 +1,38 @@
using System;
using System.Drawing;
using OpenRA.Traits;
namespace OpenRA.Mods.RA
{
public class UnitStanceHoldFireInfo : UnitStanceInfo
{
public override object Create(ActorInitializer init) { return new UnitStanceHoldFire(init.self, this); }
}
/// <summary>
/// Hold Fire
///
/// Will not perform any attacks automaticly
/// </summary>
public class UnitStanceHoldFire : UnitStance, ISelectionColorModifier
{
public UnitStanceHoldFire(Actor self, UnitStanceHoldFireInfo info)
{
Info = info;
Active = (self.World.LocalPlayer == self.Owner || (self.Owner.IsBot && Game.IsHost)) ? Info.Default : false;
}
protected override void OnFirstTick(Actor self)
{
if (!self.HasTrait<AttackBase>()) return;
if (self.Trait<AttackBase>().IsAttacking)
StopAttack(self);
}
public Color GetSelectionColorModifier(Actor self, Color defaultColor)
{
return Active ? Color.SpringGreen : defaultColor;
}
}
}