Skip to content

Commit

Permalink
Support for sector presets without unlock requirements
Browse files Browse the repository at this point in the history
  • Loading branch information
Anuken committed Feb 9, 2025
1 parent f77803d commit d20f9eb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
2 changes: 2 additions & 0 deletions core/src/mindustry/type/SectorPreset.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ public class SectorPreset extends UnlockableContent{
public boolean noLighting = false;
/** If true, this is the last sector in its planetary campaign. */
public boolean isLastSector;
/** If true, this sector must be unlocked before landing is permitted. */
public boolean requireUnlock = true;
public boolean showSectorLandInfo = true;
/** If true, uses this sector's launch fields instead */
public boolean overrideLaunchDefaults = false;
Expand Down
10 changes: 5 additions & 5 deletions core/src/mindustry/ui/dialogs/PlanetDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ boolean canSelect(Sector sector){

if(sector.hasBase() || sector.id == sector.planet.startSector) return true;
//preset sectors can only be selected once unlocked
if(sector.preset != null){
if(sector.preset != null && sector.preset.requireUnlock){
TechNode node = sector.preset.techNode;
return sector.preset.unlocked() || node == null || node.parent == null || (node.parent.content.unlocked() && (!(node.parent.content instanceof SectorPreset preset) || preset.sector.hasBase()));
}
Expand Down Expand Up @@ -453,7 +453,7 @@ public void renderSectors(Planet planet){

Color color =
sec.hasBase() ? Tmp.c2.set(Team.sharded.color).lerp(Team.crux.color, sec.hasEnemyBase() ? 0.5f : 0f) :
sec.preset != null ?
sec.preset != null && sec.preset.requireUnlock ?
sec.preset.unlocked() ? Tmp.c2.set(Team.derelict.color).lerp(Color.white, Mathf.absin(Time.time, 10f, 1f)) :
Color.gray :
sec.hasEnemyBase() ? Team.crux.color :
Expand Down Expand Up @@ -537,9 +537,9 @@ public void renderProjections(Planet planet){
sec.isAttacked() ? Fonts.getLargeIcon("warning") :
!sec.hasBase() && sec.preset != null && sec.preset.unlocked() && preficon == null ?
Fonts.getLargeIcon("terrain") :
sec.preset != null && sec.preset.locked() && sec.preset.techNode != null && (sec.preset.techNode.parent == null || !sec.preset.techNode.parent.content.locked()) ? Fonts.getLargeIcon("lock") :
sec.preset != null && sec.preset.requireUnlock && sec.preset.locked() && sec.preset.techNode != null && (sec.preset.techNode.parent == null || !sec.preset.techNode.parent.content.locked()) ? Fonts.getLargeIcon("lock") :
preficon;
var color = sec.preset != null && !sec.hasBase() ? Team.derelict.color : Team.sharded.color;
var color = sec.preset != null && sec.preset.requireUnlock && !sec.hasBase() ? Team.derelict.color : Team.sharded.color;

if(icon != null){
planets.drawPlane(sec, () -> {
Expand Down Expand Up @@ -1254,7 +1254,7 @@ void playSelected(){
return;
}

if(sector.preset != null && sector.preset.locked() && sector.preset.techNode != null && !sector.hasBase()){
if(sector.preset != null && sector.preset.requireUnlock && sector.preset.locked() && sector.preset.techNode != null && !sector.hasBase()){
return;
}

Expand Down

0 comments on commit d20f9eb

Please sign in to comment.