Special border for challenge sectors (WIP)
This commit is contained in:
@@ -159,8 +159,6 @@ public class SectorPresets{
|
||||
isLastSector = true;
|
||||
}};
|
||||
|
||||
//TODO: show up differently with PLT selected.
|
||||
|
||||
new SectorPreset("geothermalStronghold", serpulo, 264){{
|
||||
requireUnlock = false;
|
||||
difficulty = 10;
|
||||
|
||||
@@ -9,6 +9,7 @@ import arc.math.geom.*;
|
||||
import arc.util.*;
|
||||
import mindustry.game.EventType.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.graphics.g3d.PlanetGrid.*;
|
||||
import mindustry.type.*;
|
||||
|
||||
public class PlanetRenderer implements Disposable{
|
||||
@@ -229,6 +230,37 @@ public class PlanetRenderer implements Disposable{
|
||||
sector.planet.drawSelection(batch, sector, color, stroke, length);
|
||||
}
|
||||
|
||||
/** Draws sector when selected. Supply the batch with {@link Gl#triangles triangle} vertices. */
|
||||
public void drawSpecialSelection(Sector sector, Color color, float stroke, float length){
|
||||
drawSelection(sector, color, stroke, length);
|
||||
|
||||
float arad = (outlineRad + length) * sector.planet.radius;
|
||||
float span = 0.1f;
|
||||
|
||||
for(int i = 0; i < sector.tile.corners.length; i += 2){
|
||||
Corner next = sector.tile.corners[(i + 1) % sector.tile.corners.length];
|
||||
Corner curr = sector.tile.corners[i];
|
||||
|
||||
next.v.scl(arad);
|
||||
curr.v.scl(arad);
|
||||
sector.tile.v.scl(arad);
|
||||
|
||||
Tmp.v31.set(curr.v).sub(sector.tile.v).setLength(curr.v.dst(sector.tile.v) - stroke).add(sector.tile.v);
|
||||
Tmp.v32.set(next.v).sub(sector.tile.v).setLength(next.v.dst(sector.tile.v) - stroke).add(sector.tile.v);
|
||||
Tmp.v33.set(Tmp.v31).lerp(Tmp.v32, span);
|
||||
Tmp.v34.set(Tmp.v31).lerp(Tmp.v32, 1f - span);
|
||||
|
||||
Tmp.v31.set(Tmp.v33).sub(sector.tile.v).setLength(Tmp.v31.len() - stroke).add(sector.tile.v);
|
||||
Tmp.v32.set(Tmp.v34).sub(sector.tile.v).setLength(Tmp.v32.len() - stroke).add(sector.tile.v);
|
||||
|
||||
batch.quad(Tmp.v33, Tmp.v34, Tmp.v32, Tmp.v31, color);
|
||||
|
||||
sector.tile.v.scl(1f / arad);
|
||||
next.v.scl(1f / arad);
|
||||
curr.v.scl(1f / arad);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispose(){
|
||||
skybox.dispose();
|
||||
|
||||
@@ -37,7 +37,6 @@ import mindustry.ui.fragments.*;
|
||||
import mindustry.world.*;
|
||||
import mindustry.world.blocks.ConstructBlock.*;
|
||||
import mindustry.world.blocks.*;
|
||||
import mindustry.world.blocks.defense.turrets.*;
|
||||
import mindustry.world.blocks.distribution.*;
|
||||
import mindustry.world.blocks.payloads.*;
|
||||
import mindustry.world.blocks.storage.*;
|
||||
@@ -1842,7 +1841,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
||||
if((!config.isShown() && build.shouldShowConfigure(player)) //if the config fragment is hidden, show
|
||||
//alternatively, the current selected block can 'agree' to switch config tiles
|
||||
|| (config.isShown() && config.getSelected().onConfigureBuildTapped(build) && build.shouldShowConfigure(player))){
|
||||
Sounds.click.at(build);
|
||||
build.block.configureSound.at(build);
|
||||
config.showConfig(build);
|
||||
}
|
||||
//otherwise...
|
||||
|
||||
@@ -549,8 +549,7 @@ public class Planet extends UnlockableContent{
|
||||
Tmp.v31.set(curr.v).sub(sector.tile.v).setLength(curr.v.dst(sector.tile.v) - stroke).add(sector.tile.v);
|
||||
Tmp.v32.set(next.v).sub(sector.tile.v).setLength(next.v.dst(sector.tile.v) - stroke).add(sector.tile.v);
|
||||
|
||||
batch.tri(curr.v, next.v, Tmp.v31, color);
|
||||
batch.tri(Tmp.v31, next.v, Tmp.v32, color);
|
||||
batch.quad(curr.v, next.v, Tmp.v32, Tmp.v31, color);
|
||||
|
||||
sector.tile.v.scl(1f / arad);
|
||||
next.v.scl(1f / arad);
|
||||
|
||||
@@ -31,6 +31,7 @@ public class Sector{
|
||||
|
||||
public @Nullable SaveSlot save;
|
||||
public @Nullable SectorPreset preset;
|
||||
public @Nullable Sector shieldTarget;
|
||||
public SectorInfo info = new SectorInfo();
|
||||
|
||||
/** Number 0-1 indicating the difficulty based on nearby bases. */
|
||||
@@ -121,6 +122,10 @@ public class Sector{
|
||||
Core.settings.remove(planet.name + "-s-" + id + "-info");
|
||||
}
|
||||
|
||||
public boolean isShielded(){
|
||||
return preset != null && preset.shieldSectors.size > 0 && preset.shieldSectors.contains(s -> !s.isCaptured());
|
||||
}
|
||||
|
||||
public boolean isAttacked(){
|
||||
if(isBeingPlayed()) return state.rules.waves || state.rules.attackMode;
|
||||
return save != null && (info.waves || info.attack) && info.hasCore;
|
||||
|
||||
@@ -2,6 +2,7 @@ package mindustry.type;
|
||||
|
||||
import arc.*;
|
||||
import arc.func.*;
|
||||
import arc.struct.*;
|
||||
import arc.util.*;
|
||||
import mindustry.ctype.*;
|
||||
import mindustry.game.*;
|
||||
@@ -38,6 +39,8 @@ public class SectorPreset extends UnlockableContent{
|
||||
public boolean attackAfterWaves = false;
|
||||
/** The original position of this sector; used for migration. Internal use for vanilla campaign only! */
|
||||
public int originalPosition;
|
||||
/** Sectors that prevent this sector from being landed on until they are completed. */
|
||||
public Seq<Sector> shieldSectors = new Seq<>();
|
||||
|
||||
public SectorPreset(String name, Planet planet, int sector){
|
||||
this(name, null, planet, sector);
|
||||
@@ -81,6 +84,16 @@ public class SectorPreset extends UnlockableContent{
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(){
|
||||
super.init();
|
||||
|
||||
//note that sectors can only have one visual shield target
|
||||
for(var other : shieldSectors){
|
||||
other.shieldTarget = sector;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadIcon(){
|
||||
if(Icon.terrain != null){
|
||||
|
||||
@@ -414,13 +414,14 @@ public class PlanetDialog extends BaseDialog implements PlanetInterfaceRenderer{
|
||||
boolean canSelect(Sector sector){
|
||||
if(mode == select) return sector.hasBase() && launchSector != null && sector.planet == launchSector.planet;
|
||||
|
||||
if(mode == planetLaunch && sector.hasBase()){
|
||||
return false;
|
||||
}
|
||||
if(mode == planetLaunch && sector.hasBase()) return false;
|
||||
|
||||
if(sector.planet.generator == null) return false;
|
||||
|
||||
if(sector.isShielded()) return false;
|
||||
|
||||
if(sector.hasBase() || sector.id == sector.planet.startSector) return true;
|
||||
|
||||
//preset sectors can only be selected once unlocked
|
||||
if(sector.preset != null && sector.preset.requireUnlock){
|
||||
TechNode node = sector.preset.techNode;
|
||||
@@ -444,9 +445,10 @@ public class PlanetDialog extends BaseDialog implements PlanetInterfaceRenderer{
|
||||
@Override
|
||||
public void renderSectors(Planet planet){
|
||||
|
||||
//draw all sector stuff
|
||||
if(state.uiAlpha > 0.01f){
|
||||
for(Sector sec : planet.sectors){
|
||||
if(sec == selected) continue;
|
||||
|
||||
if(canSelect(sec) || sec.unlocked() || debugSelect){
|
||||
|
||||
Color color =
|
||||
@@ -458,7 +460,12 @@ public class PlanetDialog extends BaseDialog implements PlanetInterfaceRenderer{
|
||||
null;
|
||||
|
||||
if(color != null){
|
||||
planets.drawSelection(sec, Tmp.c1.set(color).mul(0.8f).a(state.uiAlpha), 0.026f, -0.001f);
|
||||
var destColor = Tmp.c1.set(color).mul(0.8f).a(state.uiAlpha);
|
||||
if(!sec.isCaptured() && sec.preset != null && sec.preset.showHidden){
|
||||
planets.drawSpecialSelection(sec, destColor, 0.026f, -0.001f);
|
||||
}else{
|
||||
planets.drawSelection(sec, destColor, 0.026f, -0.001f);
|
||||
}
|
||||
}
|
||||
}else{
|
||||
planets.fill(sec, Tmp.c1.set(shadowColor).mul(1, 1, 1, state.uiAlpha), -0.001f);
|
||||
@@ -502,6 +509,12 @@ public class PlanetDialog extends BaseDialog implements PlanetInterfaceRenderer{
|
||||
|
||||
if(state.uiAlpha > 0.001f){
|
||||
for(Sector sec : planet.sectors){
|
||||
|
||||
//draw shield arc
|
||||
if(sec.shieldTarget != null && !sec.isCaptured() && !sec.shieldTarget.isCaptured()){
|
||||
planets.drawArcLine(planet, sec.tile.v, sec.shieldTarget.tile.v, Team.crux.color.write(Tmp.c2).a(state.uiAlpha), Tmp.c3.set(Tmp.c2).mulA(0.5f), 0.15f, 110f, 25, 0.006f);
|
||||
}
|
||||
|
||||
if(sec.hasBase()){
|
||||
//draw vulnerable sector attack arc
|
||||
if(planet.campaignRules.sectorInvasion){
|
||||
|
||||
@@ -247,6 +247,8 @@ public class Block extends UnlockableContent implements Senseable{
|
||||
public int unitCapModifier = 0;
|
||||
/** Whether the block can be tapped and selected to configure. */
|
||||
public boolean configurable;
|
||||
/** Sound played when this block is configured. */
|
||||
public Sound configureSound = Sounds.click;
|
||||
/** If true, this block does not have pointConfig with a transform called on map resize. */
|
||||
public boolean ignoreResizeConfig;
|
||||
/** If true, this building can be selected like a unit when commanding. */
|
||||
|
||||
@@ -21,6 +21,7 @@ public class SwitchBlock extends Block{
|
||||
update = true;
|
||||
drawDisabled = false;
|
||||
autoResetEnabled = false;
|
||||
configureSound = Sounds.none;
|
||||
group = BlockGroup.logic;
|
||||
envEnabled = Env.any;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user