Logic fixes / Bigger erekir sectors

This commit is contained in:
Anuken
2022-02-13 11:09:27 -05:00
parent 3039a404eb
commit d72153c67a
15 changed files with 147 additions and 31 deletions

View File

@ -94,11 +94,12 @@ android{
buildTypes{
all{
//TODO without these lines (r8 enabled), Mindustry crashes with missing default interface method errors.
//WHY THE HELL ARE DEFAULT INTERFACES NOT BEING DESUGARED? WHY DID UPDATING AGP MAKE THIS HAPPEN?
//When I ENABLE shrinking, r8 goes and REMOVES ALL DEFAULT INTERFACE CLASSES, which breaks mods. Why?
//-keep class mindustry.** { *; } should *keep the classes* - WHY IS R8 REMOVING THEM?
minifyEnabled = true
shrinkResources = true
//this is the ONLY WAY I could find to force r8 to keep its filthy hands off of my default interfaces.
//may have undesirable side effects
debuggable = true
proguardFiles("proguard-rules.pro")
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 373 B

View File

@ -17,6 +17,7 @@ import static mindustry.Vars.*;
import static mindustry.ai.Pathfinder.*;
public class ControlPathfinder{
//TODO this FPS-based update system could be flawed.
private static final long maxUpdate = Time.millisToNanos(20);
private static final int updateFPS = 60;
private static final int updateInterval = 1000 / updateFPS;
@ -316,7 +317,7 @@ public class ControlPathfinder{
int ww = world.width(), wh = world.height();
int x = x1, dx = Math.abs(x2 - x), sx = x < x2 ? 1 : -1;
int y = y1, dy = Math.abs(y2 - y), sy = y < y2 ? 1 : -1;
int e2, err = dx - dy;
int err = dx - dy;
while(x >= 0 && y >= 0 && x < ww && y < wh){
if(solid(type, x + y * wwidth)) return true;
@ -455,7 +456,7 @@ public class ControlPathfinder{
}
lastId = curId;
//re-do everything when world updates
//re-do everything when world updates, but keep the old path around
if(Time.timeSinceMillis(lastTime) > 1000 * 3 && (worldUpdateId != lastWorldUpdate || !destination.epsilonEquals(lastDestination, 2f))){
lastTime = Time.millis();
lastWorldUpdate = worldUpdateId;
@ -466,7 +467,6 @@ public class ControlPathfinder{
long ns = Time.nanos();
int counter = 0;
//Log.info("running; @ in frontier", frontier.size);
while(frontier.size > 0){
int current = frontier.poll();

View File

@ -150,7 +150,7 @@ public class Blocks{
//logic
message, switchBlock, microProcessor, logicProcessor, hyperProcessor, largeLogicDisplay, logicDisplay, memoryCell, memoryBank,
worldProcessor,
worldProcessor, worldCell,
//campaign
//TODO launch pad on erekir, 5x5, uses nuclear(?) fuel
@ -3853,7 +3853,6 @@ public class Blocks{
}};
worldProcessor = new LogicBlock("world-processor"){{
//currently incomplete, debugOnly for now
requirements(Category.logic, BuildVisibility.editorOnly, with());
//TODO customizable IPT
@ -3864,6 +3863,13 @@ public class Blocks{
size = 1;
}};
worldCell = new MemoryBlock("world-cell"){{
requirements(Category.logic, BuildVisibility.editorOnly, with());
privileged = true;
memoryCapacity = 128;
}};
//endregion
}
}

View File

@ -504,7 +504,7 @@ public class World{
}
if(state.hasSector() && state.getSector().preset == null){
int circleBlend = 14;
int circleBlend = 7;
//quantized angle
float offset = state.getSector().rect.rotation + 90;
float angle = Angles.angle(x, y, tiles.width/2, tiles.height/2) + offset;

View File

@ -163,7 +163,7 @@ public class MinimapRenderer{
TextureRegion icon = Icon.units.getRegion();
Lines.stroke(3f);
Lines.stroke(Scl.scl(3f));
Draw.color(state.rules.waveTeam.color, Tmp.c2.set(state.rules.waveTeam.color).value(1.2f), Mathf.absin(Time.time, 16f, 1f));

View File

@ -1208,19 +1208,21 @@ public class LExecutor{
@Override
public void run(LExecutor exec){
if(net.client()) return;
Tile tile = world.tile(exec.numi(x), exec.numi(y));
if(tile != null && exec.obj(block) instanceof Block b){
//TODO this can be quite laggy...
switch(layer){
case ore -> {
if(b instanceof OverlayFloor o) tile.setOverlay(o);
if(b instanceof OverlayFloor o) tile.setOverlayNet(o);
}
case floor -> {
if(b instanceof Floor f) tile.setFloor(f);
if(b instanceof Floor f) tile.setFloorNet(f);
}
case block -> {
Team t = exec.obj(team) instanceof Team steam ? steam : Team.derelict;
tile.setBlock(b, t, Mathf.clamp(exec.numi(rotation), 0, 3));
tile.setNet(b, t, Mathf.clamp(exec.numi(rotation), 0, 3));
}
//building case not allowed
}
@ -1230,7 +1232,6 @@ public class LExecutor{
public static class SpawnUnitI implements LInstruction{
public int type, x, y, rotation, team, result;
public boolean effect;
public SpawnUnitI(int type, int x, int y, int rotation, int team, boolean effect, int result){
this.type = type;
@ -1238,7 +1239,6 @@ public class LExecutor{
this.y = y;
this.rotation = rotation;
this.team = team;
this.effect = effect;
this.result = result;
}
@ -1247,13 +1247,13 @@ public class LExecutor{
@Override
public void run(LExecutor exec){
if(net.client()) return;
if(exec.obj(type) instanceof UnitType type && !type.hidden && exec.obj(team) instanceof Team team && Units.canCreate(team, type)){
//random offset to prevent stacking
var unit = type.spawn(team, World.unconv(exec.numf(x)) + Mathf.range(0.01f), World.unconv(exec.numf(y)) + Mathf.range(0.01f));
unit.rotation = exec.numf(rotation);
if(effect){
spawner.spawnEffect(unit);
}
spawner.spawnEffect(unit);
exec.setobj(result, unit);
}
}

View File

@ -141,16 +141,20 @@ public abstract class PlanetGenerator extends BasicGenerator implements HexMeshe
this.tiles = tiles;
this.seed = seed + baseSeed;
this.sector = sec;
this.width = tiles.width;
this.height = tiles.height;
this.rand.setSeed(sec.id + seed + baseSeed);
TileGen gen = new TileGen();
tiles.each((x, y) -> {
gen.reset();
Vec3 position = sector.rect.project(x / (float)tiles.width, y / (float)tiles.height);
for(int y = 0; y < height; y++){
for(int x = 0; x < width; x++){
gen.reset();
Vec3 position = sector.rect.project(x / (float)tiles.width, y / (float)tiles.height);
genTile(position, gen);
tiles.set(x, y, new Tile(x, y, gen.floor, gen.overlay, gen.block));
});
genTile(position, gen);
tiles.set(x, y, new Tile(x, y, gen.floor, gen.overlay, gen.block));
}
}
generate(tiles);
}

View File

@ -56,7 +56,8 @@ public class ErekirPlanetGenerator extends PlanetGenerator{
@Override
public float getSizeScl(){
return 2000 * 1.06f;
//TODO should sectors be 600, or 500 blocks?
return 2000 * 1.07f * 6f / 5f;
}
@Override
@ -139,8 +140,50 @@ public class ErekirPlanetGenerator extends PlanetGenerator{
}
}
private @Nullable String lastSec;
private void sec(String name){
if(lastSec != null){
float elapsed = Time.elapsed();
Log.info("@: @ (@ sec)", lastSec.toUpperCase(), elapsed, Strings.fixed(elapsed / 1000f, 2));
}
if(name != null){
Time.mark();
}
lastSec = name;
}
//TODO remove
@Override
public void generate(Tiles tiles, Sector sec, int seed){
this.tiles = tiles;
this.seed = seed + baseSeed;
this.sector = sec;
this.width = tiles.width;
this.height = tiles.height;
this.rand.setSeed(sec.id + seed + baseSeed);
long begin = Time.millis();
sec("genTile");
TileGen gen = new TileGen();
for(int y = 0; y < height; y++){
for(int x = 0; x < width; x++){
gen.reset();
Vec3 position = sector.rect.project(x / (float)tiles.width, y / (float)tiles.height);
genTile(position, gen);
tiles.set(x, y, new Tile(x, y, gen.floor, gen.overlay, gen.block));
}
}
generate(tiles);
Log.info("TOTAL TILE: @ (@ sec)", Time.timeSinceMillis(begin), Strings.fixed(Time.timeSinceMillis(begin) / 1000f, 2));
}
@Override
protected void generate(){
sec("tempPass");
float temp = rawTemp(sector.tile.v);
if(temp > 0.7){
@ -165,6 +208,8 @@ public class ErekirPlanetGenerator extends PlanetGenerator{
});
}
sec("cells1");
cells(4);
//regolith walls for more dense terrain
@ -175,7 +220,6 @@ public class ErekirPlanetGenerator extends PlanetGenerator{
});
//TODO: yellow regolith biome tweaks
//TODO: crystal biome on the dark side w/ terrain tweaks
//TODO ice biome
float length = width/3f;
@ -185,10 +229,14 @@ public class ErekirPlanetGenerator extends PlanetGenerator{
endX = (int)(-trns.x + width/2f), endY = (int)(-trns.y + height/2f);
float maxd = Mathf.dst(width/2f, height/2f);
sec("pathfinding");
erase(spawnX, spawnY, 15);
brush(pathfind(spawnX, spawnY, endX, endY, tile -> (tile.solid() ? 300f : 0f) + maxd - tile.dst(width/2f, height/2f)/10f, Astar.manhattan), 9);
erase(endX, endY, 15);
sec("arkycite");
//arkycite
pass((x, y) -> {
if(floor != Blocks.beryllicStone) return;
@ -211,19 +259,26 @@ public class ErekirPlanetGenerator extends PlanetGenerator{
blend(Blocks.arkyciteFloor, Blocks.arkyicStone, 4);
sec("slag");
//TODO may overwrite floor blocks under walls and look bad
blend(Blocks.slag, Blocks.yellowStonePlates, 4);
distort(10f, 12f);
sec("distort");
distort(10f, 12f);
distort(5f, 7f);
sec("arkycite-slag-median");
//does arkycite need smoothing?
median(2, 0.6, Blocks.arkyciteFloor);
//smooth out slag to prevent random 1-tile patches
median(3, 0.6, Blocks.slag);
sec("details 1");
pass((x, y) -> {
//rough rhyolite
if(noise(x, y + 600 + x, 5, 0.86f, 60f, 1f) < 0.41f && floor == Blocks.rhyolite){
@ -240,6 +295,7 @@ public class ErekirPlanetGenerator extends PlanetGenerator{
float max = 0;
for(Point2 p : Geometry.d8){
//TODO I think this is the cause of lag
max = Math.max(max, world.getDarkness(x + p.x, y + p.y));
}
if(max > 0){
@ -256,11 +312,17 @@ public class ErekirPlanetGenerator extends PlanetGenerator{
}
});
sec("inverse flood fill");
inverseFloodFill(tiles.getn(spawnX, spawnY));
sec("redStone");
//TODO veins, blend after inverse flood fill?
blend(Blocks.redStoneWall, Blocks.denseRedStone, 4);
sec("ores");
//make sure enemies have room
erase(endX, endY, 6);
@ -321,6 +383,8 @@ public class ErekirPlanetGenerator extends PlanetGenerator{
//}
});
sec("trim dark");
//remove props near ores, they're too annoying
pass((x, y) -> {
if(ore.asFloor().wallOre || block.itemDrop != null || (block == Blocks.air && ore != Blocks.air)){
@ -330,6 +394,8 @@ public class ErekirPlanetGenerator extends PlanetGenerator{
trimDark();
sec("vents");
int minVents = rand.random(6, 9);
int ventCount = 0;
@ -437,6 +503,8 @@ public class ErekirPlanetGenerator extends PlanetGenerator{
}
}
sec("decoration");
for(Tile tile : tiles){
if(tile.overlay().needsSurface && !tile.floor().hasSurface()){
tile.setOverlay(Blocks.air);
@ -456,5 +524,7 @@ public class ErekirPlanetGenerator extends PlanetGenerator{
//all sectors are wave sectors
state.rules.waves = true;
state.rules.showSpawns = true;
sec("");
}
}

View File

@ -101,12 +101,20 @@ public class LaunchLoadoutDialog extends BaseDialog{
});
}).width(204);
buttons.button("@launch.text", Icon.ok, () -> {
boolean rows = Core.graphics.isPortrait() && mobile;
if(rows) buttons.row();
var cell = buttons.button("@launch.text", Icon.ok, () -> {
universe.updateLoadout(core, selected);
confirm.run();
hide();
}).disabled(b -> !valid);
if(rows){
cell.colspan(2).size(160f + 204f + 4f, 64f);
}
int cols = Math.max((int)(Core.graphics.getWidth() / Scl.scl(230)), 1);
ButtonGroup<Button> group = new ButtonGroup<>();
selected = universe.getLoadout(core);

View File

@ -488,7 +488,7 @@ public class PlanetDialog extends BaseDialog implements PlanetInterfaceRenderer{
//TODO what if any sector is selectable?
//TODO launch criteria - which planets can be launched to? Where should this be defined? Should planets even be selectable?
if(mode == planetLaunch) return launchSector != null && planet != launchSector.planet && launchSector.planet.launchCandidates.contains(planet);
return (planet.alwaysUnlocked && planet.isLandable()) || planet.sectors.contains(Sector::hasBase);
return (planet.alwaysUnlocked && planet.isLandable()) || planet.sectors.contains(Sector::hasBase) || debugSelect;
}
void setup(){

View File

@ -105,6 +105,8 @@ public class Block extends UnlockableContent implements Senseable{
public boolean breakable;
/** whether to add this block to brokenblocks */
public boolean rebuildable = true;
/** if true, this logic-related block can only be used with privileged processors (or is one itself) */
public boolean privileged = false;
/** whether this block can only be placed on water */
public boolean requiresWater = false;
/** whether this block can be placed on any liquids, anywhere */

View File

@ -369,6 +369,11 @@ public class Tile implements Position, QuadTreeObject, Displayable{
setFloorNet(floor, Blocks.air);
}
/** set()-s this tile, except it's synced across the network */
public void setOverlayNet(Block overlay){
Call.setOverlay(this, overlay);
}
public short overlayID(){
return overlay.id;
}
@ -699,6 +704,11 @@ public class Tile implements Position, QuadTreeObject, Displayable{
tile.setOverlay(overlay);
}
@Remote(called = Loc.server)
public static void setOverlay(Tile tile, Block overlay){
tile.setOverlay(overlay);
}
@Remote(called = Loc.server)
public static void removeTile(Tile tile){
tile.remove();

View File

@ -34,7 +34,6 @@ public class LogicBlock extends Block{
public int maxInstructionScale = 5;
public int instructionsPerTick = 1;
public float range = 8 * 10;
public boolean privileged;
public LogicBlock(String name){
super(name);
@ -535,7 +534,7 @@ public class LogicBlock extends Block{
}
public boolean validLink(Building other){
return other != null && other.isValid() && (privileged || (other.team == team && other.within(this, range + other.block.size*tilesize/2f))) && !(other instanceof ConstructBuild);
return other != null && other.isValid() && (privileged || (!other.block.privileged && other.team == team && other.within(this, range + other.block.size*tilesize/2f))) && !(other instanceof ConstructBuild);
}
@Override

View File

@ -33,6 +33,22 @@ public class MemoryBlock extends Block{
return false;
}
@Override
public boolean collide(Bullet other){
return !privileged;
}
@Override
public boolean displayable(){
return !privileged;
}
@Override
public void damage(float damage){
if(privileged) return;
super.damage(damage);
}
@Override
public void write(Writes write){
super.write(write);