Asteroid background improvements
This commit is contained in:
BIN
core/assets-raw/sprites/blocks/environment/empty.png
Normal file
BIN
core/assets-raw/sprites/blocks/environment/empty.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 116 B |
@@ -35,7 +35,7 @@ public class Blocks implements ContentList{
|
|||||||
public static Block
|
public static Block
|
||||||
|
|
||||||
//environment
|
//environment
|
||||||
air, spawn, cliff, deepwater, water, taintedWater, deepTaintedWater, tar, slag, stone, craters, charr, sand, darksand, dirt, mud, ice, snow, darksandTaintedWater, space,
|
air, spawn, cliff, deepwater, water, taintedWater, deepTaintedWater, tar, slag, stone, craters, charr, sand, darksand, dirt, mud, ice, snow, darksandTaintedWater, space, empty,
|
||||||
dacite, rhyolite, rhyoliteCrater, regolith, yellowStone, redIce,
|
dacite, rhyolite, rhyoliteCrater, regolith, yellowStone, redIce,
|
||||||
redmat, bluemat,
|
redmat, bluemat,
|
||||||
stoneWall, dirtWall, sporeWall, iceWall, daciteWall, sporePine, snowPine, pine, shrubs, whiteTree, whiteTreeDead, sporeCluster,
|
stoneWall, dirtWall, sporeWall, iceWall, daciteWall, sporePine, snowPine, pine, shrubs, whiteTree, whiteTreeDead, sporeCluster,
|
||||||
@@ -231,6 +231,12 @@ public class Blocks implements ContentList{
|
|||||||
placeableOn = false;
|
placeableOn = false;
|
||||||
solid = true;
|
solid = true;
|
||||||
variants = 0;
|
variants = 0;
|
||||||
|
canShadow = false;
|
||||||
|
}};
|
||||||
|
|
||||||
|
empty = new EmptyFloor("empty"){{
|
||||||
|
placeableOn = false;
|
||||||
|
solid = true;
|
||||||
}};
|
}};
|
||||||
|
|
||||||
stone = new Floor("stone");
|
stone = new Floor("stone");
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package mindustry.core;
|
package mindustry.core;
|
||||||
|
|
||||||
import arc.*;
|
import arc.*;
|
||||||
|
import arc.assets.loaders.TextureLoader.*;
|
||||||
import arc.files.*;
|
import arc.files.*;
|
||||||
import arc.graphics.*;
|
import arc.graphics.*;
|
||||||
import arc.graphics.Texture.*;
|
import arc.graphics.Texture.*;
|
||||||
@@ -310,8 +311,43 @@ public class Renderer implements ApplicationListener{
|
|||||||
Events.fire(Trigger.postDraw);
|
Events.fire(Trigger.postDraw);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void drawBackground(){
|
protected void drawBackground(){
|
||||||
//nothing to draw currently
|
if(state.rules.backgroundTexture != null){
|
||||||
|
if(!assets.isLoaded(state.rules.backgroundTexture, Texture.class)){
|
||||||
|
var file = assets.getFileHandleResolver().resolve(state.rules.backgroundTexture);
|
||||||
|
|
||||||
|
//don't draw invalid/non-existent backgrounds.
|
||||||
|
if(!file.exists() || !file.extEquals("png")){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var desc = assets.load(state.rules.backgroundTexture, Texture.class, new TextureParameter(){{
|
||||||
|
wrapU = TextureWrap.mirroredRepeat;
|
||||||
|
wrapV = TextureWrap.mirroredRepeat;
|
||||||
|
magFilter = TextureFilter.linear;
|
||||||
|
minFilter = TextureFilter.linear;
|
||||||
|
}});
|
||||||
|
|
||||||
|
assets.finishLoadingAsset(desc);
|
||||||
|
}
|
||||||
|
|
||||||
|
Texture tex = assets.get(state.rules.backgroundTexture, Texture.class);
|
||||||
|
Tmp.tr1.set(tex);
|
||||||
|
Tmp.tr1.u = 0f;
|
||||||
|
Tmp.tr1.v = 0f;
|
||||||
|
|
||||||
|
float ratio = camera.width / camera.height;
|
||||||
|
float size = state.rules.backgroundScl;
|
||||||
|
|
||||||
|
Tmp.tr1.u2 = size;
|
||||||
|
Tmp.tr1.v2 = size / ratio;
|
||||||
|
|
||||||
|
float sx = (camera.position.x) / state.rules.backgroundSpeed, sy = (camera.position.y) / state.rules.backgroundSpeed;
|
||||||
|
|
||||||
|
Tmp.tr1.scroll(sx + state.rules.backgroundOffsetX, -sy + state.rules.backgroundOffsetY);
|
||||||
|
|
||||||
|
Draw.rect(Tmp.tr1, camera.position.x, camera.position.y, camera.width, camera.height);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void updateLandParticles(){
|
void updateLandParticles(){
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import arc.math.geom.Geometry.*;
|
|||||||
import arc.struct.*;
|
import arc.struct.*;
|
||||||
import arc.util.*;
|
import arc.util.*;
|
||||||
import arc.util.noise.*;
|
import arc.util.noise.*;
|
||||||
|
import mindustry.*;
|
||||||
import mindustry.content.*;
|
import mindustry.content.*;
|
||||||
import mindustry.core.GameState.*;
|
import mindustry.core.GameState.*;
|
||||||
import mindustry.ctype.*;
|
import mindustry.ctype.*;
|
||||||
@@ -479,12 +480,14 @@ public class World{
|
|||||||
|
|
||||||
//TODO optimize; this is very slow and called too often!
|
//TODO optimize; this is very slow and called too often!
|
||||||
public float getDarkness(int x, int y){
|
public float getDarkness(int x, int y){
|
||||||
int edgeBlend = 2;
|
|
||||||
|
|
||||||
float dark = 0;
|
float dark = 0;
|
||||||
int edgeDst = Math.min(x, Math.min(y, Math.min(Math.abs(x - (tiles.width - 1)), Math.abs(y - (tiles.height - 1)))));
|
|
||||||
if(edgeDst <= edgeBlend){
|
if(Vars.state.rules.borderDarkness){
|
||||||
dark = Math.max((edgeBlend - edgeDst) * (4f / edgeBlend), dark);
|
int edgeBlend = 2;
|
||||||
|
int edgeDst = Math.min(x, Math.min(y, Math.min(Math.abs(x - (tiles.width - 1)), Math.abs(y - (tiles.height - 1)))));
|
||||||
|
if(edgeDst <= edgeBlend){
|
||||||
|
dark = Math.max((edgeBlend - edgeDst) * (4f / edgeBlend), dark);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(state.hasSector() && state.getSector().preset == null){
|
if(state.hasSector() && state.getSector().preset == null){
|
||||||
|
|||||||
@@ -44,6 +44,7 @@ abstract class UnitComp implements Healthc, Physicsc, Hitboxc, Statusc, Teamc, I
|
|||||||
boolean spawnedByCore;
|
boolean spawnedByCore;
|
||||||
double flag;
|
double flag;
|
||||||
|
|
||||||
|
transient float shadowAlpha = -1f;
|
||||||
transient Seq<Ability> abilities = new Seq<>(0);
|
transient Seq<Ability> abilities = new Seq<>(0);
|
||||||
transient float healTime;
|
transient float healTime;
|
||||||
private transient float resupplyTime = Mathf.random(10f);
|
private transient float resupplyTime = Mathf.random(10f);
|
||||||
|
|||||||
@@ -117,8 +117,18 @@ public class Rules{
|
|||||||
public @Nullable String modeName;
|
public @Nullable String modeName;
|
||||||
/** Whether cores incinerate items when full, just like in the campaign. */
|
/** Whether cores incinerate items when full, just like in the campaign. */
|
||||||
public boolean coreIncinerates = false;
|
public boolean coreIncinerates = false;
|
||||||
|
/** If false, borders fade out into darkness. Only use with custom backgrounds!*/
|
||||||
|
public boolean borderDarkness = true;
|
||||||
/** special tags for additional info. */
|
/** special tags for additional info. */
|
||||||
public StringMap tags = new StringMap();
|
public StringMap tags = new StringMap();
|
||||||
|
/** path to background texture with extension (e.g. "sprites/space.png")*/
|
||||||
|
public @Nullable String backgroundTexture;
|
||||||
|
/** background texture move speed scaling - bigger numbers mean slower movement */
|
||||||
|
public float backgroundSpeed = 27000f;
|
||||||
|
/** background texture scaling factor */
|
||||||
|
public float backgroundScl = 1f;
|
||||||
|
/** background UV offsets */
|
||||||
|
public float backgroundOffsetX = 0.1f, backgroundOffsetY = 0.1f;
|
||||||
|
|
||||||
/** Copies this ruleset exactly. Not efficient at all, do not use often. */
|
/** Copies this ruleset exactly. Not efficient at all, do not use often. */
|
||||||
public Rules copy(){
|
public Rules copy(){
|
||||||
|
|||||||
@@ -46,9 +46,9 @@ public class AsteroidGenerator extends BlankPlanetGenerator{
|
|||||||
int sx = width/2, sy = height/2;
|
int sx = width/2, sy = height/2;
|
||||||
rand = new Rand(seed);
|
rand = new Rand(seed);
|
||||||
|
|
||||||
pass((x, y) -> {
|
Floor background = Blocks.empty.asFloor();
|
||||||
floor = Blocks.space;
|
|
||||||
});
|
tiles.eachTile(t -> t.setFloor(background));
|
||||||
|
|
||||||
//spawn asteroids
|
//spawn asteroids
|
||||||
asteroid(sx, sy, rand.random(30, 50));
|
asteroid(sx, sy, rand.random(30, 50));
|
||||||
@@ -70,7 +70,7 @@ public class AsteroidGenerator extends BlankPlanetGenerator{
|
|||||||
|
|
||||||
//random noise stone
|
//random noise stone
|
||||||
pass((x, y) -> {
|
pass((x, y) -> {
|
||||||
if(floor != Blocks.space){
|
if(floor != background){
|
||||||
if(Ridged.noise2d(seed, x, y, foct, fper, 1f / fscl) - Ridged.noise2d(seed, x, y, 1, 1f, 5f)/2.7f > fmag){
|
if(Ridged.noise2d(seed, x, y, foct, fper, 1f / fscl) - Ridged.noise2d(seed, x, y, 1, 1f, 5f)/2.7f > fmag){
|
||||||
floor = Blocks.stone;
|
floor = Blocks.stone;
|
||||||
}
|
}
|
||||||
@@ -79,12 +79,12 @@ public class AsteroidGenerator extends BlankPlanetGenerator{
|
|||||||
|
|
||||||
//walls at insides
|
//walls at insides
|
||||||
pass((x, y) -> {
|
pass((x, y) -> {
|
||||||
if(floor == Blocks.space || Ridged.noise2d(seed + 1, x, y, 4, 0.7f, 1f / 60f) > 0.45f || Mathf.within(x, y, sx, sy, 20 + Ridged.noise2d(seed, x, y, 3, 0.5f, 1f / 30f) * 6f)) return;
|
if(floor == background || Ridged.noise2d(seed + 1, x, y, 4, 0.7f, 1f / 60f) > 0.45f || Mathf.within(x, y, sx, sy, 20 + Ridged.noise2d(seed, x, y, 3, 0.5f, 1f / 30f) * 6f)) return;
|
||||||
|
|
||||||
int radius = 6;
|
int radius = 6;
|
||||||
for(int dx = x - radius; dx <= x + radius; dx++){
|
for(int dx = x - radius; dx <= x + radius; dx++){
|
||||||
for(int dy = y - radius; dy <= y + radius; dy++){
|
for(int dy = y - radius; dy <= y + radius; dy++){
|
||||||
if(Mathf.within(dx, dy, x, y, radius + 0.0001f) && tiles.in(dx, dy) && tiles.getn(dx, dy).floor() == Blocks.space){
|
if(Mathf.within(dx, dy, x, y, radius + 0.0001f) && tiles.in(dx, dy) && tiles.getn(dx, dy).floor() == background){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -132,6 +132,8 @@ public class AsteroidGenerator extends BlankPlanetGenerator{
|
|||||||
|
|
||||||
Schematics.placeLaunchLoadout(sx, sy);
|
Schematics.placeLaunchLoadout(sx, sy);
|
||||||
|
|
||||||
|
state.rules.backgroundTexture = "sprites/space.png";
|
||||||
|
state.rules.borderDarkness = false;
|
||||||
state.rules.environment = Env.space;
|
state.rules.environment = Env.space;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -698,8 +698,15 @@ public class UnitType extends UnlockableContent{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void drawShadow(Unit unit){
|
public void drawShadow(Unit unit){
|
||||||
Draw.color(Pal.shadow);
|
|
||||||
float e = Math.max(unit.elevation, visualElevation) * (1f - unit.drownTime);
|
float e = Math.max(unit.elevation, visualElevation) * (1f - unit.drownTime);
|
||||||
|
float x = unit.x + shadowTX * e, y = unit.y + shadowTY * e;
|
||||||
|
Floor floor = world.floorWorld(x, y);
|
||||||
|
|
||||||
|
float dest = floor.canShadow ? 1f : 0f;
|
||||||
|
//yes, this updates state in draw()... which isn't a problem, because I don't want it to be obvious anyway
|
||||||
|
unit.shadowAlpha = unit.shadowAlpha < 0 ? dest : Mathf.approachDelta(unit.shadowAlpha, dest, 0.11f);
|
||||||
|
Draw.color(Pal.shadow, Pal.shadow.a * unit.shadowAlpha);
|
||||||
|
|
||||||
Draw.rect(shadowRegion, unit.x + shadowTX * e, unit.y + shadowTY * e, unit.rotation - 90);
|
Draw.rect(shadowRegion, unit.x + shadowTX * e, unit.y + shadowTY * e, unit.rotation - 90);
|
||||||
Draw.color();
|
Draw.color();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ public class AirBlock extends Floor{
|
|||||||
useColor = false;
|
useColor = false;
|
||||||
wall = this;
|
wall = this;
|
||||||
needsSurface = false;
|
needsSurface = false;
|
||||||
|
canShadow = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
24
core/src/mindustry/world/blocks/environment/EmptyFloor.java
Normal file
24
core/src/mindustry/world/blocks/environment/EmptyFloor.java
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
package mindustry.world.blocks.environment;
|
||||||
|
|
||||||
|
import mindustry.content.*;
|
||||||
|
import mindustry.world.*;
|
||||||
|
|
||||||
|
public class EmptyFloor extends Floor{
|
||||||
|
|
||||||
|
public EmptyFloor(String name){
|
||||||
|
super(name);
|
||||||
|
variants = 0;
|
||||||
|
canShadow = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void drawBase(Tile tile){
|
||||||
|
//draws only edges, never itself
|
||||||
|
drawEdges(tile);
|
||||||
|
|
||||||
|
Floor floor = tile.overlay();
|
||||||
|
if(floor != Blocks.air && floor != this){
|
||||||
|
floor.drawBase(tile);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -59,6 +59,8 @@ public class Floor extends Block{
|
|||||||
public Block wall = Blocks.air;
|
public Block wall = Blocks.air;
|
||||||
/** Decoration block. Usually a rock. May be air. */
|
/** Decoration block. Usually a rock. May be air. */
|
||||||
public Block decoration = Blocks.air;
|
public Block decoration = Blocks.air;
|
||||||
|
/** Whether units can draw shadows over this. */
|
||||||
|
public boolean canShadow = true;
|
||||||
/** Whether this overlay needs a surface to be on. False for floating blocks, like spawns. */
|
/** Whether this overlay needs a surface to be on. False for floating blocks, like spawns. */
|
||||||
public boolean needsSurface = true;
|
public boolean needsSurface = true;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user