Core vicinity buildup system

This commit is contained in:
Anuken
2022-04-11 12:14:17 -04:00
parent bdeef68a0b
commit 6fe71dfe9c
12 changed files with 86 additions and 16 deletions

Binary file not shown.

View File

@@ -356,9 +356,9 @@ public class BlockIndexer{
float dist = candidate.dst(x, y) - candidate.hitSize() / 2f; float dist = candidate.dst(x, y) - candidate.hitSize() / 2f;
if(target == null || if(target == null ||
//if its closer and is at least equal priority //if its closer and is at least equal priority
(dist < targetDist && candidate.block.priority.ordinal() >= target.block.priority.ordinal()) || (dist < targetDist && candidate.block.priority >= target.block.priority) ||
// block has higher priority (so range doesnt matter) // block has higher priority (so range doesnt matter)
(candidate.block.priority.ordinal() > target.block.priority.ordinal())){ (candidate.block.priority > target.block.priority)){
target = candidate; target = candidate;
targetDist = dist; targetDist = dist;
} }
@@ -388,9 +388,9 @@ public class BlockIndexer{
float bdst = next.dst(x, y) - next.hitSize() / 2f; float bdst = next.dst(x, y) - next.hitSize() / 2f;
if(bdst < range && (closest == null || if(bdst < range && (closest == null ||
//this one is closer, and it is at least of equal priority //this one is closer, and it is at least of equal priority
(bdst < dst && (!usePriority || closest.block.priority.ordinal() <= next.block.priority.ordinal())) || (bdst < dst && (!usePriority || closest.block.priority <= next.block.priority)) ||
//priority is used, and new block has higher priority regardless of range //priority is used, and new block has higher priority regardless of range
(usePriority && closest.block.priority.ordinal() < next.block.priority.ordinal()))){ (usePriority && closest.block.priority < next.block.priority))){
dst = bdst; dst = bdst;
closest = next; closest = next;
} }

View File

@@ -131,7 +131,7 @@ public class Pathfinder implements Runnable{
} }
} }
//the other tile is no longer near solid, remove the solid bit //the other tile is no longer near solid, remove the solid bit
if(!otherNearSolid){ if(!otherNearSolid && tiles.length > other.array()){
tiles[other.array()] &= ~(PathTile.bitMaskNearSolid); tiles[other.array()] &= ~(PathTile.bitMaskNearSolid);
} }
} }

View File

@@ -182,6 +182,22 @@ public class Fx{
} }
}), }),
coreBuildShockwave = new Effect(120, 500f, e -> {
e.lifetime = e.rotation;
color(Pal.command);
stroke(e.fout(Interp.pow5Out) * 4f);
Lines.circle(e.x, e.y, e.fin() * e.rotation);
}),
coreBuildBlock = new Effect(80f, e -> {
if(!(e.data instanceof Block block)) return;
mixcol(Pal.accent, 1f);
alpha(e.fout());
rect(block.fullIcon, e.x, e.y);
}).layer(Layer.turret - 5f),
moveCommand = new Effect(20, e -> { moveCommand = new Effect(20, e -> {
color(Pal.command); color(Pal.command);
stroke(e.fout() * 5f); stroke(e.fout() * 5f);

View File

@@ -72,9 +72,9 @@ public class Planets{
r.attributes.set(Attribute.heat, 0.8f); r.attributes.set(Attribute.heat, 0.8f);
r.showSpawns = true; r.showSpawns = true;
r.fog = true; r.fog = true;
r.staticFog = true; //TODO decide, is this a good idea? r.staticFog = true;
r.lighting = false; r.lighting = false;
r.onlyDepositCore = true; r.onlyDepositCore = true; //TODO not sure
}; };
unlockedOnLand.add(Blocks.coreBastion); unlockedOnLand.add(Blocks.coreBastion);

View File

@@ -30,6 +30,7 @@ import mindustry.net.*;
import mindustry.type.*; import mindustry.type.*;
import mindustry.ui.dialogs.*; import mindustry.ui.dialogs.*;
import mindustry.world.*; import mindustry.world.*;
import mindustry.world.blocks.storage.CoreBlock.*;
import java.io.*; import java.io.*;
import java.text.*; import java.text.*;
@@ -207,7 +208,10 @@ public class Control implements ApplicationListener, Loadable{
camera.position.set(core); camera.position.set(core);
player.set(core); player.set(core);
float coreDelay = 0f;
if(!settings.getBool("skipcoreanimation")){ if(!settings.getBool("skipcoreanimation")){
coreDelay = coreLandDuration;
//delay player respawn so animation can play. //delay player respawn so animation can play.
player.deathTimer = -80f; player.deathTimer = -80f;
//TODO this sounds pretty bad due to conflict //TODO this sounds pretty bad due to conflict
@@ -232,6 +236,47 @@ public class Control implements ApplicationListener, Loadable{
} }
}); });
} }
if(state.isCampaign()){
//TODO add a delay for landing.
if(state.rules.sector.planet.prebuildBase){
float unitsPerTick = 1f;
boolean anyBuilds = false;
for(Tile tile : world.tiles){
var build = tile.build;
if(!(build instanceof CoreBuild) && build != null && build.team == state.rules.defaultTeam){
var ccore = build.closestCore();
if(ccore != null && build.within(ccore, state.rules.enemyCoreBuildRadius)){
build.pickedUp();
build.tile.remove();
anyBuilds = true;
Time.run(build.dst(ccore) * unitsPerTick + coreDelay, () -> {
//TODO instance reuse bad?
build.tile.setBlock(build.block, build.team, build.rotation, () -> build);
//TODO dropped bad?
build.dropped();
Fx.coreBuildBlock.at(build.x, build.y, 0f, build.block);
Fx.placeBlock.at(build.x, build.y, build.block.size);
});
}
}
}
if(anyBuilds){
for(var ccore : state.rules.defaultTeam.data().cores){
Time.run(coreDelay, () -> {
Fx.coreBuildShockwave.at(ccore.x, ccore.y, state.rules.enemyCoreBuildRadius);
});
}
}
}
}
}); });
} }

