Decal cleanup
This commit is contained in:
@@ -170,7 +170,7 @@ public class Control implements ApplicationListener, Loadable{
|
|||||||
|
|
||||||
app.post(() -> ui.hudfrag.showLand());
|
app.post(() -> ui.hudfrag.showLand());
|
||||||
renderer.zoomIn(Fx.coreLand.lifetime);
|
renderer.zoomIn(Fx.coreLand.lifetime);
|
||||||
app.post(() -> Fx.coreLand.at(core.x, core.y, 0, core.block));
|
app.post(() -> Fx.coreLand.at(core.getX(), core.getY(), 0, core.getBlock()));
|
||||||
Time.run(Fx.coreLand.lifetime, () -> {
|
Time.run(Fx.coreLand.lifetime, () -> {
|
||||||
Fx.launch.at(core);
|
Fx.launch.at(core);
|
||||||
Effects.shake(5f, 5f, core);
|
Effects.shake(5f, 5f, core);
|
||||||
@@ -178,8 +178,8 @@ public class Control implements ApplicationListener, Loadable{
|
|||||||
});
|
});
|
||||||
|
|
||||||
Events.on(UnitDestroyEvent.class, e -> {
|
Events.on(UnitDestroyEvent.class, e -> {
|
||||||
if(e.unit instanceof BaseUnit && world.isZone()){
|
if(world.isZone()){
|
||||||
data.unlockContent(((BaseUnit)e.unit).getType());
|
data.unlockContent(e.unit.getType());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -259,7 +259,7 @@ public class Control implements ApplicationListener, Loadable{
|
|||||||
state.rules.zone = zone;
|
state.rules.zone = zone;
|
||||||
for(Tilec core : state.teams.playerCores()){
|
for(Tilec core : state.teams.playerCores()){
|
||||||
for(ItemStack stack : zone.getStartingItems()){
|
for(ItemStack stack : zone.getStartingItems()){
|
||||||
core.items.add(stack.item, stack.amount);
|
core.getItems().add(stack.item, stack.amount);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
state.set(State.playing);
|
state.set(State.playing);
|
||||||
@@ -308,11 +308,11 @@ public class Control implements ApplicationListener, Loadable{
|
|||||||
state.rules.zone = zone;
|
state.rules.zone = zone;
|
||||||
for(Tilec core : state.teams.playerCores()){
|
for(Tilec core : state.teams.playerCores()){
|
||||||
for(ItemStack stack : zone.getStartingItems()){
|
for(ItemStack stack : zone.getStartingItems()){
|
||||||
core.items.add(stack.item, stack.amount);
|
core.getItems().add(stack.item, stack.amount);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Tilec core = state.teams.playerCores().first();
|
Tilec core = state.teams.playerCores().first();
|
||||||
core.items.clear();
|
core.getItems().clear();
|
||||||
|
|
||||||
logic.play();
|
logic.play();
|
||||||
state.rules.waveTimer = false;
|
state.rules.waveTimer = false;
|
||||||
@@ -437,7 +437,7 @@ public class Control implements ApplicationListener, Loadable{
|
|||||||
if(world.isZone()){
|
if(world.isZone()){
|
||||||
for(Tilec tile : state.teams.cores(player.getTeam())){
|
for(Tilec tile : state.teams.cores(player.getTeam())){
|
||||||
for(Item item : content.items()){
|
for(Item item : content.items()){
|
||||||
if(tile.items.has(item)){
|
if(tile.getItems().has(item)){
|
||||||
data.unlockContent(item);
|
data.unlockContent(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -210,7 +210,8 @@ public class Logic implements ApplicationListener{
|
|||||||
|
|
||||||
if(!state.is(State.menu)){
|
if(!state.is(State.menu)){
|
||||||
if(!net.client()){
|
if(!net.client()){
|
||||||
state.enemies = unitGroup.count(b -> b.getTeam() == state.rules.waveTeam && b.countsAsEnemy());
|
//TODO
|
||||||
|
//state.enemies = unitGroup.count(b -> b.getTeam() == state.rules.waveTeam && b.countsAsEnemy());
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!state.isPaused()){
|
if(!state.isPaused()){
|
||||||
@@ -226,6 +227,8 @@ public class Logic implements ApplicationListener{
|
|||||||
runWave();
|
runWave();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//TODO update groups
|
||||||
|
/*
|
||||||
if(!headless){
|
if(!headless){
|
||||||
effectGroup.update();
|
effectGroup.update();
|
||||||
groundEffectGroup.update();
|
groundEffectGroup.update();
|
||||||
@@ -254,7 +257,7 @@ public class Logic implements ApplicationListener{
|
|||||||
if(!state.isEditor()){
|
if(!state.isEditor()){
|
||||||
//bulletGroup
|
//bulletGroup
|
||||||
collisions.collideGroups(bulletGroup, unitGroup);
|
collisions.collideGroups(bulletGroup, unitGroup);
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!net.client() && !world.isInvalidMap() && !state.isEditor() && state.rules.canGameOver){
|
if(!net.client() && !world.isInvalidMap() && !state.isEditor() && state.rules.canGameOver){
|
||||||
|
|||||||
@@ -801,6 +801,18 @@ public class EntityComps{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Component
|
||||||
|
abstract class DecalComp implements Drawc, Timedc, Rotc, Posc{
|
||||||
|
Color color = new Color(1, 1, 1, 1);
|
||||||
|
TextureRegion region;
|
||||||
|
|
||||||
|
public void draw(){
|
||||||
|
Draw.color(color);
|
||||||
|
Draw.rect(region, getX(), getY(), getRotation());
|
||||||
|
Draw.color();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
abstract class DrawLightComp implements Drawc{
|
abstract class DrawLightComp implements Drawc{
|
||||||
void drawLight(){}
|
void drawLight(){}
|
||||||
|
|||||||
@@ -13,4 +13,7 @@ class EntityDefs{
|
|||||||
|
|
||||||
@EntityDef({EffectComp.class})
|
@EntityDef({EffectComp.class})
|
||||||
class EffectDef{}
|
class EffectDef{}
|
||||||
|
|
||||||
|
@EntityDef({DecalComp.class})
|
||||||
|
class DecalDef{}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,33 +0,0 @@
|
|||||||
package mindustry.entities.effect;
|
|
||||||
|
|
||||||
import arc.graphics.g2d.Draw;
|
|
||||||
import arc.math.Mathf;
|
|
||||||
import mindustry.entities.EntityGroup;
|
|
||||||
import mindustry.graphics.Pal;
|
|
||||||
|
|
||||||
import static mindustry.Vars.groundEffectGroup;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Class for creating block rubble on the ground.
|
|
||||||
*/
|
|
||||||
public abstract class Decal extends TimedEntity implements DrawTrait{
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public float lifetime(){
|
|
||||||
return 3600;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void draw(){
|
|
||||||
Draw.color(Pal.rubble.r, Pal.rubble.g, Pal.rubble.b, 1f - Mathf.curve(fin(), 0.98f));
|
|
||||||
drawDecal();
|
|
||||||
Draw.color();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public EntityGroup targetGroup(){
|
|
||||||
return groundEffectGroup;
|
|
||||||
}
|
|
||||||
|
|
||||||
abstract void drawDecal();
|
|
||||||
}
|
|
||||||
@@ -1,46 +0,0 @@
|
|||||||
package mindustry.entities.effect;
|
|
||||||
|
|
||||||
import arc.Core;
|
|
||||||
import arc.graphics.g2d.Draw;
|
|
||||||
import arc.graphics.g2d.TextureRegion;
|
|
||||||
import arc.math.Mathf;
|
|
||||||
|
|
||||||
import static mindustry.Vars.headless;
|
|
||||||
|
|
||||||
public class RubbleDecal extends Decal{
|
|
||||||
private TextureRegion region;
|
|
||||||
|
|
||||||
/** Creates a rubble effect at a position. Provide a block size to use. */
|
|
||||||
public static void create(float x, float y, int size){
|
|
||||||
if(headless) return;
|
|
||||||
|
|
||||||
RubbleDecal decal = new RubbleDecal();
|
|
||||||
decal.region = Core.atlas.find("rubble-" + size + "-" + Mathf.randomSeed(decal.id, 0, 1));
|
|
||||||
|
|
||||||
if(!Core.atlas.isFound(decal.region)){
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
decal.set(x, y);
|
|
||||||
decal.add();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public float lifetime(){
|
|
||||||
return 8200f;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void drawDecal(){
|
|
||||||
if(!Core.atlas.isFound(region)){
|
|
||||||
remove();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
Draw.rect(region, x, y, Mathf.randomSeed(id, 0, 4) * 90);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public float drawSize(){
|
|
||||||
return region.getWidth() * 3f;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,49 +0,0 @@
|
|||||||
package mindustry.entities.effect;
|
|
||||||
|
|
||||||
import arc.Core;
|
|
||||||
import arc.graphics.g2d.Draw;
|
|
||||||
import arc.graphics.g2d.TextureRegion;
|
|
||||||
import arc.math.Angles;
|
|
||||||
import arc.math.Mathf;
|
|
||||||
import mindustry.world.Tile;
|
|
||||||
|
|
||||||
import static mindustry.Vars.headless;
|
|
||||||
import static mindustry.Vars.world;
|
|
||||||
|
|
||||||
public class ScorchDecal extends Decal{
|
|
||||||
private static final int scorches = 5;
|
|
||||||
private static final TextureRegion[] regions = new TextureRegion[scorches];
|
|
||||||
|
|
||||||
public static void create(float x, float y){
|
|
||||||
if(headless) return;
|
|
||||||
|
|
||||||
if(regions[0] == null || regions[0].getTexture().isDisposed()){
|
|
||||||
for(int i = 0; i < regions.length; i++){
|
|
||||||
regions[i] = Core.atlas.find("scorch" + (i + 1));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Tile tile = world.tileWorld(x, y);
|
|
||||||
|
|
||||||
if(tile == null || tile.floor().liquidDrop != null) return;
|
|
||||||
|
|
||||||
ScorchDecal decal = new ScorchDecal();
|
|
||||||
decal.set(x, y);
|
|
||||||
decal.add();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void drawDecal(){
|
|
||||||
for(int i = 0; i < 3; i++){
|
|
||||||
TextureRegion region = regions[Mathf.randomSeed(id - i, 0, scorches - 1)];
|
|
||||||
float rotation = Mathf.randomSeed(id + i, 0, 360);
|
|
||||||
float space = 1.5f + Mathf.randomSeed(id + i + 1, 0, 20) / 10f;
|
|
||||||
Draw.rect(region,
|
|
||||||
x + Angles.trnsx(rotation, space),
|
|
||||||
y + Angles.trnsy(rotation, space) + region.getHeight() / 2f * Draw.scl,
|
|
||||||
region.getWidth() * Draw.scl,
|
|
||||||
region.getHeight() * Draw.scl,
|
|
||||||
region.getWidth() / 2f * Draw.scl, 0, rotation - 90);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -221,7 +221,7 @@ public class PlacementFragment extends Fragment{
|
|||||||
|
|
||||||
button.update(() -> { //color unplacable things gray
|
button.update(() -> { //color unplacable things gray
|
||||||
Tilec core = player.getClosestCore();
|
Tilec core = player.getClosestCore();
|
||||||
Color color = state.rules.infiniteResources || (core != null && (core.items.has(block.requirements, state.rules.buildCostMultiplier) || state.rules.infiniteResources)) ? Color.white : Color.gray;
|
Color color = state.rules.infiniteResources || (core != null && (core.getItems().has(block.requirements, state.rules.buildCostMultiplier) || state.rules.infiniteResources)) ? Color.white : Color.gray;
|
||||||
button.forEach(elem -> elem.setColor(color));
|
button.forEach(elem -> elem.setColor(color));
|
||||||
button.setChecked(control.input.block == block);
|
button.setChecked(control.input.block == block);
|
||||||
|
|
||||||
@@ -311,7 +311,7 @@ public class PlacementFragment extends Fragment{
|
|||||||
Tilec core = player.getClosestCore();
|
Tilec core = player.getClosestCore();
|
||||||
if(core == null || state.rules.infiniteResources) return "*/*";
|
if(core == null || state.rules.infiniteResources) return "*/*";
|
||||||
|
|
||||||
int amount = core.items.get(stack.item);
|
int amount = core.getItems().get(stack.item);
|
||||||
int stackamount = Math.round(stack.amount * state.rules.buildCostMultiplier);
|
int stackamount = Math.round(stack.amount * state.rules.buildCostMultiplier);
|
||||||
String color = (amount < stackamount / 2f ? "[red]" : amount < stackamount ? "[accent]" : "[white]");
|
String color = (amount < stackamount / 2f ? "[red]" : amount < stackamount ? "[accent]" : "[white]");
|
||||||
|
|
||||||
|
|||||||
@@ -228,7 +228,7 @@ public class BuildBlock extends Block{
|
|||||||
setConstruct(previous, cblock);
|
setConstruct(previous, cblock);
|
||||||
}
|
}
|
||||||
|
|
||||||
float maxProgress = core == null ? amount : checkRequired(core.items, amount, false);
|
float maxProgress = core == null ? amount : checkRequired(core.getItems(), amount, false);
|
||||||
|
|
||||||
for(int i = 0; i < cblock.requirements.length; i++){
|
for(int i = 0; i < cblock.requirements.length; i++){
|
||||||
int reqamount = Math.round(state.rules.buildCostMultiplier * cblock.requirements[i].amount);
|
int reqamount = Math.round(state.rules.buildCostMultiplier * cblock.requirements[i].amount);
|
||||||
@@ -236,7 +236,7 @@ public class BuildBlock extends Block{
|
|||||||
totalAccumulator[i] = Math.min(totalAccumulator[i] + reqamount * maxProgress, reqamount);
|
totalAccumulator[i] = Math.min(totalAccumulator[i] + reqamount * maxProgress, reqamount);
|
||||||
}
|
}
|
||||||
|
|
||||||
maxProgress = core == null ? maxProgress : checkRequired(core.items, maxProgress, true);
|
maxProgress = core == null ? maxProgress : checkRequired(core.getItems(), maxProgress, true);
|
||||||
|
|
||||||
progress = Mathf.clamp(progress + maxProgress);
|
progress = Mathf.clamp(progress + maxProgress);
|
||||||
builderID = builder.getId();
|
builderID = builder.getId();
|
||||||
|
|||||||
Reference in New Issue
Block a user