diff --git a/StoneRed.LogicSimulator/Simulation/LogicGates/TestLogicGate.cs b/StoneRed.LogicSimulator/Simulation/LogicGates/TestLogicGate.cs index 32e15fc..4e01ccf 100644 --- a/StoneRed.LogicSimulator/Simulation/LogicGates/TestLogicGate.cs +++ b/StoneRed.LogicSimulator/Simulation/LogicGates/TestLogicGate.cs @@ -11,19 +11,43 @@ namespace StoneRed.LogicSimulator.Simulation.LogicGates; [LogicGateName("Test")] internal class TestLogicGate : LogicGate, Interfaces.IDrawable { - public override int OutputCount { get; set; } = 1; - public override int InputCount { get; set; } = 1; + private readonly Color[] colors = new Color[9]; + private Texture2D texture = null!; + public override int OutputCount { get; set; } = 0; + public override int InputCount { get; set; } = 9; - public Texture2D Texture => CreateTexture(1, 1); + public Texture2D Texture + { + get + { + Draw(); + return texture; + } + } + + protected internal override void Initialize() + { + texture = CreateTexture(3, 3); + texture.SetData(new Color[] + { + Color.Red, Color.Blue, Color.Red, + Color.Blue, Color.Red, Color.Blue, + Color.Red, Color.Blue, Color.Red + }); + } protected override void Execute() { - Texture.SetData(new Color[] { Color.Red }); - for (int i = 0; i < InputCount; i++) { - SetOutputBit(GetInputBit(i), i); + colors[i] = GetInputBit(i) == 1 ? Color.Red : Color.Gray; } } + + private void Draw() + { + texture.SetData(colors); + } } + #endif \ No newline at end of file diff --git a/StoneRed.LogicSimulator/UserInterface/Screens/WorldScreen.cs b/StoneRed.LogicSimulator/UserInterface/Screens/WorldScreen.cs index 6f410d6..13f896e 100644 --- a/StoneRed.LogicSimulator/UserInterface/Screens/WorldScreen.cs +++ b/StoneRed.LogicSimulator/UserInterface/Screens/WorldScreen.cs @@ -98,7 +98,7 @@ internal class WorldScreen : SrlsScreen fps = 1f / gameTime.GetElapsedSeconds(); Matrix transformMatrix = camera.GetViewMatrix(); - srls.SpriteBatch.Begin(SpriteSortMode.BackToFront, transformMatrix: transformMatrix); + srls.SpriteBatch.Begin(SpriteSortMode.BackToFront, samplerState: SamplerState.PointClamp, transformMatrix: transformMatrix); foreach (LogicGate logicGate in simulator.GetLogicGates()) { @@ -336,11 +336,11 @@ internal class WorldScreen : SrlsScreen if (connectionContext.IsInput) { - isConnected = logicGate.IsConnectedTo(connectionContext.LogicGate); + isConnected = logicGate.IsConnectedTo(connectionContext.LogicGate, connectionContext.Index, i); } else { - isConnected = connectionContext.LogicGate.IsConnectedTo(logicGate); + isConnected = connectionContext.LogicGate.IsConnectedTo(logicGate, i, connectionContext.Index); } connectionStatus = isConnected ? "[Disconnect]" : "[Connect]"; @@ -382,9 +382,9 @@ internal class WorldScreen : SrlsScreen if (connectionContext.IsInput) { - if (logicGate.IsConnectedTo(connectionContext.LogicGate)) + if (logicGate.IsConnectedTo(connectionContext.LogicGate, connectionContext.Index, index)) { - logicGate.Disconnect(connectionContext.LogicGate); + logicGate.Disconnect(connectionContext.LogicGate, connectionContext.Index, index); } else { @@ -393,9 +393,9 @@ internal class WorldScreen : SrlsScreen } else { - if (connectionContext.LogicGate.IsConnectedTo(logicGate)) + if (connectionContext.LogicGate.IsConnectedTo(logicGate, index, connectionContext.Index)) { - connectionContext.LogicGate.Disconnect(logicGate); + connectionContext.LogicGate.Disconnect(logicGate, index, connectionContext.Index); } else {