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:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user