Gets rid of coroutine spam by turning Duration into its own DurationListElement similar to how Delays were handled.
Added tags to Status Effects, which also allows for fancy stuff like checking for tags over duration elements for more interesting interactions. Adds "stackable" variable which dictates whether or not the same duration/delay effect can be applied to the same target(s) at the same time. This is a bit imperfect at the moment. Adds Chloromydride which is a non-stackable chem stabilizing critical health which stops its effects once the health is stabilized. TODO: Remove target from Targets if he already has it, and if targets becomes empty, return; TODO: Conditional tag-checking and status effect tag-checking, plus more "special" checks like SpeciesName and other non-serialized options. TODO: StatusEffect Cancel component to stop delayed/duration effects
This commit is contained in:
@@ -12,7 +12,7 @@ namespace Barotrauma
|
||||
}
|
||||
class DelayedEffect : StatusEffect
|
||||
{
|
||||
public static List<DelayedListElement> List = new List<DelayedListElement>();
|
||||
public static List<DelayedListElement> DelayList = new List<DelayedListElement>();
|
||||
|
||||
private float delay;
|
||||
|
||||
@@ -25,27 +25,34 @@ namespace Barotrauma
|
||||
public override void Apply(ActionType type, float deltaTime, Entity entity, List<ISerializableEntity> targets)
|
||||
{
|
||||
if (this.type != type || !HasRequiredItems(entity)) return;
|
||||
if (!base.Stackable && DelayList.Find(d => d.Parent == this && d.Entity == entity && d.Targets == targets) != null) return;
|
||||
|
||||
DelayedListElement element = new DelayedListElement();
|
||||
element.Parent = this;
|
||||
element.StartTimer = delay;
|
||||
element.Entity = entity;
|
||||
element.Targets = targets;
|
||||
|
||||
List.Add(element);
|
||||
DelayList.Add(element);
|
||||
}
|
||||
|
||||
public static void Update(float deltaTime)
|
||||
{
|
||||
for (int i = DelayedEffect.List.Count - 1; i >= 0; i--)
|
||||
for (int i = DelayList.Count - 1; i >= 0; i--)
|
||||
{
|
||||
DelayedListElement element = DelayedEffect.List[i];
|
||||
DelayedListElement element = DelayList[i];
|
||||
if (element.Parent.CheckConditionalAlways && !element.Parent.HasRequiredConditions(element.Targets))
|
||||
{
|
||||
DelayList.Remove(element);
|
||||
continue;
|
||||
}
|
||||
|
||||
element.StartTimer -= deltaTime;
|
||||
|
||||
if (element.StartTimer > 0.0f) continue;
|
||||
|
||||
element.Parent.Apply(1.0f, element.Entity, element.Targets);
|
||||
List.Remove(element);
|
||||
DelayList.Remove(element);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user