Files
LuaCsForBarotraumaEP/Barotrauma/BarotraumaShared/Source/Characters/DelayedEffect.cs
T
Alex Noir c26cef89c6 Fixed DelayedEffect applying when dropped from hands
Amanitin is now craftable from Erythrozine, Flash Powder and Sulphuric Acid with 60 medical skill
Diving Mask and Diving Suit are now craftable
Diving Suit is now deconstructable
Fixed buttons yielding different materials on deconstruction
2017-12-21 23:03:25 +03:00

52 lines
1.5 KiB
C#

using System.Collections.Generic;
using System.Xml.Linq;
namespace Barotrauma
{
class DelayedListElement
{
public DelayedEffect Parent;
public Entity Entity;
public List<ISerializableEntity> Targets;
public float StartTimer;
}
class DelayedEffect : StatusEffect
{
public static List<DelayedListElement> List = new List<DelayedListElement>();
private float delay;
public DelayedEffect(XElement element)
: base(element)
{
delay = element.GetAttributeFloat("delay", 1.0f);
}
public override void Apply(ActionType type, float deltaTime, Entity entity, List<ISerializableEntity> targets)
{
if (this.type != type || !HasRequiredItems(entity)) return;
DelayedListElement element = new DelayedListElement();
element.Parent = this;
element.StartTimer = delay;
element.Entity = entity;
element.Targets = targets;
List.Add(element);
}
public static void Update(float deltaTime)
{
for (int i = DelayedEffect.List.Count - 1; i >= 0; i--)
{
DelayedListElement element = DelayedEffect.List[i];
element.StartTimer -= deltaTime;
if (element.StartTimer > 0.0f) continue;
element.Parent.Apply(1.0f, element.Entity, element.Targets);
List.Remove(element);
}
}
}
}