Better sector null checks

This commit is contained in:
Anuken 2020-03-01 12:15:38 -05:00
parent 51cec64118
commit 3ed5282e14
7 changed files with 14 additions and 12 deletions

View File

@ -130,7 +130,7 @@ public class Logic implements ApplicationListener{
public void runWave(){
spawner.spawnEnemies();
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());
}

View File

@ -344,7 +344,7 @@ public class World{
}
//TODO tweak noise and radius
if(state.isCampaign()){
if(state.hasSector()){
int circleBlend = 14;
//quantized angle
float offset = state.getSector().rect.rotation + 90;

View File

@ -44,12 +44,14 @@ public class Universe{
}
}
//update sector light
float light = state.getSector().getLight();
float alpha = Mathf.clamp(Mathf.map(light, 0f, 0.8f, 0.1f, 1f));
//assign and map so darkness is not 100% dark
state.rules.ambientLight.a = 1f - alpha;
state.rules.lighting = !Mathf.equal(alpha, 1f);
if(state.hasSector()){
//update sector light
float light = state.getSector().getLight();
float alpha = Mathf.clamp(Mathf.map(light, 0f, 0.8f, 0.1f, 1f));
//assign and map so darkness is not 100% dark
state.rules.ambientLight.a = 1f - alpha;
state.rules.lighting = !Mathf.equal(alpha, 1f);
}
}
public float secondsMod(float mod, float scale){

View File

@ -27,7 +27,7 @@ public class FileMapGenerator implements WorldGenerator{
SaveIO.load(map.file);
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){
if(content instanceof Item && Mathf.chance(0.3)){
tile.entity.items().add((Item)content, Math.min(Mathf.random(500), tile.block().itemCapacity));

View File

@ -80,7 +80,7 @@ public class GameOverDialog extends FloatingDialog{
}
}
if(state.isCampaign()){
if(state.hasSector()){
RankResult result = state.stats.calculateRank(state.getSector(), state.launched);
t.add(Core.bundle.format("stat.rank", result.rank + result.modifier));
t.row();

View File

@ -497,7 +497,7 @@ public class HudFragment extends Fragment{
}
private boolean inLaunchWave(){
return state.isCampaign() &&
return state.hasSector() &&
state.getSector().metCondition() &&
!net.client() &&
state.wave % state.getSector().launchPeriod == 0 && !spawner.isSpawning();

View File

@ -231,7 +231,7 @@ public class SStats implements SteamUserStatsCallback{
});
Events.on(WinEvent.class, e -> {
if(campaign()){
if(state.hasSector()){
if(Vars.state.wave <= 5 && state.rules.attackMode){
defeatAttack5Waves.complete();
}