Status apply instruction / Bugfixes
This commit is contained in:
@@ -1320,6 +1320,35 @@ public class LExecutor{
|
||||
}
|
||||
}
|
||||
|
||||
public static class ApplyEffectI implements LInstruction{
|
||||
public boolean clear;
|
||||
public String effect;
|
||||
public int unit, duration;
|
||||
|
||||
public ApplyEffectI(boolean clear, String effect, int unit, int duration){
|
||||
this.clear = clear;
|
||||
this.effect = effect;
|
||||
this.unit = unit;
|
||||
this.duration = duration;
|
||||
}
|
||||
|
||||
public ApplyEffectI(){
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(LExecutor exec){
|
||||
if(net.client()) return;
|
||||
|
||||
if(exec.obj(unit) instanceof Unit unit && content.statusEffect(effect) != null){
|
||||
if(clear){
|
||||
unit.unapply(content.statusEffect(effect));
|
||||
}else{
|
||||
unit.apply(content.statusEffect(effect), exec.numf(duration) * 60f);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class SetRuleI implements LInstruction{
|
||||
public LogicRule rule = LogicRule.waveSpacing;
|
||||
public int value, p1, p2, p3, p4;
|
||||
|
||||
@@ -115,7 +115,7 @@ public abstract class LStatement{
|
||||
}
|
||||
}
|
||||
|
||||
protected <T extends Enum<T>> void showSelect(Button b, T[] values, T current, Cons<T> getter, int cols, Cons<Cell> sizer){
|
||||
protected <T> void showSelect(Button b, T[] values, T current, Cons<T> getter, int cols, Cons<Cell> sizer){
|
||||
showSelectTable(b, (t, hide) -> {
|
||||
ButtonGroup<Button> group = new ButtonGroup<>();
|
||||
int i = 0;
|
||||
@@ -125,14 +125,18 @@ public abstract class LStatement{
|
||||
sizer.get(t.button(p.toString(), Styles.logicTogglet, () -> {
|
||||
getter.get(p);
|
||||
hide.run();
|
||||
}).self(c -> tooltip(c, p)).checked(current == p).group(group));
|
||||
}).self(c -> {
|
||||
if(p instanceof Enum e){
|
||||
tooltip(c, e);
|
||||
}
|
||||
}).checked(current == p).group(group));
|
||||
|
||||
if(++i % cols == 0) t.row();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
protected <T extends Enum<T>> void showSelect(Button b, T[] values, T current, Cons<T> getter){
|
||||
protected <T> void showSelect(Button b, T[] values, T current, Cons<T> getter){
|
||||
showSelect(b, values, current, getter, 4, c -> {});
|
||||
}
|
||||
|
||||
|
||||
@@ -1234,6 +1234,71 @@ public class LStatements{
|
||||
}
|
||||
}
|
||||
|
||||
@RegisterStatement("status")
|
||||
public static class ApplyStatusStatement extends LStatement{
|
||||
public boolean clear;
|
||||
public String effect = "wet", unit = "unit", duration = "10";
|
||||
|
||||
private static @Nullable String[] statusNames;
|
||||
|
||||
@Override
|
||||
public void build(Table table){
|
||||
rebuild(table);
|
||||
}
|
||||
|
||||
void rebuild(Table table){
|
||||
table.clearChildren();
|
||||
|
||||
table.button(clear ? "clear" : "apply", Styles.logict, () -> {
|
||||
clear = !clear;
|
||||
rebuild(table);
|
||||
}).size(80f, 40f).pad(4f).color(table.color);
|
||||
|
||||
if(statusNames == null){
|
||||
statusNames = content.statusEffects().select(s -> !s.isHidden()).map(s -> s.name).toArray(String.class);
|
||||
}
|
||||
|
||||
table.button(b -> {
|
||||
b.label(() -> effect).grow().wrap().labelAlign(Align.center).center();
|
||||
b.clicked(() -> showSelect(b, statusNames, effect, o -> {
|
||||
effect = o;
|
||||
}, 2, c -> c.size(120f, 38f)));
|
||||
}, Styles.logict, () -> {}).size(120f, 40f).pad(4f).color(table.color);
|
||||
|
||||
//TODO effect select
|
||||
|
||||
table.add(clear ? " from " : " to ");
|
||||
|
||||
row(table);
|
||||
|
||||
fields(table, unit, str -> unit = str);
|
||||
|
||||
if(!clear){
|
||||
|
||||
table.add(" for ");
|
||||
|
||||
fields(table, duration, str -> duration = str);
|
||||
|
||||
table.add(" sec");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean privileged(){
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Color color(){
|
||||
return Pal.logicWorld;
|
||||
}
|
||||
|
||||
@Override
|
||||
public LInstruction build(LAssembler builder){
|
||||
return new ApplyEffectI(clear, effect, builder.var(unit), builder.var(duration));
|
||||
}
|
||||
}
|
||||
|
||||
@RegisterStatement("spawnwave")
|
||||
public static class SpawnWaveStatement extends LStatement{
|
||||
public String x = "10", y = "10";
|
||||
|
||||
Reference in New Issue
Block a user