Status apply instruction / Bugfixes
This commit is contained in:
@@ -175,7 +175,7 @@ public class Placement{
|
||||
plans.set(result);
|
||||
}
|
||||
|
||||
public static void calculateBridges(Seq<BuildPlan> plans, DirectionBridge bridge, boolean hasJunction){
|
||||
public static void calculateBridges(Seq<BuildPlan> plans, DirectionBridge bridge, boolean hasJunction, Boolf<Block> same){
|
||||
if(isSidePlace(plans)) return;
|
||||
|
||||
//check for orthogonal placement + unlocked state
|
||||
@@ -185,9 +185,9 @@ public class Placement{
|
||||
|
||||
//TODO for chains of ducts, do not count consecutives in a different rotation as 'placeable'
|
||||
Boolf<BuildPlan> placeable = plan ->
|
||||
!(!hasJunction && plan.build() != null && plan.build().block == plan.block && plan.rotation != plan.build().rotation) &&
|
||||
!(!hasJunction && plan.build() != null && same.get(plan.build().block) && plan.rotation != plan.build().rotation) &&
|
||||
(plan.placeable(player.team()) ||
|
||||
(plan.tile() != null && plan.tile().block() == plan.block)); //don't count the same block as inaccessible
|
||||
(plan.tile() != null && same.get(plan.tile().block()))); //don't count the same block as inaccessible
|
||||
|
||||
var result = plans1.clear();
|
||||
|
||||
|
||||
@@ -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";
|
||||
|
||||
@@ -76,7 +76,7 @@ public class LaserTurret extends PowerTurret{
|
||||
|
||||
wasShooting = true;
|
||||
heat = 1f;
|
||||
curRecoil = recoil;
|
||||
curRecoil = 1f;
|
||||
}else if(reloadCounter > 0){
|
||||
wasShooting = true;
|
||||
|
||||
|
||||
@@ -95,7 +95,7 @@ public class Duct extends Block implements Autotiler{
|
||||
|
||||
@Override
|
||||
public void handlePlacementLine(Seq<BuildPlan> plans){
|
||||
Placement.calculateBridges(plans, (DuctBridge)Blocks.ductBridge, false);
|
||||
Placement.calculateBridges(plans, (DuctBridge)Blocks.ductBridge, false, b -> b instanceof Duct);
|
||||
}
|
||||
|
||||
public class DuctBuild extends Building{
|
||||
|
||||
@@ -136,7 +136,7 @@ public class Conduit extends LiquidBlock implements Autotiler{
|
||||
if(bridgeReplacement == null) return;
|
||||
|
||||
if(rotBridgeReplacement instanceof DirectionBridge duct){
|
||||
Placement.calculateBridges(plans, duct, true);
|
||||
Placement.calculateBridges(plans, duct, true, b -> b instanceof Conduit);
|
||||
}else{
|
||||
Placement.calculateBridges(plans, (ItemBridge)bridgeReplacement);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user