Debug option for editing sector attack designation

This commit is contained in:
Anuken 2025-05-09 00:26:37 -04:00
parent 648b5c4e69
commit 27c4210482
4 changed files with 43 additions and 3 deletions

View file

@ -164,7 +164,6 @@ public class SectorPresets{
difficulty = 10;
}};
//TODO: for wave survival sectors the capture wave is incorrect
registerHiddenSectors(serpulo,
68, //Winter Forest by wpx: https://discord.com/channels/391020510269669376/1165421701362897000/1235654407006322700
241,//River Bastion by wpx: https://discord.com/channels/391020510269669376/1165421701362897000/1232658317126402050

View file

@ -11,6 +11,7 @@ import arc.math.geom.*;
import arc.struct.*;
import arc.util.*;
import arc.util.noise.*;
import arc.util.serialization.*;
import mindustry.content.*;
import mindustry.content.TechTree.*;
import mindustry.ctype.*;
@ -152,6 +153,8 @@ public class Planet extends UnlockableContent{
public boolean allowSelfSectorLaunch;
/** If true, all content in this planet's tech tree will be assigned this planet in their shownPlanets. */
public boolean autoAssignPlanet = true;
/** Base64 encoded string to use as data for setting generateAttackSector status. See {@link #writeAttackSectorBits()}}*/
public @Nullable String attackSectorBitString;
/** Content (usually planet-specific) that is unlocked upon landing here. */
public Seq<UnlockableContent> unlockedOnLand = new Seq<>();
/** Loads the mesh. Clientside only. Defaults to a boring sphere mesh. */
@ -383,6 +386,14 @@ public class Planet extends UnlockableContent{
generator.generateSector(sector);
}
if(attackSectorBitString != null){
try{
loadAttackBits(attackSectorBitString);
}catch(Exception e){
Log.err(e);
}
}
updateBaseCoverage();
}
@ -580,4 +591,25 @@ public class Planet extends UnlockableContent{
Tmp.v31.set(Tmp.v32).rotate(Vec3.Y, -rotation).add(sector.tile.v).rotate(sector.tile.v, 90).sub(sector.tile.v).rotate(Vec3.Y, rotation).nor()
);
}
public String writeAttackSectorBits(){
byte[] bits = new byte[Mathf.ceil(sectors.size / 8f)];
for(int i = 0; i < sectors.size; i++){
int bit = (i >> 3), mask = (i & 0b111);
if(sectors.get(i).generateEnemyBase){
bits[bit] |= (1 << mask);
}
}
return new String(Base64Coder.encode(bits));
}
public void loadAttackBits(String str){
byte[] bits = Base64Coder.decode(str);
for(int i = 0; i < sectors.size; i++){
int bit = (i >> 3), mask = (i & 0b111);
if(bit < bits.length && (bits[bit] & (1 << mask)) != 0){
sectors.get(i).generateEnemyBase = true;
}
}
}
}

View file

@ -44,7 +44,7 @@ import static mindustry.ui.dialogs.PlanetDialog.Mode.*;
public class PlanetDialog extends BaseDialog implements PlanetInterfaceRenderer{
//if true, enables launching anywhere for testing
public static boolean debugSelect = false;
public static boolean debugSelect = false, debugSectorAttackEdit;
public static float sectorShowDuration = 60f * 2.4f;
public final FrameBuffer buffer = new FrameBuffer(2, 2, true);
@ -603,7 +603,7 @@ public class PlanetDialog extends BaseDialog implements PlanetInterfaceRenderer{
addListener(new ElementGestureListener(){
@Override
public void tap(InputEvent event, float x, float y, int count, KeyCode button){
if(showing()) return;
if(showing() || button != KeyCode.mouseLeft) return;
if(hovered != null && selected == hovered && count == 2){
playSelected();
@ -617,6 +617,15 @@ public class PlanetDialog extends BaseDialog implements PlanetInterfaceRenderer{
updateSelected();
}
}
@Override
public void touchDown(InputEvent event, float x, float y, int pointer, KeyCode button){
super.touchDown(event, x, y, pointer, button);
if(debugSectorAttackEdit && button == KeyCode.mouseRight && hovered != null){
hovered.generateEnemyBase = !hovered.generateEnemyBase;
}
}
});
}