mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-02-11 11:17:11 +07:00
Added block rubble, more liquid interaction
This commit is contained in:
parent
32fb79478c
commit
7df232c65d
BIN
core/assets-raw/sprites/blocks/extra/rubble-1-0.png
Normal file
BIN
core/assets-raw/sprites/blocks/extra/rubble-1-0.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 232 B |
BIN
core/assets-raw/sprites/blocks/extra/rubble-1-1.png
Normal file
BIN
core/assets-raw/sprites/blocks/extra/rubble-1-1.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 240 B |
BIN
core/assets-raw/sprites/blocks/extra/rubble-2-0.png
Normal file
BIN
core/assets-raw/sprites/blocks/extra/rubble-2-0.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 393 B |
BIN
core/assets-raw/sprites/blocks/extra/rubble-2-1.png
Normal file
BIN
core/assets-raw/sprites/blocks/extra/rubble-2-1.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 416 B |
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Before Width: | Height: | Size: 104 KiB After Width: | Height: | Size: 106 KiB |
@ -1,7 +1,7 @@
|
||||
#Autogenerated file. Do not modify.
|
||||
#Wed Apr 18 21:31:08 EDT 2018
|
||||
#Thu Apr 19 19:06:19 EDT 2018
|
||||
version=release
|
||||
androidBuildCode=1049
|
||||
androidBuildCode=1073
|
||||
name=Mindustry
|
||||
code=3.5
|
||||
build=custom build
|
||||
|
@ -147,7 +147,7 @@ public class Vars{
|
||||
public static final EntityGroup<Shield> shieldGroup = Entities.addGroup(Shield.class, false);
|
||||
public static final EntityGroup<EffectEntity> effectGroup = Entities.addGroup(EffectEntity.class, false);
|
||||
public static final EntityGroup<EffectEntity> groundEffectGroup = Entities.addGroup(EffectEntity.class, false);
|
||||
public static final EntityGroup<Puddle> groundItemGroup = Entities.addGroup(Puddle.class, false);
|
||||
public static final EntityGroup<Puddle> puddleGroup = Entities.addGroup(Puddle.class, false);
|
||||
public static final EntityGroup<Fire> airItemGroup = Entities.addGroup(Fire.class, false);
|
||||
public static final EntityGroup<BaseUnit>[] unitGroups = new EntityGroup[Team.values().length];
|
||||
|
||||
|
@ -44,7 +44,12 @@ public class Items {
|
||||
}
|
||||
},
|
||||
silicon = new Item("silicon", Color.valueOf("53565c")),
|
||||
plastic = new Item("plastic", Color.valueOf("e9ead3")),
|
||||
plastic = new Item("plastic", Color.valueOf("e9ead3")){
|
||||
{
|
||||
flammability = 0.2f;
|
||||
explosiveness = 0.1f;
|
||||
}
|
||||
},
|
||||
densealloy = new Item("densealloy", Color.valueOf("b4d5c7")),
|
||||
biomatter = new Item("biomatter", Color.valueOf("648b55")) {
|
||||
{
|
||||
|
@ -126,7 +126,7 @@ public class Logic extends Module {
|
||||
for(EntityGroup group : unitGroups){
|
||||
Entities.update(group);
|
||||
}
|
||||
Entities.update(groundItemGroup);
|
||||
Entities.update(puddleGroup);
|
||||
Entities.update(tileGroup);
|
||||
Entities.update(airItemGroup);
|
||||
Entities.update(shieldGroup);
|
||||
|
@ -23,6 +23,7 @@ import io.anuke.mindustry.entities.units.BaseUnit;
|
||||
import io.anuke.mindustry.game.Team;
|
||||
import io.anuke.mindustry.graphics.BlockRenderer;
|
||||
import io.anuke.mindustry.graphics.Layer;
|
||||
import io.anuke.mindustry.graphics.MinimapRenderer;
|
||||
import io.anuke.mindustry.graphics.Shaders;
|
||||
import io.anuke.mindustry.input.InputHandler;
|
||||
import io.anuke.mindustry.input.PlaceMode;
|
||||
@ -57,6 +58,7 @@ public class Renderer extends RendererModule{
|
||||
private Array<Callable> shieldDraws = new Array<>();
|
||||
private Rectangle rect = new Rectangle(), rect2 = new Rectangle();
|
||||
private BlockRenderer blocks = new BlockRenderer();
|
||||
private MinimapRenderer minimap = new MinimapRenderer();
|
||||
|
||||
public Renderer() {
|
||||
Lines.setCircleVertices(14);
|
||||
@ -203,17 +205,13 @@ public class Renderer extends RendererModule{
|
||||
Graphics.surface(pixelSurface, false);
|
||||
else
|
||||
batch.begin();
|
||||
|
||||
//clears shield surface
|
||||
//Graphics.surface(shieldSurface);
|
||||
//Graphics.surface();
|
||||
|
||||
drawPadding();
|
||||
|
||||
blocks.drawFloor();
|
||||
|
||||
Entities.draw(groundItemGroup);
|
||||
Entities.draw(groundEffectGroup);
|
||||
Entities.draw(puddleGroup);
|
||||
|
||||
blocks.processBlocks();
|
||||
blocks.drawBlocks(Layer.overlay);
|
||||
@ -275,6 +273,10 @@ public class Renderer extends RendererModule{
|
||||
background.dispose();
|
||||
}
|
||||
|
||||
public MinimapRenderer minimap() {
|
||||
return minimap;
|
||||
}
|
||||
|
||||
public void clearTiles(){
|
||||
blocks.clearTiles();
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package io.anuke.mindustry.core;
|
||||
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.math.GridPoint2;
|
||||
import com.badlogic.gdx.math.MathUtils;
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
@ -13,7 +14,6 @@ import io.anuke.mindustry.world.Tile;
|
||||
import io.anuke.mindustry.world.WorldGenerator;
|
||||
import io.anuke.ucore.entities.Entities;
|
||||
import io.anuke.ucore.modules.Module;
|
||||
import io.anuke.ucore.util.Log;
|
||||
import io.anuke.ucore.util.Mathf;
|
||||
import io.anuke.ucore.util.Tmp;
|
||||
|
||||
@ -157,7 +157,6 @@ public class World extends Module{
|
||||
}
|
||||
|
||||
public void loadMap(Map map, int seed){
|
||||
Log.info("--BEGIN LOAD MAP--");
|
||||
this.currentMap = map;
|
||||
this.seed = seed;
|
||||
|
||||
|
@ -8,6 +8,7 @@ import io.anuke.mindustry.content.StatusEffects;
|
||||
import io.anuke.mindustry.content.fx.EnvironmentFx;
|
||||
import io.anuke.mindustry.entities.SerializableEntity;
|
||||
import io.anuke.mindustry.entities.TileEntity;
|
||||
import io.anuke.mindustry.world.Block;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
import io.anuke.ucore.core.Effects;
|
||||
import io.anuke.ucore.core.Timers;
|
||||
@ -27,6 +28,7 @@ public class Fire extends TimedEntity implements SerializableEntity, Poolable{
|
||||
|
||||
private int loadedPosition = -1;
|
||||
private Tile tile;
|
||||
private Block block;
|
||||
private float baseFlammability = -1, puddleFlammability;
|
||||
|
||||
/**Start a fire on the tile. If there already is a file there, refreshes its lifetime..*/
|
||||
@ -67,8 +69,9 @@ public class Fire extends TimedEntity implements SerializableEntity, Poolable{
|
||||
time += Timers.delta()*8;
|
||||
}
|
||||
|
||||
if (baseFlammability < 0){
|
||||
if (baseFlammability < 0 || block != tile.block()){
|
||||
baseFlammability = tile.block().getFlammability(tile);
|
||||
block = tile.block();
|
||||
}
|
||||
|
||||
if(damage) {
|
||||
|
@ -27,7 +27,7 @@ import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import static io.anuke.mindustry.Vars.groundItemGroup;
|
||||
import static io.anuke.mindustry.Vars.puddleGroup;
|
||||
import static io.anuke.mindustry.Vars.world;
|
||||
|
||||
public class Puddle extends Entity implements SerializableEntity, Poolable{
|
||||
@ -60,6 +60,16 @@ public class Puddle extends Entity implements SerializableEntity, Poolable{
|
||||
}
|
||||
|
||||
private static void deposit(Tile tile, Tile source, Liquid liquid, float amount, int generation){
|
||||
if(tile.floor().liquid){
|
||||
reactPuddle(tile.floor().liquidDrop, liquid, amount, tile, tile.worldx(), tile.worldy());
|
||||
|
||||
if(generation == 0 && Timers.get(tile, "ripple", 50)){
|
||||
Effects.effect(BlockFx.ripple, tile.floor().liquidDrop.color,
|
||||
(tile.worldx() + source.worldx())/2f, (tile.worldy() + source.worldy())/2f);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
Puddle p = map.get(tile.packedPosition());
|
||||
if(p == null){
|
||||
Puddle puddle = Pools.obtain(Puddle.class);
|
||||
@ -76,28 +86,29 @@ public class Puddle extends Entity implements SerializableEntity, Poolable{
|
||||
Effects.effect(BlockFx.ripple, p.liquid.color, (tile.worldx() + source.worldx())/2f, (tile.worldy() + source.worldy())/2f);
|
||||
}
|
||||
}else{
|
||||
reactPuddle(p, liquid, amount);
|
||||
p.amount -= reactPuddle(p.liquid, liquid, amount, p.tile, p.x, p.y);
|
||||
}
|
||||
}
|
||||
|
||||
private static void reactPuddle(Puddle p, Liquid liquid, float amount){
|
||||
if((p.liquid.flammability > 0.3f && liquid.temperature > 0.7f) ||
|
||||
(liquid.flammability > 0.3f && p.liquid.temperature > 0.7f)){ //flammable liquid + hot liquid
|
||||
Fire.create(p.tile);
|
||||
private static float reactPuddle(Liquid pliquid, Liquid liquid, float amount, Tile tile, float x, float y){
|
||||
if((pliquid.flammability > 0.3f && liquid.temperature > 0.7f) ||
|
||||
(liquid.flammability > 0.3f && pliquid.temperature > 0.7f)){ //flammable liquid + hot liquid
|
||||
Fire.create(tile);
|
||||
if(Mathf.chance(0.006 * amount)){
|
||||
new Fireball(p.x, p.y, p.liquid.flameColor, Mathf.random(360f)).add();
|
||||
new Fireball(x, y, pliquid.flameColor, Mathf.random(360f)).add();
|
||||
}
|
||||
}else if(p.liquid.temperature > 0.7f && liquid.temperature < 0.55f){ //cold liquid poured onto hot puddle
|
||||
}else if(pliquid.temperature > 0.7f && liquid.temperature < 0.55f){ //cold liquid poured onto hot puddle
|
||||
if(Mathf.chance(0.5f * amount)){
|
||||
Effects.effect(EnvironmentFx.steam, p.x, p.y);
|
||||
Effects.effect(EnvironmentFx.steam, x, y);
|
||||
}
|
||||
p.amount -= 0.1f * amount;
|
||||
}else if(liquid.temperature > 0.7f && p.liquid.temperature < 0.55f){ //hot liquid poured onto cold puddle
|
||||
return - 0.1f * amount;
|
||||
}else if(liquid.temperature > 0.7f && pliquid.temperature < 0.55f){ //hot liquid poured onto cold puddle
|
||||
if(Mathf.chance(0.8f * amount)){
|
||||
Effects.effect(EnvironmentFx.steam, p.x, p.y);
|
||||
Effects.effect(EnvironmentFx.steam, x, y);
|
||||
}
|
||||
p.amount -= 0.4f * amount;
|
||||
return - 0.4f * amount;
|
||||
}
|
||||
return 0f;
|
||||
}
|
||||
|
||||
/**Deserialization use only!*/
|
||||
@ -209,6 +220,6 @@ public class Puddle extends Entity implements SerializableEntity, Poolable{
|
||||
|
||||
@Override
|
||||
public Puddle add() {
|
||||
return add(groundItemGroup);
|
||||
return add(puddleGroup);
|
||||
}
|
||||
}
|
||||
|
35
core/src/io/anuke/mindustry/entities/effect/Rubble.java
Normal file
35
core/src/io/anuke/mindustry/entities/effect/Rubble.java
Normal file
@ -0,0 +1,35 @@
|
||||
package io.anuke.mindustry.entities.effect;
|
||||
|
||||
import com.badlogic.gdx.graphics.Color;
|
||||
import io.anuke.ucore.entities.TimedEntity;
|
||||
import io.anuke.ucore.graphics.Draw;
|
||||
import io.anuke.ucore.util.Mathf;
|
||||
|
||||
import static io.anuke.mindustry.Vars.groundEffectGroup;
|
||||
|
||||
public class Rubble extends TimedEntity{
|
||||
private static final Color color = Color.valueOf("52504e");
|
||||
private int size;
|
||||
|
||||
public static void create(float x, float y, int size){
|
||||
Rubble rubble = new Rubble();
|
||||
rubble.size = size;
|
||||
rubble.set(x + Mathf.range(1), y + Mathf.range(1)).add();
|
||||
}
|
||||
|
||||
private Rubble(){
|
||||
lifetime = 7000f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(){
|
||||
Draw.color(color.r, color.g, color.b, 1f-Mathf.curve(fin(), 0.98f));
|
||||
Draw.rect("rubble-" + size + "-" + Mathf.randomSeed(id, 0, 1), x, y, Mathf.randomSeed(id, 0, 4) * 90);
|
||||
Draw.color();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Rubble add() {
|
||||
return add(groundEffectGroup);
|
||||
}
|
||||
}
|
@ -54,9 +54,6 @@ public class BlockRenderer{
|
||||
requestidx = 0;
|
||||
lastLayer = null;
|
||||
|
||||
int crangex = (int) (camera.viewportWidth / (chunksize * tilesize)) + 1;
|
||||
int crangey = (int) (camera.viewportHeight / (chunksize * tilesize)) + 1;
|
||||
|
||||
int rangex = (int) (camera.viewportWidth * camera.zoom / tilesize / 2)+2;
|
||||
int rangey = (int) (camera.viewportHeight * camera.zoom / tilesize / 2)+2;
|
||||
|
||||
@ -99,7 +96,8 @@ public class BlockRenderer{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//TODO this actually isn't necessary
|
||||
Draw.color(0, 0, 0, 0.15f);
|
||||
Graphics.flushSurface();
|
||||
Draw.color();
|
||||
|
@ -65,10 +65,10 @@ public enum DrawLayer {
|
||||
}
|
||||
|
||||
protected void beginShader(){
|
||||
renderer.getBlocks().endFloor();
|
||||
//renderer.getBlocks().endFloor();
|
||||
renderer.waterSurface.getBuffer().begin();
|
||||
Graphics.clear(Color.CLEAR);
|
||||
renderer.getBlocks().beginFloor();
|
||||
//renderer.getBlocks().beginFloor();
|
||||
}
|
||||
|
||||
public void endShader(Shader shader){
|
||||
|
@ -113,9 +113,8 @@ public class FloorRenderer {
|
||||
}
|
||||
|
||||
public void beginDraw(){
|
||||
Gdx.gl.glEnable(GL20.GL_BLEND);
|
||||
|
||||
Core.atlas.getTextures().first().bind();
|
||||
Gdx.gl.glEnable(GL20.GL_BLEND);
|
||||
|
||||
program.begin();
|
||||
program.setUniformMatrix("u_projTrans", Core.camera.combined);
|
||||
@ -187,6 +186,7 @@ public class FloorRenderer {
|
||||
|
||||
int idx = chunk.idx;
|
||||
TextureRegion region = new TextureRegion(Core.atlas.getTextures().first());
|
||||
IntArray edges = new IntArray();
|
||||
|
||||
for(int tilex = cx * chunksize; tilex < (cx + 1) * chunksize; tilex++){
|
||||
for(int tiley = cy * chunksize; tiley < (cy + 1) * chunksize; tiley++){
|
||||
@ -194,9 +194,9 @@ public class FloorRenderer {
|
||||
if(tile == null) continue;
|
||||
|
||||
if(tile.floor().drawLayer == layer && tile.block().drawLayer != DrawLayer.walls){
|
||||
idx = drawFloor(tile, idx, region, vertices, false);
|
||||
}else if(tile.floor().drawLayer.ordinal() < layer.ordinal() && tile.block().drawLayer != DrawLayer.walls){
|
||||
idx = drawFloor(tile, idx, region, vertices, true);
|
||||
idx = drawFloor(tile, idx, region, vertices, false, edges);
|
||||
}else if(tile.floor().drawLayer.ordinal() < layer.ordinal() && tile.block().drawLayer != DrawLayer.walls && layer != DrawLayer.walls){
|
||||
idx = drawFloor(tile, idx, region, vertices, true, edges);
|
||||
}
|
||||
|
||||
if(tile.block().drawLayer == layer && layer == DrawLayer.walls){
|
||||
@ -214,7 +214,7 @@ public class FloorRenderer {
|
||||
chunk.idx = idx;
|
||||
}
|
||||
|
||||
private int drawFloor(Tile tile, int idx, TextureRegion region, float[] vertices, boolean edgesOnly){
|
||||
private int drawFloor(Tile tile, int idx, TextureRegion region, float[] vertices, boolean edgesOnly, IntArray edges){
|
||||
MathUtils.random.setSeed(tile.id());
|
||||
Block block = tile.floor();
|
||||
|
||||
|
29
core/src/io/anuke/mindustry/graphics/MinimapRenderer.java
Normal file
29
core/src/io/anuke/mindustry/graphics/MinimapRenderer.java
Normal file
@ -0,0 +1,29 @@
|
||||
package io.anuke.mindustry.graphics;
|
||||
|
||||
import com.badlogic.gdx.graphics.Pixmap;
|
||||
import com.badlogic.gdx.graphics.Texture;
|
||||
import com.sun.media.jfxmediaimpl.MediaDisposer.Disposable;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
|
||||
public class MinimapRenderer implements Disposable{
|
||||
private Pixmap pixmap;
|
||||
private Texture texture;
|
||||
|
||||
public Texture getTexture(){
|
||||
return texture;
|
||||
}
|
||||
|
||||
public void reset(){
|
||||
|
||||
}
|
||||
|
||||
public void updated(Tile tile){
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispose() {
|
||||
pixmap.dispose();
|
||||
texture.dispose();
|
||||
}
|
||||
}
|
@ -33,6 +33,7 @@ public class BlockConfigFragment implements Fragment {
|
||||
public void showConfig(Tile tile){
|
||||
configTile = tile;
|
||||
|
||||
table.setVisible(true);
|
||||
table.clear();
|
||||
tile.block().buildTable(tile, table);
|
||||
table.pack();
|
||||
|
@ -11,6 +11,7 @@ import io.anuke.mindustry.entities.TileEntity;
|
||||
import io.anuke.mindustry.entities.Unit;
|
||||
import io.anuke.mindustry.entities.effect.DamageArea;
|
||||
import io.anuke.mindustry.entities.effect.Puddle;
|
||||
import io.anuke.mindustry.entities.effect.Rubble;
|
||||
import io.anuke.mindustry.graphics.DrawLayer;
|
||||
import io.anuke.mindustry.graphics.Layer;
|
||||
import io.anuke.mindustry.graphics.Palette;
|
||||
@ -264,6 +265,7 @@ public class Block extends BaseBlock {
|
||||
}
|
||||
|
||||
DamageArea.dynamicExplosion(x, y, flammability, explosiveness, power, tilesize * size/2f, tempColor);
|
||||
Rubble.create(tile.drawx(), tile.drawy(), size);
|
||||
}
|
||||
|
||||
/**Returns the flammability of the tile. Used for fire calculations.
|
||||
|
Loading…
Reference in New Issue
Block a user