Many bugfixes and tweaks, added doors
This commit is contained in:
@@ -435,9 +435,7 @@ public class Control extends Module{
|
||||
|
||||
Entities.initPhysics();
|
||||
|
||||
Entities.setCollider(tilesize, (x, y)->{
|
||||
return world.solid(x, y);
|
||||
});
|
||||
Entities.setCollider(tilesize, (x, y)-> world.solid(x, y));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -9,6 +9,7 @@ import com.badlogic.gdx.math.Vector2;
|
||||
|
||||
import io.anuke.mindustry.Vars;
|
||||
import io.anuke.mindustry.entities.effect.Fx;
|
||||
import io.anuke.mindustry.input.Input;
|
||||
import io.anuke.mindustry.resource.Recipe;
|
||||
import io.anuke.mindustry.resource.Weapon;
|
||||
import io.anuke.ucore.core.*;
|
||||
@@ -78,7 +79,7 @@ public class Player extends DestructibleEntity{
|
||||
if(Inputs.keyDown("right"))
|
||||
vector.x += speed;
|
||||
|
||||
boolean shooting = Inputs.buttonDown(Buttons.LEFT) && recipe == null && !ui.hasMouse();
|
||||
boolean shooting = Inputs.buttonDown(Buttons.LEFT) && recipe == null && !ui.hasMouse() && !Input.onConfigurable();
|
||||
|
||||
if(shooting && Timers.get(this, "reload", weapon.reload)){
|
||||
weapon.shoot(this);
|
||||
|
||||
@@ -216,6 +216,18 @@ public class Fx{
|
||||
Draw.reset();
|
||||
}),
|
||||
|
||||
dooropen = new Effect(10, e -> {
|
||||
Draw.thickness(e.fract() * 1.6f);
|
||||
Draw.square(e.x, e.y, Vars.tilesize / 2f + e.ifract() * 2f);
|
||||
Draw.reset();
|
||||
}),
|
||||
|
||||
doorclose= new Effect(10, e -> {
|
||||
Draw.thickness(e.fract() * 1.6f);
|
||||
Draw.square(e.x, e.y, Vars.tilesize / 2f + e.fract() * 2f);
|
||||
Draw.reset();
|
||||
}),
|
||||
|
||||
purify = new Effect(10, e -> {
|
||||
Draw.color(Color.ROYAL, Color.GRAY, e.ifract());
|
||||
Draw.thickness(2f);
|
||||
|
||||
@@ -95,6 +95,11 @@ public class Input{
|
||||
public static boolean cursorNear(){
|
||||
return Vector2.dst(player.x, player.y, tilex() * tilesize, tiley() * tilesize) <= placerange;
|
||||
}
|
||||
|
||||
public static boolean onConfigurable(){
|
||||
Tile tile = Vars.world.tile(tilex(), tiley());
|
||||
return tile != null && tile.block() instanceof Configurable;
|
||||
}
|
||||
|
||||
public static int tilex(){
|
||||
return (player.recipe != null && player.recipe.result.isMultiblock() &&
|
||||
|
||||
@@ -17,6 +17,7 @@ public enum Recipe{
|
||||
steelwalllarge(defense, DefenseBlocks.steelwalllarge, stack(Item.steel, 8)),
|
||||
titaniumwalllarge(defense, DefenseBlocks.titaniumwalllarge, stack(Item.titanium, 8)),
|
||||
duriumwalllarge(defense, DefenseBlocks.diriumwalllarge, stack(Item.dirium, 8)),
|
||||
door(defense, DefenseBlocks.door, stack(Item.steel, 3), stack(Item.iron, 3)),
|
||||
titaniumshieldwall(defense, DefenseBlocks.titaniumshieldwall, stack(Item.titanium, 2)),
|
||||
|
||||
conveyor(distribution, DistributionBlocks.conveyor, stack(Item.stone, 1)),
|
||||
|
||||
@@ -39,6 +39,8 @@ public class Block{
|
||||
public boolean destructible;
|
||||
/**whether this is solid*/
|
||||
public boolean solid;
|
||||
/**whethe this block CAN be solid.*/
|
||||
public boolean solidifes;
|
||||
/**whether this is rotateable*/
|
||||
public boolean rotate;
|
||||
/**whether you can break this with rightblick*/
|
||||
@@ -89,8 +91,8 @@ public class Block{
|
||||
return name;
|
||||
}
|
||||
|
||||
public String errorMessage(Tile tile){
|
||||
return null;
|
||||
public boolean isSolidFor(Tile tile){
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean canReplace(Block other){
|
||||
|
||||
@@ -151,7 +151,7 @@ public class Tile{
|
||||
public boolean solid(){
|
||||
Block block = block();
|
||||
Block floor = floor();
|
||||
return block.solid || floor.solid;
|
||||
return block.solid || (floor.solid && block == Blocks.air) || block.isSolidFor(this);
|
||||
}
|
||||
|
||||
public boolean breakable(){
|
||||
|
||||
@@ -12,6 +12,7 @@ import io.anuke.mindustry.Vars;
|
||||
import io.anuke.mindustry.ai.Pathfind;
|
||||
import io.anuke.mindustry.entities.TileEntity;
|
||||
import io.anuke.mindustry.entities.effect.Fx;
|
||||
import io.anuke.mindustry.entities.enemies.Enemy;
|
||||
import io.anuke.mindustry.resource.ItemStack;
|
||||
import io.anuke.mindustry.resource.Recipe;
|
||||
import io.anuke.mindustry.world.blocks.*;
|
||||
@@ -64,7 +65,7 @@ public class World extends Module{
|
||||
public boolean solid(int x, int y){
|
||||
Tile tile = tile(x, y);
|
||||
|
||||
return tile == null || tile.block().solid || (tile.floor().solid && (tile.block() == Blocks.air));
|
||||
return tile == null || tile.solid();
|
||||
}
|
||||
|
||||
public boolean wallSolid(int x, int y){
|
||||
@@ -269,7 +270,7 @@ public class World extends Module{
|
||||
Vector2 offset = type.getPlaceOffset();
|
||||
Tmp.r2.setCenter(offset.x + x * Vars.tilesize, offset.y + y * Vars.tilesize);
|
||||
|
||||
for(SolidEntity e : Entities.getNearby(x * tilesize, y * tilesize, tilesize * 2f)){
|
||||
for(SolidEntity e : Entities.getNearby(Entities.getGroup(Enemy.class), x * tilesize, y * tilesize, tilesize * 2f)){
|
||||
Rectangle rect = e.hitbox.getRect(e.x, e.y);
|
||||
|
||||
if(Tmp.r2.overlaps(rect)){
|
||||
@@ -277,6 +278,10 @@ public class World extends Module{
|
||||
}
|
||||
}
|
||||
|
||||
if(Tmp.r2.overlaps(player.hitbox.getRect(player.x, player.y))){
|
||||
return false;
|
||||
}
|
||||
|
||||
Tile tile = tile(x, y);
|
||||
|
||||
if(tile == null) return false;
|
||||
|
||||
@@ -2,9 +2,7 @@ package io.anuke.mindustry.world.blocks;
|
||||
|
||||
import io.anuke.mindustry.world.Block;
|
||||
import io.anuke.mindustry.world.blocks.types.Wall;
|
||||
import io.anuke.mindustry.world.blocks.types.defense.RepairTurret;
|
||||
import io.anuke.mindustry.world.blocks.types.defense.ShieldBlock;
|
||||
import io.anuke.mindustry.world.blocks.types.defense.ShieldedWallBlock;
|
||||
import io.anuke.mindustry.world.blocks.types.defense.*;
|
||||
|
||||
public class DefenseBlocks{
|
||||
|
||||
@@ -96,5 +94,9 @@ public class DefenseBlocks{
|
||||
+ "but drains energy quickly on bullet contact.";
|
||||
formalName = "shield generator";
|
||||
}
|
||||
};
|
||||
},
|
||||
door = new Door("door"){{
|
||||
fullDescription = "A block than can be opened and closed by clicking it.";
|
||||
health = 90;
|
||||
}};
|
||||
}
|
||||
|
||||
@@ -1,11 +1,85 @@
|
||||
package io.anuke.mindustry.world.blocks.types.defense;
|
||||
|
||||
import io.anuke.mindustry.world.blocks.types.Wall;
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
|
||||
public class Door extends Wall{
|
||||
import com.badlogic.gdx.math.Rectangle;
|
||||
import com.badlogic.gdx.math.Vector2;
|
||||
import com.badlogic.gdx.utils.ObjectMap;
|
||||
|
||||
import io.anuke.mindustry.Vars;
|
||||
import io.anuke.mindustry.entities.effect.Fx;
|
||||
import io.anuke.mindustry.entities.enemies.Enemy;
|
||||
import io.anuke.mindustry.world.Block;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
import io.anuke.mindustry.world.blocks.types.Configurable;
|
||||
import io.anuke.mindustry.world.blocks.types.Wall;
|
||||
import io.anuke.ucore.core.Draw;
|
||||
import io.anuke.ucore.core.Effects;
|
||||
import io.anuke.ucore.core.Effects.Effect;
|
||||
import io.anuke.ucore.entities.Entities;
|
||||
import io.anuke.ucore.entities.SolidEntity;
|
||||
import io.anuke.ucore.scene.ui.layout.Table;
|
||||
import io.anuke.ucore.util.Tmp;
|
||||
|
||||
public class Door extends Wall implements Configurable{
|
||||
private ObjectMap<Tile, Boolean> open = new ObjectMap<>();
|
||||
|
||||
protected Effect openfx = Fx.dooropen;
|
||||
protected Effect closefx = Fx.doorclose;
|
||||
|
||||
public Door(String name) {
|
||||
super(name);
|
||||
solid = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(Tile tile){
|
||||
if(open.get(tile, true)){
|
||||
Draw.rect(name, tile.worldx(), tile.worldy());
|
||||
}else{
|
||||
Draw.rect(name + "-open", tile.worldx(), tile.worldy());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSolidFor(Tile tile){
|
||||
return open.get(tile, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void buildTable(Tile tile, Table table){
|
||||
if(anyEntities(tile) && !open.get(tile, true)){
|
||||
return;
|
||||
}
|
||||
|
||||
open.put(tile, !open.get(tile, true));
|
||||
if(open.get(tile)){
|
||||
Effects.effect(closefx, tile.worldx(), tile.worldy());
|
||||
}else{
|
||||
Effects.effect(openfx, tile.worldx(), tile.worldy());
|
||||
}
|
||||
}
|
||||
|
||||
boolean anyEntities(Tile tile){
|
||||
int x = tile.x, y = tile.y;
|
||||
Block type = tile.block();
|
||||
Tmp.r2.setSize(type.width * Vars.tilesize, type.height * Vars.tilesize);
|
||||
Vector2 offset = type.getPlaceOffset();
|
||||
Tmp.r2.setCenter(offset.x + x * Vars.tilesize, offset.y + y * Vars.tilesize);
|
||||
|
||||
for(SolidEntity e : Entities.getNearby(Entities.getGroup(Enemy.class), x * tilesize, y * tilesize, tilesize * 2f)){
|
||||
Rectangle rect = e.hitbox.getRect(e.x, e.y);
|
||||
|
||||
if(Tmp.r2.overlaps(rect)){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if(Tmp.r2.overlaps(player.hitbox.getRect(player.x, player.y))){
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package io.anuke.mindustry.world.blocks.types.production;
|
||||
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
|
||||
import io.anuke.mindustry.entities.effect.Fx;
|
||||
import io.anuke.mindustry.resource.Item;
|
||||
import io.anuke.mindustry.world.Block;
|
||||
@@ -21,6 +23,13 @@ public class Drill extends Block{
|
||||
solid = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getStats(Array<String> list){
|
||||
super.getStats(list);
|
||||
list.add("[iteminfo]Capacity: " + capacity);
|
||||
list.add("[iteminfo]Seconds/item: " + time);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(Tile tile){
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@ public class Generator extends PowerBlock{
|
||||
public boolean explosive = true;
|
||||
public boolean drawRadius = false;
|
||||
public boolean hasLasers = true;
|
||||
public boolean outputOnly = false;
|
||||
|
||||
public Generator(String name) {
|
||||
super(name);
|
||||
@@ -78,15 +79,17 @@ public class Generator extends PowerBlock{
|
||||
@Override
|
||||
public void drawOver(Tile tile){
|
||||
PowerEntity entity = tile.entity();
|
||||
if(entity.power > powerSpeed){
|
||||
Draw.alpha(1f);
|
||||
}else{
|
||||
Draw.alpha(0.5f);
|
||||
}
|
||||
|
||||
|
||||
for(int i = 0; i < laserDirections; i++){
|
||||
if(entity.power > powerSpeed){
|
||||
Draw.alpha(1f);
|
||||
}else{
|
||||
Draw.alpha(0.5f);
|
||||
}
|
||||
drawLaserTo(tile, (tile.getRotation() + i) - laserDirections/2);
|
||||
}
|
||||
|
||||
Draw.color();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -121,7 +124,7 @@ public class Generator extends PowerBlock{
|
||||
|
||||
Tmp.v1.set(Angles.translation(rotation * 90, target.block().width * Vars.tilesize/2 + 2f +
|
||||
(interfering ?
|
||||
Vector2.dst(tile.worldx(), tile.worldy(), target.worldx(), target.worldy()) / 2f - Vars.tilesize/2f - 1 : 0)));
|
||||
Vector2.dst(tile.worldx(), tile.worldy(), target.worldx(), target.worldy()) / 2f - Vars.tilesize/2f * target.block().width - 1 : 0)));
|
||||
|
||||
Angles.translation(rotation * 90, width * Vars.tilesize/2 + 2f);
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@ public class ItemPowerGenerator extends Generator{
|
||||
|
||||
public ItemPowerGenerator(String name) {
|
||||
super(name);
|
||||
outputOnly = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -7,6 +7,7 @@ import io.anuke.mindustry.Vars;
|
||||
import io.anuke.mindustry.entities.TileEntity;
|
||||
import io.anuke.mindustry.resource.Item;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
import io.anuke.ucore.core.Draw;
|
||||
import io.anuke.ucore.core.Effects;
|
||||
import io.anuke.ucore.core.Timers;
|
||||
|
||||
@@ -29,6 +30,7 @@ public class LiquidItemPowerGenerator extends LiquidPowerGenerator{
|
||||
|
||||
Vars.renderer.drawBar(Color.GREEN, tile.worldx() + offset.x, tile.worldy() + 6 +
|
||||
offset.y + height*Vars.tilesize/2f, (float)entity.totalItems() / itemCapacity);
|
||||
Draw.reset();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -30,6 +30,7 @@ public class LiquidPowerGenerator extends Generator implements LiquidAcceptor{
|
||||
|
||||
public LiquidPowerGenerator(String name) {
|
||||
super(name);
|
||||
outputOnly = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -56,7 +57,7 @@ public class LiquidPowerGenerator extends Generator implements LiquidAcceptor{
|
||||
|
||||
public void drawLiquidCenter(Tile tile){
|
||||
Vector2 offset = getPlaceOffset();
|
||||
Draw.rect("black", tile.worldx() + offset.x, tile.worldy() + offset.y, 2, 2);
|
||||
Draw.rect("blank", tile.worldx() + offset.x, tile.worldy() + offset.y, 2, 2);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
package io.anuke.mindustry.world.blocks.types.production;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import com.badlogic.gdx.graphics.Color;
|
||||
import com.badlogic.gdx.math.Vector2;
|
||||
|
||||
@@ -26,7 +30,7 @@ public class NuclearReactor extends LiquidItemPowerGenerator{
|
||||
protected float smokeThreshold = 0.3f; //threshold at which block starts smoking
|
||||
protected int explosionRadius = 19;
|
||||
protected int explosionDamage = 128;
|
||||
protected float flashThreshold = 0.5f;
|
||||
protected float flashThreshold = 0.46f;
|
||||
|
||||
public NuclearReactor(String name) {
|
||||
super(name);
|
||||
@@ -91,7 +95,7 @@ public class NuclearReactor extends LiquidItemPowerGenerator{
|
||||
|
||||
int fuel = entity.getItem(generateItem);
|
||||
|
||||
if(fuel < 5) return;
|
||||
if(fuel < 5 && entity.heat < 0.5f) return;
|
||||
|
||||
int waves = 6;
|
||||
float delay = 8f;
|
||||
@@ -156,13 +160,14 @@ public class NuclearReactor extends LiquidItemPowerGenerator{
|
||||
Draw.rect("white", tile.worldx() + offset.x, tile.worldy() + offset.y, width * Vars.tilesize, height * Vars.tilesize);
|
||||
|
||||
if(entity.heat > flashThreshold){
|
||||
float flash = 9f - ((entity.heat - flashThreshold) / (1f - flashThreshold)) * 4f;
|
||||
Draw.color(Color.RED, Color.YELLOW, Mathf.absin(Timers.time(), flash, 1f));
|
||||
float flash = 1f + ((entity.heat - flashThreshold) / (1f - flashThreshold)) * 5.4f;
|
||||
entity.flash += flash * Timers.delta();
|
||||
Draw.color(Color.RED, Color.YELLOW, Mathf.absin(entity.flash, 9f, 1f));
|
||||
Draw.alpha(0.6f);
|
||||
Draw.rect(name + "-lights", tile.worldx() + offset.x, tile.worldy() + offset.y);
|
||||
}
|
||||
|
||||
Draw.color();
|
||||
Draw.reset();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -172,5 +177,18 @@ public class NuclearReactor extends LiquidItemPowerGenerator{
|
||||
|
||||
public static class NuclearReactorEntity extends LiquidPowerEntity{
|
||||
public float heat;
|
||||
public float flash;
|
||||
|
||||
@Override
|
||||
public void write(DataOutputStream stream) throws IOException{
|
||||
super.write(stream);
|
||||
stream.writeFloat(heat);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void read(DataInputStream stream) throws IOException{
|
||||
super.read(stream);
|
||||
heat = stream.readFloat();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user