BIG FORMATING COMMIT
This commit is contained in:
@@ -7,33 +7,33 @@ import lib.Color;
|
||||
|
||||
using tink.CoreApi;
|
||||
|
||||
abstract BundleMask(Int) from cc.Colors.Color to cc.Colors.Color {
|
||||
abstract BundleMask(Int) from cc.Colors.Color to cc.Colors.Color {
|
||||
public inline function new(i:Int) {
|
||||
this = i;
|
||||
}
|
||||
|
||||
@:from
|
||||
public static function fromColor(c: Color) {
|
||||
public static function fromColor(c:Color) {
|
||||
return new BundleMask(c);
|
||||
}
|
||||
|
||||
@:op(A + B)
|
||||
@:op(A | B)
|
||||
public inline function combine(rhs: BundleMask):BundleMask {
|
||||
public inline function combine(rhs:BundleMask):BundleMask {
|
||||
return this | rhs;
|
||||
}
|
||||
|
||||
@:op(A + B)
|
||||
@:op(A | B)
|
||||
public inline function combineWithColor(rhs: Color):BundleMask {
|
||||
public inline function combineWithColor(rhs:Color):BundleMask {
|
||||
return this | rhs;
|
||||
}
|
||||
|
||||
public function getComponents(): ReadOnlyArray<Color> {
|
||||
var components: Array<Color> = [];
|
||||
public function getComponents():ReadOnlyArray<Color> {
|
||||
var components:Array<Color> = [];
|
||||
var mask = 1;
|
||||
for (i in 0...16){
|
||||
if ((this & mask) > 0 ){
|
||||
for (i in 0...16) {
|
||||
if ((this & mask) > 0) {
|
||||
components.push(mask);
|
||||
}
|
||||
mask = mask << 1;
|
||||
@@ -57,19 +57,18 @@ class Redstone implements IPeripheral implements IExportable {
|
||||
private var bundleInputState:BundleMask;
|
||||
|
||||
@:allow(kernel.peripherals)
|
||||
private function new(side: Side) {
|
||||
private function new(side:Side) {
|
||||
this.addr = side;
|
||||
this.onChange = this.onChangeTrigger.asSignal();
|
||||
|
||||
updateState();
|
||||
|
||||
KernelEvents.onRedstone.handle(()->{
|
||||
if ((this.getAnalogInput() != this.analogInputState) || (this.bundleInputState != this.getBundledInput())){
|
||||
KernelEvents.onRedstone.handle(() -> {
|
||||
if ((this.getAnalogInput() != this.analogInputState) || (this.bundleInputState != this.getBundledInput())) {
|
||||
updateState();
|
||||
this.onChangeTrigger.trigger(null);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public function getAddr():String {
|
||||
@@ -87,35 +86,35 @@ class Redstone implements IPeripheral implements IExportable {
|
||||
|
||||
public inline function setOutput(on:Bool):Void {
|
||||
this.analogInputState = 15;
|
||||
cc.Redstone.setOutput(this.addr,on);
|
||||
cc.Redstone.setOutput(this.addr, on);
|
||||
}
|
||||
|
||||
@export("output")
|
||||
public inline function getOutput(): Bool {
|
||||
public inline function getOutput():Bool {
|
||||
return cc.Redstone.getOutput(this.addr);
|
||||
}
|
||||
|
||||
@export("input")
|
||||
public inline function getInput(): Bool {
|
||||
public inline function getInput():Bool {
|
||||
return cc.Redstone.getInput(this.addr);
|
||||
}
|
||||
|
||||
public inline function setAnalogOutput(strength:Int): Void {
|
||||
public inline function setAnalogOutput(strength:Int):Void {
|
||||
this.analogInputState = strength;
|
||||
cc.Redstone.setAnalogOutput(this.addr,strength);
|
||||
cc.Redstone.setAnalogOutput(this.addr, strength);
|
||||
}
|
||||
|
||||
public inline function getAnalogOutput(): Int {
|
||||
public inline function getAnalogOutput():Int {
|
||||
return cc.Redstone.getAnalogOutput(this.addr);
|
||||
}
|
||||
|
||||
public inline function getAnalogInput(): Int {
|
||||
public inline function getAnalogInput():Int {
|
||||
return cc.Redstone.getAnalogInput(this.addr);
|
||||
}
|
||||
|
||||
public inline function setBundledOutput(output: BundleMask) {
|
||||
public inline function setBundledOutput(output:BundleMask) {
|
||||
this.bundleInputState = output;
|
||||
cc.Redstone.setBundledOutput(this.addr,output);
|
||||
cc.Redstone.setBundledOutput(this.addr, output);
|
||||
}
|
||||
|
||||
public inline function getBundledOutput():BundleMask {
|
||||
@@ -126,7 +125,7 @@ class Redstone implements IPeripheral implements IExportable {
|
||||
return cc.Redstone.getBundledInput(this.addr);
|
||||
}
|
||||
|
||||
public inline function testBundledInput(mask: Color): Bool {
|
||||
return cc.Redstone.testBundledInput(this.addr,mask);
|
||||
public inline function testBundledInput(mask:Color):Bool {
|
||||
return cc.Redstone.testBundledInput(this.addr, mask);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user