Better sector null checks
This commit is contained in:
@@ -130,7 +130,7 @@ public class Logic implements ApplicationListener{
|
|||||||
public void runWave(){
|
public void runWave(){
|
||||||
spawner.spawnEnemies();
|
spawner.spawnEnemies();
|
||||||
state.wave++;
|
state.wave++;
|
||||||
state.wavetime = state.isCampaign() && state.getSector().isLaunchWave(state.wave) ? state.rules.waveSpacing * state.rules.launchWaveMultiplier : state.rules.waveSpacing;
|
state.wavetime = state.hasSector() && state.getSector().isLaunchWave(state.wave) ? state.rules.waveSpacing * state.rules.launchWaveMultiplier : state.rules.waveSpacing;
|
||||||
|
|
||||||
Events.fire(new WaveEvent());
|
Events.fire(new WaveEvent());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -344,7 +344,7 @@ public class World{
|
|||||||
}
|
}
|
||||||
|
|
||||||
//TODO tweak noise and radius
|
//TODO tweak noise and radius
|
||||||
if(state.isCampaign()){
|
if(state.hasSector()){
|
||||||
int circleBlend = 14;
|
int circleBlend = 14;
|
||||||
//quantized angle
|
//quantized angle
|
||||||
float offset = state.getSector().rect.rotation + 90;
|
float offset = state.getSector().rect.rotation + 90;
|
||||||
|
|||||||
@@ -44,12 +44,14 @@ public class Universe{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//update sector light
|
if(state.hasSector()){
|
||||||
float light = state.getSector().getLight();
|
//update sector light
|
||||||
float alpha = Mathf.clamp(Mathf.map(light, 0f, 0.8f, 0.1f, 1f));
|
float light = state.getSector().getLight();
|
||||||
//assign and map so darkness is not 100% dark
|
float alpha = Mathf.clamp(Mathf.map(light, 0f, 0.8f, 0.1f, 1f));
|
||||||
state.rules.ambientLight.a = 1f - alpha;
|
//assign and map so darkness is not 100% dark
|
||||||
state.rules.lighting = !Mathf.equal(alpha, 1f);
|
state.rules.ambientLight.a = 1f - alpha;
|
||||||
|
state.rules.lighting = !Mathf.equal(alpha, 1f);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public float secondsMod(float mod, float scale){
|
public float secondsMod(float mod, float scale){
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ public class FileMapGenerator implements WorldGenerator{
|
|||||||
SaveIO.load(map.file);
|
SaveIO.load(map.file);
|
||||||
|
|
||||||
for(Tile tile : tiles){
|
for(Tile tile : tiles){
|
||||||
if(tile.block() instanceof StorageBlock && !(tile.block() instanceof CoreBlock) && state.getSector() != null){
|
if(tile.block() instanceof StorageBlock && !(tile.block() instanceof CoreBlock) && state.hasSector()){
|
||||||
for(Content content : state.getSector().data.resources){
|
for(Content content : state.getSector().data.resources){
|
||||||
if(content instanceof Item && Mathf.chance(0.3)){
|
if(content instanceof Item && Mathf.chance(0.3)){
|
||||||
tile.entity.items().add((Item)content, Math.min(Mathf.random(500), tile.block().itemCapacity));
|
tile.entity.items().add((Item)content, Math.min(Mathf.random(500), tile.block().itemCapacity));
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ public class GameOverDialog extends FloatingDialog{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(state.isCampaign()){
|
if(state.hasSector()){
|
||||||
RankResult result = state.stats.calculateRank(state.getSector(), state.launched);
|
RankResult result = state.stats.calculateRank(state.getSector(), state.launched);
|
||||||
t.add(Core.bundle.format("stat.rank", result.rank + result.modifier));
|
t.add(Core.bundle.format("stat.rank", result.rank + result.modifier));
|
||||||
t.row();
|
t.row();
|
||||||
|
|||||||
@@ -497,7 +497,7 @@ public class HudFragment extends Fragment{
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean inLaunchWave(){
|
private boolean inLaunchWave(){
|
||||||
return state.isCampaign() &&
|
return state.hasSector() &&
|
||||||
state.getSector().metCondition() &&
|
state.getSector().metCondition() &&
|
||||||
!net.client() &&
|
!net.client() &&
|
||||||
state.wave % state.getSector().launchPeriod == 0 && !spawner.isSpawning();
|
state.wave % state.getSector().launchPeriod == 0 && !spawner.isSpawning();
|
||||||
|
|||||||
@@ -231,7 +231,7 @@ public class SStats implements SteamUserStatsCallback{
|
|||||||
});
|
});
|
||||||
|
|
||||||
Events.on(WinEvent.class, e -> {
|
Events.on(WinEvent.class, e -> {
|
||||||
if(campaign()){
|
if(state.hasSector()){
|
||||||
if(Vars.state.wave <= 5 && state.rules.attackMode){
|
if(Vars.state.wave <= 5 && state.rules.attackMode){
|
||||||
defeatAttack5Waves.complete();
|
defeatAttack5Waves.complete();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user