Basic documentation for fire/puddles
This commit is contained in:
@@ -15,17 +15,25 @@ import io.anuke.ucore.util.Mathf;
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
|
||||
public class Fire extends TimedEntity {
|
||||
private static GridMap<Fire> map = new GridMap<>();
|
||||
private static final GridMap<Fire> map = new GridMap<>();
|
||||
private static final float baseLifetime = 1000f;
|
||||
|
||||
private Tile tile;
|
||||
private float baseFlammability = -1, puddleFlammability;
|
||||
|
||||
/**Start a fire on the tile. If there already is a file there, refreshes its lifetime..*/
|
||||
public static void create(Tile tile){
|
||||
if(!map.containsKey(tile.x, tile.y)){
|
||||
new Fire(tile).add();
|
||||
Fire fire = map.get(tile.x, tile.y);
|
||||
|
||||
if(fire == null){
|
||||
map.put(tile.x, tile.y, new Fire(tile).add());
|
||||
}else{
|
||||
fire.lifetime = baseLifetime;
|
||||
fire.time = 0f;
|
||||
}
|
||||
}
|
||||
|
||||
/**Attempts to extinguish a fire by shortening its life. If there is no fire here, does nothing.*/
|
||||
public static void extinguish(Tile tile, float intensity){
|
||||
if(map.containsKey(tile.x, tile.y)){
|
||||
map.get(tile.x, tile.y).time += intensity * Timers.delta();
|
||||
@@ -34,7 +42,7 @@ public class Fire extends TimedEntity {
|
||||
|
||||
private Fire(Tile tile){
|
||||
this.tile = tile;
|
||||
lifetime = 1000f;
|
||||
lifetime = baseLifetime;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -90,11 +98,6 @@ public class Fire extends TimedEntity {
|
||||
return add(effectGroup);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void added() {
|
||||
map.put(tile.x, tile.y, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removed() {
|
||||
map.remove(tile.x, tile.y);
|
||||
|
||||
@@ -36,14 +36,17 @@ public class Puddle extends Entity {
|
||||
private int generation;
|
||||
private float accepting;
|
||||
|
||||
/**Deposists a puddle between tile and source.*/
|
||||
public static void deposit(Tile tile, Tile source, Liquid liquid, float amount){
|
||||
deposit(tile, source, liquid, amount, 0);
|
||||
}
|
||||
|
||||
/**Deposists a puddle at a tile.*/
|
||||
public static void deposit(Tile tile, Liquid liquid, float amount){
|
||||
deposit(tile, tile, liquid, amount, 0);
|
||||
}
|
||||
|
||||
/**Returns the puddle on the specified tile. May return null.*/
|
||||
public static Puddle getPuddle(Tile tile){
|
||||
return map.get(tile.x, tile.y);
|
||||
}
|
||||
|
||||
@@ -243,6 +243,8 @@ public class Block extends BaseBlock {
|
||||
DamageArea.dynamicExplosion(x, y, flammability, explosiveness, power, tilesize * size/2f, tempColor);
|
||||
}
|
||||
|
||||
/**Returns the flammability of the tile. Used for fire calculations.
|
||||
* Takes flammability of floor liquid into account.*/
|
||||
public float getFlammability(Tile tile){
|
||||
if(!hasInventory || tile.entity == null){
|
||||
if(tile.floor().liquid && !solid){
|
||||
|
||||
Reference in New Issue
Block a user