diff --git a/Barotrauma/BarotraumaShared/Source/StatusEffects/DelayedEffect.cs b/Barotrauma/BarotraumaShared/Source/StatusEffects/DelayedEffect.cs index db754da57..225c061ca 100644 --- a/Barotrauma/BarotraumaShared/Source/StatusEffects/DelayedEffect.cs +++ b/Barotrauma/BarotraumaShared/Source/StatusEffects/DelayedEffect.cs @@ -26,7 +26,7 @@ namespace Barotrauma public override void Apply(ActionType type, float deltaTime, Entity entity, ISerializableEntity target) { if (this.type != type || !HasRequiredItems(entity)) return; - if (!Stackable && DelayList.Any(d => d.Parent == this && d.Entity == entity && d.Targets.Count == 1 && d.Targets[0] == target)) return; + if (!Stackable && DelayList.Any(d => d.Parent == this && d.Targets.Count == 1 && d.Targets[0] == target)) return; if (targetNames != null && !targetNames.Contains(target.Name)) return; @@ -44,7 +44,7 @@ namespace Barotrauma public override void Apply(ActionType type, float deltaTime, Entity entity, List targets) { if (this.type != type || !HasRequiredItems(entity)) return; - if (!Stackable && DelayList.Any(d => d.Parent == this && d.Entity == entity && d.Targets.SequenceEqual(targets))) return; + if (!Stackable && DelayList.Any(d => d.Parent == this && d.Targets.SequenceEqual(targets))) return; //remove invalid targets if (targetNames != null) diff --git a/Barotrauma/BarotraumaShared/Source/StatusEffects/StatusEffect.cs b/Barotrauma/BarotraumaShared/Source/StatusEffects/StatusEffect.cs index 4578f3831..f98e1e3c1 100644 --- a/Barotrauma/BarotraumaShared/Source/StatusEffects/StatusEffect.cs +++ b/Barotrauma/BarotraumaShared/Source/StatusEffects/StatusEffect.cs @@ -14,7 +14,7 @@ namespace Barotrauma public StatusEffect Parent; public Entity Entity; public List Targets; - public float StartTimer; + public float Timer; } partial class StatusEffect @@ -54,7 +54,7 @@ namespace Barotrauma public bool CheckConditionalAlways; //Always do the conditional checks for the duration/delay. If false, only check conditional on apply. - public bool Stackable; //Can the same status effect be applied several times to the same targets? + public bool Stackable = true; //Can the same status effect be applied several times to the same targets? private readonly int useItemCount; @@ -308,7 +308,12 @@ namespace Barotrauma if (duration > 0.0f && !Stackable) { //ignore if not stackable and there's already an identical statuseffect - if (DurationList.Any(d => d.Parent == this && d.Entity == entity && d.Targets.SequenceEqual(targets))) return; + DurationListElement existingEffect = DurationList.Find(d => d.Parent == this && d.Targets.SequenceEqual(targets)); + if (existingEffect != null) + { + existingEffect.Timer = Math.Max(existingEffect.Timer, duration); + return; + } } Apply(deltaTime, entity, targets); @@ -349,7 +354,7 @@ namespace Barotrauma { DurationListElement element = new DurationListElement(); element.Parent = this; - element.StartTimer = duration; + element.Timer = duration; element.Entity = entity; element.Targets = targets; @@ -458,9 +463,9 @@ namespace Barotrauma } } - element.StartTimer -= deltaTime; + element.Timer -= deltaTime; - if (element.StartTimer > 0.0f) continue; + if (element.Timer > 0.0f) continue; DurationList.Remove(element); } }