More components, less entities

This commit is contained in:
Anuken
2020-02-02 23:38:16 -05:00
parent f2f31120a0
commit f937cb30f0
77 changed files with 586 additions and 570 deletions

View File

@@ -1,20 +1,16 @@
package mindustry.ai;
import arc.Events;
import arc.struct.Array;
import arc.func.Floatc2;
import arc.math.Angles;
import arc.math.Mathf;
import arc.util.Time;
import arc.util.Tmp;
import mindustry.content.Blocks;
import mindustry.content.Fx;
import mindustry.entities.Damage;
import mindustry.entities.Effects;
import arc.*;
import arc.func.*;
import arc.math.*;
import arc.struct.*;
import arc.util.*;
import mindustry.content.*;
import mindustry.entities.*;
import mindustry.entities.type.*;
import mindustry.game.EventType.WorldLoadEvent;
import mindustry.game.SpawnGroup;
import mindustry.world.Tile;
import mindustry.game.EventType.*;
import mindustry.game.*;
import mindustry.world.*;
import static mindustry.Vars.*;
@@ -77,7 +73,7 @@ public class WaveSpawner{
eachGroundSpawn((spawnX, spawnY, doShockwave) -> {
if(doShockwave){
Time.run(20f, () -> Effects.effect(Fx.spawnShockwave, spawnX, spawnY, state.rules.dropZoneRadius));
Time.run(20f, () -> Fx.spawnShockwave.at(spawnX, spawnY, state.rules.dropZoneRadius));
Time.run(40f, () -> Damage.damage(state.rules.waveTeam, spawnX, spawnY, state.rules.dropZoneRadius, 99999999f, true));
}
});
@@ -142,10 +138,10 @@ public class WaveSpawner{
}
private void spawnEffect(BaseUnit unit){
Effects.effect(Fx.unitSpawn, unit.x, unit.y, 0f, unit);
Fx.unitSpawn.at(unit.x, unit.y, 0f, unit);
Time.run(30f, () -> {
unit.add();
Effects.effect(Fx.spawn, unit);
Fx.spawn.at(unit);
});
}

View File

@@ -431,11 +431,11 @@ public class Bullets implements ContentList{
}
if(Mathf.chance(0.1 * Time.delta())){
Effects.effect(Fx.fireballsmoke, b.x, b.y);
Fx.fireballsmoke.at(b.x, b.y);
}
if(Mathf.chance(0.1 * Time.delta())){
Effects.effect(Fx.ballfire, b.x, b.y);
Fx.ballfire.at(b.x, b.y);
}
}
};
@@ -519,7 +519,7 @@ public class Bullets implements ContentList{
@Override
public void hit(Bullet b, float hitx, float hity){
Effects.effect(hitEffect, colors[2], hitx, hity);
hitEffect.at(colors[2], hitx, hity);
if(Mathf.chance(0.4)){
Fire.create(world.tileWorld(hitx + Mathf.range(5f), hity + Mathf.range(5f)));
}

View File

@@ -6,7 +6,7 @@ import arc.graphics.g2d.*;
import arc.math.*;
import arc.util.*;
import mindustry.ctype.ContentList;
import mindustry.entities.Effects.*;
import mindustry.entities.*;
import mindustry.entities.effect.GroundEffectEntity.*;
import mindustry.entities.type.*;
import mindustry.graphics.*;

View File

@@ -75,9 +75,9 @@ public class Mechs implements ContentList{
if(player.timer.get(Player.timerAbility, healReload)){
if(indexer.eachBlock(player, healRange, other -> other.entity.damaged(), other -> {
other.entity.healBy(other.entity.maxHealth() * healPercent / 100f);
Effects.effect(Fx.healBlockFull, Pal.heal, other.drawx(), other.drawy(), other.block().size);
Fx.healBlockFull.at(other.drawx(), other.drawy(), other.block().size, Pal.heal);
})){
Effects.effect(Fx.healWave, player);
Fx.healWave.at(player);
}
}
}
@@ -193,14 +193,14 @@ public class Mechs implements ContentList{
Units.nearby(player.getTeam(), player.x, player.y, healRange, unit -> {
if(unit.health < unit.maxHealth()){
Effects.effect(Fx.heal, unit);
Fx.heal.at(unit);
wasHealed = true;
}
unit.healBy(healAmount);
});
if(wasHealed){
Effects.effect(Fx.healWave, player);
Fx.healWave.at(player);
}
}
}
@@ -316,10 +316,10 @@ public class Mechs implements ContentList{
indexer.eachBlock(player, effectRange, other -> other.entity.damaged(), other -> {
other.entity.applyBoost(1.5f, effectDuration);
Effects.effect(Fx.healBlockFull, Pal.heal, other.drawx(), other.drawy(), other.block().size);
Fx.healBlockFull.at(other.drawx(), other.drawy(), other.block().size, Pal.heal);
});
Effects.effect(Fx.overdriveWave, player);
Fx.overdriveWave.at(player);
}
}
};
@@ -367,7 +367,7 @@ public class Mechs implements ContentList{
public void update(Player player){
float scl = scld(player);
if(Mathf.chance(Time.delta() * (0.15 * scl))){
Effects.effect(Fx.hitLancer, Pal.lancerLaser, player.x, player.y);
Fx.hitLancer.at(Pal.lancerLaser, player.x, player.y);
Lightning.create(player.getTeam(), Pal.lancerLaser, 10f * Vars.state.rules.playerDamageMultiplier,
player.x + player.velocity().x, player.y + player.velocity().y, player.rotation, 14);
}

View File

@@ -24,7 +24,7 @@ public class StatusEffects implements ContentList{
opposite(wet,freezing);
trans(tarred, ((unit, time, newTime, result) -> {
unit.damage(1f);
Effects.effect(Fx.burning, unit.x + Mathf.range(unit.getSize() / 2f), unit.y + Mathf.range(unit.getSize() / 2f));
Fx.burning.at(unit.x + Mathf.range(unit.getSize() / 2f), unit.y + Mathf.range(unit.getSize() / 2f));
result.set(this, Math.min(time + newTime, 300f));
}));
});

View File

@@ -169,9 +169,9 @@ public class Control implements ApplicationListener, Loadable{
app.post(() -> ui.hudfrag.showLand());
renderer.zoomIn(Fx.coreLand.lifetime);
app.post(() -> Effects.effect(Fx.coreLand, core.x, core.y, 0, core.block));
app.post(() -> Fx.coreLand.at(core.x, core.y, 0, core.block));
Time.run(Fx.coreLand.lifetime, () -> {
Effects.effect(Fx.launch, core);
Fx.launch.at(core);
Effects.shake(5f, 5f, core);
});
});

View File

