Fixed item tags & aliases not being taken into account when determining target validity in StatusEffect.Apply. Closes #316
This commit is contained in:
@@ -694,6 +694,16 @@ namespace Barotrauma
|
|||||||
return (tags.Contains(tag) || tags.Contains(tag.ToLowerInvariant()));
|
return (tags.Contains(tag) || tags.Contains(tag.ToLowerInvariant()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool HasTag(IEnumerable<string> allowedTags)
|
||||||
|
{
|
||||||
|
if (allowedTags == null) return true;
|
||||||
|
|
||||||
|
foreach (string tag in allowedTags)
|
||||||
|
{
|
||||||
|
if (tags.Contains(tag) || tags.Contains(tag.ToLowerInvariant())) return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public void ApplyStatusEffects(ActionType type, float deltaTime, Character character = null, bool isNetworkEvent = false)
|
public void ApplyStatusEffects(ActionType type, float deltaTime, Character character = null, bool isNetworkEvent = false)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -228,6 +228,15 @@ namespace Barotrauma
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool NameMatches(IEnumerable<string> allowedNames, bool caseSensitive = false)
|
||||||
|
{
|
||||||
|
foreach (string name in allowedNames)
|
||||||
|
{
|
||||||
|
if (NameMatches(name, caseSensitive)) return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
//a method that allows the GUIListBoxes to check through a delegate if the entityprefab is still selected
|
//a method that allows the GUIListBoxes to check through a delegate if the entityprefab is still selected
|
||||||
public static object GetSelected()
|
public static object GetSelected()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -299,7 +299,20 @@ namespace Barotrauma
|
|||||||
//remove invalid targets
|
//remove invalid targets
|
||||||
if (targetNames != null)
|
if (targetNames != null)
|
||||||
{
|
{
|
||||||
targets.RemoveAll(t => !targetNames.Contains(t.Name));
|
targets.RemoveAll(t =>
|
||||||
|
{
|
||||||
|
Item item = t as Item;
|
||||||
|
if (item == null)
|
||||||
|
{
|
||||||
|
return !targetNames.Contains(t.Name);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (item.HasTag(targetNames)) return false;
|
||||||
|
if (item.Prefab.NameMatches(targetNames)) return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
});
|
||||||
if (targets.Count == 0) return;
|
if (targets.Count == 0) return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user