diff --git a/core/assets-raw/sprites/blocks/storage/core-aegis-team.png b/core/assets-raw/sprites/blocks/storage/core-aegis-team.png deleted file mode 100644 index 6a34bde394..0000000000 Binary files a/core/assets-raw/sprites/blocks/storage/core-aegis-team.png and /dev/null differ diff --git a/core/assets-raw/sprites/blocks/storage/core-aegis-thruster1.png b/core/assets-raw/sprites/blocks/storage/core-aegis-thruster1.png deleted file mode 100644 index aaf48c0a64..0000000000 Binary files a/core/assets-raw/sprites/blocks/storage/core-aegis-thruster1.png and /dev/null differ diff --git a/core/assets-raw/sprites/blocks/storage/core-aegis-thruster2.png b/core/assets-raw/sprites/blocks/storage/core-aegis-thruster2.png deleted file mode 100644 index 23cee644e7..0000000000 Binary files a/core/assets-raw/sprites/blocks/storage/core-aegis-thruster2.png and /dev/null differ diff --git a/core/assets-raw/sprites/blocks/storage/core-aegis.png b/core/assets-raw/sprites/blocks/storage/core-aegis.png deleted file mode 100644 index d1fe947bab..0000000000 Binary files a/core/assets-raw/sprites/blocks/storage/core-aegis.png and /dev/null differ diff --git a/core/assets-raw/sprites/blocks/storage/core-bastion-team.png b/core/assets-raw/sprites/blocks/storage/core-bastion-team.png index 50e4e1012d..6a34bde394 100644 Binary files a/core/assets-raw/sprites/blocks/storage/core-bastion-team.png and b/core/assets-raw/sprites/blocks/storage/core-bastion-team.png differ diff --git a/core/assets-raw/sprites/blocks/storage/core-bastion-thruster1.png b/core/assets-raw/sprites/blocks/storage/core-bastion-thruster1.png index 1e8d8f8190..aaf48c0a64 100644 Binary files a/core/assets-raw/sprites/blocks/storage/core-bastion-thruster1.png and b/core/assets-raw/sprites/blocks/storage/core-bastion-thruster1.png differ diff --git a/core/assets-raw/sprites/blocks/storage/core-bastion-thruster2.png b/core/assets-raw/sprites/blocks/storage/core-bastion-thruster2.png index 9990ca0808..23cee644e7 100644 Binary files a/core/assets-raw/sprites/blocks/storage/core-bastion-thruster2.png and b/core/assets-raw/sprites/blocks/storage/core-bastion-thruster2.png differ diff --git a/core/assets-raw/sprites/blocks/storage/core-bastion.png b/core/assets-raw/sprites/blocks/storage/core-bastion.png index 6708686765..d1fe947bab 100644 Binary files a/core/assets-raw/sprites/blocks/storage/core-bastion.png and b/core/assets-raw/sprites/blocks/storage/core-bastion.png differ diff --git a/core/assets/icons/icons.properties b/core/assets/icons/icons.properties index 1ac8ca077d..104337ba18 100755 --- a/core/assets/icons/icons.properties +++ b/core/assets/icons/icons.properties @@ -407,7 +407,6 @@ 63301=neoplasm|liquid-neoplasm-ui 63300=scuttler|unit-scuttler-ui 63299=breach|block-breach-ui -63298=core-bastion|block-core-bastion-ui 63297=plasma-bore|block-plasma-bore-ui 63296=steam-vent|block-steam-vent-ui 63295=pressure-turbine|block-pressure-turbine-ui @@ -432,7 +431,7 @@ 63276=einforced-liquid-tank|block-einforced-liquid-tank-ui 63275=reinforced-liquid-tank|block-reinforced-liquid-tank-ui 63274=reinforced-bridge-conduit|block-reinforced-bridge-conduit-ui -63273=core-aegis|block-core-aegis-ui 63272=core-citadel|block-core-citadel-ui 63271=core-acropolis|block-core-acropolis-ui 63270=heat-reactor|block-heat-reactor-ui +63269=core-bastion|block-core-bastion-ui diff --git a/core/assets/logicids.dat b/core/assets/logicids.dat index a9c5b29ed3..2f1b489b21 100644 Binary files a/core/assets/logicids.dat and b/core/assets/logicids.dat differ diff --git a/core/src/mindustry/content/Blocks.java b/core/src/mindustry/content/Blocks.java index 83314fe9ec..71bed3a426 100644 --- a/core/src/mindustry/content/Blocks.java +++ b/core/src/mindustry/content/Blocks.java @@ -96,7 +96,7 @@ public class Blocks implements ContentList{ //storage coreShard, coreFoundation, coreNucleus, vault, container, unloader, //storage - erekir - coreBastion, coreAegis, coreCitadel, coreAcropolis, + coreBastion, coreCitadel, coreAcropolis, //turrets duo, scatter, scorch, hail, arc, wave, lancer, swarmer, salvo, fuse, ripple, cyclone, foreshadow, spectre, meltdown, segment, parallax, tsunami, @@ -1822,19 +1822,7 @@ public class Blocks implements ContentList{ researchCostMultiplier = 0.11f; }}; - //TODO remove - too small coreBastion = new CoreBlock("core-bastion"){{ - requirements(Category.effect, BuildVisibility.editorOnly, with(Items.beryllium, 1000, Items.graphite, 1000)); - - unitType = UnitTypes.evoke; - health = 3000; - itemCapacity = 3000; //TODO more or less? - size = 3; - - unitCapModifier = 10; - }}; - - coreAegis = new CoreBlock("core-aegis"){{ //TODO cost requirements(Category.effect, BuildVisibility.editorOnly, with(Items.beryllium, 2000, Items.graphite, 2000, Items.tungsten, 1000)); diff --git a/core/src/mindustry/content/Loadouts.java b/core/src/mindustry/content/Loadouts.java index d166cc43d3..2f964274c7 100644 --- a/core/src/mindustry/content/Loadouts.java +++ b/core/src/mindustry/content/Loadouts.java @@ -8,15 +8,13 @@ public class Loadouts implements ContentList{ basicShard, basicFoundation, basicNucleus, - basicBastion, - basicAegis; + basicBastion; @Override public void load(){ basicShard = Schematics.readBase64("bXNjaAB4nD2K2wqAIBiD5ymibnoRn6YnEP1BwUMoBL19FuJ2sbFvUFgYZDaJsLeQrkinN9UJHImsNzlYE7WrIUastuSbnlKx2VJJt+8IQGGKdfO/8J5yrGJSMegLg+YUIA=="); basicFoundation = Schematics.readBase64("bXNjaAB4nD1OSQ6DMBBzFhVu8BG+0X8MQyoiJTNSukj8nlCi2Adbtg/GA4OBF8oB00rvyE/9ykafqOIw58A7SWRKy1ZiShhZ5RcOLZhYS1hefQ1gRIeptH9jq/qW2lvc1d2tgWsOfVX/tOwE86AYBA=="); basicNucleus = Schematics.readBase64("bXNjaAB4nD2MUQqAIBBEJy0s6qOLdJXuYNtCgikYBd2+LNmdj308hkGHtkId7M4YFns4mk/yfB4a48602eDI+mlNznu0FMPFd0wYKCaewl8F0EOueqM+yKSLVfJrNKWnSw/FZGzEGXFG9sy/px4gEBW1"); - basicBastion = Schematics.readBase64("bXNjaAF4nGNgZmBmZmDJS8xNZWBNzMsEUtwpqcXJRZkFJZn5eQyClfmlCin5Cnn5JQqpFZnFJVwMbDmJSak5xQxM0bGMDDzJ+UWpukmJxWDVDAyMIAQkACJxFp8="); - basicAegis = Schematics.readBase64("bXNjaAF4nGNgYWBhZmDJS8xNZeDPyc/PVkhKzcjMS1GozC9l4E5JLU4uyiwoyczPY2BgYMtJTErNKWZgio5lZOBKzi9K1U1MTc8sBkoxghCQAAA85RNL"); + basicBastion = Schematics.readBase64("bXNjaAF4nGNgYWBhZmDJS8xNZWBNzMsEUtwpqcXJRZkFJZn5eQyClfmlCin5Cnn5JQqpFZnFJVwMbDmJSak5xQxM0bGMDDzJ+UWpukmJxWDVDAyMIAQkACMdFqE="); } } diff --git a/core/src/mindustry/maps/planet/ErekirPlanetGenerator.java b/core/src/mindustry/maps/planet/ErekirPlanetGenerator.java index fe0584930e..1aa2a76d7a 100644 --- a/core/src/mindustry/maps/planet/ErekirPlanetGenerator.java +++ b/core/src/mindustry/maps/planet/ErekirPlanetGenerator.java @@ -49,7 +49,7 @@ public class ErekirPlanetGenerator extends PlanetGenerator{ @Override public Schematic getDefaultLoadout(){ - return Loadouts.basicAegis; + return Loadouts.basicBastion; } float rawHeight(Vec3 position){ diff --git a/core/src/mindustry/world/blocks/defense/ForceProjector.java b/core/src/mindustry/world/blocks/defense/ForceProjector.java index 41d56526fd..250d9e4921 100644 --- a/core/src/mindustry/world/blocks/defense/ForceProjector.java +++ b/core/src/mindustry/world/blocks/defense/ForceProjector.java @@ -196,9 +196,11 @@ public class ForceProjector extends Block{ if(buildup > 0f){ Draw.alpha(buildup / shieldHealth * 0.75f); + Draw.z(Layer.blockAdditive); Draw.blend(Blending.additive); Draw.rect(topRegion, x, y); Draw.blend(); + Draw.z(Layer.block); Draw.reset(); } diff --git a/core/src/mindustry/world/blocks/defense/turrets/LaserTurret.java b/core/src/mindustry/world/blocks/defense/turrets/LaserTurret.java index 1f80bb26fc..8dd7cb9d7b 100644 --- a/core/src/mindustry/world/blocks/defense/turrets/LaserTurret.java +++ b/core/src/mindustry/world/blocks/defense/turrets/LaserTurret.java @@ -52,9 +52,8 @@ public class LaserTurret extends PowerTurret{ if(bulletLife > 0 && bullet != null){ wasShooting = true; - tr.trns(rotation, shootLength, 0f); bullet.rotation(rotation); - bullet.set(x + tr.x, y + tr.y); + bullet.set(x + bulletOffset.x, y + bulletOffset.y); bullet.time(0f); heat = 1f; recoil = recoilAmount; @@ -106,7 +105,7 @@ public class LaserTurret extends PowerTurret{ @Override protected void bullet(BulletType type, float angle){ - bullet = type.create(this, team, x + tr.x, y + tr.y, angle); + bullet = type.create(this, team, x + bulletOffset.x, y + bulletOffset.y, angle); bulletLife = shootDuration; } diff --git a/core/src/mindustry/world/blocks/defense/turrets/LiquidTurret.java b/core/src/mindustry/world/blocks/defense/turrets/LiquidTurret.java index 72c0475aa2..5e02e195a5 100644 --- a/core/src/mindustry/world/blocks/defense/turrets/LiquidTurret.java +++ b/core/src/mindustry/world/blocks/defense/turrets/LiquidTurret.java @@ -30,7 +30,6 @@ public class LiquidTurret extends Turret{ shootSound = Sounds.none; smokeEffect = Fx.none; shootEffect = Fx.none; - outlinedIcon = 1; } /** Initializes accepted ammo map. Format: [liquid1, bullet1, liquid2, bullet2...] */ @@ -79,9 +78,9 @@ public class LiquidTurret extends Turret{ super.draw(); if(liquidRegion.found()){ - Drawf.liquid(liquidRegion, x + tr2.x, y + tr2.y, liquids.total() / liquidCapacity, liquids.current().color, rotation - 90); + Drawf.liquid(liquidRegion, x + recoilOffset.x, y + recoilOffset.y, liquids.total() / liquidCapacity, liquids.current().color, rotation - 90); } - if(topRegion.found()) Draw.rect(topRegion, x + tr2.x, y + tr2.y, rotation - 90); + if(topRegion.found()) Draw.rect(topRegion, x + recoilOffset.x, y + recoilOffset.y, rotation - 90); } @Override @@ -126,24 +125,6 @@ public class LiquidTurret extends Turret{ super.findTarget(); } - @Override - protected void effects(){ - BulletType type = peekAmmo(); - - Effect fshootEffect = shootEffect == Fx.none ? type.shootEffect : shootEffect; - Effect fsmokeEffect = smokeEffect == Fx.none ? type.smokeEffect : smokeEffect; - - fshootEffect.at(x + tr.x, y + tr.y, rotation, liquids.current().color); - fsmokeEffect.at(x + tr.x, y + tr.y, rotation, liquids.current().color); - shootSound.at(tile); - - if(shootShake > 0){ - Effect.shake(shootShake, shootShake, tile.build); - } - - recoil = recoilAmount; - } - @Override public BulletType useAmmo(){ if(cheating()) return ammoTypes.get(liquids.current()); diff --git a/core/src/mindustry/world/blocks/defense/turrets/Turret.java b/core/src/mindustry/world/blocks/defense/turrets/Turret.java index 62183e155e..ceb1e49bd5 100644 --- a/core/src/mindustry/world/blocks/defense/turrets/Turret.java +++ b/core/src/mindustry/world/blocks/defense/turrets/Turret.java @@ -16,14 +16,15 @@ import mindustry.core.*; import mindustry.entities.*; import mindustry.entities.Units.*; import mindustry.entities.bullet.*; -import mindustry.game.*; import mindustry.game.EventType.*; +import mindustry.game.*; import mindustry.gen.*; import mindustry.graphics.*; import mindustry.logic.*; import mindustry.type.*; import mindustry.world.blocks.*; import mindustry.world.consumers.*; +import mindustry.world.drawturret.*; import mindustry.world.meta.*; import static mindustry.Vars.*; @@ -78,29 +79,31 @@ public class Turret extends ReloadTurret{ public Sortf unitSort = UnitSorts.closest; - protected Vec2 tr = new Vec2(); - protected Vec2 tr2 = new Vec2(); - public @Nullable String basePrefix; public @Load(value = "@-base", fallback = "block-@size") TextureRegion baseRegion; public @Load("@-heat") TextureRegion heatRegion; public float elevation = -1f; - public Cons drawer = tile -> Draw.rect(region, tile.x + tr2.x, tile.y + tr2.y, tile.rotation - 90); - public Cons heatDrawer = tile -> { - if(tile.heat <= 0.00001f) return; + public DrawTurret draw = new DrawTurret(); - Draw.color(heatColor, tile.heat); - Draw.blend(Blending.additive); - Draw.rect(heatRegion, tile.x + tr2.x, tile.y + tr2.y, tile.rotation - 90); - Draw.blend(); - Draw.color(); - }; + /** @deprecated use bulletOffset; this will always be zero. **/ + @Deprecated + protected Vec2 tr = new Vec2(); + /** @deprecated use recoilOffset; this will always be zero. **/ + @Deprecated + protected Vec2 tr2 = new Vec2(); + /** @deprecated set the draw field instead, this does nothing */ + @Deprecated + public Cons drawer = tile -> {}; + /** @deprecated set the draw field instead, this does nothing */ + @Deprecated + public Cons heatDrawer = tile -> {}; public Turret(String name){ super(name); liquidCapacity = 20f; quickRotate = false; + outlinedIcon = 1; } @Override @@ -136,6 +139,8 @@ public class Turret extends ReloadTurret{ public void load(){ super.load(); + draw.load(this); + if(basePrefix != null){ baseRegion = Core.atlas.find(basePrefix + "-block-" + size); } @@ -143,7 +148,7 @@ public class Turret extends ReloadTurret{ @Override public TextureRegion[] icons(){ - return new TextureRegion[]{baseRegion, region}; + return draw.icons(this); } public static abstract class AmmoEntry{ @@ -153,6 +158,12 @@ public class Turret extends ReloadTurret{ } public class TurretBuild extends ReloadTurretBuild implements ControlBlock{ + //TODO storing these as instance variables is bad design, but it's probably too late to change everything + /** Turret sprite offset, based on recoil. Updated every frame. */ + public Vec2 recoilOffset = new Vec2(); + /** Turret bullet position offset. Updated every frame. */ + public Vec2 bulletOffset = new Vec2(); + public Seq ammo = new Seq<>(); public int totalAmmo; public float recoil, heat, logicControlTime = -1; @@ -252,14 +263,10 @@ public class Turret extends ReloadTurret{ Draw.z(Layer.turret); - tr2.trns(rotation, -recoil); + Drawf.shadow(region, x + recoilOffset.x - elevation, y + recoilOffset.y - elevation, rotation - 90); - Drawf.shadow(region, x + tr2.x - elevation, y + tr2.y - elevation, rotation - 90); - drawer.get(this); - - if(heatRegion != Core.atlas.find("error")){ - heatDrawer.get(this); - } + draw.draw(Turret.this, this); + draw.drawHeat(Turret.this, this); } @Override @@ -274,6 +281,8 @@ public class Turret extends ReloadTurret{ unit.tile(this); unit.rotation(rotation); unit.team(team); + recoilOffset.trns(rotation, -recoil); + bulletOffset.trns(rotation, shootLength); if(logicControlTime > 0){ logicControlTime -= Time.delta; @@ -400,15 +409,14 @@ public class Turret extends ReloadTurret{ if(chargeTime > 0){ useAmmo(); - tr.trns(rotation, shootLength); - chargeBeginEffect.at(x + tr.x, y + tr.y, rotation); - chargeSound.at(x + tr.x, y + tr.y, 1); + chargeBeginEffect.at(x + bulletOffset.x, y + bulletOffset.y, rotation); + chargeSound.at(x + bulletOffset.x, y + bulletOffset.y, 1); for(int i = 0; i < chargeEffects; i++){ Time.run(Mathf.random(chargeMaxDelay), () -> { if(dead) return; - tr.trns(rotation, shootLength); - chargeEffect.at(x + tr.x, y + tr.y, rotation); + bulletOffset.trns(rotation, shootLength); + chargeEffect.at(x + bulletOffset.x, y + bulletOffset.y, rotation); }); } @@ -416,7 +424,7 @@ public class Turret extends ReloadTurret{ Time.run(chargeTime, () -> { if(dead) return; - tr.trns(rotation, shootLength); + bulletOffset.trns(rotation, shootLength); recoil = recoilAmount; heat = 1f; bullet(type, rotation + Mathf.range(inaccuracy + type.inaccuracy)); @@ -430,7 +438,7 @@ public class Turret extends ReloadTurret{ int ii = i; Time.run(burstSpacing * i, () -> { if(dead || !hasAmmo()) return; - tr.trns(rotation, shootLength, Mathf.range(xRand)); + bulletOffset.trns(rotation, shootLength, Mathf.range(xRand)); bullet(type, rotation + Mathf.range(inaccuracy + type.inaccuracy) + (ii - (int)(shots / 2f)) * spread); effects(); useAmmo(); @@ -445,10 +453,10 @@ public class Turret extends ReloadTurret{ if(alternate){ float i = (shotCounter % shots) - (shots-1)/2f; - tr.trns(rotation - 90, spread * i + Mathf.range(xRand), shootLength); + bulletOffset.trns(rotation - 90, spread * i + Mathf.range(xRand), shootLength); bullet(type, rotation + Mathf.range(inaccuracy + type.inaccuracy)); }else{ - tr.trns(rotation, shootLength, Mathf.range(xRand)); + bulletOffset.trns(rotation, shootLength, Mathf.range(xRand)); for(int i = 0; i < shots; i++){ bullet(type, rotation + Mathf.range(inaccuracy + type.inaccuracy) + (i - (int)(shots / 2f)) * spread); @@ -465,18 +473,18 @@ public class Turret extends ReloadTurret{ } protected void bullet(BulletType type, float angle){ - float lifeScl = type.scaleVelocity ? Mathf.clamp(Mathf.dst(x + tr.x, y + tr.y, targetPos.x, targetPos.y) / type.range(), minRange / type.range(), range / type.range()) : 1f; + float lifeScl = type.scaleVelocity ? Mathf.clamp(Mathf.dst(x + bulletOffset.x, y + bulletOffset.y, targetPos.x, targetPos.y) / type.range(), minRange / type.range(), range / type.range()) : 1f; - type.create(this, team, x + tr.x, y + tr.y, angle, 1f + Mathf.range(velocityInaccuracy), lifeScl); + type.create(this, team, x + bulletOffset.x, y + bulletOffset.y, angle, 1f + Mathf.range(velocityInaccuracy), lifeScl); } protected void effects(){ Effect fshootEffect = shootEffect == Fx.none ? peekAmmo().shootEffect : shootEffect; Effect fsmokeEffect = smokeEffect == Fx.none ? peekAmmo().smokeEffect : smokeEffect; - fshootEffect.at(x + tr.x, y + tr.y, rotation); - fsmokeEffect.at(x + tr.x, y + tr.y, rotation); - shootSound.at(x + tr.x, y + tr.y, Mathf.random(0.9f, 1.1f)); + fshootEffect.at(x + bulletOffset.x, y + bulletOffset.y, rotation); + fsmokeEffect.at(x + bulletOffset.x, y + bulletOffset.y, rotation); + shootSound.at(x + bulletOffset.x, y + bulletOffset.y, Mathf.random(0.9f, 1.1f)); if(shootShake > 0){ Effect.shake(shootShake, shootShake, this); diff --git a/core/src/mindustry/world/draw/DrawBlock.java b/core/src/mindustry/world/draw/DrawBlock.java index 4c186f137b..2961cab669 100644 --- a/core/src/mindustry/world/draw/DrawBlock.java +++ b/core/src/mindustry/world/draw/DrawBlock.java @@ -5,7 +5,7 @@ import arc.math.*; import mindustry.world.*; import mindustry.world.blocks.production.GenericCrafter.*; -/** An implementation of custom rendering behavior for a block. +/** An implementation of custom rendering behavior for a crafter block. * This is used mostly for mods. */ public class DrawBlock{ protected static final Rand rand = new Rand(); diff --git a/core/src/mindustry/world/drawturret/DrawTurret.java b/core/src/mindustry/world/drawturret/DrawTurret.java new file mode 100644 index 0000000000..079bef25f7 --- /dev/null +++ b/core/src/mindustry/world/drawturret/DrawTurret.java @@ -0,0 +1,37 @@ +package mindustry.world.drawturret; + +import arc.graphics.*; +import arc.graphics.g2d.*; +import arc.math.*; +import mindustry.world.blocks.defense.turrets.*; +import mindustry.world.blocks.defense.turrets.Turret.*; + +/** Extend to implement custom drawing behavior for a turret. */ +public class DrawTurret{ + protected static final Rand rand = new Rand(); + + /** Draws the block. */ + public void draw(Turret block, TurretBuild build){ + Draw.rect(block.region, build.x + build.recoilOffset.x, build.y + build.recoilOffset.y, build.rotation - 90); + } + + public void drawHeat(Turret block, TurretBuild build){ + if(build.heat <= 0.00001f || !block.heatRegion.found()) return; + + Draw.color(block.heatColor, build.heat); + Draw.blend(Blending.additive); + Draw.rect(block.heatRegion, build.x + build.recoilOffset.x, build.y + build.recoilOffset.y, build.rotation - 90); + Draw.blend(); + Draw.color(); + } + + /** Load any relevant texture regions. */ + public void load(Turret block){ + + } + + /** @return the generated icons to be used for this block. */ + public TextureRegion[] icons(Turret block){ + return new TextureRegion[]{block.baseRegion, block.region}; + } +}