Compare commits
3 Commits
24d9268b4a
...
fa62e3a2eb
| Author | SHA1 | Date | |
|---|---|---|---|
| fa62e3a2eb | |||
| a1bb41f8a2 | |||
| 57bf49bea9 |
@@ -109,7 +109,7 @@ abstract WriteBinaryHandle(FileHandle) from FileHandle {
|
||||
}
|
||||
}
|
||||
|
||||
@:enum abstract BinarySeekWhence(String) to String {
|
||||
enum abstract BinarySeekWhence(String) to String {
|
||||
var Set = "set"; // Relative to the beginning of the file.
|
||||
var Current = "cur"; // Relative to the current position. This is the default.
|
||||
var End = "end"; // Relative to the end of the file.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package kernel.http;
|
||||
|
||||
@:enum abstract StatusCode(Int) from Int {
|
||||
enum abstract StatusCode(Int) from Int {
|
||||
var Continue = 100;
|
||||
var SwitchingProtocols = 101;
|
||||
var Processing = 102;
|
||||
|
||||
@@ -1,10 +1,45 @@
|
||||
package kernel.peripherals;
|
||||
|
||||
import haxe.ds.ReadOnlyArray;
|
||||
import util.Color;
|
||||
|
||||
using tink.CoreApi;
|
||||
|
||||
typedef BundleMask = 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) {
|
||||
return new BundleMask(c);
|
||||
}
|
||||
|
||||
@:op(A + B)
|
||||
@:op(A | B)
|
||||
public inline function combine(rhs: BundleMask):BundleMask {
|
||||
return this | rhs;
|
||||
}
|
||||
|
||||
@:op(A + B)
|
||||
@:op(A | B)
|
||||
public inline function combineWithColor(rhs: Color):BundleMask {
|
||||
return this | rhs;
|
||||
}
|
||||
|
||||
public function getComponents(): ReadOnlyArray<Color> {
|
||||
var components: Array<Color> = [];
|
||||
var mask = 1;
|
||||
for (i in 0...16){
|
||||
if ((this & mask) > 0 ){
|
||||
components.push(mask);
|
||||
}
|
||||
mask = mask << 1;
|
||||
}
|
||||
|
||||
return components;
|
||||
}
|
||||
}
|
||||
|
||||
class Redstone implements IPeripheral {
|
||||
|
||||
@@ -22,16 +57,19 @@ class Redstone implements IPeripheral {
|
||||
this.addr = side;
|
||||
this.onChange = this.onChangeTrigger.asSignal();
|
||||
|
||||
updateState();
|
||||
|
||||
KernelEvents.instance.onRedstone.handle(()->{
|
||||
if ((this.getAnalogInput() != this.analogInputState) || (this.bundleInputState == this.getBundledInput())){
|
||||
if ((this.getAnalogInput() != this.analogInputState) || (this.bundleInputState != this.getBundledInput())){
|
||||
updateState();
|
||||
this.onChangeTrigger.trigger(null);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public function getAddr():String {
|
||||
return this.addr;
|
||||
updateState();
|
||||
}
|
||||
|
||||
private function updateState() {
|
||||
|
||||
@@ -45,8 +45,7 @@ bit.tohex = function(x,n)
|
||||
end
|
||||
|
||||
bit.lshift = function(x,n)
|
||||
print("ERROR: Tell a dev to implement: bit.lshift")
|
||||
error()
|
||||
return bit.blshift(x,n);
|
||||
end
|
||||
|
||||
|
||||
|
||||
@@ -21,7 +21,8 @@ enum abstract Color(Int) from cc.Colors.Color to cc.Colors.Color {
|
||||
var Black = 0x8000;
|
||||
|
||||
@:op(A + B)
|
||||
@:op(A | B)
|
||||
public inline function combine(rhs: Color):BundleMask {
|
||||
return this + rhs;
|
||||
return this | rhs;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user