Compare commits

..

2 Commits

@ -1,9 +1,11 @@
using System;
using CriticalPathAnalyzer.Shared.Packets.C2S;
using CriticalPathAnalyzer.Shared.Packets.S2C;
using JimmysUnityUtilities;
using LogicAPI.Data;
using LogicLog;
using LogicWorld.Interfaces;
using LogicWorld.Outlines;
using LogicWorld.Physics;
using LogicWorld.Players;
@ -19,21 +21,26 @@ namespace CriticalPathAnalyzer.Client.Tool {
private static Guid _currentRequestGuid = Guid.NewGuid();
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) {
_logger = logger;
}
public static void Clear() {
PathHighLighter.RemoveHighLighting();
Outliner.RemoveOutline(_startPegAddress);
Outliner.RemoveOutline(_endPegAddress);
_startPegAddress = 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
HitInfo hitInfo = PlayerCaster.CameraCast(Masks.Environment | Masks.Structure | Masks.Peg | Masks.Wire);
if (!hitInfo.HitSomething) {
return null;
return PegAddress.Empty;
}
// Resolve hit target:
@ -50,15 +57,17 @@ namespace CriticalPathAnalyzer.Client.Tool {
return wire.Point1.IsInputAddress() ? wire.Point1 : wire.Point2;
}
return null;
return PegAddress.Empty;
}
public static void SelectPathStart() {
_logger.Info("Analyze Path Start");
PegAddress? pegAddress = RayCastPeg();
if (pegAddress != null) {
_startPegAddress = pegAddress.Value;
if (_startPegAddress != null && _endPegAddress != null) {
PegAddress pegAddress = RayCastPeg();
if (!pegAddress.IsEmpty()) {
Outliner.RemoveOutline(_startPegAddress);
Outliner.Outline(pegAddress, StartOutline);
_startPegAddress = pegAddress;
if (!_startPegAddress.IsEmpty() && !_endPegAddress.IsEmpty()) {
CalculateCriticalPath();
}
}
@ -66,10 +75,12 @@ namespace CriticalPathAnalyzer.Client.Tool {
public static void SelectPathEnd() {
_logger.Info("Analyze Path End");
PegAddress? pegAddress = RayCastPeg();
if (pegAddress != null) {
_endPegAddress = pegAddress.Value;
if (_startPegAddress != null && _endPegAddress != null) {
PegAddress pegAddress = RayCastPeg();
if (!pegAddress.IsEmpty()) {
Outliner.RemoveOutline(_endPegAddress);
Outliner.Outline(pegAddress, EndOutline);
_endPegAddress = pegAddress;
if (!_startPegAddress.IsEmpty() && !_endPegAddress.IsEmpty()) {
CalculateCriticalPath();
}
}

Loading…
Cancel
Save