PR: world-switch (#9167)

This commit is contained in:
WayZer
2023-10-14 21:09:59 +08:00
committed by GitHub
parent 002f322563
commit a6d0a17bd9
5 changed files with 30 additions and 1 deletions

View File

@@ -160,7 +160,7 @@ public class Blocks{
//logic
message, switchBlock, microProcessor, logicProcessor, hyperProcessor, largeLogicDisplay, logicDisplay, memoryCell, memoryBank,
canvas, reinforcedMessage,
worldProcessor, worldCell, worldMessage,
worldProcessor, worldCell, worldMessage, worldSwitch,
//campaign
launchPad, interplanetaryAccelerator
@@ -5944,6 +5944,13 @@ public class Blocks{
privileged = true;
}};
worldSwitch = new SwitchBlock("world-switch"){{
requirements(Category.logic, BuildVisibility.editorOnly, with());
targetable = false;
privileged = true;
}};
//endregion
}
}

View File

@@ -8,6 +8,8 @@ import mindustry.gen.*;
import mindustry.world.*;
import mindustry.world.meta.*;
import static mindustry.Vars.state;
public class SwitchBlock extends Block{
public Sound clickSound = Sounds.click;
@@ -25,7 +27,26 @@ public class SwitchBlock extends Block{
config(Boolean.class, (SwitchBuild entity, Boolean b) -> entity.enabled = b);
}
public boolean accessible(){
return !privileged || state.rules.editor;
}
@Override
public boolean canBreak(Tile tile){
return accessible();
}
public class SwitchBuild extends Building{
@Override
public void damage(float damage){
if(privileged) return;
super.damage(damage);
}
@Override
public boolean collide(Bullet other){
return !privileged;
}
@Override
public boolean configTapped(){