Files
LuaCsForBarotraumaEP/Subsurface/Characters/DelayedEffect.cs
2015-06-07 18:03:08 +03:00

56 lines
1.2 KiB
C#

using System.Collections.Generic;
using System.Xml.Linq;
namespace Subsurface
{
class DelayedEffect : StatusEffect
{
public static List<DelayedEffect> list = new List<DelayedEffect>();
float delay;
float timer;
private Item item;
private Character character;
private Limb limb;
public float Timer
{
get { return timer; }
}
public DelayedEffect(XElement element)
: base(element)
{
delay = ToolBox.GetAttributeFloat(element, "delay", 1.0f);
}
public override void Apply(ActionType type, float deltaTime, Item item, Character character = null, Limb limb = null)
{
if (this.type != type) return;
this.item = item;
this.character = character;
this.limb = limb;
timer = delay;
list.Add(this);
}
public void Update(float deltaTime)
{
timer -= deltaTime;
if (timer > 0.0f) return;
base.Apply(1.0f, character, item, limb);
list.Remove(this);
}
}
}