From 00a2c1aad0a626b663c6379013ad322395a53729 Mon Sep 17 00:00:00 2001 From: Anuken Date: Sun, 8 Aug 2021 13:37:55 -0400 Subject: [PATCH] Refactored fireball into FireBulletType --- core/assets/scripts/global.js | 2 +- core/src/mindustry/content/Bullets.java | 52 +-------------- core/src/mindustry/content/UnitTypes.java | 6 +- .../mindustry/entities/bullet/BulletType.java | 18 +++--- .../entities/bullet/FireBulletType.java | 64 +++++++++++++++++++ .../entities/bullet/MassDriverBolt.java | 2 +- core/src/mindustry/mod/ClassMap.java | 3 +- .../mindustry/ui/dialogs/KeybindDialog.java | 13 ++-- .../world/blocks/distribution/DuctRouter.java | 2 +- 9 files changed, 92 insertions(+), 70 deletions(-) create mode 100644 core/src/mindustry/entities/bullet/FireBulletType.java diff --git a/core/assets/scripts/global.js b/core/assets/scripts/global.js index 4f81328cce..37b756544e 100755 --- a/core/assets/scripts/global.js +++ b/core/assets/scripts/global.js @@ -90,7 +90,6 @@ importPackage(Packages.mindustry.editor) importPackage(Packages.mindustry.entities) importPackage(Packages.mindustry.entities.abilities) importPackage(Packages.mindustry.entities.bullet) -importPackage(Packages.mindustry.entities.comp) importPackage(Packages.mindustry.entities.effect) importPackage(Packages.mindustry.entities.units) importPackage(Packages.mindustry.game) @@ -157,6 +156,7 @@ const ResearchEvent = Packages.mindustry.game.EventType.ResearchEvent const UnlockEvent = Packages.mindustry.game.EventType.UnlockEvent const StateChangeEvent = Packages.mindustry.game.EventType.StateChangeEvent const CoreChangeEvent = Packages.mindustry.game.EventType.CoreChangeEvent +const BuildTeamChangeEvent = Packages.mindustry.game.EventType.BuildTeamChangeEvent const TileChangeEvent = Packages.mindustry.game.EventType.TileChangeEvent const TilePreChangeEvent = Packages.mindustry.game.EventType.TilePreChangeEvent const GameOverEvent = Packages.mindustry.game.EventType.GameOverEvent diff --git a/core/src/mindustry/content/Bullets.java b/core/src/mindustry/content/Bullets.java index 600bf4fddf..abef6c9c16 100644 --- a/core/src/mindustry/content/Bullets.java +++ b/core/src/mindustry/content/Bullets.java @@ -1,17 +1,9 @@ package mindustry.content; import arc.graphics.*; -import arc.graphics.g2d.*; -import arc.math.*; -import arc.util.*; import mindustry.ctype.*; -import mindustry.entities.*; import mindustry.entities.bullet.*; -import mindustry.gen.*; import mindustry.graphics.*; -import mindustry.world.*; - -import static mindustry.Vars.*; public class Bullets implements ContentList{ public static BulletType @@ -377,47 +369,9 @@ public class Bullets implements ContentList{ ammoMultiplier = 3; }}; - fireball = new BulletType(1f, 4){ - { - pierce = true; - collidesTiles = false; - collides = false; - drag = 0.03f; - hitEffect = despawnEffect = Fx.none; - } + fireball = new FireBulletType(1f, 4); - @Override - public void init(Bullet b){ - b.vel.setLength(0.6f + Mathf.random(2f)); - } - - @Override - public void draw(Bullet b){ - Draw.color(Pal.lightFlame, Pal.darkFlame, Color.gray, b.fin()); - Fill.circle(b.x, b.y, 3f * b.fout()); - Draw.reset(); - } - - @Override - public void update(Bullet b){ - if(Mathf.chance(0.04 * Time.delta)){ - Tile tile = world.tileWorld(b.x, b.y); - if(tile != null){ - Fires.create(tile); - } - } - - if(Mathf.chance(0.1 * Time.delta)){ - Fx.fireballsmoke.at(b.x, b.y); - } - - if(Mathf.chance(0.1 * Time.delta)){ - Fx.ballfire.at(b.x, b.y); - } - } - }; - - basicFlame = new BulletType(3.35f, 16f){{ + basicFlame = new BulletType(3.35f, 17f){{ ammoMultiplier = 3f; hitSize = 7f; lifetime = 18f; @@ -432,7 +386,7 @@ public class Bullets implements ContentList{ hittable = false; }}; - pyraFlame = new BulletType(4f, 45f){{ + pyraFlame = new BulletType(4f, 50f){{ ammoMultiplier = 6f; hitSize = 7f; lifetime = 18f; diff --git a/core/src/mindustry/content/UnitTypes.java b/core/src/mindustry/content/UnitTypes.java index 67d7bde521..cbf721be16 100644 --- a/core/src/mindustry/content/UnitTypes.java +++ b/core/src/mindustry/content/UnitTypes.java @@ -101,10 +101,10 @@ public class UnitTypes implements ContentList{ reload = 11f; recoil = 1f; ejectEffect = Fx.none; - bullet = new BulletType(4.1f, 32f){{ + bullet = new BulletType(4.1f, 35f){{ ammoMultiplier = 3f; hitSize = 7f; - lifetime = 12f; + lifetime = 13f; pierce = true; statusDuration = 60f * 4; shootEffect = Fx.shootSmallFlame; @@ -344,7 +344,7 @@ public class UnitTypes implements ContentList{ bullet = new LightningBulletType(){{ lightningColor = hitColor = Pal.heal; - damage = 12f; + damage = 14f; lightningLength = 7; lightningLengthRand = 7; shootEffect = Fx.shootHeal; diff --git a/core/src/mindustry/entities/bullet/BulletType.java b/core/src/mindustry/entities/bullet/BulletType.java index 3640299921..213c911a6b 100644 --- a/core/src/mindustry/entities/bullet/BulletType.java +++ b/core/src/mindustry/entities/bullet/BulletType.java @@ -343,15 +343,6 @@ public class BulletType extends Content implements Cloneable{ if(instantDisappear){ b.time = lifetime; } - - if(fragBullet != null || splashDamageRadius > 0 || lightning > 0){ - despawnHit = true; - } - - if(lightRadius == -1){ - lightRadius = Math.max(18, hitSize * 5f); - } - drawSize = Math.max(drawSize, trailLength * speed * 2f); } public void update(Bullet b){ @@ -412,6 +403,15 @@ public class BulletType extends Content implements Cloneable{ if(lightningType == null){ lightningType = !collidesAir ? Bullets.damageLightningGround : Bullets.damageLightning; } + + if(fragBullet != null || splashDamageRadius > 0 || lightning > 0){ + despawnHit = true; + } + + if(lightRadius == -1){ + lightRadius = Math.max(18, hitSize * 5f); + } + drawSize = Math.max(drawSize, trailLength * speed * 2f); } @Override diff --git a/core/src/mindustry/entities/bullet/FireBulletType.java b/core/src/mindustry/entities/bullet/FireBulletType.java new file mode 100644 index 0000000000..a2b14e4481 --- /dev/null +++ b/core/src/mindustry/entities/bullet/FireBulletType.java @@ -0,0 +1,64 @@ +package mindustry.entities.bullet; + +import arc.graphics.*; +import arc.graphics.g2d.*; +import arc.math.*; +import mindustry.content.*; +import mindustry.entities.*; +import mindustry.gen.*; +import mindustry.graphics.*; + +public class FireBulletType extends BulletType{ + public Color colorFrom = Pal.lightFlame, colorMid = Pal.darkFlame, colorTo = Color.gray; + public float radius = 3f; + public float velMin = 0.6f, velMax = 2.6f; + public float fireTrailChance = 0.04f; + public Effect trailEffect2 = Fx.ballfire; + public float fireEffectChance = 0.1f, fireEffectChance2 = 0.1f; + + { + pierce = true; + collidesTiles = false; + collides = false; + drag = 0.03f; + hitEffect = despawnEffect = Fx.none; + trailEffect = Fx.fireballsmoke; + } + + public FireBulletType(float speed, float damage){ + super(speed, damage); + } + + public FireBulletType(){} + + @Override + public void init(Bullet b){ + super.init(b); + + b.vel.setLength(Mathf.random(velMin, velMax)); + } + + @Override + public void draw(Bullet b){ + Draw.color(colorFrom, colorMid, colorTo, b.fin()); + Fill.circle(b.x, b.y, radius * b.fout()); + Draw.reset(); + } + + @Override + public void update(Bullet b){ + super.update(b); + + if(Mathf.chanceDelta(fireTrailChance)){ + Fires.create(b.tileOn()); + } + + if(Mathf.chanceDelta(fireEffectChance)){ + trailEffect.at(b.x, b.y); + } + + if(Mathf.chanceDelta(fireEffectChance2)){ + trailEffect2.at(b.x, b.y); + } + } +} diff --git a/core/src/mindustry/entities/bullet/MassDriverBolt.java b/core/src/mindustry/entities/bullet/MassDriverBolt.java index 91dae839a8..006c490183 100644 --- a/core/src/mindustry/entities/bullet/MassDriverBolt.java +++ b/core/src/mindustry/entities/bullet/MassDriverBolt.java @@ -13,7 +13,7 @@ import static mindustry.Vars.*; public class MassDriverBolt extends BulletType{ public MassDriverBolt(){ - super(1f, 50); + super(1f, 75); collidesTiles = false; lifetime = 1f; despawnEffect = Fx.smeltsmoke; diff --git a/core/src/mindustry/mod/ClassMap.java b/core/src/mindustry/mod/ClassMap.java index 9b7b017cf8..9faafacdeb 100644 --- a/core/src/mindustry/mod/ClassMap.java +++ b/core/src/mindustry/mod/ClassMap.java @@ -31,6 +31,7 @@ public class ClassMap{ classes.put("BulletType", mindustry.entities.bullet.BulletType.class); classes.put("ContinuousLaserBulletType", mindustry.entities.bullet.ContinuousLaserBulletType.class); classes.put("EmpBulletType", mindustry.entities.bullet.EmpBulletType.class); + classes.put("FireBulletType", mindustry.entities.bullet.FireBulletType.class); classes.put("FlakBulletType", mindustry.entities.bullet.FlakBulletType.class); classes.put("LaserBoltBulletType", mindustry.entities.bullet.LaserBoltBulletType.class); classes.put("LaserBulletType", mindustry.entities.bullet.LaserBulletType.class); @@ -140,7 +141,7 @@ public class ClassMap{ classes.put("DuctBridge", mindustry.world.blocks.distribution.DuctBridge.class); classes.put("DuctBridgeBuild", mindustry.world.blocks.distribution.DuctBridge.DuctBridgeBuild.class); classes.put("DuctRouter", mindustry.world.blocks.distribution.DuctRouter.class); - classes.put("DuctBuild", mindustry.world.blocks.distribution.DuctRouter.DuctBuild.class); + classes.put("DuctRouterBuild", mindustry.world.blocks.distribution.DuctRouter.DuctRouterBuild.class); classes.put("ExtendingItemBridge", mindustry.world.blocks.distribution.ExtendingItemBridge.class); classes.put("ExtendingItemBridgeBuild", mindustry.world.blocks.distribution.ExtendingItemBridge.ExtendingItemBridgeBuild.class); classes.put("ItemBridge", mindustry.world.blocks.distribution.ItemBridge.class); diff --git a/core/src/mindustry/ui/dialogs/KeybindDialog.java b/core/src/mindustry/ui/dialogs/KeybindDialog.java index f718333ee3..c51003724c 100644 --- a/core/src/mindustry/ui/dialogs/KeybindDialog.java +++ b/core/src/mindustry/ui/dialogs/KeybindDialog.java @@ -13,6 +13,7 @@ import arc.struct.*; import arc.util.*; import mindustry.gen.*; import mindustry.graphics.*; +import mindustry.ui.*; import static arc.Core.*; @@ -72,7 +73,7 @@ public class KeybindDialog extends Dialog{ } if(sections.length != 1){ - TextButton button = new TextButton(bundle.get("section." + section.name + ".name", Strings.capitalize(section.name))/*, "toggle"*/); + TextButton button = new TextButton(bundle.get("section." + section.name + ".name", Strings.capitalize(section.name))); if(section.equals(this.section)) button.toggle(); @@ -115,6 +116,7 @@ public class KeybindDialog extends Dialog{ } }).disabled(sectionControls.get(section, 0) + 1 >= devices.size).size(40); + //no alternate devices until further notice //table.add(stable).colspan(4).row(); table.add().height(10); @@ -126,6 +128,7 @@ public class KeybindDialog extends Dialog{ table.row(); String lastCategory = null; + var tstyle = Styles.defaultt; for(KeyBind keybind : keybinds.getKeybinds()){ if(lastCategory != keybind.category() && keybind.category() != null){ @@ -148,7 +151,7 @@ public class KeybindDialog extends Dialog{ table.add(axt).left().minWidth(90).padRight(20); } - table.button(bundle.get("settings.rebind", "Rebind"), () -> { + table.button("@settings.rebind", tstyle, () -> { rebindAxis = true; rebindMin = true; openDialog(section, keybind); @@ -159,13 +162,13 @@ public class KeybindDialog extends Dialog{ table.add(keybinds.get(section, keybind).key.toString(), style.keyColor).left().minWidth(90).padRight(20); - table.button(bundle.get("settings.rebind", "Rebind"), () -> { + table.button("@settings.rebind", tstyle, () -> { rebindAxis = false; rebindMin = false; openDialog(section, keybind); }).width(130f); } - table.button(bundle.get("settings.resetKey", "Reset"), () -> { + table.button("@settings.resetKey", tstyle, () -> { keybinds.resetToDefault(section, keybind); setup(); }).width(130f); @@ -174,7 +177,7 @@ public class KeybindDialog extends Dialog{ table.visible(() -> this.section.equals(section)); - table.button(bundle.get("settings.reset", "Reset to Defaults"), () -> { + table.button("@settings.reset", () -> { keybinds.resetToDefaults(); setup(); }).colspan(4).padTop(4).fill(); diff --git a/core/src/mindustry/world/blocks/distribution/DuctRouter.java b/core/src/mindustry/world/blocks/distribution/DuctRouter.java index 69f90d52d4..c9f8cb0967 100644 --- a/core/src/mindustry/world/blocks/distribution/DuctRouter.java +++ b/core/src/mindustry/world/blocks/distribution/DuctRouter.java @@ -48,7 +48,7 @@ public class DuctRouter extends Block{ Draw.rect(topRegion, req.drawx(), req.drawy(), req.rotation * 90); } - public class DuctBuild extends Building{ + public class DuctRouterBuild extends Building{ public float progress; public @Nullable Item current;