|
|
@@ -26,8 +26,8 @@ namespace GamecraftModdingAPI.Blocks |
|
|
|
|
|
|
|
public static Wire Connect(SignalingBlock start, byte startPort, SignalingBlock end, byte endPort) |
|
|
|
{ |
|
|
|
EGID wireEgid = signalEngine.CreateNewWire(start.Id, startPort, end.Id, endPort); |
|
|
|
return new Wire(start, end, startPort, endPort, wireEgid, false); |
|
|
|
WireEntityStruct wire = signalEngine.CreateNewWire(start.Id, startPort, end.Id, endPort); |
|
|
|
return new Wire(wire); |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary> |
|
|
@@ -155,6 +155,22 @@ namespace GamecraftModdingAPI.Blocks |
|
|
|
this.startBlockEGID = wire.sourceBlockEGID; |
|
|
|
this.endBlockEGID = wire.destinationBlockEGID; |
|
|
|
this.inputToOutput = false; |
|
|
|
endPortEGID = signalEngine.MatchBlockInputToPort(wire.destinationBlockEGID, wire.destinationPortUsage, out bool exists); |
|
|
|
if (!exists) throw new WireInvalidException("Wire end port not found"); |
|
|
|
startPortEGID = signalEngine.MatchBlockOutputToPort(wire.sourceBlockEGID, wire.sourcePortUsage, out exists); |
|
|
|
if (!exists) throw new WireInvalidException("Wire start port not found"); |
|
|
|
} |
|
|
|
|
|
|
|
internal Wire(WireEntityStruct wire) |
|
|
|
{ |
|
|
|
this.wireEGID = wire.ID; |
|
|
|
this.startBlockEGID = wire.sourceBlockEGID; |
|
|
|
this.endBlockEGID = wire.destinationBlockEGID; |
|
|
|
inputToOutput = false; |
|
|
|
endPortEGID = signalEngine.MatchBlockInputToPort(wire.destinationBlockEGID, wire.destinationPortUsage, out bool exists); |
|
|
|
if (!exists) throw new WireInvalidException("Wire end port not found"); |
|
|
|
startPortEGID = signalEngine.MatchBlockOutputToPort(wire.sourceBlockEGID, wire.sourcePortUsage, out exists); |
|
|
|
if (!exists) throw new WireInvalidException("Wire start port not found"); |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary> |
|
|
@@ -328,9 +344,9 @@ namespace GamecraftModdingAPI.Blocks |
|
|
|
{ |
|
|
|
if (signalEngine.Exists<WireEntityStruct>(wireEGID)) |
|
|
|
{ |
|
|
|
return $"{nameof(Id)}: {Id}, Start{nameof(Start.Id)}: {Start.Id}, End{nameof(Id)}: {End.Id}, ({Start.Type}::{StartPort} aka {Start.PortName(StartPort, inputToOutput)}) -> ({End.Type}::{EndPort} aka {End.PortName(EndPort, !inputToOutput)})"; |
|
|
|
return $"{nameof(Id)}: {Id}, Start{nameof(Start.Id)}: {Start.Id}, End{nameof(End.Id)}: {End.Id}, ({Start.Type}::{StartPort} aka {Start.PortName(StartPort, inputToOutput)}) -> ({End.Type}::{EndPort} aka {End.PortName(EndPort, !inputToOutput)})"; |
|
|
|
} |
|
|
|
return $"{nameof(Id)}: {Id}, Start{nameof(Start.Id)}: {Start.Id}, End{nameof(Id)}: {End.Id}, ({Start.Type}::{StartPort}) -> ({End.Type}::{EndPort})"; |
|
|
|
return $"{nameof(Id)}: {Id}, Start{nameof(Start.Id)}: {Start.Id}, End{nameof(End.Id)}: {End.Id}, ({Start.Type} -> {End.Type})"; |
|
|
|
} |
|
|
|
|
|
|
|
internal static void Init() { } |
|
|
|