Convert relevant blocks to wireable blocks and fix wire connect during block init
This commit is contained in:
parent
daf4a24bc9
commit
aae2057972
9 changed files with 18 additions and 31 deletions
|
@ -10,7 +10,7 @@ using GamecraftModdingAPI.Utility;
|
||||||
|
|
||||||
namespace GamecraftModdingAPI.Blocks
|
namespace GamecraftModdingAPI.Blocks
|
||||||
{
|
{
|
||||||
public class ConsoleBlock : Block
|
public class ConsoleBlock : SignalingBlock
|
||||||
{
|
{
|
||||||
public ConsoleBlock(EGID id): base(id)
|
public ConsoleBlock(EGID id): base(id)
|
||||||
{
|
{
|
||||||
|
|
|
@ -9,7 +9,7 @@ using GamecraftModdingAPI.Utility;
|
||||||
|
|
||||||
namespace GamecraftModdingAPI.Blocks
|
namespace GamecraftModdingAPI.Blocks
|
||||||
{
|
{
|
||||||
public class Motor : Block
|
public class Motor : SignalingBlock
|
||||||
{
|
{
|
||||||
public Motor(EGID id) : base(id)
|
public Motor(EGID id) : base(id)
|
||||||
{
|
{
|
||||||
|
|
|
@ -14,7 +14,7 @@ using GamecraftModdingAPI.Utility;
|
||||||
|
|
||||||
namespace GamecraftModdingAPI.Blocks
|
namespace GamecraftModdingAPI.Blocks
|
||||||
{
|
{
|
||||||
public class MusicBlock : Block
|
public class MusicBlock : SignalingBlock
|
||||||
{
|
{
|
||||||
public MusicBlock(EGID id) : base(id)
|
public MusicBlock(EGID id) : base(id)
|
||||||
{
|
{
|
||||||
|
|
|
@ -9,7 +9,7 @@ using RobocraftX.Common;
|
||||||
|
|
||||||
namespace GamecraftModdingAPI.Blocks
|
namespace GamecraftModdingAPI.Blocks
|
||||||
{
|
{
|
||||||
public class Piston : Block
|
public class Piston : SignalingBlock
|
||||||
{
|
{
|
||||||
public Piston(EGID id) : base(id)
|
public Piston(EGID id) : base(id)
|
||||||
{
|
{
|
||||||
|
|
|
@ -9,7 +9,7 @@ using GamecraftModdingAPI.Utility;
|
||||||
|
|
||||||
namespace GamecraftModdingAPI.Blocks
|
namespace GamecraftModdingAPI.Blocks
|
||||||
{
|
{
|
||||||
public class Servo : Block
|
public class Servo : SignalingBlock
|
||||||
{
|
{
|
||||||
public Servo(EGID id) : base(id)
|
public Servo(EGID id) : base(id)
|
||||||
{
|
{
|
||||||
|
|
|
@ -10,7 +10,7 @@ using GamecraftModdingAPI.Utility;
|
||||||
|
|
||||||
namespace GamecraftModdingAPI.Blocks
|
namespace GamecraftModdingAPI.Blocks
|
||||||
{
|
{
|
||||||
public class TextBlock : Block
|
public class TextBlock : SignalingBlock
|
||||||
{
|
{
|
||||||
public TextBlock(EGID id) : base(id)
|
public TextBlock(EGID id) : base(id)
|
||||||
{
|
{
|
||||||
|
|
|
@ -11,7 +11,7 @@ using GamecraftModdingAPI.Utility;
|
||||||
|
|
||||||
namespace GamecraftModdingAPI.Blocks
|
namespace GamecraftModdingAPI.Blocks
|
||||||
{
|
{
|
||||||
public class Timer : Block
|
public class Timer : SignalingBlock
|
||||||
{
|
{
|
||||||
public Timer(EGID id) : base(id)
|
public Timer(EGID id) : base(id)
|
||||||
{
|
{
|
||||||
|
|
|
@ -31,7 +31,7 @@ namespace GamecraftModdingAPI.Blocks
|
||||||
public static Wire Connect(SignalingBlock start, byte startPort, SignalingBlock end, byte endPort)
|
public static Wire Connect(SignalingBlock start, byte startPort, SignalingBlock end, byte endPort)
|
||||||
{
|
{
|
||||||
WireEntityStruct wire = signalEngine.CreateNewWire(start.Id, startPort, end.Id, endPort);
|
WireEntityStruct wire = signalEngine.CreateNewWire(start.Id, startPort, end.Id, endPort);
|
||||||
return new Wire(wire);
|
return new Wire(wire, start, end);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -173,15 +173,15 @@ namespace GamecraftModdingAPI.Blocks
|
||||||
this.startPort = wire.sourcePortUsage;
|
this.startPort = wire.sourcePortUsage;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal Wire(WireEntityStruct wire)
|
internal Wire(WireEntityStruct wire, SignalingBlock src, SignalingBlock dest)
|
||||||
{
|
{
|
||||||
this.wireEGID = wire.ID;
|
this.wireEGID = wire.ID;
|
||||||
this.startBlockEGID = wire.sourceBlockEGID;
|
this.startBlockEGID = wire.sourceBlockEGID;
|
||||||
this.endBlockEGID = wire.destinationBlockEGID;
|
this.endBlockEGID = wire.destinationBlockEGID;
|
||||||
inputToOutput = false;
|
inputToOutput = false;
|
||||||
endPortEGID = signalEngine.MatchBlockInputToPort(wire.destinationBlockEGID, wire.destinationPortUsage, out bool exists);
|
endPortEGID = signalEngine.MatchBlockInputToPort(dest, wire.destinationPortUsage, out bool exists);
|
||||||
if (!exists) throw new WireInvalidException("Wire end port not found");
|
if (!exists) throw new WireInvalidException("Wire end port not found");
|
||||||
startPortEGID = signalEngine.MatchBlockOutputToPort(wire.sourceBlockEGID, wire.sourcePortUsage, out exists);
|
startPortEGID = signalEngine.MatchBlockOutputToPort(src, wire.sourcePortUsage, out exists);
|
||||||
if (!exists) throw new WireInvalidException("Wire start port not found");
|
if (!exists) throw new WireInvalidException("Wire start port not found");
|
||||||
this.endPort = wire.destinationPortUsage;
|
this.endPort = wire.destinationPortUsage;
|
||||||
this.startPort = wire.sourcePortUsage;
|
this.startPort = wire.sourcePortUsage;
|
||||||
|
|
|
@ -22,33 +22,29 @@ using GamecraftModdingAPI.Players;
|
||||||
|
|
||||||
namespace GamecraftModdingAPI.Tests
|
namespace GamecraftModdingAPI.Tests
|
||||||
{
|
{
|
||||||
|
#if DEBUG
|
||||||
// unused by design
|
// unused by design
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Modding API implemented as a standalone IPA Plugin.
|
/// Modding API implemented as a standalone IPA Plugin.
|
||||||
/// Ideally, GamecraftModdingAPI should be loaded by another mod; not itself
|
/// Ideally, GamecraftModdingAPI should be loaded by another mod; not itself
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class GamecraftModdingAPIPluginTest
|
public class GamecraftModdingAPIPluginTest : IllusionPlugin.IEnhancedPlugin
|
||||||
#if DEBUG
|
|
||||||
: IllusionPlugin.IEnhancedPlugin
|
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
|
|
||||||
private static Harmony harmony { get; set; }
|
private static Harmony harmony { get; set; }
|
||||||
|
|
||||||
public string[] Filter { get; } = new string[] { "Gamecraft", "GamecraftPreview" };
|
public override string Name { get; } = Assembly.GetExecutingAssembly().GetName().Name;
|
||||||
|
|
||||||
public string Name { get; } = Assembly.GetExecutingAssembly().GetName().Name;
|
public override string Version { get; } = Assembly.GetExecutingAssembly().GetName().Version.ToString();
|
||||||
|
|
||||||
public string Version { get; } = Assembly.GetExecutingAssembly().GetName().Version.ToString();
|
|
||||||
|
|
||||||
public string HarmonyID { get; } = "org.git.exmods.modtainers.gamecraftmoddingapi";
|
public string HarmonyID { get; } = "org.git.exmods.modtainers.gamecraftmoddingapi";
|
||||||
|
|
||||||
public void OnApplicationQuit()
|
public override void OnApplicationQuit()
|
||||||
{
|
{
|
||||||
GamecraftModdingAPI.Main.Shutdown();
|
GamecraftModdingAPI.Main.Shutdown();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnApplicationStart()
|
public override void OnApplicationStart()
|
||||||
{
|
{
|
||||||
FileLog.Reset();
|
FileLog.Reset();
|
||||||
Harmony.DEBUG = true;
|
Harmony.DEBUG = true;
|
||||||
|
@ -387,16 +383,6 @@ namespace GamecraftModdingAPI.Tests
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnFixedUpdate() { }
|
|
||||||
|
|
||||||
public void OnLateUpdate() { }
|
|
||||||
|
|
||||||
public void OnLevelWasInitialized(int level) { }
|
|
||||||
|
|
||||||
public void OnLevelWasLoaded(int level) { }
|
|
||||||
|
|
||||||
public void OnUpdate() { }
|
|
||||||
|
|
||||||
[HarmonyPatch]
|
[HarmonyPatch]
|
||||||
public class MinimumSpecsPatch
|
public class MinimumSpecsPatch
|
||||||
{
|
{
|
||||||
|
@ -411,4 +397,5 @@ namespace GamecraftModdingAPI.Tests
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue