Minor tweaks
This commit is contained in:
@@ -105,7 +105,7 @@ public class EntityProcess extends BaseProcessor{
|
|||||||
//add utility methods to interface
|
//add utility methods to interface
|
||||||
for(Smethod method : component.methods()){
|
for(Smethod method : component.methods()){
|
||||||
//skip private methods, those are for internal use.
|
//skip private methods, those are for internal use.
|
||||||
if(method.is(Modifier.PRIVATE)) continue;
|
if(method.isAny(Modifier.PRIVATE, Modifier.STATIC)) continue;
|
||||||
|
|
||||||
//keep track of signatures used to prevent dupes
|
//keep track of signatures used to prevent dupes
|
||||||
signatures.add(method.e.toString());
|
signatures.add(method.e.toString());
|
||||||
@@ -353,6 +353,8 @@ public class EntityProcess extends BaseProcessor{
|
|||||||
MethodSpec.Builder resetBuilder = MethodSpec.methodBuilder("reset").addModifiers(Modifier.PUBLIC);
|
MethodSpec.Builder resetBuilder = MethodSpec.methodBuilder("reset").addModifiers(Modifier.PUBLIC);
|
||||||
for(FieldSpec spec : builder.fieldSpecs){
|
for(FieldSpec spec : builder.fieldSpecs){
|
||||||
Svar variable = specVariables.get(spec);
|
Svar variable = specVariables.get(spec);
|
||||||
|
if(variable.isAny(Modifier.STATIC, Modifier.FINAL)) continue;
|
||||||
|
|
||||||
if(spec.type.isPrimitive()){
|
if(spec.type.isPrimitive()){
|
||||||
//set to primitive default
|
//set to primitive default
|
||||||
resetBuilder.addStatement("$L = $L", spec.name, varInitializers.containsKey(variable) ? varInitializers.get(variable) : getDefault(spec.type.toString()));
|
resetBuilder.addStatement("$L = $L", spec.name, varInitializers.containsKey(variable) ? varInitializers.get(variable) : getDefault(spec.type.toString()));
|
||||||
|
|||||||
@@ -11,6 +11,13 @@ public class Svar extends Selement<VariableElement>{
|
|||||||
super(e);
|
super(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isAny(Modifier... mods){
|
||||||
|
for(Modifier m : mods){
|
||||||
|
if(is(m)) return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean is(Modifier mod){
|
public boolean is(Modifier mod){
|
||||||
return e.getModifiers().contains(mod);
|
return e.getModifiers().contains(mod);
|
||||||
}
|
}
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 1.9 MiB After Width: | Height: | Size: 125 KiB |
@@ -1,8 +1,142 @@
|
|||||||
package mindustry.entities.def;
|
package mindustry.entities.def;
|
||||||
|
|
||||||
|
import arc.*;
|
||||||
|
import arc.math.*;
|
||||||
|
import arc.math.geom.*;
|
||||||
|
import arc.struct.*;
|
||||||
|
import arc.util.*;
|
||||||
|
import mindustry.*;
|
||||||
import mindustry.annotations.Annotations.*;
|
import mindustry.annotations.Annotations.*;
|
||||||
|
import mindustry.content.*;
|
||||||
|
import mindustry.entities.*;
|
||||||
|
import mindustry.game.EventType.*;
|
||||||
|
import mindustry.game.*;
|
||||||
import mindustry.gen.*;
|
import mindustry.gen.*;
|
||||||
|
import mindustry.world.*;
|
||||||
|
|
||||||
|
import static mindustry.Vars.*;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
abstract class FireComp implements Timedc{
|
abstract class FireComp implements Timedc, Posc, Firec{
|
||||||
|
private static final IntMap<Firec> map = new IntMap<>();
|
||||||
|
private static final float baseLifetime = 1000f, spreadChance = 0.05f, fireballChance = 0.07f;
|
||||||
|
|
||||||
|
transient float time, lifetime, x, y;
|
||||||
|
|
||||||
|
Tile tile;
|
||||||
|
private Block block;
|
||||||
|
private float baseFlammability = -1, puddleFlammability;
|
||||||
|
|
||||||
|
//TODO move these somewhere else.
|
||||||
|
/** Start a fire on the tile. If there already is a file there, refreshes its lifetime. */
|
||||||
|
public static void create(Tile tile){
|
||||||
|
if(net.client() || tile == null) return; //not clientside.
|
||||||
|
|
||||||
|
Firec fire = map.get(tile.pos());
|
||||||
|
|
||||||
|
if(fire == null){
|
||||||
|
fire = FireEntity.create();
|
||||||
|
fire.tile(tile);
|
||||||
|
fire.lifetime(baseLifetime);
|
||||||
|
fire.set(tile.worldx(), tile.worldy());
|
||||||
|
fire.add();
|
||||||
|
map.put(tile.pos(), fire);
|
||||||
|
}else{
|
||||||
|
fire.lifetime(baseLifetime);
|
||||||
|
fire.time(0f);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean has(int x, int y){
|
||||||
|
if(!Structs.inBounds(x, y, world.width(), world.height()) || !map.containsKey(Pos.get(x, y))){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
Firec fire = map.get(Pos.get(x, y));
|
||||||
|
return fire.isAdded() && fire.fin() < 1f && fire.tile() != null && fire.tile().x == x && fire.tile().y == y;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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(tile != null && map.containsKey(tile.pos())){
|
||||||
|
Firec fire = map.get(tile.pos());
|
||||||
|
fire.time(fire.time() + intensity * Time.delta());
|
||||||
|
if(fire.time() >= fire.lifetime()){
|
||||||
|
Events.fire(Trigger.fireExtinguish);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void update(){
|
||||||
|
if(Mathf.chance(0.1 * Time.delta())){
|
||||||
|
Fx.fire.at(x + Mathf.range(4f), y + Mathf.range(4f));
|
||||||
|
}
|
||||||
|
|
||||||
|
if(Mathf.chance(0.05 * Time.delta())){
|
||||||
|
Fx.fireSmoke.at(x + Mathf.range(4f), y + Mathf.range(4f));
|
||||||
|
}
|
||||||
|
|
||||||
|
if(Mathf.chance(0.001 * Time.delta())){
|
||||||
|
Sounds.fire.at(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
time = Mathf.clamp(time + Time.delta(), 0, lifetime());
|
||||||
|
map.put(tile.pos(), this);
|
||||||
|
|
||||||
|
if(Vars.net.client()){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(time >= lifetime() || tile == null){
|
||||||
|
remove();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Tilec entity = tile.link().entity;
|
||||||
|
boolean damage = entity != null;
|
||||||
|
|
||||||
|
float flammability = baseFlammability + puddleFlammability;
|
||||||
|
|
||||||
|
if(!damage && flammability <= 0){
|
||||||
|
time += Time.delta() * 8;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(baseFlammability < 0 || block != tile.block()){
|
||||||
|
baseFlammability = tile.block().getFlammability(tile);
|
||||||
|
block = tile.block();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(damage){
|
||||||
|
lifetime += Mathf.clamp(flammability / 8f, 0f, 0.6f) * Time.delta();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(flammability > 1f && Mathf.chance(spreadChance * Time.delta() * Mathf.clamp(flammability / 5f, 0.3f, 2f))){
|
||||||
|
Point2 p = Geometry.d4[Mathf.random(3)];
|
||||||
|
Tile other = world.tile(tile.x + p.x, tile.y + p.y);
|
||||||
|
create(other);
|
||||||
|
|
||||||
|
if(Mathf.chance(fireballChance * Time.delta() * Mathf.clamp(flammability / 10f))){
|
||||||
|
Bullets.fireball.createNet(Team.derelict, x, y, Mathf.random(360f), -1f, 1, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(Mathf.chance(0.1 * Time.delta())){
|
||||||
|
//TODO implement
|
||||||
|
//Puddle p = Puddle.getPuddle(tile);
|
||||||
|
//if(p != null){
|
||||||
|
// puddleFlammability = p.getFlammability() / 3f;
|
||||||
|
//}else{
|
||||||
|
puddleFlammability = 0;
|
||||||
|
//}
|
||||||
|
|
||||||
|
if(damage){
|
||||||
|
entity.damage(0.4f);
|
||||||
|
}
|
||||||
|
Damage.damageUnits(null, tile.worldx(), tile.worldy(), tilesize, 3f,
|
||||||
|
unit -> !unit.isFlying() && !unit.isImmune(StatusEffects.burning),
|
||||||
|
unit -> unit.apply(StatusEffects.burning, 60 * 5));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ package mindustry.graphics;
|
|||||||
|
|
||||||
import arc.graphics.*;
|
import arc.graphics.*;
|
||||||
import arc.math.*;
|
import arc.math.*;
|
||||||
import arc.util.*;
|
|
||||||
import arc.util.noise.*;
|
import arc.util.noise.*;
|
||||||
|
|
||||||
/** Generates a scorch pixmap based on parameters. Thread safe, unless multiple scorch generators are running in parallel. */
|
/** Generates a scorch pixmap based on parameters. Thread safe, unless multiple scorch generators are running in parallel. */
|
||||||
@@ -20,9 +19,7 @@ public class ScorchGenerator{
|
|||||||
double dst = Mathf.dst(x, y, size/2, size/2) / (size / 2f);
|
double dst = Mathf.dst(x, y, size/2, size/2) / (size / 2f);
|
||||||
double scaled = Math.abs(dst - 0.5f) * 5f + add;
|
double scaled = Math.abs(dst - 0.5f) * 5f + add;
|
||||||
scaled -= noise(Angles.angle(x, y, size/2, size/2))*nscl;
|
scaled -= noise(Angles.angle(x, y, size/2, size/2))*nscl;
|
||||||
boolean present = scaled < 1.5f;
|
if(scaled < 1.5f) pix.draw(x, y, color);
|
||||||
|
|
||||||
pix.draw(x, y, Tmp.c1.set(Color.white).a(Mathf.clamp(1f + 1.5f - (float)scaled)));
|
|
||||||
});
|
});
|
||||||
|
|
||||||
return pix;
|
return pix;
|
||||||
|
|||||||
Reference in New Issue
Block a user