Bugfixes / Logic category (no icon) / Switch block
This commit is contained in:
@@ -284,7 +284,7 @@ public abstract class Turret extends Block{
|
||||
}
|
||||
|
||||
protected boolean validateTarget(){
|
||||
return !Units.invalidateTarget(target, team, x, y) || isControlled();
|
||||
return !Units.invalidateTarget(target, team, x, y) || isControlled() || logicControlled();
|
||||
}
|
||||
|
||||
protected void findTarget(){
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package mindustry.world.blocks.storage;
|
||||
package mindustry.world.blocks.logic;
|
||||
|
||||
import arc.*;
|
||||
import arc.Input.*;
|
||||
45
core/src/mindustry/world/blocks/logic/SwitchBlock.java
Normal file
45
core/src/mindustry/world/blocks/logic/SwitchBlock.java
Normal file
@@ -0,0 +1,45 @@
|
||||
package mindustry.world.blocks.logic;
|
||||
|
||||
import arc.graphics.g2d.*;
|
||||
import mindustry.annotations.Annotations.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.logic.*;
|
||||
import mindustry.world.*;
|
||||
|
||||
public class SwitchBlock extends Block{
|
||||
public @Load("@-on") TextureRegion onRegion;
|
||||
|
||||
public SwitchBlock(String name){
|
||||
super(name);
|
||||
configurable = true;
|
||||
update = true;
|
||||
|
||||
config(Boolean.class, (ButtonEntity entity, Boolean b) -> entity.on = b);
|
||||
}
|
||||
|
||||
public class ButtonEntity extends Building{
|
||||
public boolean on;
|
||||
|
||||
@Override
|
||||
public double sense(LAccess sensor){
|
||||
if(sensor == LAccess.enabled) return on ? 1 : 0;
|
||||
return super.sense(sensor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean configTapped(){
|
||||
configure(!on);
|
||||
Sounds.click.at(this);
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(){
|
||||
super.draw();
|
||||
|
||||
if(on){
|
||||
Draw.rect(onRegion, x, y);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user