mirror of
https://github.com/tobspr/shapez.io.git
synced 2024-10-27 20:34:29 +00:00
Make logic gates output empty if there is a conflict
This commit is contained in:
parent
f667329572
commit
244cede010
@ -35,18 +35,40 @@ export class LogicGateSystem extends GameSystemWithFilter {
|
||||
|
||||
const slotValues = [];
|
||||
|
||||
// Store if any conflict was found
|
||||
let anyConflict = false;
|
||||
|
||||
// Gather inputs from all connected networks
|
||||
for (let i = 0; i < slotComp.slots.length; ++i) {
|
||||
const slot = slotComp.slots[i];
|
||||
if (slot.type !== enumPinSlotType.logicalAcceptor) {
|
||||
continue;
|
||||
}
|
||||
if (slot.linkedNetwork) {
|
||||
if (slot.linkedNetwork.valueConflict) {
|
||||
anyConflict = true;
|
||||
break;
|
||||
}
|
||||
|
||||
slotValues.push(slot.linkedNetwork.currentValue);
|
||||
} else {
|
||||
slotValues.push(null);
|
||||
}
|
||||
}
|
||||
|
||||
// Handle conflicts
|
||||
if (anyConflict) {
|
||||
for (let i = 0; i < slotComp.slots.length; ++i) {
|
||||
const slot = slotComp.slots[i];
|
||||
if (slot.type !== enumPinSlotType.logicalEjector) {
|
||||
continue;
|
||||
}
|
||||
slot.value = null;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
// Compute actual result
|
||||
const result = this.boundOperations[logicComp.type](slotValues);
|
||||
|
||||
if (Array.isArray(result)) {
|
||||
|
Loading…
Reference in New Issue
Block a user