@@ -177,7 +177,7 @@ public class Logic implements ApplicationListener{
}
for(TileEntity tile : state.teams.playerCores()){
Effects.effect(Fx.launch, tile);
Fx.launch.at(tile);
}
if(world.getZone() != null){

View File

@@ -13,9 +13,9 @@ import mindustry.annotations.Annotations.*;
import mindustry.core.GameState.*;
import mindustry.ctype.*;
import mindustry.entities.*;
import mindustry.entities.traits.BuilderTrait.*;
import mindustry.entities.traits.*;
import mindustry.entities.type.*;
import mindustry.entities.units.*;
import mindustry.game.EventType.*;
import mindustry.game.*;
import mindustry.gen.*;
@@ -281,12 +281,12 @@ public class NetClient implements ApplicationListener{
@Remote(variants = Variant.both, unreliable = true)
public static void onEffect(Effect effect, float x, float y, float rotation, Color color){
Effects.effect(effect, color, x, y, rotation);
effect.at(color, x, y, rotation);
}
@Remote(variants = Variant.both)
public static void onEffectReliable(Effect effect, float x, float y, float rotation, Color color){
Effects.effect(effect, color, x, y, rotation);
effect.at(color, x, y, rotation);
}*/
@Remote(variants = Variant.both)

View File

@@ -12,9 +12,9 @@ import mindustry.annotations.Annotations.*;
import mindustry.content.*;
import mindustry.core.GameState.*;
import mindustry.entities.*;
import mindustry.entities.traits.BuilderTrait.*;
import mindustry.entities.traits.*;
import mindustry.entities.type.*;
import mindustry.entities.units.*;
import mindustry.net.Administration;
import mindustry.game.EventType.*;
import mindustry.game.*;

View File

@@ -10,12 +10,8 @@ import arc.math.*;
import arc.math.geom.*;
import arc.scene.ui.layout.*;
import arc.util.*;
import arc.util.pooling.*;
import mindustry.content.*;
import mindustry.core.GameState.*;
import mindustry.entities.*;
import mindustry.entities.effect.*;
import mindustry.entities.effect.GroundEffectEntity.*;
import mindustry.entities.traits.*;
import mindustry.entities.type.*;
import mindustry.game.EventType.*;
@@ -48,51 +44,14 @@ public class Renderer implements ApplicationListener{
camera = new Camera();
Shaders.init();
Effects.setScreenShakeProvider((intensity, duration) -> {
shakeIntensity = Math.max(intensity, shakeIntensity);
shaketime = Math.max(shaketime, duration);
});
Effects.setEffectProvider((effect, color, x, y, rotation, data) -> {
if(effect == Fx.none) return;
if(Core.settings.getBool("effects")){
Rect view = camera.bounds(rect);
Rect pos = rect2.setSize(effect.size).setCenter(x, y);
if(view.overlaps(pos)){
if(!(effect instanceof GroundEffect)){
EffectEntity entity = Pools.obtain(EffectEntity.class, EffectEntity::new);
entity.effect = effect;
entity.color.set(color);
entity.rotation = rotation;
entity.data = data;
entity.id++;
entity.set(x, y);
if(data instanceof Entity){
entity.setParent((Entity)data);
}
effectGroup.add(entity);
}else{
GroundEffectEntity entity = Pools.obtain(GroundEffectEntity.class, GroundEffectEntity::new);
entity.effect = effect;
entity.color.set(color);
entity.rotation = rotation;
entity.id++;
entity.data = data;
entity.set(x, y);
if(data instanceof Entity){
entity.setParent((Entity)data);
}
groundEffectGroup.add(entity);
}
}
}
});
clearColor = new Color(0f, 0f, 0f, 1f);
}
public void shake(float intensity, float duration){
shakeIntensity = Math.max(shakeIntensity, intensity);
shaketime = Math.max(shaketime, duration);
}
@Override
public void init(){
if(settings.getBool("bloom")){

View File

@@ -47,21 +47,21 @@ public class Damage{
int f = i;
Time.run(i * 2f, () -> {
Damage.damage(x, y, Mathf.clamp(radius + explosiveness, 0, 50f) * ((f + 1f) / waves), explosiveness / 2f);
Effects.effect(Fx.blockExplosionSmoke, x + Mathf.range(radius), y + Mathf.range(radius));
Fx.blockExplosionSmoke.at(x + Mathf.range(radius), y + Mathf.range(radius));
});
}
if(explosiveness > 15f){
Effects.effect(Fx.shockwave, x, y);
Fx.shockwave.at(x, y);
}
if(explosiveness > 30f){
Effects.effect(Fx.bigShockwave, x, y);
Fx.bigShockwave.at(x, y);
}
float shake = Math.min(explosiveness / 4f + 3f, 9f);
Effects.shake(shake, shake, x, y);
Effects.effect(Fx.dynamicExplosion, x, y, radius / 8f);
Fx.dynamicExplosion.at(x, y, radius / 8f);
}
public static void createIncend(float x, float y, float range, int amount){
@@ -136,7 +136,7 @@ public class Damage{
Vec2 vec = Geometry.raycastRect(x, y, x2, y2, other);
if(vec != null){
Effects.effect(effect, vec.x, vec.y);
effect.at(vec.x, vec.y);
e.collision(hitter, vec.x, vec.y);
hitter.collision(e, vec.x, vec.y);
}

View File

@@ -0,0 +1,96 @@
package mindustry.entities;
import arc.func.*;
import arc.graphics.*;
import arc.graphics.g2d.*;
import arc.math.*;
import arc.math.geom.*;
public class Effect{
private static final EffectContainer container = new EffectContainer();
private static int lastid = 0;
public final int id;
public final Cons<EffectContainer> renderer;
public final float lifetime;
/** Clip size. */
public float size;
public Effect(float life, float clipsize, Cons<EffectContainer> renderer){
this.id = lastid++;
this.lifetime = life;
this.renderer = renderer;
this.size = clipsize;
}
public Effect(float life, Cons<EffectContainer> renderer){
this(life, 28f, renderer);
}
public void at(Position pos){
Effects.createEffect(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);
}
public void at(float x, float y){
Effects.createEffect(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);
}
public void at(float x, float y, float rotation, Color color){
Effects.createEffect(this, x, y, rotation, color, null);
}
public void at(float x, float y, float rotation, Color color, Object data){
Effects.createEffect(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);
}
public void render(int id, Color color, float life, float rotation, float x, float y, Object data){
container.set(id, color, life, lifetime, rotation, x, y, data);
renderer.get(container);
Draw.reset();
}
public static class EffectContainer implements Scaled{
public float x, y, time, lifetime, rotation;
public Color color;
public int id;
public Object data;
private EffectContainer innerContainer;
public void set(int id, Color color, float life, float lifetime, float rotation, float x, float y, Object data){
this.x = x;
this.y = y;
this.color = color;
this.time = life;
this.lifetime = lifetime;
this.id = id;
this.rotation = rotation;
this.data = data;
}
public void scaled(float lifetime, Cons<EffectContainer> cons){
if(innerContainer == null) innerContainer = new EffectContainer();
if(time <= lifetime){
innerContainer.set(id, color, time, lifetime, rotation, x, y, data);
cons.get(innerContainer);
}
}
@Override
public float fin(){
return time / lifetime;
}
}
}

View File

@@ -1,90 +1,23 @@
package mindustry.entities;
import arc.*;
import arc.func.*;
import arc.graphics.*;
import arc.graphics.g2d.*;
import arc.math.*;
import arc.math.geom.*;
import arc.struct.*;
import arc.util.*;
import arc.util.pooling.*;
import mindustry.content.*;
import mindustry.entities.type.*;
import static mindustry.Vars.*;
public class Effects{
private static final EffectContainer container = new EffectContainer();
private static Array<Effect> effects = new Array<>();
private static ScreenshakeProvider shakeProvider;
private static float shakeFalloff = 10000f;
private static EffectProvider provider = (effect, color, x, y, rotation, data) -> {
EffectEntity entity = Pools.obtain(EffectEntity.class, EffectEntity::new);
entity.effect = effect;
entity.color = color;
entity.rotation = rotation;
entity.data = data;
entity.set(x, y);
entity.add();
};
public static void setEffectProvider(EffectProvider prov){
provider = prov;
}
public static void setScreenShakeProvider(ScreenshakeProvider provider){
shakeProvider = provider;
}
public static void renderEffect(int id, Effect render, Color color, float life, float rotation, float x, float y, Object data){
container.set(id, color, life, render.lifetime, rotation, x, y, data);
render.draw.render(container);
Draw.reset();
}
public static Effect getEffect(int id){
if(id >= effects.size || id < 0)
throw new IllegalArgumentException("The effect with ID \"" + id + "\" does not exist!");
return effects.get(id);
}
public static Array<Effect> all(){
return effects;
}
public static void effect(Effect effect, float x, float y, float rotation){
provider.createEffect(effect, Color.white, x, y, rotation, null);
}
public static void effect(Effect effect, float x, float y){
effect(effect, x, y, 0);
}
public static void effect(Effect effect, Color color, float x, float y){
provider.createEffect(effect, color, x, y, 0f, null);
}
public static void effect(Effect effect, Position loc){
provider.createEffect(effect, Color.white, loc.getX(), loc.getY(), 0f, null);
}
public static void effect(Effect effect, Color color, float x, float y, float rotation){
provider.createEffect(effect, color, x, y, rotation, null);
}
public static void effect(Effect effect, Color color, float x, float y, float rotation, Object data){
provider.createEffect(effect, color, x, y, rotation, data);
}
public static void effect(Effect effect, float x, float y, float rotation, Object data){
provider.createEffect(effect, Color.white, x, y, rotation, data);
}
/** Default value is 1000. Higher numbers mean more powerful shake (less falloff). */
public static void setShakeFalloff(float falloff){
shakeFalloff = falloff;
}
private static final float shakeFalloff = 10000f;
private static void shake(float intensity, float duration){
if(shakeProvider == null) throw new RuntimeException("Screenshake provider is null! Set it first.");
shakeProvider.accept(intensity, duration);
if(!headless){
renderer.shake(intensity, duration);
}
}
public static void shake(float intensity, float duration, float x, float y){
@@ -100,68 +33,26 @@ public class Effects{
shake(intensity, duration, loc.getX(), loc.getY());
}
public interface ScreenshakeProvider{
void accept(float intensity, float duration);
}
public static void createEffect(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);
Rect pos = Tmp.r2.setSize(effect.size).setCenter(x, y);
public static class Effect{
private static int lastid = 0;
public final int id;
public final EffectRenderer draw;
public final float lifetime;
/** Clip size. */
public float size;
public Effect(float life, float clipsize, EffectRenderer draw){
this.id = lastid++;
this.lifetime = life;
this.draw = draw;
this.size = clipsize;
effects.add(this);
}
public Effect(float life, EffectRenderer draw){
this(life, 28f, draw);
}
}
public static class EffectContainer implements Scaled{
public float x, y, time, lifetime, rotation;
public Color color;
public int id;
public Object data;
private EffectContainer innerContainer;
public void set(int id, Color color, float life, float lifetime, float rotation, float x, float y, Object data){
this.x = x;
this.y = y;
this.color = color;
this.time = life;
this.lifetime = lifetime;
this.id = id;
this.rotation = rotation;
this.data = data;
}
public void scaled(float lifetime, Cons<EffectContainer> cons){
if(innerContainer == null) innerContainer = new EffectContainer();
if(time <= lifetime){
innerContainer.set(id, color, time, lifetime, rotation, x, y, data);
cons.get(innerContainer);
if(view.overlaps(pos)){
EffectEntity entity = Pools.obtain(EffectEntity.class, EffectEntity::new);
entity.effect = effect;
entity.color.set(color);
entity.rotation = rotation;
entity.data = data;
entity.id++;
entity.set(x, y);
//if(data instanceof Entity){
// entity.setParent((Entity)data);
//}
//TODO ground effect
//effectGroup.add(entity);
}
}
@Override
public float fin(){
return time / lifetime;
}
}
public interface EffectProvider{
void createEffect(Effect effect, Color color, float x, float y, float rotation, Object data);
}
public interface EffectRenderer{
void render(EffectContainer effect);
}
}

View File

@@ -3,7 +3,6 @@ package mindustry.entities;
import arc.struct.Array;
import arc.math.Mathf;
import arc.math.geom.*;
import mindustry.entities.traits.Entity;
import mindustry.world.Tile;
import static mindustry.Vars.tilesize;

View File

@@ -3,7 +3,6 @@ package mindustry.entities.bullet;
import arc.graphics.g2d.*;
import mindustry.content.*;
import mindustry.entities.*;
import mindustry.entities.Effects.*;
import mindustry.entities.type.Bullet;
import mindustry.gen.*;
@@ -29,7 +28,7 @@ public class ArtilleryBulletType extends BasicBulletType{
super.update(b);
if(b.timer.get(0, 3 + b.fslope() * 2f)){
Effects.effect(trailEffect, backColor, b.x, b.y, b.fslope() * 4f);
trailEffect.at(b.x, b.y, b.fslope() * 4f, backColor);
}
}

View File

@@ -110,7 +110,7 @@ public abstract class BulletType extends Content{
}
public void hit(Bullet b, float x, float y){
Effects.effect(hitEffect, x, y, b.rot());
hitEffect.at(x, y, b.rot());
hitSound.at(b);
Effects.shake(hitShake, hitShake, b);
@@ -133,7 +133,7 @@ public abstract class BulletType extends Content{
}
public void despawned(Bullet b){
Effects.effect(despawnEffect, b.x, b.y, b.rot());
despawnEffect.at(b.x, b.y, b.rot());
hitSound.at(b);
if(fragBullet != null || splashDamageRadius > 0){

View File

@@ -3,7 +3,6 @@ package mindustry.entities.bullet;
import arc.graphics.*;
import arc.graphics.g2d.*;
import mindustry.content.*;
import mindustry.entities.*;
import mindustry.entities.type.*;
import mindustry.graphics.*;
import mindustry.world.*;
@@ -49,7 +48,7 @@ public class HealBulletType extends BulletType{
tile = tile.link();
if(tile.entity != null && tile.getTeam() == b.getTeam() && !(tile.block() instanceof BuildBlock)){
Effects.effect(Fx.healBlockFull, Pal.heal, tile.drawx(), tile.drawy(), tile.block().size);
Fx.healBlockFull.at(tile.drawx(), tile.drawy(), tile.block().size, Pal.heal);
tile.entity.healBy(healPercent / 100f * tile.entity.maxHealth());
}
}

View File

@@ -67,7 +67,7 @@ public class LiquidBulletType extends BulletType{
@Override
public void hit(Bullet b, float hitx, float hity){
Effects.effect(hitEffect, liquid.color, hitx, hity);
hitEffect.at(liquid.color, hitx, hity);
Puddle.deposit(world.tileWorld(hitx, hity), liquid, puddleSize);
if(liquid.temperature <= 0.5f && liquid.flammability < 0.3f){

View File

@@ -5,7 +5,6 @@ import arc.graphics.g2d.Draw;
import arc.math.Angles;
import arc.math.Mathf;
import mindustry.content.Fx;
import mindustry.entities.Effects;
import mindustry.entities.type.Bullet;
import mindustry.graphics.Pal;
import mindustry.world.blocks.distribution.MassDriver.DriverBulletData;
@@ -94,7 +93,7 @@ public class MassDriverBolt extends BulletType{
int amountDropped = Mathf.random(0, data.items[i]);
if(amountDropped > 0){
float angle = b.rot() + Mathf.range(100f);
Effects.effect(Fx.dropItem, Color.white, b.x, b.y, angle, content.item(i));
Fx.dropItem.at(b.x, b.y, angle, Color.white, content.item(i));
}
}
}

View File

@@ -4,7 +4,6 @@ import arc.graphics.Color;
import arc.math.Mathf;
import arc.util.Time;
import mindustry.content.Fx;
import mindustry.entities.Effects;
import mindustry.entities.type.Bullet;
import mindustry.gen.*;
import mindustry.graphics.Pal;
@@ -32,7 +31,7 @@ public class MissileBulletType extends BasicBulletType{
super.update(b);
if(Mathf.chance(Time.delta() * 0.2)){
Effects.effect(Fx.missileTrail, trailColor, b.x, b.y, 2f);
Fx.missileTrail.at(b.x, b.y, 2f, trailColor);
}
if(weaveMag > 0){

View File

@@ -6,6 +6,7 @@ import arc.math.*;
import arc.math.geom.*;
import arc.struct.Bits;
import arc.struct.*;
import arc.util.ArcAnnotate.*;
import arc.util.*;
import arc.util.pooling.*;
import mindustry.*;
@@ -13,8 +14,9 @@ import mindustry.annotations.Annotations.*;
import mindustry.content.*;
import mindustry.ctype.*;
import mindustry.entities.*;
import mindustry.entities.Effects.*;
import mindustry.entities.bullet.*;
import mindustry.entities.def.EntityComps.MinerComp.*;
import mindustry.entities.effect.*;
import mindustry.entities.traits.*;
import mindustry.entities.type.*;
import mindustry.entities.units.*;
@@ -22,11 +24,15 @@ import mindustry.game.*;
import mindustry.gen.*;
import mindustry.net.*;
import mindustry.type.*;
import mindustry.world.*;
import mindustry.world.blocks.BuildBlock.*;
import java.io.*;
import static mindustry.Vars.content;
import static arc.math.Mathf.dst;
import static mindustry.Vars.*;
@SuppressWarnings("unused")
public class EntityComps{
@Component({HealthComp.class, VelComp.class, StatusComp.class, TeamComp.class, ItemsComp.class})
@@ -38,7 +44,7 @@ public class EntityComps{
Entityc owner;
}
@Component({TimedComp.class, DamageComp.class, Hitboxc.class})
@Component({TimedComp.class, DamageComp.class, HitboxComp.class})
class BulletComp{
BulletType bullet;
@@ -58,8 +64,8 @@ public class EntityComps{
}
@Component
abstract class DamageComp{
abstract float getDamage();
class DamageComp{
native float getDamage();
}
@Component
@@ -146,12 +152,18 @@ public class EntityComps{
}
@Component
class TeamComp{
abstract class TeamComp{
transient float x, y;
Team team = Team.sharded;
public @Nullable TileEntity getClosestCore(){
return state.teams.closestCore(x, y, team);
}
}
@Component({RotComp.class, PosComp.class})
static class WeaponsComp{
abstract static class WeaponsComp implements Teamc{
transient float x, y, rotation;
/** 1 */
@@ -164,7 +176,7 @@ public class EntityComps{
/** weapon mount array, never null */
WeaponMount[] mounts = {};
public void init(UnitDef def){
void init(UnitDef def){
mounts = new WeaponMount[def.weapons.size];
for(int i = 0; i < mounts.length; i++){
mounts[i] = new WeaponMount(def.weapons.get(i));
@@ -172,12 +184,12 @@ public class EntityComps{
}
/** Aim at something. This will make all mounts point at it. */
public void aim(Unit unit, float x, float y){
Tmp.v1.set(x, y).sub(unit.x, unit.y);
void aim(Unit unit, float x, float y){
Tmp.v1.set(x, y).sub(this.x, this.y);
if(Tmp.v1.len() < minAimDst) Tmp.v1.setLength(minAimDst);
x = Tmp.v1.x + unit.x;
y = Tmp.v1.y + unit.y;
x = Tmp.v1.x + this.x;
y = Tmp.v1.y + this.y;
for(WeaponMount mount : mounts){
mount.aimX = x;
@@ -186,7 +198,7 @@ public class EntityComps{
}
/** Update shooting and rotation for this unit. */
public void update(Unit unit){
void update(Unit unit){
for(WeaponMount mount : mounts){
Weapon weapon = mount.weapon;
mount.reload -= Time.delta();
@@ -196,8 +208,8 @@ public class EntityComps{
//rotate if applicable
if(weapon.rotate){
float axisXOffset = weapon.mirror ? 0f : weapon.x;
float axisX = unit.x + Angles.trnsx(rotation, axisXOffset, weapon.y),
axisY = unit.y + Angles.trnsy(rotation, axisXOffset, weapon.y);
float axisX = this.x + Angles.trnsx(rotation, axisXOffset, weapon.y),
axisY = this.y + Angles.trnsy(rotation, axisXOffset, weapon.y);
mount.rotation = Angles.moveToward(mount.rotation, Angles.angle(axisX, axisY, mount.aimX, mount.aimY), weapon.rotateSpeed);
}
@@ -210,13 +222,13 @@ public class EntityComps{
//m a t h
float weaponRotation = rotation + (weapon.rotate ? mount.rotation : 0);
float mountX = unit.x + Angles.trnsx(rotation, weapon.x * i, weapon.y),
mountY = unit.y + Angles.trnsy(rotation, weapon.x * i, weapon.y);
float mountX = this.x + Angles.trnsx(rotation, weapon.x * i, weapon.y),
mountY = this.y + Angles.trnsy(rotation, weapon.x * i, weapon.y);
float shootX = mountX + Angles.trnsx(weaponRotation, weapon.shootX * i, weapon.shootY),
shootY = mountY + Angles.trnsy(weaponRotation, weapon.shootX * i, weapon.shootY);
float shootAngle = weapon.rotate ? weaponRotation : Angles.angle(shootX, shootY, mount.aimX, mount.aimY);
shoot(unit, weapon, shootX, shootY, shootAngle);
shoot(weapon, shootX, shootY, shootAngle);
}
mount.side = !mount.side;
@@ -247,47 +259,50 @@ public class EntityComps{
}
}
private void shoot(ShooterTrait shooter, Weapon weapon, float x, float y, float rotation){
float baseX = shooter.getX(), baseY = shooter.getY();
private void shoot(Weapon weapon, float x, float y, float rotation){
float baseX = this.x, baseY = this.y;
weapon.shootSound.at(x, y, Mathf.random(0.8f, 1.0f));
sequenceNum = 0;
if(weapon.shotDelay > 0.01f){
Angles.shotgun(weapon.shots, weapon.spacing, rotation, f -> {
Time.run(sequenceNum * weapon.shotDelay, () -> bullet(shooter, weapon, x + shooter.getX() - baseX, y + shooter.getY() - baseY, f + Mathf.range(weapon.inaccuracy)));
Time.run(sequenceNum * weapon.shotDelay, () -> bullet(weapon, x + this.x - baseX, y + this.y - baseY, f + Mathf.range(weapon.inaccuracy)));
sequenceNum++;
});
}else{
Angles.shotgun(weapon.shots, weapon.spacing, rotation, f -> bullet(shooter, weapon, x, y, f + Mathf.range(weapon.inaccuracy)));
Angles.shotgun(weapon.shots, weapon.spacing, rotation, f -> bullet(weapon, x, y, f + Mathf.range(weapon.inaccuracy)));
}
BulletType ammo = weapon.bullet;
Tmp.v1.trns(rotation + 180f, ammo.recoil);
shooter.velocity().add(Tmp.v1);
if(this instanceof Velc){
//TODO apply force?
((Velc)this).getVel().add(Tmp.v1);
}
Tmp.v1.trns(rotation, 3f);
boolean parentize = ammo.keepVelocity;
Effects.shake(weapon.shake, weapon.shake, x, y);
Effects.effect(weapon.ejectEffect, x, y, rotation);
Effects.effect(ammo.shootEffect, x + Tmp.v1.x, y + Tmp.v1.y, rotation, parentize ? shooter : null);
Effects.effect(ammo.smokeEffect, x + Tmp.v1.x, y + Tmp.v1.y, rotation, parentize ? shooter : null);
weapon.ejectEffect.at(x, y, rotation);
ammo.shootEffect.at(x + Tmp.v1.x, y + Tmp.v1.y, rotation, parentize ? this : null);
ammo.smokeEffect.at(x + Tmp.v1.x, y + Tmp.v1.y, rotation, parentize ? this : null);
}
private void bullet(ShooterTrait owner, Weapon weapon, float x, float y, float angle){
private void bullet(Weapon weapon, float x, float y, float angle){
Tmp.v1.trns(angle, 3f);
Bullet.create(weapon.bullet, owner, owner.getTeam(), x + Tmp.v1.x, y + Tmp.v1.y, angle, (1f - weapon.velocityRnd) + Mathf.random(weapon.velocityRnd));
Bullet.create(weapon.bullet, this, getTeam(), x + Tmp.v1.x, y + Tmp.v1.y, angle, (1f - weapon.velocityRnd) + Mathf.random(weapon.velocityRnd));
}
}
@Component
abstract class DrawComp{
class DrawComp{
//TODO ponder.
abstract float drawSize();
native float drawSize();
void draw(){
@@ -336,21 +351,161 @@ public class EntityComps{
void trns(float x, float y){
set(this.x + x, this.y + y);
}
int tileX(){
return Vars.world.toTile(getX());
}
int tileY(){
return Vars.world.toTile(getY());
}
}
@Component
class MinerComp{
@Component({ItemsComp.class, TeamComp.class, RotComp.class})
static abstract class MinerComp implements Itemsc, Posc, Teamc, Rotc{
static float miningRange = 70f;
@Nullable Tile mineTile;
native boolean canMine(Item item);
native float getMiningSpeed();
native boolean offloadImmediately();
boolean isMining(){
return mineTile != null;
}
void updateMining(){
TileEntity core = getClosestCore();
if(core != null && mineTile != null && mineTile.drop() != null && !acceptsItem(mineTile.drop()) && dst(core) < mineTransferRange){
int accepted = core.tile.block().acceptStack(item(), getStack().amount, core.tile, unit);
if(accepted > 0){
Call.transferItemTo(item(), accepted,
mineTile.worldx() + Mathf.range(tilesize / 2f),
mineTile.worldy() + Mathf.range(tilesize / 2f), core.tile);
clearItem();
}
}
if(mineTile == null || core == null || mineTile.block() != Blocks.air || dst(mineTile.worldx(), mineTile.worldy()) > miningRange
|| mineTile.drop() == null || !acceptsItem(mineTile.drop()) || !canMine(mineTile.drop())){
mineTile = null;
}else{
Item item = mineTile.drop();
setRotation(Mathf.slerpDelta(getRotation(), angleTo(mineTile.worldx(), mineTile.worldy()), 0.4f));
if(Mathf.chance(Time.delta() * (0.06 - item.hardness * 0.01) * getMiningSpeed())){
if(dst(core) < mineTransferRange && core.tile.block().acceptStack(item, 1, core.tile, unit) == 1 && offloadImmediately()){
Call.transferItemTo(item, 1,
mineTile.worldx() + Mathf.range(tilesize / 2f),
mineTile.worldy() + Mathf.range(tilesize / 2f), core.tile);
}else if(acceptsItem(item)){
//this is clientside, since items are synced anyway
ItemTransfer.transferItemToUnit(item,
mineTile.worldx() + Mathf.range(tilesize / 2f),
mineTile.worldy() + Mathf.range(tilesize / 2f),
unit);
}
}
if(Mathf.chance(0.06 * Time.delta())){
Fx.pulverizeSmall.at(mineTile.worldx() + Mathf.range(tilesize / 2f), mineTile.worldy() + Mathf.range(tilesize / 2f), 0f, item.color);
}
}
}
}
@Component
class BuilderComp{
Queue<BuildRequest> requests = new Queue<>();
float buildSpeed = 1f;
//boolean building;
void removeBuild(int x, int y, boolean breaking){
//remove matching request
int idx = player.buildQueue().indexOf(req -> req.breaking == breaking && req.x == x && req.y == y);
if(idx != -1){
player.buildQueue().removeIndex(idx);
}
}
/** Return whether this builder's place queue contains items. */
boolean isBuilding(){
return requests.size != 0;
}
/** Clears the placement queue. */
void clearBuilding(){
requests.clear();
}
/** Add another build requests to the tail of the queue, if it doesn't exist there yet. */
void addBuild(BuildRequest place){
addBuild(place, true);
}
/** Add another build requests to the queue, if it doesn't exist there yet. */
void addBuild(BuildRequest place, boolean tail){
BuildRequest replace = null;
for(BuildRequest request : requests){
if(request.x == place.x && request.y == place.y){
replace = request;
break;
}
}
if(replace != null){
requests.remove(replace);
}
Tile tile = world.tile(place.x, place.y);
if(tile != null && tile.entity instanceof BuildEntity){
place.progress = tile.<BuildEntity>ent().progress;
}
if(tail){
requests.addLast(place);
}else{
requests.addFirst(place);
}
}
/** Return the build requests currently active, or the one at the top of the queue.*/
@Nullable BuildRequest buildRequest(){
return requests.size == 0 ? null : requests.first();
}
}
@Component(DamageComp.class)
class ShielderComp{
void absorb(){
}
}
@Component
class ItemsComp{
ItemStack item = new ItemStack();
ItemStack stack = new ItemStack();
native int getItemCapacity();
public Item item(){
return stack.item;
}
void clearItem(){
stack.amount = 0;
}
boolean acceptsItem(Item item){
return !hasItem() || item == stack.item && stack.amount + 1 <= getItemCapacity();
}
boolean hasItem(){
return stack.amount > 0;
}
}
@Component(VelComp.class)
@@ -543,7 +698,13 @@ public class EntityComps{
void update(){}
void remove(){}
void remove(){
}
void add(){
}
boolean isLocal(){
//TODO fix

View File

@@ -4,7 +4,6 @@ import arc.graphics.g2d.Draw;
import arc.math.Mathf;
import mindustry.entities.EntityGroup;
import mindustry.entities.type.TimedEntity;
import mindustry.entities.traits.BelowLiquidTrait;
import mindustry.graphics.Pal;
import static mindustry.Vars.groundEffectGroup;
@@ -12,7 +11,7 @@ import static mindustry.Vars.groundEffectGroup;
/**
* Class for creating block rubble on the ground.
*/
public abstract class Decal extends TimedEntity implements BelowLiquidTrait, DrawTrait{
public abstract class Decal extends TimedEntity implements DrawTrait{
@Override
public float lifetime(){

View File

@@ -97,11 +97,11 @@ public class Fire extends TimedEntity implements SaveTrait, SyncTrait{
@Override
public void update(){
if(Mathf.chance(0.1 * Time.delta())){
Effects.effect(Fx.fire, x + Mathf.range(4f), y + Mathf.range(4f));
Fx.fire.at(x + Mathf.range(4f), y + Mathf.range(4f));
}
if(Mathf.chance(0.05 * Time.delta())){
Effects.effect(Fx.fireSmoke, x + Mathf.range(4f), y + Mathf.range(4f));
Fx.fireSmoke.at(x + Mathf.range(4f), y + Mathf.range(4f));
}
if(Mathf.chance(0.001 * Time.delta())){

View File

@@ -70,7 +70,7 @@ public class Puddle extends SolidEntity implements SaveTrait, Poolable, DrawTrai
Puddle p = map.get(tile.pos());
if(generation == 0 && p != null && p.lastRipple <= Time.time() - 40f){
Effects.effect(Fx.ripple, tile.floor().liquidDrop.color,
Fx.ripple.at(tile.floor().liquidDrop.color,
(tile.worldx() + source.worldx()) / 2f, (tile.worldy() + source.worldy()) / 2f);
p.lastRipple = Time.time();
}
@@ -93,7 +93,7 @@ public class Puddle extends SolidEntity implements SaveTrait, Poolable, DrawTrai
p.accepting = Math.max(amount, p.accepting);
if(generation == 0 && p.lastRipple <= Time.time() - 40f && p.amount >= maxLiquid / 2f){
Effects.effect(Fx.ripple, p.liquid.color, (tile.worldx() + source.worldx()) / 2f, (tile.worldy() + source.worldy()) / 2f);
Fx.ripple.at(p.liquid.color, (tile.worldx() + source.worldx()) / 2f, (tile.worldy() + source.worldy()) / 2f);
p.lastRipple = Time.time();
}
}else{
@@ -119,12 +119,12 @@ public class Puddle extends SolidEntity implements SaveTrait, Poolable, DrawTrai
}
}else if(dest.temperature > 0.7f && liquid.temperature < 0.55f){ //cold liquid poured onto hot puddle
if(Mathf.chance(0.5f * amount)){
Effects.effect(Fx.steam, x, y);
Fx.steam.at(x, y);
}
return -0.1f * amount;
}else if(liquid.temperature > 0.7f && dest.temperature < 0.55f){ //hot liquid poured onto cold puddle
if(Mathf.chance(0.8f * amount)){
Effects.effect(Fx.steam, x, y);
Fx.steam.at(x, y);
}
return -0.4f * amount;
}
@@ -204,7 +204,7 @@ public class Puddle extends SolidEntity implements SaveTrait, Poolable, DrawTrai
unit.applyEffect(liquid.effect, 60 * 2);
if(unit.velocity().len() > 0.1){
Effects.effect(Fx.ripple, liquid.color, unit.x, unit.y);
Fx.ripple.at(liquid.color, unit.x, unit.y);
}
});

View File

@@ -1,13 +0,0 @@
package mindustry.entities.traits;
public interface AbsorbTrait extends Entity, TeamTrait, DamageTrait{
void absorb();
default boolean canBeAbsorbed(){
return true;
}
default float getShieldDamage(){
return damage();
}
}

View File

@@ -1,7 +0,0 @@
package mindustry.entities.traits;
/**
* A flag interface for marking an effect as appearing below liquids.
*/
public interface BelowLiquidTrait{
}

View File

@@ -1,22 +0,0 @@
package mindustry.entities.traits;
/** A class for gracefully merging mining and building traits.*/
public interface BuilderMinerTrait extends MinerTrait, BuilderTrait{
default void updateMechanics(){
updateBuilding();
//mine only when not building
if(buildRequest() == null){
updateMining();
}
}
default void drawMechanics(){
if(isBuilding()){
drawBuilding();
}else{
drawMining();
}
}
}

View File

@@ -10,6 +10,7 @@ import arc.util.*;
import mindustry.*;
import mindustry.content.*;
import mindustry.entities.type.*;
import mindustry.entities.units.*;
import mindustry.game.EventType.*;
import mindustry.gen.*;
import mindustry.graphics.*;
@@ -281,122 +282,4 @@ public interface BuilderTrait extends Entity, TeamTrait{
Draw.color();
}
/** Class for storing build requests. Can be either a place or remove request. */
class BuildRequest{
/** Position and rotation of this request. */
public int x, y, rotation;
/** Block being placed. If null, this is a breaking request.*/
public @Nullable Block block;
/** Whether this is a break request.*/
public boolean breaking;
/** Whether this request comes with a config int. If yes, any blocks placed with this request will not call playerPlaced.*/
public boolean hasConfig;
/** Config int. Not used unless hasConfig is true.*/
public int config;
/** Original position, only used in schematics.*/
public int originalX, originalY, originalWidth, originalHeight;
/** Last progress.*/
public float progress;
/** Whether construction has started for this request, and other special variables.*/
public boolean initialized, worldContext = true, stuck;
/** Visual scale. Used only for rendering.*/
public float animScale = 0f;
/** This creates a build request. */
public BuildRequest(int x, int y, int rotation, Block block){
this.x = x;
this.y = y;
this.rotation = rotation;
this.block = block;
this.breaking = false;
}
/** This creates a remove request. */
public BuildRequest(int x, int y){
this.x = x;
this.y = y;
this.rotation = -1;
this.block = world.tile(x, y).block();
this.breaking = true;
}
public BuildRequest(){
}
public BuildRequest copy(){
BuildRequest copy = new BuildRequest();
copy.x = x;
copy.y = y;
copy.rotation = rotation;
copy.block = block;
copy.breaking = breaking;
copy.hasConfig = hasConfig;
copy.config = config;
copy.originalX = originalX;
copy.originalY = originalY;
copy.progress = progress;
copy.initialized = initialized;
copy.animScale = animScale;
return copy;
}
public BuildRequest original(int x, int y, int originalWidth, int originalHeight){
originalX = x;
originalY = y;
this.originalWidth = originalWidth;
this.originalHeight = originalHeight;
return this;
}
public Rect bounds(Rect rect){
if(breaking){
return rect.set(-100f, -100f, 0f, 0f);
}else{
return block.bounds(x, y, rect);
}
}
public BuildRequest set(int x, int y, int rotation, Block block){
this.x = x;
this.y = y;
this.rotation = rotation;
this.block = block;
this.breaking = false;
return this;
}
public float drawx(){
return x*tilesize + block.offset();
}
public float drawy(){
return y*tilesize + block.offset();
}
public BuildRequest configure(int config){
this.config = config;
this.hasConfig = true;
return this;
}
public @Nullable Tile tile(){
return world.tile(x, y);
}
@Override
public String toString(){
return "BuildRequest{" +
"x=" + x +
", y=" + y +
", rotation=" + rotation +
", recipe=" + block +
", breaking=" + breaking +
", progress=" + progress +
", initialized=" + initialized +
'}';
}
}
}

View File

@@ -1,51 +0,0 @@
package mindustry.entities.traits;
import mindustry.*;
import mindustry.entities.*;
public interface Entity extends MoveTrait{
int getID();
void resetID(int id);
default void update(){}
default void removed(){}
default void added(){}
default int tileX(){
return Vars.world.toTile(getX());
}
default int tileY(){
return Vars.world.toTile(getY());
}
EntityGroup targetGroup();
@SuppressWarnings("unchecked")
default void add(){
if(targetGroup() != null){
targetGroup().add(this);
}
}
@SuppressWarnings("unchecked")
default void remove(){
if(getGroup() != null){
getGroup().remove(this);
}
setGroup(null);
}
EntityGroup getGroup();
void setGroup(EntityGroup group);
default boolean isAdded(){
return getGroup() != null;
}
}

View File

@@ -1,8 +1,6 @@
package mindustry.entities.type;
import mindustry.*;
import mindustry.entities.EntityGroup;
import mindustry.entities.traits.Entity;
public abstract class BaseEntity implements Entity{
private static int lastid;

View File

@@ -18,6 +18,7 @@ import mindustry.core.*;
import mindustry.ctype.ContentType;
import mindustry.entities.*;
import mindustry.entities.traits.*;
import mindustry.entities.units.*;
import mindustry.game.*;
import mindustry.gen.*;
import mindustry.input.*;
@@ -491,7 +492,7 @@ public class Player extends Unit implements BuilderMinerTrait, ShooterTrait{
if(boostHeat <= liftoffBoost + 0.05f && achievedFlight && !mech.flying){
if(tile != null){
Effects.effect(Fx.unitLand, tile.floor().color, x, y, tile.floor().isLiquid ? 1f : 0.5f);
Fx.unitLand.at(x, y, tile.floor().isLiquid ? 1f : 0.5f, tile.floor().color);
}
mech.onLand(this);
achievedFlight = false;

View File

@@ -124,7 +124,7 @@ public abstract class Unit extends DestructibleEntity implements SaveTrait, Targ
Damage.dynamicExplosion(x, y, flammability, explosiveness, 0f, getSize() / 2f, Pal.darkFlame);
ScorchDecal.create(x, y);
Effects.effect(Fx.explosion, this);
Fx.explosion.at(this);
Effects.shake(2f, 2f, this);
Sounds.bang.at(this);
@@ -330,7 +330,7 @@ public abstract class Unit extends DestructibleEntity implements SaveTrait, Targ
}
if(onLiquid && velocity.len() > 0.4f && Mathf.chance((velocity.len() * floor.speedMultiplier) * 0.06f * Time.delta())){
Effects.effect(floor.walkEffect, floor.color, x, y);
floor.walkEffect.at(floor.color, x, y);
}
if(onLiquid){
@@ -344,7 +344,7 @@ public abstract class Unit extends DestructibleEntity implements SaveTrait, Targ
if(onLiquid && floor.drownTime > 0){
drownTime += Time.delta() * 1f / floor.drownTime;
if(Mathf.chance(Time.delta() * 0.05f)){
Effects.effect(floor.drownUpdateEffect, floor.color, x, y);
floor.drownUpdateEffect.at(floor.color, x, y);
}
}else{
drownTime = Mathf.lerpDelta(drownTime, 0f, 0.03f);

View File

@@ -0,0 +1,126 @@
package mindustry.entities.units;
import arc.math.geom.*;
import arc.util.ArcAnnotate.*;
import mindustry.world.*;
import static mindustry.Vars.*;
/** Class for storing build requests. Can be either a place or remove request. */
public class BuildRequest{
/** Position and rotation of this request. */
public int x, y, rotation;
/** Block being placed. If null, this is a breaking request.*/
public @Nullable Block block;
/** Whether this is a break request.*/
public boolean breaking;
/** Whether this request comes with a config int. If yes, any blocks placed with this request will not call playerPlaced.*/
public boolean hasConfig;
/** Config int. Not used unless hasConfig is true.*/
public int config;
/** Original position, only used in schematics.*/
public int originalX, originalY, originalWidth, originalHeight;
/** Last progress.*/
public float progress;
/** Whether construction has started for this request, and other special variables.*/
public boolean initialized, worldContext = true, stuck;
/** Visual scale. Used only for rendering.*/
public float animScale = 0f;
/** This creates a build request. */
public BuildRequest(int x, int y, int rotation, Block block){
this.x = x;
this.y = y;
this.rotation = rotation;
this.block = block;
this.breaking = false;
}
/** This creates a remove request. */
public BuildRequest(int x, int y){
this.x = x;
this.y = y;
this.rotation = -1;
this.block = world.tile(x, y).block();
this.breaking = true;
}
public BuildRequest(){
}
public BuildRequest copy(){
BuildRequest copy = new BuildRequest();
copy.x = x;
copy.y = y;
copy.rotation = rotation;
copy.block = block;
copy.breaking = breaking;
copy.hasConfig = hasConfig;
copy.config = config;
copy.originalX = originalX;
copy.originalY = originalY;
copy.progress = progress;
copy.initialized = initialized;
copy.animScale = animScale;
return copy;
}
public BuildRequest original(int x, int y, int originalWidth, int originalHeight){
originalX = x;
originalY = y;
this.originalWidth = originalWidth;
this.originalHeight = originalHeight;
return this;
}
public Rect bounds(Rect rect){
if(breaking){
return rect.set(-100f, -100f, 0f, 0f);
}else{
return block.bounds(x, y, rect);
}
}
public BuildRequest set(int x, int y, int rotation, Block block){
this.x = x;
this.y = y;
this.rotation = rotation;
this.block = block;
this.breaking = false;
return this;
}
public float drawx(){
return x*tilesize + block.offset();
}
public float drawy(){
return y*tilesize + block.offset();
}
public BuildRequest configure(int config){
this.config = config;
this.hasConfig = true;
return this;
}
public @Nullable Tile tile(){
return world.tile(x, y);
}
@Override
public String toString(){
return "BuildRequest{" +
"x=" + x +
", y=" + y +
", rotation=" + rotation +
", recipe=" + block +
", breaking=" + breaking +
", progress=" + progress +
", initialized=" + initialized +
'}';
}
}

View File

@@ -14,7 +14,7 @@ import arc.util.serialization.*;
import mindustry.*;
import mindustry.content.*;
import mindustry.ctype.ContentType;
import mindustry.entities.traits.BuilderTrait.*;
import mindustry.entities.units.*;
import mindustry.game.EventType.*;
import mindustry.game.Schematic.*;
import mindustry.input.*;

View File

@@ -13,7 +13,7 @@ import arc.util.ArcAnnotate.*;
import arc.util.*;
import mindustry.*;
import mindustry.core.GameState.*;
import mindustry.entities.traits.BuilderTrait.*;
import mindustry.entities.units.*;
import mindustry.game.EventType.*;
import mindustry.game.*;
import mindustry.gen.*;

View File

@@ -18,8 +18,8 @@ import mindustry.annotations.Annotations.*;
import mindustry.content.*;
import mindustry.entities.*;
import mindustry.entities.effect.*;
import mindustry.entities.traits.BuilderTrait.*;
import mindustry.entities.type.*;
import mindustry.entities.units.*;
import mindustry.game.EventType.*;
import mindustry.game.*;
import mindustry.game.Teams.*;
@@ -78,7 +78,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
throw new ValidateException(player, "Player cannot drop an item.");
}
Effects.effect(Fx.dropItem, Color.white, player.x, player.y, angle, player.item().item);
Fx.dropItem.at(player.x, player.y, angle, Color.white, player.item().item);
player.clearItem();
}

View File

@@ -16,9 +16,9 @@ import mindustry.*;
import mindustry.content.*;
import mindustry.core.GameState.*;
import mindustry.entities.*;
import mindustry.entities.traits.BuilderTrait.*;
import mindustry.entities.traits.*;
import mindustry.entities.type.*;
import mindustry.entities.units.*;
import mindustry.game.EventType.*;
import mindustry.game.*;
import mindustry.gen.*;
@@ -537,10 +537,10 @@ public class MobileInput extends InputHandler implements GestureListener{
lineMode = true;
if(mode == breaking){
Effects.effect(Fx.tapBlock, cursor.worldx(), cursor.worldy(), 1f);
Fx.tapBlock.at(cursor.worldx(), cursor.worldy(), 1f);
}else if(block != null){
updateLine(lineStartX, lineStartY, cursor.x, cursor.y);
Effects.effect(Fx.tapBlock, cursor.worldx() + block.offset(), cursor.worldy() + block.offset(), block.size);
Fx.tapBlock.at(cursor.worldx() + block.offset(), cursor.worldy() + block.offset(), block.size);
}
return false;

View File

@@ -8,7 +8,7 @@ import mindustry.entities.Effects;
import mindustry.entities.Effects.Effect;
import mindustry.entities.type.Bullet;
import mindustry.entities.bullet.BulletType;
import mindustry.entities.traits.BuilderTrait.BuildRequest;
import mindustry.entities.units.BuildRequest;
import mindustry.entities.type.*;
import mindustry.entities.units.*;
import mindustry.game.*;

View File

@@ -3,8 +3,8 @@ package mindustry.net;
import arc.struct.*;
import arc.util.ArcAnnotate.*;
import arc.util.*;
import mindustry.entities.traits.BuilderTrait.*;
import mindustry.entities.type.*;
import mindustry.entities.units.*;
import mindustry.gen.*;
import mindustry.net.Administration.*;
import mindustry.net.Net.*;

View File

@@ -52,7 +52,7 @@ public class StatusEffect extends MappableContent{
}
if(effect != Fx.none && Mathf.chance(Time.delta() * 0.15f)){
Effects.effect(effect, unit.x + Mathf.range(unit.getSize() / 2f), unit.y + Mathf.range(unit.getSize() / 2f));
effect.at(unit.x + Mathf.range(unit.getSize() / 2f), unit.y + Mathf.range(unit.getSize() / 2f));
}
}

View File

@@ -12,8 +12,8 @@ import arc.scene.ui.layout.*;
import arc.struct.*;
import arc.util.*;
import mindustry.content.*;
import mindustry.entities.traits.BuilderTrait.*;
import mindustry.entities.type.*;
import mindustry.entities.units.*;
import mindustry.game.EventType.*;
import mindustry.gen.*;
import mindustry.graphics.*;

View File

@@ -21,8 +21,8 @@ import mindustry.ctype.*;
import mindustry.ctype.ContentType;
import mindustry.entities.*;
import mindustry.entities.effect.*;
import mindustry.entities.traits.BuilderTrait.*;
import mindustry.entities.type.*;
import mindustry.entities.units.*;
import mindustry.gen.*;
import mindustry.graphics.*;
import mindustry.graphics.MultiPacker.*;

View File

@@ -169,12 +169,12 @@ public abstract class BlockStorage extends UnlockableContent{
tile.entity.damage(1 * Time.delta());
next.entity.damage(1 * Time.delta());
if(Mathf.chance(0.1 * Time.delta())){
Effects.effect(Fx.fire, (tile.worldx() + next.worldx()) / 2f, (tile.worldy() + next.worldy()) / 2f);
Fx.fire.at((tile.worldx() + next.worldx()) / 2f, (tile.worldy() + next.worldy()) / 2f);
}
}else if((liquid.temperature > 0.7f && other.temperature < 0.55f) || (other.temperature > 0.7f && liquid.temperature < 0.55f)){
tile.entity.liquids.remove(liquid, Math.min(tile.entity.liquids.get(liquid), 0.7f * Time.delta()));
if(Mathf.chance(0.2f * Time.delta())){
Effects.effect(Fx.steam, (tile.worldx() + next.worldx()) / 2f, (tile.worldy() + next.worldy()) / 2f);
Fx.steam.at((tile.worldx() + next.worldx()) / 2f, (tile.worldy() + next.worldy()) / 2f);
}
}
}

View File

@@ -4,7 +4,7 @@ import arc.math.*;
import arc.math.geom.*;
import arc.util.*;
import arc.util.ArcAnnotate.*;
import mindustry.entities.traits.BuilderTrait.*;
import mindustry.entities.units.*;
import mindustry.world.*;
import java.util.*;

View File

@@ -9,10 +9,9 @@ import arc.math.*;
import arc.util.ArcAnnotate.*;
import arc.util.*;
import mindustry.content.*;
import mindustry.entities.*;
import mindustry.entities.effect.*;
import mindustry.entities.traits.BuilderTrait.*;
import mindustry.entities.type.*;
import mindustry.entities.units.*;
import mindustry.game.EventType.*;
import mindustry.game.*;
import mindustry.gen.*;
@@ -56,7 +55,7 @@ public class BuildBlock extends Block{
@Remote(called = Loc.server)
public static void onDeconstructFinish(Tile tile, Block block, int builderID){
Team team = tile.getTeam();
Effects.effect(Fx.breakBlock, tile.drawx(), tile.drawy(), block.size);
Fx.breakBlock.at(tile.drawx(), tile.drawy(), block.size);
Events.fire(new BlockBuildEndEvent(tile, playerGroup.getByID(builderID), team, true));
tile.remove();
if(shouldPlay()) Sounds.breaks.at(tile, calcPitch(false));
@@ -76,7 +75,7 @@ public class BuildBlock extends Block{
tile.block().playerPlaced(tile);
}
}
Effects.effect(Fx.placeBlock, tile.drawx(), tile.drawy(), block.size);
Fx.placeBlock.at(tile.drawx(), tile.drawy(), block.size);
}
static boolean shouldPlay(){
@@ -155,7 +154,7 @@ public class BuildBlock extends Block{
@Override
public void onDestroyed(Tile tile){
Effects.effect(Fx.blockExplosionSmoke, tile);
Fx.blockExplosionSmoke.at(tile);
if(!tile.floor().solid && !tile.floor().isLiquid){
RubbleDecal.create(tile.drawx(), tile.drawy(), size);

View File

@@ -43,9 +43,9 @@ public class Door extends Wall{
pathfinder.updateTile(tile);
if(!entity.open){
Effects.effect(door.openfx, tile.drawx(), tile.drawy());
door.openfx.at(tile.drawx(), tile.drawy());
}else{
Effects.effect(door.closefx, tile.drawx(), tile.drawy());
door.closefx.at(tile.drawx(), tile.drawy());
}
Sounds.door.at(tile);
}

View File

@@ -40,7 +40,7 @@ public class ForceProjector extends Block{
private static Cons<AbsorbTrait> shieldConsumer = trait -> {
if(trait.canBeAbsorbed() && trait.getTeam() != paramTile.getTeam() && Intersector.isInsideHexagon(trait.getX(), trait.getY(), paramBlock.realRadius(paramEntity) * 2f, paramTile.drawx(), paramTile.drawy())){
trait.absorb();
Effects.effect(Fx.absorb, trait);
Fx.absorb.at(trait);
paramEntity.hit = 1f;
paramEntity.buildup += trait.getShieldDamage() * paramEntity.warmup;
}
@@ -107,7 +107,7 @@ public class ForceProjector extends Block{
entity.radscl = Mathf.lerpDelta(entity.radscl, entity.broken ? 0f : entity.warmup, 0.05f);
if(Mathf.chance(Time.delta() * entity.buildup / breakage * 0.1f)){
Effects.effect(Fx.reactorsmoke, tile.drawx() + Mathf.range(tilesize / 2f), tile.drawy() + Mathf.range(tilesize / 2f));
Fx.reactorsmoke.at(tile.drawx() + Mathf.range(tilesize / 2f), tile.drawy() + Mathf.range(tilesize / 2f));
}
entity.warmup = Mathf.lerpDelta(entity.warmup, entity.efficiency(), 0.1f);
@@ -130,7 +130,7 @@ public class ForceProjector extends Block{
if(entity.buildup >= breakage && !entity.broken){
entity.broken = true;
entity.buildup = breakage;
Effects.effect(Fx.shieldBreak, tile.drawx(), tile.drawy(), radius);
Fx.shieldBreak.at(tile.drawx(), tile.drawy(), radius);
}
if(entity.hit > 0f){

View File

@@ -7,7 +7,6 @@ import arc.graphics.g2d.*;
import arc.math.Mathf;
import arc.util.*;
import mindustry.content.Fx;
import mindustry.entities.Effects;
import mindustry.entities.type.TileEntity;
import mindustry.graphics.*;
import mindustry.world.*;
@@ -80,7 +79,7 @@ public class MendProjector extends Block{
indexer.eachBlock(entity, realRange, other -> other.entity.damaged(), other -> {
other.entity.healBy(other.entity.maxHealth() * (healPercent + entity.phaseHeat * phaseBoost) / 100f * entity.efficiency());
Effects.effect(Fx.healBlockFull, Tmp.c1.set(baseColor).lerp(phaseColor, entity.phaseHeat), other.drawx(), other.drawy(), other.block().size);
Fx.healBlockFull.at(other.drawx(), other.drawy(), other.block().size, Tmp.c1.set(baseColor).lerp(phaseColor, entity.phaseHeat));
});
}
}

View File

@@ -30,13 +30,13 @@ public class ChargeTurret extends PowerTurret{
useAmmo(tile);
tr.trns(entity.rotation, size * tilesize / 2);
Effects.effect(chargeBeginEffect, tile.drawx() + tr.x, tile.drawy() + tr.y, entity.rotation);
chargeBeginEffect.at(tile.drawx() + tr.x, tile.drawy() + tr.y, entity.rotation);
for(int i = 0; i < chargeEffects; i++){
Time.run(Mathf.random(chargeMaxDelay), () -> {
if(!isTurret(tile)) return;
tr.trns(entity.rotation, size * tilesize / 2);
Effects.effect(chargeEffect, tile.drawx() + tr.x, tile.drawy() + tr.y, entity.rotation);
chargeEffect.at(tile.drawx() + tr.x, tile.drawy() + tr.y, entity.rotation);
});
}

View File

@@ -58,7 +58,7 @@ public class CooledTurret extends Turret{
entity.liquids.remove(liquid, used);
if(Mathf.chance(0.06 * used)){
Effects.effect(coolEffect, tile.drawx() + Mathf.range(size * tilesize / 2f), tile.drawy() + Mathf.range(size * tilesize / 2f));
coolEffect.at(tile.drawx() + Mathf.range(size * tilesize / 2f), tile.drawy() + Mathf.range(size * tilesize / 2f));
}
}
}

View File

@@ -80,7 +80,7 @@ public class LaserTurret extends PowerTurret{
entity.liquids.remove(liquid, used);
if(Mathf.chance(0.06 * used)){
Effects.effect(coolEffect, tile.drawx() + Mathf.range(size * tilesize / 2f), tile.drawy() + Mathf.range(size * tilesize / 2f));
coolEffect.at(tile.drawx() + Mathf.range(size * tilesize / 2f), tile.drawy() + Mathf.range(size * tilesize / 2f));
}
}
}

View File

@@ -102,8 +102,8 @@ public class LiquidTurret extends Turret{
TurretEntity entity = tile.ent();
Effects.effect(type.shootEffect, entity.liquids.current().color, tile.drawx() + tr.x, tile.drawy() + tr.y, entity.rotation);
Effects.effect(type.smokeEffect, entity.liquids.current().color, tile.drawx() + tr.x, tile.drawy() + tr.y, entity.rotation);
type.shootEffect.at(tile.drawx() + tr.x, tile.drawy() + tr.y, entity.rotation, entity.liquids.current().color);
type.smokeEffect.at(tile.drawx() + tr.x, tile.drawy() + tr.y, entity.rotation, entity.liquids.current().color);
//shootSound.at(tile);
if(shootShake > 0){

View File

@@ -279,8 +279,8 @@ public abstract class Turret extends Block{
TurretEntity entity = tile.ent();
Effects.effect(shootEffect, tile.drawx() + tr.x, tile.drawy() + tr.y, entity.rotation);
Effects.effect(smokeEffect, tile.drawx() + tr.x, tile.drawy() + tr.y, entity.rotation);
shootEffect.at(tile.drawx() + tr.x, tile.drawy() + tr.y, entity.rotation);
smokeEffect.at(tile.drawx() + tr.x, tile.drawy() + tr.y, entity.rotation);
shootSound.at(tile, Mathf.random(0.9f, 1.1f));
if(shootShake > 0){
@@ -294,7 +294,7 @@ public abstract class Turret extends Block{
if(!isTurret(tile)) return;
TurretEntity entity = tile.ent();
Effects.effect(ammoUseEffect, tile.drawx() - Angles.trnsx(entity.rotation, ammoEjectBack),
ammoUseEffect.at(tile.drawx() - Angles.trnsx(entity.rotation, ammoEjectBack),
tile.drawy() - Angles.trnsy(entity.rotation, ammoEjectBack), entity.rotation);
}

View File

@@ -9,8 +9,8 @@ import arc.struct.*;
import arc.util.ArcAnnotate.*;
import arc.util.*;
import mindustry.content.*;
import mindustry.entities.traits.BuilderTrait.*;
import mindustry.entities.type.*;
import mindustry.entities.units.*;
import mindustry.gen.*;
import mindustry.graphics.*;
import mindustry.type.*;

View File

@@ -8,8 +8,8 @@ import arc.graphics.g2d.*;
import arc.math.*;
import arc.math.geom.*;
import arc.util.*;
import mindustry.entities.traits.BuilderTrait.*;
import mindustry.entities.type.*;
import mindustry.entities.units.*;
import mindustry.graphics.*;
import mindustry.type.*;
import mindustry.world.*;

View File

@@ -253,10 +253,10 @@ public class MassDriver extends Block{
tile.drawx() + Angles.trnsx(angle, translation), tile.drawy() + Angles.trnsy(angle, translation),
angle, 1f, 1f, data);
Effects.effect(shootEffect, tile.drawx() + Angles.trnsx(angle, translation),
shootEffect.at(tile.drawx() + Angles.trnsx(angle, translation),
tile.drawy() + Angles.trnsy(angle, translation), angle);
Effects.effect(smokeEffect, tile.drawx() + Angles.trnsx(angle, translation),
smokeEffect.at(tile.drawx() + Angles.trnsx(angle, translation),
tile.drawy() + Angles.trnsy(angle, translation), angle);
Effects.shake(shake, shake, entity);
@@ -278,7 +278,7 @@ public class MassDriver extends Block{
}
Effects.shake(shake, shake, entity);
Effects.effect(recieveEffect, bullet);
recieveEffect.at(bullet);
entity.reload = 1f;
bullet.remove();

View File

@@ -5,8 +5,8 @@ import arc.math.*;
import arc.scene.ui.layout.*;
import arc.util.ArcAnnotate.*;
import arc.util.*;
import mindustry.entities.traits.BuilderTrait.*;
import mindustry.entities.type.*;
import mindustry.entities.units.*;
import mindustry.type.*;
import mindustry.world.*;
import mindustry.world.blocks.*;

View File

@@ -8,8 +8,8 @@ import arc.math.geom.*;
import arc.struct.*;
import arc.util.*;
import mindustry.content.*;
import mindustry.entities.traits.BuilderTrait.*;
import mindustry.entities.type.*;
import mindustry.entities.units.*;
import mindustry.type.*;
import mindustry.world.*;
import mindustry.world.blocks.*;

View File

@@ -138,9 +138,9 @@ public class ImpactReactor extends PowerGenerator{
Sounds.explosionbig.at(tile);
Effects.shake(6f, 16f, tile.worldx(), tile.worldy());
Effects.effect(Fx.impactShockwave, tile.worldx(), tile.worldy());
Fx.impactShockwave.at(tile.worldx(), tile.worldy());
for(int i = 0; i < 6; i++){
Time.run(Mathf.random(80), () -> Effects.effect(Fx.impactcloud, tile.worldx(), tile.worldy()));
Time.run(Mathf.random(80), () -> Fx.impactcloud.at(tile.worldx(), tile.worldy()));
}
Damage.damage(tile.worldx(), tile.worldy(), explosionRadius * tilesize, explosionDamage * 4);
@@ -149,14 +149,14 @@ public class ImpactReactor extends PowerGenerator{
for(int i = 0; i < 20; i++){
Time.run(Mathf.random(80), () -> {
Tmp.v1.rnd(Mathf.random(40f));
Effects.effect(Fx.explosion, Tmp.v1.x + tile.worldx(), Tmp.v1.y + tile.worldy());
Fx.explosion.at(Tmp.v1.x + tile.worldx(), Tmp.v1.y + tile.worldy());
});
}
for(int i = 0; i < 70; i++){
Time.run(Mathf.random(90), () -> {
Tmp.v1.rnd(Mathf.random(120f));
Effects.effect(Fx.impactsmoke, Tmp.v1.x + tile.worldx(), Tmp.v1.y + tile.worldy());
Fx.impactsmoke.at(Tmp.v1.x + tile.worldx(), Tmp.v1.y + tile.worldy());
});
}
}

View File

@@ -124,12 +124,12 @@ public class ItemLiquidGenerator extends PowerGenerator{
entity.productionEfficiency = baseLiquidEfficiency * used / maximumPossible;
if(used > 0.001f && Mathf.chance(0.05 * entity.delta())){
Effects.effect(generateEffect, tile.drawx() + Mathf.range(3f), tile.drawy() + Mathf.range(3f));
generateEffect.at(tile.drawx() + Mathf.range(3f), tile.drawy() + Mathf.range(3f));
}
}else if(hasItems){
// No liquids accepted or none supplied, try using items if accepted
if(entity.generateTime <= 0f && entity.items.total() > 0){
Effects.effect(generateEffect, tile.worldx() + Mathf.range(3f), tile.worldy() + Mathf.range(3f));
generateEffect.at(tile.worldx() + Mathf.range(3f), tile.worldy() + Mathf.range(3f));
Item item = entity.items.take();
entity.productionEfficiency = getItemEfficiency(item);
entity.explosiveness = item.explosiveness;
@@ -143,7 +143,7 @@ public class ItemLiquidGenerator extends PowerGenerator{
//this block is run last so that in the event of a block destruction, no code relies on the block type
Core.app.post(() -> {
entity.damage(Mathf.random(11f));
Effects.effect(explodeEffect, tile.worldx() + Mathf.range(size * tilesize / 2f), tile.worldy() + Mathf.range(size * tilesize / 2f));
explodeEffect.at(tile.worldx() + Mathf.range(size * tilesize / 2f), tile.worldy() + Mathf.range(size * tilesize / 2f));
});
}
}else{

View File

@@ -102,7 +102,7 @@ public class NuclearReactor extends PowerGenerator{
if(entity.heat > smokeThreshold){
float smoke = 1.0f + (entity.heat - smokeThreshold) / (1f - smokeThreshold); //ranges from 1.0 to 2.0
if(Mathf.chance(smoke / 20.0 * entity.delta())){
Effects.effect(Fx.reactorsmoke, tile.worldx() + Mathf.range(size * tilesize / 2f),
Fx.reactorsmoke.at(tile.worldx() + Mathf.range(size * tilesize / 2f),
tile.worldy() + Mathf.random(size * tilesize / 2f));
}
}
@@ -128,9 +128,9 @@ public class NuclearReactor extends PowerGenerator{
if((fuel < 5 && entity.heat < 0.5f) || !state.rules.reactorExplosions) return;
Effects.shake(6f, 16f, tile.worldx(), tile.worldy());
Effects.effect(Fx.nuclearShockwave, tile.worldx(), tile.worldy());
Fx.nuclearShockwave.at(tile.worldx(), tile.worldy());
for(int i = 0; i < 6; i++){
Time.run(Mathf.random(40), () -> Effects.effect(Fx.nuclearcloud, tile.worldx(), tile.worldy()));
Time.run(Mathf.random(40), () -> Fx.nuclearcloud.at(tile.worldx(), tile.worldy()));
}
Damage.damage(tile.worldx(), tile.worldy(), explosionRadius * tilesize, explosionDamage * 4);
@@ -138,14 +138,14 @@ public class NuclearReactor extends PowerGenerator{
for(int i = 0; i < 20; i++){
Time.run(Mathf.random(50), () -> {
tr.rnd(Mathf.random(40f));
Effects.effect(Fx.explosion, tr.x + tile.worldx(), tr.y + tile.worldy());
Fx.explosion.at(tr.x + tile.worldx(), tr.y + tile.worldy());
});
}
for(int i = 0; i < 70; i++){
Time.run(Mathf.random(80), () -> {
tr.rnd(Mathf.random(120f));
Effects.effect(Fx.nuclearsmoke, tr.x + tile.worldx(), tr.y + tile.worldy());
Fx.nuclearsmoke.at(tr.x + tile.worldx(), tr.y + tile.worldy());
});
}
}

View File

@@ -2,6 +2,7 @@ package mindustry.world.blocks.power;
import arc.Core;
import arc.math.Mathf;
import mindustry.entities.units.*;
import mindustry.ui.Bar;
import arc.util.Eachable;
import mindustry.ui.Cicon;
@@ -10,7 +11,6 @@ import mindustry.world.Block;
import arc.graphics.g2d.Draw;
import mindustry.graphics.Pal;
import arc.graphics.g2d.TextureRegion;
import mindustry.entities.traits.BuilderTrait;
public class PowerDiode extends Block{
public TextureRegion arrow;
@@ -75,7 +75,7 @@ public class PowerDiode extends Block{
}
@Override
public void drawRequestRegion(BuilderTrait.BuildRequest req, Eachable<BuilderTrait.BuildRequest> list) {
public void drawRequestRegion(BuildRequest req, Eachable<BuildRequest> list) {
TextureRegion reg = icon(Cicon.full);
Draw.rect(icon(Cicon.full), req.drawx(), req.drawy(),
reg.getWidth() * req.animScale * Draw.scl,

View File

@@ -31,7 +31,7 @@ public class ThermalGenerator extends PowerGenerator{
GeneratorEntity entity = tile.ent();
if(entity.productionEfficiency > 0.1f && Mathf.chance(0.05 * entity.delta())){
Effects.effect(generateEffect, tile.drawx() + Mathf.range(3f), tile.drawy() + Mathf.range(3f));
generateEffect.at(tile.drawx() + Mathf.range(3f), tile.drawy() + Mathf.range(3f));
}
}

View File

@@ -269,7 +269,7 @@ public class Drill extends Block{
* entity.dominantItems * speed * entity.warmup;
if(Mathf.chance(Time.delta() * updateEffectChance * entity.warmup))
Effects.effect(updateEffect, entity.x + Mathf.range(size * 2f), entity.y + Mathf.range(size * 2f));
updateEffect.at(entity.x + Mathf.range(size * 2f), entity.y + Mathf.range(size * 2f));
}else{
entity.lastDrillSpeed = 0f;
entity.warmup = Mathf.lerpDelta(entity.warmup, 0f, warmupSpeed);
@@ -285,7 +285,7 @@ public class Drill extends Block{
entity.index++;
entity.progress = 0f;
Effects.effect(drillEffect, entity.dominantItem.color,
drillEffect.at(entity.dominantItem.color,
entity.x + Mathf.range(size), entity.y + Mathf.range(size));
}
}

View File

@@ -95,7 +95,7 @@ public class GenericCrafter extends Block{
entity.warmup = Mathf.lerpDelta(entity.warmup, 1f, 0.02f);
if(Mathf.chance(Time.delta() * updateEffectChance)){
Effects.effect(updateEffect, entity.x + Mathf.range(size * 4f), entity.y + Mathf.range(size * 4));
updateEffect.at(entity.x + Mathf.range(size * 4f), entity.y + Mathf.range(size * 4));
}
}else{
entity.warmup = Mathf.lerp(entity.warmup, 0f, 0.02f);
@@ -116,7 +116,7 @@ public class GenericCrafter extends Block{
handleLiquid(tile, tile, outputLiquid.liquid, outputLiquid.amount);
}
Effects.effect(craftEffect, tile.drawx(), tile.drawy());
craftEffect.at(tile.drawx(), tile.drawy());
entity.progress = 0f;
}

View File

@@ -62,7 +62,7 @@ public class Incinerator extends Block{
@Override
public void handleItem(Item item, Tile tile, Tile source){
if(Mathf.chance(0.3)){
Effects.effect(effect, tile.drawx(), tile.drawy());
effect.at(tile.drawx(), tile.drawy());
}
}
@@ -75,7 +75,7 @@ public class Incinerator extends Block{
@Override
public void handleLiquid(Tile tile, Tile source, Liquid liquid, float amount){
if(Mathf.chance(0.02)){
Effects.effect(effect, tile.drawx(), tile.drawy());
effect.at(tile.drawx(), tile.drawy());
}
}

View File

@@ -112,7 +112,7 @@ public class SolidPump extends Pump{
entity.lastPump = maxPump;
entity.warmup = Mathf.lerpDelta(entity.warmup, 1f, 0.02f);
if(Mathf.chance(entity.delta() * updateEffectChance))
Effects.effect(updateEffect, entity.x + Mathf.range(size * 2f), entity.y + Mathf.range(size * 2f));
updateEffect.at(entity.x + Mathf.range(size * 2f), entity.y + Mathf.range(size * 2f));
}else{
entity.warmup = Mathf.lerpDelta(entity.warmup, 0f, 0.02f);
entity.lastPump = 0f;

View File

@@ -4,8 +4,8 @@ import arc.*;
import arc.graphics.g2d.*;
import arc.scene.ui.layout.*;
import arc.util.*;
import mindustry.entities.traits.BuilderTrait.*;
import mindustry.entities.type.*;
import mindustry.entities.units.*;
import mindustry.type.*;
import mindustry.world.*;
import mindustry.world.blocks.*;

View File

@@ -8,8 +8,8 @@ import arc.scene.ui.*;
import arc.scene.ui.layout.*;
import arc.util.*;
import arc.util.ArcAnnotate.*;
import mindustry.entities.traits.BuilderTrait.*;
import mindustry.entities.type.*;
import mindustry.entities.units.*;
import mindustry.gen.*;
import mindustry.type.*;
import mindustry.ui.*;

View File

@@ -44,7 +44,7 @@ public class CoreBlock extends StorageBlock{
if(player == null || tile.entity == null) return;
CoreEntity entity = tile.ent();
Effects.effect(Fx.spawn, entity);
Fx.spawn.at(entity);
entity.progress = 0;
entity.spawnPlayer = player;
entity.spawnPlayer.onRespawn(tile);

View File

@@ -76,7 +76,7 @@ public class LaunchPad extends StorageBlock{
if(world.isZone() && entity.cons.valid() && entity.items.total() >= itemCapacity && entity.timer.get(timerLaunch, launchTime / entity.timeScale)){
for(Item item : Vars.content.items()){
Events.fire(Trigger.itemLaunch);
Effects.effect(Fx.padlaunch, tile);
Fx.padlaunch.at(tile);
int used = Math.min(entity.items.get(item), itemCapacity);
data.addItem(item, used);
entity.items.remove(item, used);

View File

@@ -4,8 +4,8 @@ import arc.graphics.*;
import arc.graphics.g2d.*;
import arc.scene.ui.layout.*;
import arc.util.*;
import mindustry.entities.traits.BuilderTrait.*;
import mindustry.entities.type.*;
import mindustry.entities.units.*;
import mindustry.type.*;
import mindustry.world.*;
import mindustry.world.blocks.*;

View File

@@ -105,7 +105,7 @@ public class CommandCenter extends Block{
@Override
public void configured(Tile tile, Player player, int value){
UnitCommand command = UnitCommand.all[value];
Effects.effect(((CommandCenter)tile.block()).effect, tile);
((CommandCenter)tile.block()).effect.at(tile);
for(Tile center : indexer.getAllied(tile.getTeam(), BlockFlag.comandCenter)){
if(center.block() instanceof CommandCenter){

View File

@@ -62,7 +62,7 @@ public class MechPad extends Block{
MechFactoryEntity entity = tile.ent();
Effects.effect(Fx.spawn, entity);
Fx.spawn.at(entity);
if(entity.player == null) return;
Mech mech = ((MechPad)tile.block()).mech;

View File

@@ -55,7 +55,7 @@ public class UnitFactory extends Block{
entity.spawned = spawns;
Effects.shake(2f, 3f, entity);
Effects.effect(Fx.producesmoke, tile.drawx(), tile.drawy());
Fx.producesmoke.at(tile.drawx(), tile.drawy());
if(!net.client()){
BaseUnit unit = factory.unitType.create(tile.getTeam());