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:
38
OpenRA.Mods.RA/UnitStances/UnitStanceReturnFire.cs
Normal file
38
OpenRA.Mods.RA/UnitStances/UnitStanceReturnFire.cs
Normal file
@@ -0,0 +1,38 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.RA
|
||||
{
|
||||
public class UnitStanceReturnFireInfo : UnitStanceInfo
|
||||
{
|
||||
public override object Create(ActorInitializer init) { return new UnitStanceReturnFire(init.self, this); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Return Fire
|
||||
///
|
||||
/// Will fire only when fired upon
|
||||
/// </summary>
|
||||
public class UnitStanceReturnFire : UnitStance, INotifyDamage, ISelectionColorModifier
|
||||
{
|
||||
public UnitStanceReturnFire(Actor self, UnitStanceReturnFireInfo info)
|
||||
{
|
||||
Info = info;
|
||||
Active = (self.World.LocalPlayer == self.Owner || (self.Owner.IsBot && Game.IsHost)) ? Info.Default : false;
|
||||
}
|
||||
|
||||
public void Damaged(Actor self, AttackInfo e)
|
||||
{
|
||||
if (!Active) return;
|
||||
if (!self.HasTrait<AttackBase>()) return;
|
||||
|
||||
ReturnFire(self, e, false); // only triggers when standing still
|
||||
}
|
||||
|
||||
public Color GetSelectionColorModifier(Actor self, Color defaultColor)
|
||||
{
|
||||
return Active ? Color.Orange : defaultColor;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user