Refactored fireball into FireBulletType

This commit is contained in:
Anuken
2021-08-08 13:37:55 -04:00
parent 644d00b268
commit 00a2c1aad0
9 changed files with 92 additions and 70 deletions

View File

@@ -90,7 +90,6 @@ importPackage(Packages.mindustry.editor)
importPackage(Packages.mindustry.entities) importPackage(Packages.mindustry.entities)
importPackage(Packages.mindustry.entities.abilities) importPackage(Packages.mindustry.entities.abilities)
importPackage(Packages.mindustry.entities.bullet) importPackage(Packages.mindustry.entities.bullet)
importPackage(Packages.mindustry.entities.comp)
importPackage(Packages.mindustry.entities.effect) importPackage(Packages.mindustry.entities.effect)
importPackage(Packages.mindustry.entities.units) importPackage(Packages.mindustry.entities.units)
importPackage(Packages.mindustry.game) importPackage(Packages.mindustry.game)
@@ -157,6 +156,7 @@ const ResearchEvent = Packages.mindustry.game.EventType.ResearchEvent
const UnlockEvent = Packages.mindustry.game.EventType.UnlockEvent const UnlockEvent = Packages.mindustry.game.EventType.UnlockEvent
const StateChangeEvent = Packages.mindustry.game.EventType.StateChangeEvent const StateChangeEvent = Packages.mindustry.game.EventType.StateChangeEvent
const CoreChangeEvent = Packages.mindustry.game.EventType.CoreChangeEvent const CoreChangeEvent = Packages.mindustry.game.EventType.CoreChangeEvent
const BuildTeamChangeEvent = Packages.mindustry.game.EventType.BuildTeamChangeEvent
const TileChangeEvent = Packages.mindustry.game.EventType.TileChangeEvent const TileChangeEvent = Packages.mindustry.game.EventType.TileChangeEvent
const TilePreChangeEvent = Packages.mindustry.game.EventType.TilePreChangeEvent const TilePreChangeEvent = Packages.mindustry.game.EventType.TilePreChangeEvent
const GameOverEvent = Packages.mindustry.game.EventType.GameOverEvent const GameOverEvent = Packages.mindustry.game.EventType.GameOverEvent

View File

