Feature re-implementations

This commit is contained in:
Anuken
2020-02-08 21:54:41 -05:00
parent 5169e197b6
commit e23119e330
10 changed files with 53 additions and 23 deletions

View File

@@ -4,7 +4,7 @@ package mindustry.ctype;
public enum ContentType{
item,
block,
mech,
mech_UNUSED,
bullet,
liquid,
status,

View File

@@ -17,7 +17,7 @@ class AllEntities{
@EntityDef(value = {GroundEffectc.class, Childc.class}, pooled = true)
class GroundEffectDef{}
@EntityDef({Decalc.class})
@EntityDef(value = {Decalc.class}, pooled = true)
class DecalDef{}
@EntityDef({Playerc.class})

View File

@@ -42,35 +42,35 @@ public class Effect{
}
public void at(Position pos){
Effects.createEffect(this, pos.getX(), pos.getY(), 0, Color.white, null);
Effects.create(this, pos.getX(), pos.getY(), 0, Color.white, null);
}
public void at(Position pos, float rotation){
Effects.createEffect(this, pos.getX(), pos.getY(), rotation, Color.white, null);
Effects.create(this, pos.getX(), pos.getY(), rotation, Color.white, null);
}
public void at(float x, float y){
Effects.createEffect(this, x, y, 0, Color.white, null);
Effects.create(this, x, y, 0, Color.white, null);
}
public void at(float x, float y, float rotation){
Effects.createEffect(this, x, y, rotation, Color.white, null);
Effects.create(this, x, y, rotation, Color.white, null);
}
public void at(float x, float y, float rotation, Color color){
Effects.createEffect(this, x, y, rotation, color, null);
Effects.create(this, x, y, rotation, color, null);
}
public void at(float x, float y, Color color){
Effects.createEffect(this, x, y, 0, color, null);
Effects.create(this, x, y, 0, color, null);
}
public void at(float x, float y, float rotation, Color color, Object data){
Effects.createEffect(this, x, y, rotation, color, data);
Effects.create(this, x, y, rotation, color, data);
}
public void at(float x, float y, float rotation, Object data){
Effects.createEffect(this, x, y, rotation, Color.white, data);
Effects.create(this, x, y, rotation, Color.white, data);
}
public void render(int id, Color color, float life, float rotation, float x, float y, Object data){

View File

@@ -2,11 +2,13 @@ package mindustry.entities;
import arc.*;
import arc.graphics.*;
import arc.graphics.g2d.*;
import arc.math.*;
import arc.math.geom.*;
import arc.util.*;
import mindustry.content.*;
import mindustry.gen.*;
import mindustry.graphics.*;
import static mindustry.Vars.*;
@@ -32,7 +34,7 @@ public class Effects{
shake(intensity, duration, loc.getX(), loc.getY());
}
public static void createEffect(Effect effect, float x, float y, float rotation, Color color, Object data){
public static void create(Effect effect, float x, float y, float rotation, Color color, Object data){
if(headless || effect == Fx.none) return;
if(Core.settings.getBool("effects")){
Rect view = Core.camera.bounds(Tmp.r1);
@@ -51,4 +53,25 @@ public class Effects{
}
}
}
public static void decal(TextureRegion region, float x, float y, float rotation, float lifetime, Color color){
if(headless || region == null) return;
Decalc decal = DecalEntity.create();
decal.set(x, y);
decal.rotation(rotation);
decal.lifetime(lifetime);
decal.color().set(color);
decal.region(region);
decal.add();
}
public static void rubble(float x, float y, int blockSize){
if(headless) return;
TextureRegion region = Core.atlas.find("rubble-" + blockSize + "-" + Mathf.random(0, 1));
if(!Core.atlas.isFound(region)) return;
decal(region, x, y, Mathf.random(0, 4) * 90, 3600, Pal.rubble);
}
}

View File

@@ -2,18 +2,22 @@ package mindustry.entities.def;
import arc.graphics.*;
import arc.graphics.g2d.*;
import arc.math.*;
import mindustry.annotations.Annotations.*;
import mindustry.gen.*;
@Component
abstract class DecalComp implements Drawc, Timedc, Rotc, Posc, DrawLayerFloorc{
transient float x, y, rotation;
Color color = new Color(1, 1, 1, 1);
TextureRegion region;
@Override
public void drawFloor(){
Draw.color(color);
Draw.rect(region, x(), y(), rotation());
Draw.alpha(1f - Mathf.curve(fin(), 0.98f));
Draw.rect(region, x, y, rotation);
Draw.color();
}

View File

@@ -640,8 +640,7 @@ public class Block extends BlockStorage{
Damage.dynamicExplosion(x, y, flammability, explosiveness * 3.5f, power, tilesize * size / 2f, Pal.darkFlame);
if(!tile.floor().solid && !tile.floor().isLiquid){
//TODO rubble decal
//RubbleDecal.create(tile.drawx(), tile.drawy(), size);
Effects.rubble(tile.drawx(), tile.drawy(), size);
}
}

View File

@@ -9,6 +9,7 @@ import arc.util.ArcAnnotate.*;
import arc.util.*;
import mindustry.annotations.Annotations.*;
import mindustry.content.*;
import mindustry.entities.*;
import mindustry.game.EventType.*;
import mindustry.game.*;
import mindustry.gen.*;
@@ -156,8 +157,7 @@ public class BuildBlock extends Block{
Fx.blockExplosionSmoke.at(tile);
if(!tile.floor().solid && !tile.floor().isLiquid){
//TODO implement
// RubbleDecal.create(tile.drawx(), tile.drawy(), size);
Effects.rubble(tile.drawx(), tile.drawy(), size);
}
}