Fixed erekir unit requirements

This commit is contained in:
Anuken
2022-02-13 20:54:25 -05:00
parent 0593c66f70
commit c8b11c4447
11 changed files with 43 additions and 1 deletions

View File

@@ -61,6 +61,10 @@ public class Planets{
lightSrcTo = 0.5f;
lightDstFrom = 0.2f;
hiddenItems.addAll(Items.serpuloItems).removeAll(Items.erekirItems);
ruleSetter = r -> {
r.unitCommand = true;
r.placeRangeCheck = true;
};
unlockedOnLand.add(Blocks.coreBastion);
}};

View File

@@ -89,6 +89,8 @@ public class Logic implements ApplicationListener{
}
}
state.getSector().planet.ruleSetter.get(state.rules);
//reset values
info.damage = 0f;
info.wavesPassed = 0;

View File

@@ -311,6 +311,7 @@ public class World{
state.rules.environment = sector.planet.defaultEnv;
state.rules.hiddenBuildItems.clear();
state.rules.hiddenBuildItems.addAll(sector.planet.hiddenItems);
sector.planet.ruleSetter.get(state.rules);
sector.info.resources = content.toSeq();
sector.info.resources.sort(Structs.comps(Structs.comparing(Content::getContentType), Structs.comparingInt(c -> c.id)));
sector.saveInfo();

View File

@@ -77,6 +77,8 @@ public class Rules{
public float enemyCoreBuildRadius = 400f;
/** If true, no-build zones are calculated based on the closest core. */
public boolean polygonCoreProtection = false;
/** If true, blocks cannot be placed near blocks that are near the enemy team.*/
public boolean placeRangeCheck = false;
/** If true, dead teams in PvP automatically have their blocks & units converted to derelict upon death. */
public boolean cleanupDeadTeams = true;
/** Radius around enemy wave drop zones.*/

View File

@@ -118,6 +118,10 @@ public class Drawf{
Draw.z(pz);
}
public static void dashLineDst(Color color, float x, float y, float x2, float y2){
dashLine(color, x, y, x2, y2, (int)(Mathf.dst(x, y, x2, y2) / tilesize * 2));
}
public static void dashLine(Color color, float x, float y, float x2, float y2){
dashLine(color, x, y, x2, y2, (int)(Math.max(Math.abs(x - x2), Math.abs(y - y2)) / tilesize * 2));
}

View File

@@ -230,6 +230,20 @@ public class DesktopInput extends InputHandler{
brequest.config = null;
Draw.reset();
}
if(!valid && state.rules.placeRangeCheck){
var blocker = Build.getEnemyOverlap(block, player.team(), cursorX, cursorY);
if(blocker != null){
Drawf.selected(blocker, blocker.team.color);
Tmp.v1.set(cursorX, cursorY).scl(tilesize).add(block.offset, block.offset).sub(blocker).scl(-1f).nor();
Drawf.dashLineDst(Pal.remove,
cursorX * tilesize + block.offset + Tmp.v1.x * block.size * tilesize/2f,
cursorY * tilesize + block.offset + Tmp.v1.y * block.size * tilesize/2f,
blocker.x + Tmp.v1.x * -blocker.block.size * tilesize/2f,
blocker.y + Tmp.v1.y * -blocker.block.size * tilesize/2f
);
}
}
}
}

View File

@@ -445,6 +445,7 @@ public class ErekirPlanetGenerator extends PlanetGenerator{
state.rules.attributes.set(Attribute.heat, 0.8f);
state.rules.environment = sector.planet.defaultEnv;
state.rules.unitCommand = true;
state.rules.placeRangeCheck = true;
//TODO remove slag and arkycite around core.
Schematics.placeLaunchLoadout(spawnX, spawnY);

View File

@@ -11,6 +11,7 @@ import arc.util.*;
import arc.util.noise.*;
import mindustry.content.TechTree.*;
import mindustry.ctype.*;
import mindustry.game.*;
import mindustry.graphics.*;
import mindustry.graphics.g3d.*;
import mindustry.graphics.g3d.PlanetGrid.*;
@@ -92,6 +93,8 @@ public class Planet extends UnlockableContent{
public boolean allowSectorInvasion = false;
/** If true, builder AI is turned on for all sectors on this planet by default. */
public boolean defaultAI = false;
/** Sets up rules on game load for any sector on this planet. */
public Cons<Rules> ruleSetter = r -> {};
/** Parent body that this planet orbits around. If null, this planet is considered to be in the middle of the solar system.*/
public @Nullable Planet parent;
/** The root parent of the whole solar system this planet is in. */

View File

@@ -159,6 +159,8 @@ public class Block extends UnlockableContent implements Senseable{
public boolean expanded = false;
/** Clipping size of this block. Should be as large as the block will draw. */
public float clipSize = -1f;
/** When placeRangeCheck is enabled, this is the range checked for enemy blocks. */
public float placeOverlapRange = 30f;
/** Max of timers used. */
public int timers = 0;
/** Cache layer. Only used for 'cached' rendering. */

View File

@@ -94,7 +94,7 @@ public class Build{
Block previous = tile.block();
Block sub = ConstructBlock.get(result.size);
Seq<Building> prevBuild = new Seq<>(9);
var prevBuild = new Seq<Building>(9);
result.beforePlaceBegan(tile, previous);
tmp.clear();
@@ -201,9 +201,17 @@ public class Build{
}
}
if(state.rules.placeRangeCheck && getEnemyOverlap(type, team, x, y) != null){
return false;
}
return true;
}
public static @Nullable Building getEnemyOverlap(Block block, Team team, int x, int y){
return indexer.findEnemyTile(team, x * tilesize + block.size, y * tilesize + block.size, block.placeOverlapRange + 4f, p -> true);
}
public static boolean contactsGround(int x, int y, Block block){
if(block.isMultiblock()){
for(Point2 point : Edges.getEdges(block.size)){

View File

@@ -45,6 +45,7 @@ public class BaseTurret extends Block{
consumes.add(coolantOverride != null ? new ConsumeLiquid(coolantOverride, coolantUsage) : new ConsumeCoolant(coolantUsage)).update(false).boost();
}
placeOverlapRange = Math.max(placeOverlapRange, range);
super.init();
}