Compare commits

...

2 Commits

@ -1,9 +1,11 @@
using System; using System;
using CriticalPathAnalyzer.Shared.Packets.C2S; using CriticalPathAnalyzer.Shared.Packets.C2S;
using CriticalPathAnalyzer.Shared.Packets.S2C; using CriticalPathAnalyzer.Shared.Packets.S2C;
using JimmysUnityUtilities;
using LogicAPI.Data; using LogicAPI.Data;
using LogicLog; using LogicLog;
using LogicWorld.Interfaces; using LogicWorld.Interfaces;
using LogicWorld.Outlines;
using LogicWorld.Physics; using LogicWorld.Physics;
using LogicWorld.Players; using LogicWorld.Players;
@ -19,21 +21,26 @@ namespace CriticalPathAnalyzer.Client.Tool {
private static Guid _currentRequestGuid = Guid.NewGuid(); private static Guid _currentRequestGuid = Guid.NewGuid();
private static AnalyzePathResponse _response; private static AnalyzePathResponse _response;
private static readonly OutlineData StartOutline = new OutlineData(new Color24(0x00ff00));
private static readonly OutlineData EndOutline = new OutlineData(new Color24(0xff0000));
public static void Init(ILogicLogger logger) { public static void Init(ILogicLogger logger) {
_logger = logger; _logger = logger;
} }
public static void Clear() { public static void Clear() {
PathHighLighter.RemoveHighLighting();
Outliner.RemoveOutline(_startPegAddress);
Outliner.RemoveOutline(_endPegAddress);
_startPegAddress = PegAddress.Empty; _startPegAddress = PegAddress.Empty;
_endPegAddress = PegAddress.Empty; _endPegAddress = PegAddress.Empty;
PathHighLighter.RemoveHighLighting();
} }
private static PegAddress? RayCastPeg() { private static PegAddress RayCastPeg() {
// Ray-cast into the world to find what the player is looking at // Ray-cast into the world to find what the player is looking at
HitInfo hitInfo = PlayerCaster.CameraCast(Masks.Environment | Masks.Structure | Masks.Peg | Masks.Wire); HitInfo hitInfo = PlayerCaster.CameraCast(Masks.Environment | Masks.Structure | Masks.Peg | Masks.Wire);
if (!hitInfo.HitSomething) { if (!hitInfo.HitSomething) {
return null; return PegAddress.Empty;
} }
// Resolve hit target: // Resolve hit target:
@ -50,15 +57,17 @@ namespace CriticalPathAnalyzer.Client.Tool {
return wire.Point1.IsInputAddress() ? wire.Point1 : wire.Point2; return wire.Point1.IsInputAddress() ? wire.Point1 : wire.Point2;
} }
return null; return PegAddress.Empty;
} }
public static void SelectPathStart() { public static void SelectPathStart() {
_logger.Info("Analyze Path Start"); _logger.Info("Analyze Path Start");
PegAddress? pegAddress = RayCastPeg(); PegAddress pegAddress = RayCastPeg();
if (pegAddress != null) { if (!pegAddress.IsEmpty()) {
_startPegAddress = pegAddress.Value; Outliner.RemoveOutline(_startPegAddress);
if (_startPegAddress != null && _endPegAddress != null) { Outliner.Outline(pegAddress, StartOutline);
_startPegAddress = pegAddress;
if (!_startPegAddress.IsEmpty() && !_endPegAddress.IsEmpty()) {
CalculateCriticalPath(); CalculateCriticalPath();
} }
} }
@ -66,10 +75,12 @@ namespace CriticalPathAnalyzer.Client.Tool {
public static void SelectPathEnd() { public static void SelectPathEnd() {
_logger.Info("Analyze Path End"); _logger.Info("Analyze Path End");
PegAddress? pegAddress = RayCastPeg(); PegAddress pegAddress = RayCastPeg();
if (pegAddress != null) { if (!pegAddress.IsEmpty()) {
_endPegAddress = pegAddress.Value; Outliner.RemoveOutline(_endPegAddress);
if (_startPegAddress != null && _endPegAddress != null) { Outliner.Outline(pegAddress, EndOutline);
_endPegAddress = pegAddress;
if (!_startPegAddress.IsEmpty() && !_endPegAddress.IsEmpty()) {
CalculateCriticalPath(); CalculateCriticalPath();
} }
} }

Loading…
Cancel
Save