Bunch of fixes to statuseffects:
- Fixed the multi-target StatusEffect.Apply method ignoring target names and always allowing stacking. - Fixed delayed effects not working if the single-target StatusEffect.Apply method is used. - Fixed delayed effects ignoring target names. - Fixed delayed effects comparing the equality of the target lists, not the elements in the list (if the contents of the lists are identical the statuseffects should be considered identical).
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace Barotrauma
|
||||
@@ -22,16 +23,43 @@ namespace Barotrauma
|
||||
delay = element.GetAttributeFloat("delay", 1.0f);
|
||||
}
|
||||
|
||||
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 (targetNames != null && !targetNames.Contains(target.Name)) return;
|
||||
|
||||
DelayedListElement element = new DelayedListElement
|
||||
{
|
||||
Parent = this,
|
||||
StartTimer = delay,
|
||||
Entity = entity,
|
||||
Targets = new List<ISerializableEntity>() { target }
|
||||
};
|
||||
|
||||
DelayList.Add(element);
|
||||
}
|
||||
|
||||
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;
|
||||
if (!Stackable && DelayList.Any(d => d.Parent == this && d.Entity == entity && d.Targets.SequenceEqual(targets))) return;
|
||||
|
||||
DelayedListElement element = new DelayedListElement();
|
||||
element.Parent = this;
|
||||
element.StartTimer = delay;
|
||||
element.Entity = entity;
|
||||
element.Targets = targets;
|
||||
//remove invalid targets
|
||||
if (targetNames != null)
|
||||
{
|
||||
targets.RemoveAll(t => !targetNames.Contains(t.Name));
|
||||
if (targets.Count == 0) return;
|
||||
}
|
||||
|
||||
DelayedListElement element = new DelayedListElement
|
||||
{
|
||||
Parent = this,
|
||||
StartTimer = delay,
|
||||
Entity = entity,
|
||||
Targets = targets
|
||||
};
|
||||
|
||||
DelayList.Add(element);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user