WIP game-over core pan
This commit is contained in:
@@ -504,7 +504,7 @@ public class Control implements ApplicationListener, Loadable{
|
|||||||
@Override
|
@Override
|
||||||
public void dispose(){
|
public void dispose(){
|
||||||
//try to save when exiting
|
//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{
|
try{
|
||||||
SaveIO.save(control.saves.getCurrent().file);
|
SaveIO.save(control.saves.getCurrent().file);
|
||||||
Log.info("Saved on exit.");
|
Log.info("Saved on exit.");
|
||||||
|
|||||||
@@ -21,7 +21,11 @@ public class GameState{
|
|||||||
/** Continuously ticks up every non-paused update. */
|
/** Continuously ticks up every non-paused update. */
|
||||||
public long updateId;
|
public long updateId;
|
||||||
/** Whether the game is in game over state. */
|
/** 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. */
|
/** Server ticks/second. Only valid in multiplayer. */
|
||||||
public int serverTps = -1;
|
public int serverTps = -1;
|
||||||
/** Map that is currently being played on. */
|
/** Map that is currently being played on. */
|
||||||
@@ -77,7 +81,7 @@ public class GameState{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean isPaused(){
|
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(){
|
public boolean isPlaying(){
|
||||||
|
|||||||
@@ -402,12 +402,16 @@ public class Logic implements ApplicationListener{
|
|||||||
@Remote(called = Loc.both)
|
@Remote(called = Loc.both)
|
||||||
public static void updateGameOver(Team winner){
|
public static void updateGameOver(Team winner){
|
||||||
state.gameOver = true;
|
state.gameOver = true;
|
||||||
|
state.won = player.team() == winner;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Remote(called = Loc.both)
|
@Remote(called = Loc.both)
|
||||||
public static void gameOver(Team winner){
|
public static void gameOver(Team winner){
|
||||||
state.stats.wavesLasted = state.wave;
|
state.stats.wavesLasted = state.wave;
|
||||||
ui.restart.show(winner);
|
state.won = player.team() == winner;
|
||||||
|
Time.run(60f * 3f, () -> {
|
||||||
|
ui.restart.show(winner);
|
||||||
|
});
|
||||||
netClient.setQuiet();
|
netClient.setQuiet();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -47,6 +47,19 @@ abstract class BuilderComp implements Posc, Statusc, Teamc, Rotc{
|
|||||||
updateBuildLogic();
|
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(){
|
public void updateBuildLogic(){
|
||||||
if(type.buildSpeed <= 0f) return;
|
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);
|
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;
|
float finalPlaceDst = state.rules.infiniteResources ? Float.MAX_VALUE : type.buildRange;
|
||||||
boolean infinite = state.rules.infiniteResources || team().rules().infiniteResources;
|
boolean infinite = state.rules.infiniteResources || team().rules().infiniteResources;
|
||||||
@@ -69,14 +86,7 @@ abstract class BuilderComp implements Posc, Statusc, Teamc, Rotc{
|
|||||||
while(buildCounter >= 1){
|
while(buildCounter >= 1){
|
||||||
buildCounter -= 1f;
|
buildCounter -= 1f;
|
||||||
|
|
||||||
Iterator<BuildPlan> it = plans.iterator();
|
validatePlans();
|
||||||
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();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var core = core();
|
var core = core();
|
||||||
|
|
||||||
|
|||||||
@@ -160,6 +160,9 @@ public class Teams{
|
|||||||
data.unitCount = 0;
|
data.unitCount = 0;
|
||||||
data.units.clear();
|
data.units.clear();
|
||||||
data.players.clear();
|
data.players.clear();
|
||||||
|
if(data.cores.size > 0){
|
||||||
|
data.lastCore = data.cores.first();
|
||||||
|
}
|
||||||
if(data.unitTree != null){
|
if(data.unitTree != null){
|
||||||
data.unitTree.clear();
|
data.unitTree.clear();
|
||||||
}
|
}
|
||||||
@@ -236,7 +239,6 @@ public class Teams{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static class TeamData{
|
public static class TeamData{
|
||||||
public final Seq<CoreBuild> cores = new Seq<>();
|
|
||||||
public final Team team;
|
public final Team team;
|
||||||
|
|
||||||
/** Handles RTS unit control. */
|
/** Handles RTS unit control. */
|
||||||
@@ -249,6 +251,10 @@ public class Teams{
|
|||||||
/** Planned blocks for drones. This is usually only blocks that have been broken. */
|
/** Planned blocks for drones. This is usually only blocks that have been broken. */
|
||||||
public Queue<BlockPlan> plans = new Queue<>();
|
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. */
|
/** Quadtree for all buildings of this team. Null if not active. */
|
||||||
public @Nullable QuadTree<Building> buildingTree;
|
public @Nullable QuadTree<Building> buildingTree;
|
||||||
/** Turrets by range. Null if not active. */
|
/** 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));
|
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){
|
}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){
|
if(panCam){
|
||||||
|
|||||||
@@ -362,7 +362,7 @@ public class UnitType extends UnlockableContent{
|
|||||||
|
|
||||||
//TANK UNITS
|
//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 = {};
|
public Rect[] treadRects = {};
|
||||||
/** number of frames of movement in a tread */
|
/** number of frames of movement in a tread */
|
||||||
public int treadFrames = 18;
|
public int treadFrames = 18;
|
||||||
|
|||||||
@@ -124,7 +124,7 @@ public class PausedDialog extends BaseDialog{
|
|||||||
return;
|
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();
|
logic.reset();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user