Use PegAddress.Empty in RayCastPeg

master
D4VID 7 months ago
parent d7ef4afdc7
commit d65aeb7ba5

@ -29,11 +29,11 @@ namespace CriticalPathAnalyzer.Client.Tool {
PathHighLighter.RemoveHighLighting(); 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 +50,15 @@ 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; _startPegAddress = pegAddress;
if (_startPegAddress != null && _endPegAddress != null) { if (!_startPegAddress.IsEmpty() && !_endPegAddress.IsEmpty()) {
CalculateCriticalPath(); CalculateCriticalPath();
} }
} }
@ -66,10 +66,10 @@ 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; _endPegAddress = pegAddress;
if (_startPegAddress != null && _endPegAddress != null) { if (!_startPegAddress.IsEmpty() && !_endPegAddress.IsEmpty()) {
CalculateCriticalPath(); CalculateCriticalPath();
} }
} }

Loading…
Cancel
Save