1
0
mirror of https://github.com/tobspr/shapez.io.git synced 2026-03-02 03:39:21 +00:00

Add NOT gate

This commit is contained in:
tobspr
2020-08-13 19:33:35 +02:00
parent 52b4d4d742
commit 49da768b73
17 changed files with 970 additions and 829 deletions

View File

@@ -10,6 +10,7 @@ export class LogicGateSystem extends GameSystemWithFilter {
this.boundOperations = {
[enumLogicGateType.and]: this.compute_AND.bind(this),
[enumLogicGateType.not]: this.compute_NOT.bind(this),
};
}
@@ -75,4 +76,23 @@ export class LogicGateSystem extends GameSystemWithFilter {
return BOOL_FALSE_SINGLETON;
}
/**
* @param {Array<BaseItem|null>} parameters
* @returns {BaseItem}
*/
compute_NOT(parameters) {
const item = parameters[0];
if (!item) {
return BOOL_FALSE_SINGLETON;
}
if (item.getItemType() !== enumItemType.boolean) {
// Not a boolean actually
return BOOL_FALSE_SINGLETON;
}
const value = /** @type {BooleanItem} */ (item).value;
return value ? BOOL_FALSE_SINGLETON : BOOL_TRUE_SINGLETON;
}
}