Faction Test v1.0.1.0
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using Microsoft.Xna.Framework;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace Barotrauma;
|
||||
@@ -13,11 +14,22 @@ partial class UIHighlightAction : EventAction
|
||||
bool useCircularFlash = false;
|
||||
if (Id != ElementId.None)
|
||||
{
|
||||
FindAndFlashComponents(c => Equals(Id, c.UserData));
|
||||
var predicate = (GUIComponent c) => c is not null && Equals(Id, c.UserData);
|
||||
if (!FindAndFlashAddedComponents(predicate))
|
||||
{
|
||||
if (predicate(GUIMessageBox.VisibleBox))
|
||||
{
|
||||
Flash(GUIMessageBox.VisibleBox);
|
||||
}
|
||||
else
|
||||
{
|
||||
FindAndFlashMessageBoxComponents(predicate);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (!EntityIdentifier.IsEmpty)
|
||||
{
|
||||
FindAndFlashComponents(c =>
|
||||
FindAndFlashAddedComponents(c =>
|
||||
c.UserData is MapEntityPrefab mep && mep.Identifier == EntityIdentifier || c.UserData is MapEntity me && me.Prefab.Identifier == EntityIdentifier);
|
||||
}
|
||||
else if (!OrderIdentifier.IsEmpty)
|
||||
@@ -26,26 +38,26 @@ partial class UIHighlightAction : EventAction
|
||||
bool foundMinimapNode = false;
|
||||
if (!OrderTargetTag.IsEmpty)
|
||||
{
|
||||
foundMinimapNode = FindAndFlashComponents(c =>
|
||||
foundMinimapNode = FindAndFlashAddedComponents(c =>
|
||||
c.UserData is CrewManager.MinimapNodeData nodeData && nodeData.Order is Order order &&
|
||||
order.Identifier == OrderIdentifier && order.Option == OrderOption && order.TargetEntity is Item item && item.HasTag(OrderTargetTag));
|
||||
}
|
||||
if (!foundMinimapNode)
|
||||
{
|
||||
FindAndFlashComponents(c => c.UserData is Order order && order.Identifier == OrderIdentifier && order.Option == OrderOption,
|
||||
FindAndFlashAddedComponents(c => c.UserData is Order order && order.Identifier == OrderIdentifier && order.Option == OrderOption,
|
||||
c => c.UserData is Order order && order.Identifier == OrderIdentifier,
|
||||
c => Equals(OrderCategory, c.UserData));
|
||||
}
|
||||
}
|
||||
|
||||
bool FindAndFlashComponents(params Func<GUIComponent, bool>[] predicates)
|
||||
bool FindAndFlashComponents(IEnumerable<GUIComponent> components, params Func<GUIComponent, bool>[] predicates)
|
||||
{
|
||||
foreach (var predicate in predicates)
|
||||
{
|
||||
if (HighlightMultiple)
|
||||
{
|
||||
bool found = false;
|
||||
foreach (var component in GUI.GetAdditions())
|
||||
foreach (var component in components)
|
||||
{
|
||||
if (predicate(component))
|
||||
{
|
||||
@@ -55,7 +67,7 @@ partial class UIHighlightAction : EventAction
|
||||
};
|
||||
return found;
|
||||
}
|
||||
else if (GUI.GetAdditions().FirstOrDefault(predicate) is GUIComponent component)
|
||||
else if (components.FirstOrDefault(predicate) is GUIComponent component)
|
||||
{
|
||||
Flash(component);
|
||||
return true;
|
||||
@@ -64,6 +76,10 @@ partial class UIHighlightAction : EventAction
|
||||
return false;
|
||||
}
|
||||
|
||||
bool FindAndFlashAddedComponents(params Func<GUIComponent, bool>[] predicates) => FindAndFlashComponents(GUI.GetAdditions(), predicates);
|
||||
|
||||
bool FindAndFlashMessageBoxComponents(params Func<GUIComponent, bool>[] predicates) => FindAndFlashComponents(GUIMessageBox.VisibleBox?.GetAllChildren() ?? Enumerable.Empty<GUIComponent>(), predicates);
|
||||
|
||||
void Flash(GUIComponent component)
|
||||
{
|
||||
if (component.FlashTimer <= 0.0f)
|
||||
|
||||
Reference in New Issue
Block a user