From 7bd18c1a4c559b69a1c332f7ecc7e7ca6b8b3ed4 Mon Sep 17 00:00:00 2001 From: Niklas Kapelle Date: Sat, 13 Apr 2024 12:07:46 +0200 Subject: [PATCH] added exporter and interface for redstone --- src/kernel/peripherals/Redstone.hx | 3 ++- .../peripherals/exports/RedstoneExport.hx | 7 +++++++ src/kernel/peripherals/interfaces/IRedstone.hx | 17 +++++++++++++++++ 3 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 src/kernel/peripherals/exports/RedstoneExport.hx create mode 100644 src/kernel/peripherals/interfaces/IRedstone.hx diff --git a/src/kernel/peripherals/Redstone.hx b/src/kernel/peripherals/Redstone.hx index ce0a172..e431d23 100644 --- a/src/kernel/peripherals/Redstone.hx +++ b/src/kernel/peripherals/Redstone.hx @@ -1,5 +1,6 @@ package kernel.peripherals; +import kernel.peripherals.interfaces.IRedstone; import haxe.ds.ReadOnlyArray; import lib.Color; @@ -41,7 +42,7 @@ abstract BundleMask(Int) from cc.Colors.Color to cc.Colors.Color { } } -class Redstone implements IPeripheral { +class Redstone implements IPeripheral implements IRedstone { public static inline final TYPE_NAME:String = "redstone"; // TODO: there is technically not a type for redstone. public final onChange:Signal; diff --git a/src/kernel/peripherals/exports/RedstoneExport.hx b/src/kernel/peripherals/exports/RedstoneExport.hx new file mode 100644 index 0000000..e105452 --- /dev/null +++ b/src/kernel/peripherals/exports/RedstoneExport.hx @@ -0,0 +1,7 @@ +package kernel.peripherals.exports; + +import macros.rpc.RPCBase; +import kernel.peripherals.interfaces.IRedstone; + +@:build(macros.rpc.RPC.buildRPC(IRedstone)) +class RedstoneExport extends RPCBase {} diff --git a/src/kernel/peripherals/interfaces/IRedstone.hx b/src/kernel/peripherals/interfaces/IRedstone.hx new file mode 100644 index 0000000..09a70a3 --- /dev/null +++ b/src/kernel/peripherals/interfaces/IRedstone.hx @@ -0,0 +1,17 @@ +package kernel.peripherals.interfaces; + +import cc.Colors.Color; +import kernel.peripherals.Redstone.BundleMask; + +interface IRedstone { + function setOutput(on:Bool):Void; + function getOutput():Bool; + function getInput():Bool; + function setAnalogOutput(strength:Int):Void; + function getAnalogOutput():Int; + function getAnalogInput():Int; + function setBundledOutput(output:BundleMask):Void; + function getBundledOutput():BundleMask; + function getBundledInput():BundleMask; + function testBundledInput(mask:Color):Bool; +}