WIP game-over core pan
This commit is contained in:
@@ -504,7 +504,7 @@ public class Control implements ApplicationListener, Loadable{
|
||||
@Override
|
||||
public void dispose(){
|
||||
//try to save when exiting
|
||||
if(saves != null && saves.getCurrent() != null && saves.getCurrent().isAutosave() && !net.client() && !state.isMenu()){
|
||||
if(saves != null && saves.getCurrent() != null && saves.getCurrent().isAutosave() && !net.client() && !state.isMenu() && !state.gameOver){
|
||||
try{
|
||||
SaveIO.save(control.saves.getCurrent().file);
|
||||
Log.info("Saved on exit.");
|
||||
|
||||
@@ -21,7 +21,11 @@ public class GameState{
|
||||
/** Continuously ticks up every non-paused update. */
|
||||
public long updateId;
|
||||
/** Whether the game is in game over state. */
|
||||
public boolean gameOver = false, serverPaused = false;
|
||||
public boolean gameOver = false;
|
||||
/** Whether the player's team won the match. */
|
||||
public boolean won = false;
|
||||
/** If true, the server has been put into the paused state on multiplayer. This is synced. */
|
||||
public boolean serverPaused = false;
|
||||
/** Server ticks/second. Only valid in multiplayer. */
|
||||
public int serverTps = -1;
|
||||
/** Map that is currently being played on. */
|
||||
@@ -77,7 +81,7 @@ public class GameState{
|
||||
}
|
||||
|
||||
public boolean isPaused(){
|
||||
return (is(State.paused) && !net.active()) || (gameOver && (!net.active() || isCampaign())) || (serverPaused && !isMenu());
|
||||
return (is(State.paused) && !net.active()) || (serverPaused && !isMenu());
|
||||
}
|
||||
|
||||
public boolean isPlaying(){
|
||||
|
||||
@@ -402,12 +402,16 @@ public class Logic implements ApplicationListener{
|
||||
@Remote(called = Loc.both)
|
||||
public static void updateGameOver(Team winner){
|
||||
state.gameOver = true;
|
||||
state.won = player.team() == winner;
|
||||
}
|
||||
|
||||
@Remote(called = Loc.both)
|
||||
public static void gameOver(Team winner){
|
||||
state.stats.wavesLasted = state.wave;
|
||||
ui.restart.show(winner);
|
||||
state.won = player.team() == winner;
|
||||
Time.run(60f * 3f, () -> {
|
||||
ui.restart.show(winner);
|
||||
});
|
||||
netClient.setQuiet();
|
||||
}
|
||||
|
||||
|
||||
@@ -47,6 +47,19 @@ abstract class BuilderComp implements Posc, Statusc, Teamc, Rotc{
|
||||
updateBuildLogic();
|
||||
}
|
||||
|
||||
public void validatePlans(){
|
||||
if(plans.size > 0){
|
||||
Iterator<BuildPlan> it = plans.iterator();
|
||||
while(it.hasNext()){
|
||||
BuildPlan plan = it.next();
|
||||
Tile tile = world.tile(plan.x, plan.y);
|
||||
if(tile == null || (plan.breaking && tile.block() == Blocks.air) || (!plan.breaking && ((tile.build != null && tile.build.rotation == plan.rotation) || !plan.block.rotate) && tile.block() == plan.block)){
|
||||
it.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void updateBuildLogic(){
|
||||
if(type.buildSpeed <= 0f) return;
|
||||
|
||||
@@ -59,7 +72,11 @@ abstract class BuilderComp implements Posc, Statusc, Teamc, Rotc{
|
||||
buildAlpha = Mathf.lerpDelta(buildAlpha, activelyBuilding() ? 1f : 0f, 0.15f);
|
||||
}
|
||||
|
||||
if(!updateBuilding || !canBuild()) return;
|
||||
//validate regardless of whether building is enabled.
|
||||
if(!updateBuilding || !canBuild()){
|
||||
validatePlans();
|
||||
return;
|
||||
}
|
||||
|
||||
float finalPlaceDst = state.rules.infiniteResources ? Float.MAX_VALUE : type.buildRange;
|
||||
boolean infinite = state.rules.infiniteResources || team().rules().infiniteResources;
|
||||
@@ -69,14 +86,7 @@ abstract class BuilderComp implements Posc, Statusc, Teamc, Rotc{
|
||||
while(buildCounter >= 1){
|
||||
buildCounter -= 1f;
|
||||
|
||||
Iterator<BuildPlan> it = plans.iterator();
|
||||
while(it.hasNext()){
|
||||
BuildPlan plan = it.next();
|
||||
Tile tile = world.tile(plan.x, plan.y);
|
||||
if(tile == null || (plan.breaking && tile.block() == Blocks.air) || (!plan.breaking && ((tile.build != null && tile.build.rotation == plan.rotation) || !plan.block.rotate) && tile.block() == plan.block)){
|
||||
it.remove();
|
||||
}
|
||||
}
|
||||
validatePlans();
|
||||
|
||||
var core = core();
|
||||
|
||||
|
||||
@@ -160,6 +160,9 @@ public class Teams{
|
||||
data.unitCount = 0;
|
||||
data.units.clear();
|
||||
data.players.clear();
|
||||
if(data.cores.size > 0){
|
||||
data.lastCore = data.cores.first();
|
||||
}
|
||||
if(data.unitTree != null){
|
||||
data.unitTree.clear();
|
||||
}
|
||||
@@ -236,7 +239,6 @@ public class Teams{
|
||||
}
|
||||
|
||||
public static class TeamData{
|
||||
public final Seq<CoreBuild> cores = new Seq<>();
|
||||
public final Team team;
|
||||
|
||||
/** Handles RTS unit control. */
|
||||
@@ -249,6 +251,10 @@ public class Teams{
|
||||
/** Planned blocks for drones. This is usually only blocks that have been broken. */
|
||||
public Queue<BlockPlan> plans = new Queue<>();
|
||||
|
||||
/** List of live cores of this team. */
|
||||
public final Seq<CoreBuild> cores = new Seq<>();
|
||||
/** Last known live core of this team. */
|
||||
public @Nullable CoreBuild lastCore;
|
||||
/** Quadtree for all buildings of this team. Null if not active. */
|
||||
public @Nullable QuadTree<Building> buildingTree;
|
||||
/** Turrets by range. Null if not active. */
|
||||
|
||||
@@ -225,7 +225,10 @@ public class DesktopInput extends InputHandler{
|
||||
|
||||
Core.camera.position.add(Tmp.v1.setZero().add(Core.input.axis(Binding.move_x), Core.input.axis(Binding.move_y)).nor().scl(camSpeed));
|
||||
}else if(!player.dead() && !panning){
|
||||
Core.camera.position.lerpDelta(player, Core.settings.getBool("smoothcamera") ? 0.08f : 1f);
|
||||
//TODO do not pan
|
||||
Team corePanTeam = state.won ? state.rules.waveTeam : player.team();
|
||||
Position coreTarget = state.gameOver && !state.rules.pvp && corePanTeam.data().lastCore != null ? corePanTeam.data().lastCore : null;
|
||||
Core.camera.position.lerpDelta(coreTarget != null ? coreTarget : player, Core.settings.getBool("smoothcamera") ? 0.08f : 1f);
|
||||
}
|
||||
|
||||
if(panCam){
|
||||
|
||||
@@ -362,7 +362,7 @@ public class UnitType extends UnlockableContent{
|
||||
|
||||
//TANK UNITS
|
||||
|
||||
/** list of treads as rectangles in IMAGE COORDINATES. these should match the coordinates you see in an image editor*/
|
||||
/** list of treads as rectangles in IMAGE COORDINATES. these are mirrored, and should match the coordinates you see in an image editor. */
|
||||
public Rect[] treadRects = {};
|
||||
/** number of frames of movement in a tread */
|
||||
public int treadFrames = 18;
|
||||
|
||||
@@ -124,7 +124,7 @@ public class PausedDialog extends BaseDialog{
|
||||
return;
|
||||
}
|
||||
|
||||
if(control.saves.getCurrent() == null || !control.saves.getCurrent().isAutosave() || wasClient){
|
||||
if(control.saves.getCurrent() == null || !control.saves.getCurrent().isAutosave() || wasClient || state.gameOver){
|
||||
logic.reset();
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user