Add Sprite changes to Logic Gates to show the input/output state (#33277)

This commit is contained in:
0tito 2024-12-06 12:35:48 -03:00 committed by deltanedas
parent d6ba36aec9
commit a0ac0665ff
7 changed files with 93 additions and 4 deletions

View File

@ -102,10 +102,12 @@ public sealed class LogicGateSystem : EntitySystem
if (args.Port == comp.InputPortA)
{
comp.StateA = state;
_appearance.SetData(uid, LogicGateVisuals.InputA, state == SignalState.High); //If A == High => Sets input A sprite to True
}
else if (args.Port == comp.InputPortB)
{
comp.StateB = state;
_appearance.SetData(uid, LogicGateVisuals.InputB, state == SignalState.High); //If B == High => Sets input B sprite to True
}
UpdateOutput(uid, comp);
@ -143,6 +145,8 @@ public sealed class LogicGateSystem : EntitySystem
break;
}
_appearance.SetData(uid, LogicGateVisuals.Output, output);
// only send a payload if it actually changed
if (output != comp.LastOutput)
{

View File

@ -23,7 +23,10 @@ public enum LogicGate : byte
[Serializable, NetSerializable]
public enum LogicGateVisuals : byte
{
Gate
Gate,
InputA,
InputB,
Output
}
/// <summary>
@ -32,5 +35,8 @@ public enum LogicGateVisuals : byte
[Serializable, NetSerializable]
public enum LogicGateLayers : byte
{
Gate
Gate,
InputA,
InputB,
Output
}

View File

@ -36,6 +36,15 @@
layers:
- state: base
- state: logic
- state: logic_a
visible: false
map: [ "enum.LogicGateLayers.InputA" ]
- state: logic_b
visible: false
map: [ "enum.LogicGateLayers.InputB" ]
- state: logic_o
visible: false
map: [ "enum.LogicGateLayers.Output" ]
- state: or
map: [ "enum.LogicGateLayers.Gate" ]
- type: LogicGate
@ -63,7 +72,18 @@
Nor: { state: nor }
Nand: { state: nand }
Xnor: { state: xnor }
enum.LogicGateVisuals.InputA:
enum.LogicGateLayers.InputA:
True: { visible: true }
False: { visible: false }
enum.LogicGateVisuals.InputB:
enum.LogicGateLayers.InputB:
True: { visible: true }
False: { visible: false }
enum.LogicGateVisuals.Output:
enum.LogicGateLayers.Output:
True: { visible: true }
False: { visible: false }
- type: entity
parent: LogicGateOr
id: LogicGateAnd
@ -72,6 +92,16 @@
- type: Sprite
layers:
- state: base
- state: logic
- state: logic_a
visible: false
map: [ "enum.LogicGateLayers.InputA" ]
- state: logic_b
visible: false
map: [ "enum.LogicGateLayers.InputB" ]
- state: logic_o
visible: false
map: [ "enum.LogicGateLayers.Output" ]
- state: and
map: [ "enum.LogicGateLayers.Gate" ]
- type: LogicGate
@ -85,6 +115,16 @@
- type: Sprite
layers:
- state: base
- state: logic
- state: logic_a
visible: false
map: [ "enum.LogicGateLayers.InputA" ]
- state: logic_b
visible: false
map: [ "enum.LogicGateLayers.InputB" ]
- state: logic_o
visible: false
map: [ "enum.LogicGateLayers.Output" ]
- state: xor
map: [ "enum.LogicGateLayers.Gate" ]
- type: LogicGate
@ -98,6 +138,16 @@
- type: Sprite
layers:
- state: base
- state: logic
- state: logic_a
visible: false
map: [ "enum.LogicGateLayers.InputA" ]
- state: logic_b
visible: false
map: [ "enum.LogicGateLayers.InputB" ]
- state: logic_o
visible: false
map: [ "enum.LogicGateLayers.Output" ]
- state: nor
map: [ "enum.LogicGateLayers.Gate" ]
- type: LogicGate
@ -111,6 +161,16 @@
- type: Sprite
layers:
- state: base
- state: logic
- state: logic_a
visible: false
map: [ "enum.LogicGateLayers.InputA" ]
- state: logic_b
visible: false
map: [ "enum.LogicGateLayers.InputB" ]
- state: logic_o
visible: false
map: [ "enum.LogicGateLayers.Output" ]
- state: nand
map: [ "enum.LogicGateLayers.Gate" ]
- type: LogicGate
@ -124,6 +184,16 @@
- type: Sprite
layers:
- state: base
- state: logic
- state: logic_a
visible: false
map: [ "enum.LogicGateLayers.InputA" ]
- state: logic_b
visible: false
map: [ "enum.LogicGateLayers.InputB" ]
- state: logic_o
visible: false
map: [ "enum.LogicGateLayers.Output" ]
- state: xnor
map: [ "enum.LogicGateLayers.Gate" ]
- type: LogicGate

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.8 KiB

View File

@ -1,7 +1,7 @@
{
"version": 1,
"license": "CC-BY-SA-3.0",
"copyright": "or.png originally created by Kevin Zheng, 2022. All are modified by deltanedas (github) for SS14, 2024.",
"copyright": "or.png originally created by Kevin Zheng, 2022. All are modified by deltanedas (github) for SS14, 2024. Sprites logic_a logic_b logic_o were made by 0tito (github) for SS14",
"size": {
"x": 32,
"y": 32
@ -13,6 +13,15 @@
{
"name": "logic"
},
{
"name": "logic_o"
},
{
"name": "logic_b"
},
{
"name": "logic_a"
},
{
"name": "or"
},