View File

@@ -126,7 +126,7 @@ public class Logic implements ApplicationListener{
state.rules.coreIncinerates = true; state.rules.coreIncinerates = true;
state.rules.waveTeam.rules().infiniteResources = true; state.rules.waveTeam.rules().infiniteResources = true;
//fill enemy cores by default. //fill enemy cores by default? TODO decide
for(var core : state.rules.waveTeam.cores()){ for(var core : state.rules.waveTeam.cores()){
for(Item item : content.items()){ for(Item item : content.items()){
core.items.set(item, core.block.itemCapacity); core.items.set(item, core.block.itemCapacity);

View File

@@ -1,8 +1,10 @@
package mindustry.entities; package mindustry.entities;
/** A higher ordinal means a higher priority. Higher priority blocks will always get targeted over those of lower priority, regardless of distance. */ /** Higher priority blocks will always get targeted over those of lower priority, regardless of distance. */
public enum TargetPriority{ public class TargetPriority{
base, public static final float
turret, base = 0f,
core constructing = 1f,
turret = 2f,
core = 3f;
} }

View File

@@ -264,7 +264,11 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc,
//region utility methods //region utility methods
public void addPlan(boolean checkPrevious){ public void addPlan(boolean checkPrevious){
if(!block.rebuildable || (team == state.rules.defaultTeam && state.isCampaign() && !block.isVisible())) return; addPlan(checkPrevious, false);
}
public void addPlan(boolean checkPrevious, boolean ignoreConditions){
if(!ignoreConditions && (!block.rebuildable || (team == state.rules.defaultTeam && state.isCampaign() && !block.isVisible()))) return;
Object overrideConfig = null; Object overrideConfig = null;

View File

@@ -95,6 +95,8 @@ public class Planet extends UnlockableContent{
public boolean allowSectorInvasion = false; public boolean allowSectorInvasion = false;
/** If true, sectors saves are cleared when lost. */ /** If true, sectors saves are cleared when lost. */
public boolean clearSectorOnLose = false; public boolean clearSectorOnLose = false;
/** If true, blocks in the radius of the core will be removed and "built up" in a shockwave upon landing. */
public boolean prebuildBase = true;
/** If true, waves are created on sector loss. TODO remove. */ /** If true, waves are created on sector loss. TODO remove. */
public boolean allowWaves = false; public boolean allowWaves = false;
/** Sets up rules on game load for any sector on this planet. */ /** Sets up rules on game load for any sector on this planet. */

View File

@@ -179,7 +179,7 @@ public class Block extends UnlockableContent implements Senseable{
/** List of block flags. Used for AI indexing. */ /** List of block flags. Used for AI indexing. */
public EnumSet<BlockFlag> flags = EnumSet.of(); public EnumSet<BlockFlag> flags = EnumSet.of();
/** Targeting priority of this block, as seen by enemies. */ /** Targeting priority of this block, as seen by enemies. */
public TargetPriority priority = TargetPriority.base; public float priority = TargetPriority.base;
/** How much this block affects the unit cap by. /** How much this block affects the unit cap by.
* The block flags must contain unitModifier in order for this to work. */ * The block flags must contain unitModifier in order for this to work. */
public int unitCapModifier = 0; public int unitCapModifier = 0;

View File

@@ -44,6 +44,7 @@ public class ConstructBlock extends Block{
inEditor = false; inEditor = false;
consBlocks[size - 1] = this; consBlocks[size - 1] = this;
sync = true; sync = true;
priority = TargetPriority.constructing;
} }
/** Returns a ConstructBlock by size. */ /** Returns a ConstructBlock by size. */