@@ -1,17 +1,9 @@
package mindustry.content; package mindustry.content;
import arc.graphics.*; import arc.graphics.*;
import arc.graphics.g2d.*;
import arc.math.*;
import arc.util.*;
import mindustry.ctype.*; import mindustry.ctype.*;
import mindustry.entities.*;
import mindustry.entities.bullet.*; import mindustry.entities.bullet.*;
import mindustry.gen.*;
import mindustry.graphics.*; import mindustry.graphics.*;
import mindustry.world.*;
import static mindustry.Vars.*;
public class Bullets implements ContentList{ public class Bullets implements ContentList{
public static BulletType public static BulletType
@@ -377,47 +369,9 @@ public class Bullets implements ContentList{
ammoMultiplier = 3; ammoMultiplier = 3;
}}; }};
fireball = new BulletType(1f, 4){ fireball = new FireBulletType(1f, 4);
{
pierce = true;
collidesTiles = false;
collides = false;
drag = 0.03f;
hitEffect = despawnEffect = Fx.none;
}
@Override basicFlame = new BulletType(3.35f, 17f){{
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){{
ammoMultiplier = 3f; ammoMultiplier = 3f;
hitSize = 7f; hitSize = 7f;
lifetime = 18f; lifetime = 18f;
@@ -432,7 +386,7 @@ public class Bullets implements ContentList{
hittable = false; hittable = false;
}}; }};
pyraFlame = new BulletType(4f, 45f){{ pyraFlame = new BulletType(4f, 50f){{
ammoMultiplier = 6f; ammoMultiplier = 6f;
hitSize = 7f; hitSize = 7f;
lifetime = 18f; lifetime = 18f;

View File

@@ -101,10 +101,10 @@ public class UnitTypes implements ContentList{
reload = 11f; reload = 11f;
recoil = 1f; recoil = 1f;
ejectEffect = Fx.none; ejectEffect = Fx.none;
bullet = new BulletType(4.1f, 32f){{ bullet = new BulletType(4.1f, 35f){{
ammoMultiplier = 3f; ammoMultiplier = 3f;
hitSize = 7f; hitSize = 7f;
lifetime = 12f; lifetime = 13f;
pierce = true; pierce = true;
statusDuration = 60f * 4; statusDuration = 60f * 4;
shootEffect = Fx.shootSmallFlame; shootEffect = Fx.shootSmallFlame;
@@ -344,7 +344,7 @@ public class UnitTypes implements ContentList{
bullet = new LightningBulletType(){{ bullet = new LightningBulletType(){{
lightningColor = hitColor = Pal.heal; lightningColor = hitColor = Pal.heal;
damage = 12f; damage = 14f;
lightningLength = 7; lightningLength = 7;
lightningLengthRand = 7; lightningLengthRand = 7;
shootEffect = Fx.shootHeal; shootEffect = Fx.shootHeal;

View File

@@ -343,15 +343,6 @@ public class BulletType extends Content implements Cloneable{
if(instantDisappear){ if(instantDisappear){
b.time = lifetime; 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){ public void update(Bullet b){
@@ -412,6 +403,15 @@ public class BulletType extends Content implements Cloneable{
if(lightningType == null){ if(lightningType == null){
lightningType = !collidesAir ? Bullets.damageLightningGround : Bullets.damageLightning; 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 @Override

View File

@@ -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);
}
}
}

View File

@@ -13,7 +13,7 @@ import static mindustry.Vars.*;
public class MassDriverBolt extends BulletType{ public class MassDriverBolt extends BulletType{
public MassDriverBolt(){ public MassDriverBolt(){
super(1f, 50); super(1f, 75);
collidesTiles = false; collidesTiles = false;
lifetime = 1f; lifetime = 1f;
despawnEffect = Fx.smeltsmoke; despawnEffect = Fx.smeltsmoke;

View File

@@ -31,6 +31,7 @@ public class ClassMap{
classes.put("BulletType", mindustry.entities.bullet.BulletType.class); classes.put("BulletType", mindustry.entities.bullet.BulletType.class);
classes.put("ContinuousLaserBulletType", mindustry.entities.bullet.ContinuousLaserBulletType.class); classes.put("ContinuousLaserBulletType", mindustry.entities.bullet.ContinuousLaserBulletType.class);
classes.put("EmpBulletType", mindustry.entities.bullet.EmpBulletType.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("FlakBulletType", mindustry.entities.bullet.FlakBulletType.class);
classes.put("LaserBoltBulletType", mindustry.entities.bullet.LaserBoltBulletType.class); classes.put("LaserBoltBulletType", mindustry.entities.bullet.LaserBoltBulletType.class);
classes.put("LaserBulletType", mindustry.entities.bullet.LaserBulletType.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("DuctBridge", mindustry.world.blocks.distribution.DuctBridge.class);
classes.put("DuctBridgeBuild", mindustry.world.blocks.distribution.DuctBridge.DuctBridgeBuild.class); classes.put("DuctBridgeBuild", mindustry.world.blocks.distribution.DuctBridge.DuctBridgeBuild.class);
classes.put("DuctRouter", mindustry.world.blocks.distribution.DuctRouter.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("ExtendingItemBridge", mindustry.world.blocks.distribution.ExtendingItemBridge.class);
classes.put("ExtendingItemBridgeBuild", mindustry.world.blocks.distribution.ExtendingItemBridge.ExtendingItemBridgeBuild.class); classes.put("ExtendingItemBridgeBuild", mindustry.world.blocks.distribution.ExtendingItemBridge.ExtendingItemBridgeBuild.class);
classes.put("ItemBridge", mindustry.world.blocks.distribution.ItemBridge.class); classes.put("ItemBridge", mindustry.world.blocks.distribution.ItemBridge.class);

View File

@@ -13,6 +13,7 @@ import arc.struct.*;
import arc.util.*; import arc.util.*;
import mindustry.gen.*; import mindustry.gen.*;
import mindustry.graphics.*; import mindustry.graphics.*;
import mindustry.ui.*;
import static arc.Core.*; import static arc.Core.*;
@@ -72,7 +73,7 @@ public class KeybindDialog extends Dialog{
} }
if(sections.length != 1){ 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)) if(section.equals(this.section))
button.toggle(); button.toggle();
@@ -115,6 +116,7 @@ public class KeybindDialog extends Dialog{
} }
}).disabled(sectionControls.get(section, 0) + 1 >= devices.size).size(40); }).disabled(sectionControls.get(section, 0) + 1 >= devices.size).size(40);
//no alternate devices until further notice
//table.add(stable).colspan(4).row(); //table.add(stable).colspan(4).row();
table.add().height(10); table.add().height(10);
@@ -126,6 +128,7 @@ public class KeybindDialog extends Dialog{
table.row(); table.row();
String lastCategory = null; String lastCategory = null;
var tstyle = Styles.defaultt;
for(KeyBind keybind : keybinds.getKeybinds()){ for(KeyBind keybind : keybinds.getKeybinds()){
if(lastCategory != keybind.category() && keybind.category() != null){ 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.add(axt).left().minWidth(90).padRight(20);
} }
table.button(bundle.get("settings.rebind", "Rebind"), () -> { table.button("@settings.rebind", tstyle, () -> {
rebindAxis = true; rebindAxis = true;
rebindMin = true; rebindMin = true;
openDialog(section, keybind); openDialog(section, keybind);
@@ -159,13 +162,13 @@ public class KeybindDialog extends Dialog{
table.add(keybinds.get(section, keybind).key.toString(), table.add(keybinds.get(section, keybind).key.toString(),
style.keyColor).left().minWidth(90).padRight(20); style.keyColor).left().minWidth(90).padRight(20);
table.button(bundle.get("settings.rebind", "Rebind"), () -> { table.button("@settings.rebind", tstyle, () -> {
rebindAxis = false; rebindAxis = false;
rebindMin = false; rebindMin = false;
openDialog(section, keybind); openDialog(section, keybind);
}).width(130f); }).width(130f);
} }
table.button(bundle.get("settings.resetKey", "Reset"), () -> { table.button("@settings.resetKey", tstyle, () -> {
keybinds.resetToDefault(section, keybind); keybinds.resetToDefault(section, keybind);
setup(); setup();
}).width(130f); }).width(130f);
@@ -174,7 +177,7 @@ public class KeybindDialog extends Dialog{
table.visible(() -> this.section.equals(section)); table.visible(() -> this.section.equals(section));
table.button(bundle.get("settings.reset", "Reset to Defaults"), () -> { table.button("@settings.reset", () -> {
keybinds.resetToDefaults(); keybinds.resetToDefaults();
setup(); setup();
}).colspan(4).padTop(4).fill(); }).colspan(4).padTop(4).fill();

View File

@@ -48,7 +48,7 @@ public class DuctRouter extends Block{
Draw.rect(topRegion, req.drawx(), req.drawy(), req.rotation * 90); Draw.rect(topRegion, req.drawx(), req.drawy(), req.rotation * 90);
} }
public class DuctBuild extends Building{ public class DuctRouterBuild extends Building{
public float progress; public float progress;
public @Nullable Item current; public @Nullable Item current;