Last active
November 21, 2019 17:43
-
-
Save Geokureli/06c50e9bf0e51953e9492bf2a3e54ff3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
typedef OgmoEntityData<T> | |
= { | |
name :String, | |
id :Int, | |
x :Int, | |
y :Int, | |
rotation:Float, | |
originX :Int, | |
originY :Int, | |
values :T | |
} | |
abstract OgmoValue(String) from String to String | |
{ | |
public var isEmpty(get, never):Bool; | |
inline function get_isEmpty() return this == "-1"; | |
inline public function getColor():Null<Int> | |
{ | |
return isEmpty ? null : (Std.parseInt("0x" + this.substr(1)) >> 8); | |
} | |
inline public function getInt ():Null<Int > return isEmpty ? null : Std.parseInt(this); | |
inline public function getFloat():Null<Float> return isEmpty ? null : Std.parseFloat(this); | |
inline public function getBool ():Null<Bool > return isEmpty ? null : this == "true"; | |
} | |
@:forward abstract OgmoInt(OgmoValue) from String to String | |
{ | |
public var value(get, never):Null<Int>; | |
inline function get_value() return this.getInt(); | |
} | |
@:forward abstract OgmoFloat(OgmoValue) from String to String | |
{ | |
public var value(get, never):Null<Float>; | |
inline function get_value() return this.getFloat(); | |
} | |
@:forward abstract OgmoBool(OgmoValue) from String to String | |
{ | |
public var value(get, never):Null<Bool>; | |
inline function get_value() return this.getBool(); | |
} | |
@:forward abstract OgmoColor(OgmoValue) from String to String | |
{ | |
public var value(get, never):Null<Int>; | |
inline function get_value() return this.getColor(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment