Interplanetary Accelerator re-added with functionality (WIP)
This commit is contained in:
@@ -54,6 +54,8 @@ public class PlanetDialog extends BaseDialog implements PlanetInterfaceRenderer{
|
||||
public PlanetParams state = new PlanetParams();
|
||||
public float zoom = 1f;
|
||||
public @Nullable Sector selected, hovered, launchSector;
|
||||
/** Must not be null in planet launch mode. */
|
||||
public @Nullable Seq<Planet> launchCandidates;
|
||||
public Mode mode = look;
|
||||
public boolean launching;
|
||||
public Cons<Sector> listener = s -> {};
|
||||
@@ -294,7 +296,7 @@ public class PlanetDialog extends BaseDialog implements PlanetInterfaceRenderer{
|
||||
}
|
||||
|
||||
void addTech(){
|
||||
buttons.button("@techtree", Icon.tree, () -> ui.research.show()).size(200f, 54f).pad(2).bottom();
|
||||
buttons.button("@techtree", Icon.tree, () -> ui.research.show()).size(200f, 54f).visible(() -> mode == look).pad(2).bottom();
|
||||
}
|
||||
|
||||
public void showOverview(){
|
||||
@@ -312,16 +314,17 @@ public class PlanetDialog extends BaseDialog implements PlanetInterfaceRenderer{
|
||||
}
|
||||
|
||||
//TODO not fully implemented, cutscene needed
|
||||
public void showPlanetLaunch(Sector sector, Cons<Sector> listener){
|
||||
public void showPlanetLaunch(Sector sector, Seq<Planet> launchCandidates, Cons<Sector> listener){
|
||||
selected = null;
|
||||
hovered = null;
|
||||
launching = false;
|
||||
this.listener = listener;
|
||||
this.launchCandidates = (launchCandidates == null ? sector.planet.launchCandidates : launchCandidates);
|
||||
launchSector = sector;
|
||||
|
||||
//automatically select next planets;
|
||||
if(sector.planet.launchCandidates.size == 1){
|
||||
state.planet = sector.planet.launchCandidates.first();
|
||||
if(this.launchCandidates.size == 1){
|
||||
state.planet = this.launchCandidates.first();
|
||||
state.otherCamPos = sector.planet.position;
|
||||
state.otherCamAlpha = 0f;
|
||||
|
||||
@@ -332,8 +335,6 @@ public class PlanetDialog extends BaseDialog implements PlanetInterfaceRenderer{
|
||||
preset.unlock();
|
||||
}
|
||||
selected = destSec;
|
||||
updateSelected();
|
||||
rebuildExpand();
|
||||
}
|
||||
|
||||
//TODO pan over to correct planet
|
||||
@@ -345,6 +346,13 @@ public class PlanetDialog extends BaseDialog implements PlanetInterfaceRenderer{
|
||||
|
||||
mode = planetLaunch;
|
||||
|
||||
updateSelected();
|
||||
rebuildExpand();
|
||||
|
||||
if(sectorTop != null){
|
||||
sectorTop.color.a = 0f;
|
||||
}
|
||||
|
||||
super.show();
|
||||
}
|
||||
|
||||
@@ -382,8 +390,11 @@ public class PlanetDialog extends BaseDialog implements PlanetInterfaceRenderer{
|
||||
|
||||
boolean canSelect(Sector sector){
|
||||
if(mode == select) return sector.hasBase() && launchSector != null && sector.planet == launchSector.planet;
|
||||
//cannot launch to existing sector w/ accelerator TODO test
|
||||
if(mode == planetLaunch) return sector.id == sector.planet.startSector;
|
||||
|
||||
if(mode == planetLaunch && sector.hasBase()){
|
||||
return false;
|
||||
}
|
||||
|
||||
if(sector.hasBase() || sector.id == sector.planet.startSector) return true;
|
||||
//preset sectors can only be selected once unlocked
|
||||
if(sector.preset != null){
|
||||
@@ -393,11 +404,15 @@ public class PlanetDialog extends BaseDialog implements PlanetInterfaceRenderer{
|
||||
|
||||
return sector.planet.generator != null ?
|
||||
//use planet impl when possible
|
||||
sector.planet.generator.allowLanding(sector) :
|
||||
sector.hasBase() || sector.near().contains(Sector::hasBase); //near an occupied sector
|
||||
(mode == planetLaunch ? sector.planet.generator.allowAcceleratorLanding(sector) : sector.planet.generator.allowLanding(sector)) :
|
||||
mode == planetLaunch || sector.hasBase() || sector.near().contains(Sector::hasBase); //near an occupied sector
|
||||
}
|
||||
|
||||
Sector findLauncher(Sector to){
|
||||
if(mode == planetLaunch){
|
||||
return launchSector;
|
||||
}
|
||||
|
||||
Sector launchSector = this.launchSector != null && this.launchSector.planet == to.planet && this.launchSector.hasBase() ? this.launchSector : null;
|
||||
//directly nearby.
|
||||
if(to.near().contains(launchSector)) return launchSector;
|
||||
@@ -472,6 +487,10 @@ public class PlanetDialog extends BaseDialog implements PlanetInterfaceRenderer{
|
||||
}
|
||||
}
|
||||
|
||||
if(mode == planetLaunch && launchSector != null && selected != null && hovered == null){
|
||||
planets.drawArc(planet, launchSector.tile.v, selected.tile.v);
|
||||
}
|
||||
|
||||
if(state.uiAlpha > 0.001f){
|
||||
for(Sector sec : planet.sectors){
|
||||
if(sec.hasBase()){
|
||||
@@ -548,7 +567,7 @@ public class PlanetDialog extends BaseDialog implements PlanetInterfaceRenderer{
|
||||
//TODO what if any sector is selectable?
|
||||
//TODO launch criteria - which planets can be launched to? Where should this be defined? Should planets even be selectable?
|
||||
if(mode == select) return planet == state.planet;
|
||||
if(mode == planetLaunch) return launchSector != null && planet != launchSector.planet && launchSector.planet.launchCandidates.contains(planet);
|
||||
if(mode == planetLaunch) return launchSector != null && (launchCandidates.contains(planet) || (planet == launchSector.planet && planet.allowSelfSectorLaunch));
|
||||
return (planet.alwaysUnlocked && planet.isLandable()) || planet.sectors.contains(Sector::hasBase) || debugSelect;
|
||||
}
|
||||
|
||||
@@ -604,7 +623,11 @@ public class PlanetDialog extends BaseDialog implements PlanetInterfaceRenderer{
|
||||
new Table(t -> {
|
||||
t.touchable = Touchable.disabled;
|
||||
t.top();
|
||||
t.label(() -> mode == select ? "@sectors.select" : "").style(Styles.outlineLabel).color(Pal.accent);
|
||||
t.label(() ->
|
||||
mode == select ? "@sectors.select" :
|
||||
mode == planetLaunch ? "@sectors.launchselect" :
|
||||
""
|
||||
).style(Styles.outlineLabel).color(Pal.accent);
|
||||
}),
|
||||
buttons,
|
||||
|
||||
@@ -615,7 +638,7 @@ public class PlanetDialog extends BaseDialog implements PlanetInterfaceRenderer{
|
||||
t.add(pane).colspan(2).row();
|
||||
t.button("@campaign.difficulty", Icon.bookSmall, () -> {
|
||||
campaignRules.show(state.planet);
|
||||
}).margin(12f).size(208f, 40f).padTop(12f).visible(() -> state.planet.allowCampaignRules).row();
|
||||
}).margin(12f).size(208f, 40f).padTop(12f).visible(() -> state.planet.allowCampaignRules && mode != planetLaunch).row();
|
||||
t.add().height(64f); //padding for close button
|
||||
Table starsTable = new Table(Styles.black);
|
||||
pane.setWidget(starsTable);
|
||||
@@ -634,7 +657,6 @@ public class PlanetDialog extends BaseDialog implements PlanetInterfaceRenderer{
|
||||
if(planet.solarSystem == star && selectable(planet)){
|
||||
Button planetButton = planetTable.button(planet.localizedName, Icon.icons.get(planet.icon + "Small", Icon.icons.get(planet.icon, Icon.commandRallySmall)), Styles.flatTogglet, () -> {
|
||||
selected = null;
|
||||
launchSector = null;
|
||||
if(state.planet != planet){
|
||||
newPresets.clear();
|
||||
state.planet = planet;
|
||||
@@ -660,7 +682,7 @@ public class PlanetDialog extends BaseDialog implements PlanetInterfaceRenderer{
|
||||
void rebuildExpand(){
|
||||
Table c = expandTable;
|
||||
c.clear();
|
||||
c.visible(() -> !(graphics.isPortrait() && mobile));
|
||||
c.visible(() -> !(graphics.isPortrait() && mobile) && mode != planetLaunch);
|
||||
if(state.planet.sectors.contains(Sector::hasBase)){
|
||||
int attacked = state.planet.sectors.count(Sector::isAttacked);
|
||||
|
||||
@@ -783,7 +805,7 @@ public class PlanetDialog extends BaseDialog implements PlanetInterfaceRenderer{
|
||||
|
||||
if(Mathf.equal(state.otherCamAlpha, 1f, 0.01f)){
|
||||
//TODO change zoom too
|
||||
state.camPos.set(Tmp.v31.set(state.otherCamPos).lerp(state.planet.position, state.otherCamAlpha).add(state.camPos).sub(state.planet.position));
|
||||
state.camPos.set(Tmp.v31.set(state.otherCamPos).slerp(state.planet.position, state.otherCamAlpha).add(state.camPos).sub(state.planet.position));
|
||||
|
||||
state.otherCamPos = null;
|
||||
//announce new sector
|
||||
@@ -792,6 +814,11 @@ public class PlanetDialog extends BaseDialog implements PlanetInterfaceRenderer{
|
||||
}
|
||||
}
|
||||
|
||||
//fade in sector dialog after panning
|
||||
if(sectorTop != null && state.otherCamPos == null){
|
||||
sectorTop.color.a = Mathf.lerpDelta(sectorTop.color.a, 1f, 0.1f);
|
||||
}
|
||||
|
||||
if(hovered != null && !mobile && state.planet.hasGrid()){
|
||||
addChild(hoverLabel);
|
||||
hoverLabel.toFront();
|
||||
@@ -1258,7 +1285,7 @@ public class PlanetDialog extends BaseDialog implements PlanetInterfaceRenderer{
|
||||
//allow planet dialog to finish hiding before actually launching
|
||||
Time.runTask(5f, () -> {
|
||||
Runnable doLaunch = () -> {
|
||||
renderer.showLaunch(core, schemCore);
|
||||
renderer.showLaunch(core);
|
||||
//run with less delay, as the loading animation is delayed by several frames
|
||||
Time.runTask(core.landDuration() - 8f, () -> control.playSector(from, sector));
|
||||
};
|
||||
@@ -1275,15 +1302,8 @@ public class PlanetDialog extends BaseDialog implements PlanetInterfaceRenderer{
|
||||
}
|
||||
});
|
||||
}
|
||||
}else if(mode == select){
|
||||
}else if(mode == select || mode == planetLaunch){
|
||||
listener.get(sector);
|
||||
}else if(mode == planetLaunch){ //TODO make sure it doesn't have a base already.
|
||||
//TODO animation
|
||||
//schematic selection and cost handled by listener
|
||||
listener.get(sector);
|
||||
//unlock right before launch
|
||||
sector.planet.unlockedOnLand.each(UnlockableContent::unlock);
|
||||
control.playSector(sector);
|
||||
}else{
|
||||
//sector should have base here
|
||||
control.playSector(sector);
|
||||
|
||||
Reference in New Issue
Block a user