added infantry taking cover behavior

This commit is contained in:
Chris Forbes
2009-12-17 21:52:39 +13:00
parent 36e788b685
commit ac2b666366
9 changed files with 184 additions and 16 deletions

View File

@@ -0,0 +1,43 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using OpenRa.Game.GameRules;
namespace OpenRa.Game.Traits
{
// infantry prone behavior
class TakeCover : ITick, INotifyDamageEx, IDamageModifier, ISpeedModifier
{
const int defaultProneTime = 100; /* ticks, =4s */
const float proneDamage = .5f;
const float proneSpeed = .5f;
int remainingProneTime = 0;
public bool IsProne { get { return remainingProneTime > 0; } }
public TakeCover(Actor self) {}
public void Damaged(Actor self, int damage, WarheadInfo warhead)
{
remainingProneTime = defaultProneTime;
}
public void Tick(Actor self)
{
if (IsProne)
--remainingProneTime;
}
public float GetDamageModifier()
{
return IsProne ? proneDamage : 1f;
}
public float GetSpeedModifier()
{
return IsProne ? proneSpeed : 1f;
}
}
}