Support for weather in rules / Sector weather

This commit is contained in:
Anuken
2020-05-08 21:51:17 -04:00
parent d7eb365446
commit 95a1d84eb9
30 changed files with 141 additions and 29 deletions

View File

@@ -7,6 +7,7 @@ import arc.graphics.*;
import mindustry.content.*;
import mindustry.io.*;
import mindustry.type.*;
import mindustry.type.Weather.*;
import mindustry.world.*;
/**
@@ -82,6 +83,8 @@ public class Rules{
public boolean drawDarkness = true;
/** Starting items put in cores */
public Array<ItemStack> loadout = Array.with(ItemStack.with(Items.copper, 100));
/** Weather events that occur here. */
public Array<WeatherEntry> weather = new Array<>(1);
/** Blocks that cannot be placed. */
public ObjectSet<Block> bannedBlocks = new ObjectSet<>();
/** Whether everything is dark. Enables lights. Experimental. */

View File

@@ -6,8 +6,9 @@ import arc.util.*;
import mindustry.content.*;
import mindustry.type.*;
import static mindustry.Vars.*;
import static mindustry.Vars.state;
/** Updates the campaign universe. Has no relevance to other gamemodes. */
public class Universe{
private long seconds;
private float secondCounter;
@@ -48,6 +49,7 @@ 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);