Shale biome implementation

This commit is contained in:
Anuken
2020-05-18 17:25:50 -04:00
parent 530ff9761b
commit a9ece49c0d
5 changed files with 73 additions and 22 deletions

View File

@@ -11,7 +11,7 @@ import static mindustry.type.ItemStack.list;
public class SectorPresets implements ContentList{
public static SectorPreset
groundZero, desertWastes,
groundZero,
craters, frozenForest, ruinousShores, stainedMountains, tarFields, fungalPass,
saltFlats, overgrowth, impact0078, crags,
desolateRift, nuclearComplex;
@@ -27,13 +27,13 @@ public class SectorPresets implements ContentList{
launchPeriod = 5;
}};
saltFlats = new SectorPreset("saltFlats", starter, 16){{
saltFlats = new SectorPreset("saltFlats", starter, 101){{
startingItems = list(copper, 200, silicon, 200, lead, 200);
loadout = Loadouts.basicFoundation;
conditionWave = 10;
launchPeriod = 5;
requirements = with(
new ZoneWave(desertWastes, 60),
new ZoneWave(groundZero, 60),
//new Unlock(Blocks.daggerFactory),
//new Unlock(Blocks.draugFactory),
new Unlock(Blocks.door),
@@ -41,7 +41,7 @@ public class SectorPresets implements ContentList{
);
}};
frozenForest = new SectorPreset("frozenForest", starter, 17){{
frozenForest = new SectorPreset("frozenForest", starter, 86){{
loadout = Loadouts.basicFoundation;
startingItems = list(copper, 250);
conditionWave = 10;
@@ -68,7 +68,7 @@ public class SectorPresets implements ContentList{
conditionWave = 20;
launchPeriod = 20;
requirements = with(
new ZoneWave(desertWastes, 20),
new ZoneWave(groundZero, 20),
new ZoneWave(craters, 15),
new Unlock(Blocks.graphitePress),
new Unlock(Blocks.combustionGenerator),
@@ -129,7 +129,7 @@ public class SectorPresets implements ContentList{
);
}};
desolateRift = new SectorPreset("desolateRift", starter, 24){{
desolateRift = new SectorPreset("desolateRift", starter, 123){{
loadout = Loadouts.basicNucleus;
startingItems = list(copper, 1000, lead, 1000, Items.graphite, 250, titanium, 250, Items.silicon, 250);
conditionWave = 3;
@@ -142,7 +142,7 @@ public class SectorPresets implements ContentList{
}};
nuclearComplex = new SectorPreset("nuclearComplex", starter, 25){{
nuclearComplex = new SectorPreset("nuclearComplex", starter, 130){{
loadout = Loadouts.basicNucleus;
startingItems = list(copper, 1250, lead, 1500, Items.silicon, 400, Items.metaglass, 250);
conditionWave = 30;

View File

@@ -55,7 +55,7 @@ public class Objectives{
public int wave;
public ZoneWave(SectorPreset zone, int wave){
this.zone = zone;
this.preset = zone;
this.wave = wave;
}
@@ -63,40 +63,40 @@ public class Objectives{
@Override
public boolean complete(){
return zone.bestWave() >= wave;
return preset.bestWave() >= wave;
}
@Override
public String display(){
return Core.bundle.format("requirement.wave", wave, zone.localizedName);
return Core.bundle.format("requirement.wave", wave, preset.localizedName);
}
}
public static class Launched extends ZoneObjective{
public Launched(SectorPreset zone){
this.zone = zone;
this.preset = zone;
}
protected Launched(){}
@Override
public boolean complete(){
return zone.hasLaunched();
return preset.hasLaunched();
}
@Override
public String display(){
return Core.bundle.format("requirement.core", zone.localizedName);
return Core.bundle.format("requirement.core", preset.localizedName);
}
}
public abstract static class ZoneObjective implements Objective{
public @NonNull SectorPreset zone;
public @NonNull SectorPreset preset;
}
/** Defines a specific objective for a game. */
public static interface Objective{
public interface Objective{
/** @return whether this objective is met. */
boolean complete();
@@ -112,7 +112,7 @@ public class Objectives{
}
default SectorPreset zone(){
return this instanceof ZoneObjective ? ((ZoneObjective)this).zone : null;
return this instanceof ZoneObjective ? ((ZoneObjective)this).preset : null;
}
}
}

View File

@@ -19,7 +19,8 @@ public class TODOPlanetGenerator extends PlanetGenerator{
float scl = 5f;
float waterOffset = 0.07f;
Block[][] arr = {
Block[][] arr =
{
{Blocks.water, Blocks.darksandWater, Blocks.darksand, Blocks.darksand, Blocks.darksand, Blocks.darksand, Blocks.sand, Blocks.sand, Blocks.sand, Blocks.sand, Blocks.darksandTaintedWater, Blocks.snow, Blocks.ice},
{Blocks.water, Blocks.darksandWater, Blocks.darksand, Blocks.darksand, Blocks.sand, Blocks.sand, Blocks.sand, Blocks.sand, Blocks.sand, Blocks.darksandTaintedWater, Blocks.snow, Blocks.snow, Blocks.ice},
{Blocks.water, Blocks.darksandWater, Blocks.darksand, Blocks.sand, Blocks.salt, Blocks.sand, Blocks.sand, Blocks.sand, Blocks.sand, Blocks.darksandTaintedWater, Blocks.snow, Blocks.ice, Blocks.ice},
@@ -32,7 +33,7 @@ public class TODOPlanetGenerator extends PlanetGenerator{
{Blocks.darksandWater, Blocks.darksand, Blocks.darksand, Blocks.sporeMoss, Blocks.ice, Blocks.ice, Blocks.snow, Blocks.snow, Blocks.snow, Blocks.snow, Blocks.ice, Blocks.ice, Blocks.ice},
{Blocks.taintedWater, Blocks.darksandTaintedWater, Blocks.darksand, Blocks.sporeMoss, Blocks.sporeMoss, Blocks.ice, Blocks.ice, Blocks.snow, Blocks.snow, Blocks.ice, Blocks.ice, Blocks.ice, Blocks.ice},
{Blocks.darksandTaintedWater, Blocks.darksandTaintedWater, Blocks.darksand, Blocks.sporeMoss, Blocks.moss, Blocks.sporeMoss, Blocks.iceSnow, Blocks.snow, Blocks.ice, Blocks.ice, Blocks.ice, Blocks.ice, Blocks.ice},
{Blocks.darksandWater, Blocks.darksand, Blocks.darksand, Blocks.ice, Blocks.iceSnow, Blocks.iceSnow, Blocks.snow, Blocks.snow, Blocks.ice, Blocks.ice, Blocks.ice, Blocks.ice, Blocks.ice}
{Blocks.darksandWater, Blocks.darksand, Blocks.snow, Blocks.ice, Blocks.iceSnow, Blocks.snow, Blocks.snow, Blocks.snow, Blocks.ice, Blocks.ice, Blocks.ice, Blocks.ice, Blocks.ice}
};
ObjectMap<Block, Block> dec = ObjectMap.of(
@@ -40,11 +41,17 @@ public class TODOPlanetGenerator extends PlanetGenerator{
Blocks.moss, Blocks.sporeCluster
);
ObjectMap<Block, Block> tars = ObjectMap.of(
Blocks.sporeMoss, Blocks.shale,
Blocks.moss, Blocks.shale
);
float water = 2f / arr[0].length;
float rawHeight(Vec3 position){
position = Tmp.v33.set(position).scl(scl);
return (Mathf.pow((float)noise.octaveNoise3D(7, 0.48f, 1f/3f, position.x, position.y, position.z), 2.3f) + waterOffset) / (1f + waterOffset);
return (Mathf.pow((float)noise.octaveNoise3D(7, 0.5f, 1f/3f, position.x, position.y, position.z), 2.3f) + waterOffset) / (1f + waterOffset);
}
@Override
@@ -77,15 +84,23 @@ public class TODOPlanetGenerator extends PlanetGenerator{
Block getBlock(Vec3 position){
float height = rawHeight(position);
Tmp.v31.set(position);
position = Tmp.v33.set(position).scl(scl);
float rad = scl;
float temp = Mathf.clamp(Math.abs(position.y * 2f) / (rad));
float tnoise = (float)noise.octaveNoise3D(7, 0.48f, 1f/3f, position.x, position.y + 999f, position.z);
float tnoise = (float)noise.octaveNoise3D(7, 0.5f, 1f/3f, position.x, position.y + 999f, position.z);
temp = Mathf.lerp(temp, tnoise, 0.5f);
height *= 1.2f;
height = Mathf.clamp(height);
return arr[Mathf.clamp((int)(temp * arr.length), 0, arr.length - 1)][Mathf.clamp((int)(height * arr[0].length), 0, arr[0].length - 1)];
float tar = (float)noise.octaveNoise3D(4, 0.55f, 1f/2f, position.x, position.y + 999f, position.z) * 0.3f + Tmp.v31.dst(0, 0, 1f) * 0.2f;
Block res = arr[Mathf.clamp((int)(temp * arr.length), 0, arr[0].length - 1)][Mathf.clamp((int)(height * arr[0].length), 0, arr[0].length - 1)];
if(tar > 0.5f){
return tars.get(res, res);
}else{
return res;
}
}
@Override

View File

@@ -18,6 +18,7 @@ import static mindustry.Vars.*;
public class SectorPreset extends UnlockableContent{
public @NonNull FileMapGenerator generator;
public @NonNull Planet planet;
public @NonNull Sector sector;
public Array<Objectives.Objective> requirements = new Array<>();
public Cons<Rules> rules = rules -> {};
@@ -35,6 +36,7 @@ public class SectorPreset extends UnlockableContent{
super(name);
this.generator = new FileMapGenerator(name);
this.planet = planet;
this.sector = planet.sectors.get(sector);
planet.preset(sector, this);
}
@@ -104,7 +106,7 @@ public class SectorPreset extends UnlockableContent{
closure.run();
for(ZoneObjective objective : incomplete){
if(objective.complete()){
Events.fire(new ZoneRequireCompleteEvent(objective.zone, content.zones().find(z -> z.requirements.contains(objective)), objective));
Events.fire(new ZoneRequireCompleteEvent(objective.preset, content.zones().find(z -> z.requirements.contains(objective)), objective));
}
}
}

View File

@@ -11,11 +11,13 @@ import arc.math.geom.*;
import arc.scene.event.*;
import arc.scene.ui.TextButton.*;
import arc.scene.ui.layout.*;
import arc.struct.*;
import arc.util.*;
import arc.util.ArcAnnotate.*;
import mindustry.content.*;
import mindustry.ctype.*;
import mindustry.game.EventType.*;
import mindustry.game.Objectives.*;
import mindustry.game.*;
import mindustry.gen.*;
import mindustry.graphics.*;
@@ -35,6 +37,7 @@ public class PlanetDialog extends FloatingDialog{
shadowColor = new Color(0, 0, 0, 0.7f);
private static final float camLength = 4f;
private static final float outlineRad = 1.16f;
private static final Array<Vec3> points = new Array<>();
//the base planet that's being rendered
private final Planet solarSystem = Planets.sun;
@@ -305,6 +308,19 @@ public class PlanetDialog extends FloatingDialog{
batch.flush(Gl.triangles);
//render arcs
for(Sector sec : planet.sectors){
if(sec.preset != null){
for(Objective o : sec.preset.requirements){
if(o instanceof ZoneObjective){
SectorPreset preset = ((ZoneObjective)o).preset;
drawArc(planet, sec.tile.v, preset.sector.tile.v);
}
}
}
}
//render sector grid
Mesh mesh = outline(planet.grid.size);
Shader shader = Shaders.planetGrid;
@@ -318,6 +334,24 @@ public class PlanetDialog extends FloatingDialog{
mesh.render(shader, Gl.lines);
}
private void drawArc(Planet planet, Vec3 a, Vec3 b){
Vec3 avg = Tmp.v31.set(a).add(b).scl(0.5f);
avg.setLength(planet.radius*2f);
points.clear();
points.addAll(Tmp.v33.set(a).setLength(outlineRad), Tmp.v31, Tmp.v34.set(b).setLength(outlineRad));
Tmp.bz3.set(points);
float points = 20;
for(int i = 0; i < points + 1; i++){
float f = i / points;
batch.color(Pal.accent);
batch.vertex(Tmp.bz3.valueAt(Tmp.v32, f));
}
batch.flush(Gl.lineStrip);
}
private void drawBorders(Sector sector, Color base){
Color color = Tmp.c1.set(base).a(base.a + 0.3f + Mathf.absin(Time.globalTime(), 5f, 0.3f));