|
|
|
@ -4,29 +4,51 @@ using CriticalPathAnalyzer.Shared.Packets.S2C;
|
|
|
|
|
using JimmysUnityUtilities;
|
|
|
|
|
using LogicAPI.Data;
|
|
|
|
|
using LogicAPI.Services;
|
|
|
|
|
using LogicLog;
|
|
|
|
|
using LogicWorld.Interfaces;
|
|
|
|
|
using LogicWorld.Outlines;
|
|
|
|
|
|
|
|
|
|
namespace CriticalPathAnalyzer.Client.Tool {
|
|
|
|
|
public class PathHighlighter {
|
|
|
|
|
private static ILogicLogger _logger;
|
|
|
|
|
|
|
|
|
|
private static List<Node> _nodes = new List<Node>();
|
|
|
|
|
private static List<WireAddress> _highlightedWires = new List<WireAddress>();
|
|
|
|
|
|
|
|
|
|
public static void HighlightClusterNodes(List<Node> nodes) {
|
|
|
|
|
public static void Init(ILogicLogger logger) {
|
|
|
|
|
_logger = logger;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void SetNodes(List<Node> nodes) {
|
|
|
|
|
_nodes = nodes;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
foreach (Node node in _nodes) {
|
|
|
|
|
HighlightNode(node);
|
|
|
|
|
public static void HighlightClusterNodes(List<Node> nodes) {
|
|
|
|
|
foreach (Node node in nodes) {
|
|
|
|
|
HighlightNode(node, HsvToRgb(node.Time * 20, 1.0f, 1.0f));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void HighlightAnalyzedNode(Node node) {
|
|
|
|
|
_logger.Info($"Selected node: {node}");
|
|
|
|
|
HighlightNode(node, 0x00ff00);
|
|
|
|
|
foreach (int prevNodeIndex in node.PrevNodeIndexes) {
|
|
|
|
|
_logger.Info($"Highlighting prev node index {prevNodeIndex}");
|
|
|
|
|
HighlightNode(_nodes[prevNodeIndex], 0xff0000);
|
|
|
|
|
}
|
|
|
|
|
foreach ((int nextNodeIndex, int delay) in node.NextNodes) {
|
|
|
|
|
_logger.Info($"Highlighting next node index {nextNodeIndex}");
|
|
|
|
|
HighlightNode(_nodes[nextNodeIndex], 0x0000ff);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Highlight all pegs and wires of the given cluster.
|
|
|
|
|
/// </summary>
|
|
|
|
|
private static void HighlightNode(Node node) {
|
|
|
|
|
private static void HighlightNode(Node node, int color) {
|
|
|
|
|
IWorldData world = Instances.MainWorld.Data;
|
|
|
|
|
|
|
|
|
|
var outline = new OutlineData(new Color24(HsvToRgb(node.Time * 20, 1.0f, 1.0f)));
|
|
|
|
|
var outline = new OutlineData(new Color24(color));
|
|
|
|
|
|
|
|
|
|
foreach (ComponentAddress address in node.ConnectingComponents) {
|
|
|
|
|
if (!world.Contains(address)) {
|
|
|
|
@ -76,7 +98,6 @@ namespace CriticalPathAnalyzer.Client.Tool {
|
|
|
|
|
Outliner.RemoveOutline(wireAddress);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_nodes = null;
|
|
|
|
|
_highlightedWires.Clear();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|