Logic color unpacking (#10794)

* `unpackcolor`

* Add description
This commit is contained in:
Redstonneur1256
2025-05-11 16:43:37 +02:00
committed by GitHub
parent d51e350d75
commit 159813a7fd
3 changed files with 54 additions and 2 deletions

View File

@@ -1216,8 +1216,7 @@ public class LExecutor{
this.a = a;
}
public PackColorI(){
}
public PackColorI(){}
@Override
public void run(LExecutor exec){
@@ -1225,6 +1224,29 @@ public class LExecutor{
}
}
public static class UnpackColorI implements LInstruction{
public LVar r, g, b, a, value;
public UnpackColorI(LVar r, LVar g, LVar b, LVar a, LVar value){
this.r = r;
this.g = g;
this.b = b;
this.a = a;
this.value = value;
}
public UnpackColorI(){}
@Override
public void run(LExecutor exec){
var color = Tmp.c1.fromDouble(value.num());
r.setnum(color.r);
g.setnum(color.g);
b.setnum(color.b);
a.setnum(color.a);
}
}
public static class CutsceneI implements LInstruction{
public CutsceneAction action = CutsceneAction.stop;
public LVar p1, p2, p3, p4;

View File

@@ -897,6 +897,35 @@ public class LStatements{
}
}
@RegisterStatement("unpackcolor")
public static class UnpackColorStatement extends LStatement{
public String r = "r", g = "g", b = "b", a = "a", value = "color";
@Override
public void build(Table table){
fields(table, r, str -> r = str);
fields(table, g, str -> g = str);
fields(table, b, str -> b = str);
fields(table, a, str -> a = str);
row(table);
table.add(" = unpack ");
fields(table, value, str -> value = str);
}
@Override
public LInstruction build(LAssembler builder){
return new UnpackColorI(builder.var(r), builder.var(g), builder.var(b), builder.var(a), builder.var(value));
}
@Override
public LCategory category(){
return LCategory.operation;
}
}
@RegisterStatement("end")
public static class EndStatement extends LStatement{
@Override