diff --git a/core/src/mindustry/Vars.java b/core/src/mindustry/Vars.java index 8a9f850a61..6343998991 100644 --- a/core/src/mindustry/Vars.java +++ b/core/src/mindustry/Vars.java @@ -146,6 +146,8 @@ public class Vars implements Loadable{ public static int maxTextureSize = 2048; /** Whether to show the core landing animation. */ public static boolean showLandAnimation = true; + /** Whether to show the campaign core launch animation. */ + public static boolean showLaunchAnimation = true; /** Whether to show sector info upon landing. */ public static boolean showSectorLandInfo = true; /** Whether to check for memory use before taking screenshots. */ diff --git a/core/src/mindustry/content/UnitTypes.java b/core/src/mindustry/content/UnitTypes.java index cf0593afc6..571f01f9ad 100644 --- a/core/src/mindustry/content/UnitTypes.java +++ b/core/src/mindustry/content/UnitTypes.java @@ -14,6 +14,7 @@ import mindustry.entities.effect.*; import mindustry.gen.*; import mindustry.graphics.*; import mindustry.type.*; +import mindustry.type.ammo.*; import mindustry.type.weapons.*; import mindustry.world.meta.*; @@ -89,7 +90,7 @@ public class UnitTypes implements ContentList{ hitSize = 10f; health = 540; armor = 4f; - ammoType = AmmoTypes.coal; + ammoType = new ItemAmmoType(Items.coal); immunities.add(StatusEffects.burning); @@ -124,7 +125,7 @@ public class UnitTypes implements ContentList{ health = 900; armor = 9f; mechFrontSway = 0.55f; - ammoType = AmmoTypes.graphite; + ammoType = new ItemAmmoType(Items.graphite); weapons.add(new Weapon("artillery"){{ top = false; @@ -158,7 +159,7 @@ public class UnitTypes implements ContentList{ armor = 10f; canDrown = false; mechFrontSway = 1f; - ammoType = AmmoTypes.thorium; + ammoType = new ItemAmmoType(Items.thorium); mechStepParticles = true; mechStepShake = 0.15f; @@ -223,7 +224,7 @@ public class UnitTypes implements ContentList{ canDrown = false; mechFrontSway = 1.9f; mechSideSway = 0.6f; - ammoType = AmmoTypes.thorium; + ammoType = new ItemAmmoType(Items.thorium); weapons.add( new Weapon("reign-weapon"){{ @@ -286,7 +287,7 @@ public class UnitTypes implements ContentList{ commandLimit = 8; abilities.add(new RepairFieldAbility(10f, 60f * 4, 60f)); - ammoType = AmmoTypes.power; + ammoType = new PowerAmmoType(1000); weapons.add(new Weapon("heal-weapon"){{ top = false; @@ -323,7 +324,7 @@ public class UnitTypes implements ContentList{ commandLimit = 9; abilities.add(new ShieldRegenFieldAbility(20f, 40f, 60f * 5, 60f)); - ammoType = AmmoTypes.power; + ammoType = new PowerAmmoType(1300); weapons.add(new Weapon("heal-shotgun-weapon"){{ top = false; @@ -376,7 +377,7 @@ public class UnitTypes implements ContentList{ commandLimit = 10; mechFrontSway = 0.55f; - ammoType = AmmoTypes.power; + ammoType = new PowerAmmoType(1500); speed = 0.4f; hitSize = 13f; @@ -419,7 +420,7 @@ public class UnitTypes implements ContentList{ mechStepParticles = true; mechStepShake = 0.15f; - ammoType = AmmoTypes.powerHigh; + ammoType = new PowerAmmoType(2500); speed = 0.4f; boostMultiplier = 2.2f; @@ -497,7 +498,7 @@ public class UnitTypes implements ContentList{ hovering = true; visualElevation = 0.2f; allowLegStep = true; - ammoType = AmmoTypes.powerHigh; + ammoType = new PowerAmmoType(4000); groundLayer = Layer.legUnit; speed = 0.3f; @@ -562,7 +563,7 @@ public class UnitTypes implements ContentList{ health = 200; mechSideSway = 0.25f; range = 40f; - ammoType = AmmoTypes.coal; + ammoType = new ItemAmmoType(Items.coal); weapons.add(new Weapon(){{ reload = 24f; @@ -600,7 +601,7 @@ public class UnitTypes implements ContentList{ legMoveSpace = 1.4f; hovering = true; armor = 3f; - ammoType = AmmoTypes.coal; + ammoType = new ItemAmmoType(Items.coal); allowLegStep = true; visualElevation = 0.2f; @@ -640,7 +641,7 @@ public class UnitTypes implements ContentList{ legBaseOffset = 2f; hovering = true; armor = 5f; - ammoType = AmmoTypes.power; + ammoType = new PowerAmmoType(1000); buildSpeed = 0.75f; @@ -712,7 +713,7 @@ public class UnitTypes implements ContentList{ legLengthScl = 0.96f; rippleScale = 2f; legSpeed = 0.2f; - ammoType = AmmoTypes.power; + ammoType = new PowerAmmoType(2000); buildSpeed = 1f; legSplashDamage = 32; @@ -816,7 +817,7 @@ public class UnitTypes implements ContentList{ legLengthScl = 0.93f; rippleScale = 3f; legSpeed = 0.19f; - ammoType = AmmoTypes.powerHigh; + ammoType = new ItemAmmoType(Items.graphite, 8); buildSpeed = 1f; legSplashDamage = 80; @@ -971,7 +972,7 @@ public class UnitTypes implements ContentList{ targetFlags = new BlockFlag[]{BlockFlag.factory, null}; commandLimit = 5; circleTarget = true; - ammoType = AmmoTypes.graphite; + ammoType = new ItemAmmoType(Items.graphite); weapons.add(new Weapon(){{ minShootVelocity = 0.75f; @@ -1010,7 +1011,7 @@ public class UnitTypes implements ContentList{ targetFlags = new BlockFlag[]{BlockFlag.launchPad, BlockFlag.storage, BlockFlag.battery, null}; engineOffset = 12f; engineSize = 3f; - ammoType = AmmoTypes.graphite; + ammoType = new ItemAmmoType(Items.graphite); weapons.add(new Weapon("zenith-missiles"){{ reload = 40f; @@ -1056,7 +1057,7 @@ public class UnitTypes implements ContentList{ engineSize = 5.3f; hitSize = 46f; targetFlags = new BlockFlag[]{BlockFlag.generator, BlockFlag.core, null}; - ammoType = AmmoTypes.thorium; + ammoType = new ItemAmmoType(Items.thorium); BulletType missiles = new MissileBulletType(2.7f, 14){{ width = 8f; @@ -1132,7 +1133,7 @@ public class UnitTypes implements ContentList{ destructibleWreck = false; armor = 13f; targetFlags = new BlockFlag[]{BlockFlag.reactor, BlockFlag.core, null}; - ammoType = AmmoTypes.thorium; + ammoType = new ItemAmmoType(Items.thorium); BulletType fragBullet = new FlakBulletType(4f, 5){{ shootEffect = Fx.shootBig; @@ -1212,7 +1213,7 @@ public class UnitTypes implements ContentList{ range = 50f; isCounted = false; - ammoType = AmmoTypes.powerLow; + ammoType = new PowerAmmoType(500); mineTier = 1; mineSpeed = 2.5f; @@ -1233,7 +1234,7 @@ public class UnitTypes implements ContentList{ hitSize = 9f; lowAltitude = true; - ammoType = AmmoTypes.power; + ammoType = new PowerAmmoType(900); mineTier = 2; mineSpeed = 3.5f; @@ -1293,7 +1294,7 @@ public class UnitTypes implements ContentList{ buildSpeed = 2.6f; isCounted = false; - ammoType = AmmoTypes.power; + ammoType = new PowerAmmoType(1100); weapons.add( new Weapon("heal-weapon-mount"){{ @@ -1347,7 +1348,7 @@ public class UnitTypes implements ContentList{ targetAir = false; targetFlags = new BlockFlag[]{BlockFlag.battery, BlockFlag.factory, null}; - ammoType = AmmoTypes.powerHigh; + ammoType = new PowerAmmoType(3000); weapons.add( new Weapon(){{ @@ -1485,7 +1486,7 @@ public class UnitTypes implements ContentList{ accel = 0.3f; rotateSpeed = 2.6f; rotateShooting = false; - ammoType = AmmoTypes.graphite; + ammoType = new ItemAmmoType(Items.graphite); trailLength = 20; trailX = 5.5f; @@ -1529,7 +1530,7 @@ public class UnitTypes implements ContentList{ hitSize = 20f; armor = 7f; rotateShooting = false; - ammoType = AmmoTypes.graphite; + ammoType = new ItemAmmoType(Items.graphite); trailLength = 22; trailX = 7f; @@ -1593,7 +1594,7 @@ public class UnitTypes implements ContentList{ inaccuracy = 5f; velocityRnd = 0.1f; shootSound = Sounds.missile; - ammoType = AmmoTypes.thorium; + ammoType = new ItemAmmoType(Items.thorium); ejectEffect = Fx.none; bullet = new MissileBulletType(2.7f, 12){{ @@ -1627,7 +1628,7 @@ public class UnitTypes implements ContentList{ accel = 0.2f; rotateSpeed = 1.3f; rotateShooting = false; - ammoType = AmmoTypes.thorium; + ammoType = new ItemAmmoType(Items.thorium); trailLength = 50; trailX = 18f; @@ -1713,7 +1714,7 @@ public class UnitTypes implements ContentList{ accel = 0.19f; rotateSpeed = 0.9f; rotateShooting = false; - ammoType = AmmoTypes.powerHigh; + ammoType = new PowerAmmoType(4000); float spawnTime = 60f * 15f; @@ -1771,7 +1772,7 @@ public class UnitTypes implements ContentList{ trailScl = 1.3f; rotateShooting = false; range = 100f; - ammoType = AmmoTypes.power; + ammoType = new PowerAmmoType(900); armor = 3f; @@ -1849,7 +1850,7 @@ public class UnitTypes implements ContentList{ trailX = 5.5f; trailY = -4f; trailScl = 1.9f; - ammoType = AmmoTypes.coal; + ammoType = new ItemAmmoType(Items.coal); buildSpeed = 2f; @@ -1918,7 +1919,7 @@ public class UnitTypes implements ContentList{ hitSize = 20f; armor = 6f; rotateShooting = false; - ammoType = AmmoTypes.graphite; + ammoType = new ItemAmmoType(Items.graphite); trailLength = 23; trailX = 9f; @@ -2054,7 +2055,7 @@ public class UnitTypes implements ContentList{ accel = 0.2f; rotateSpeed = 1.4f; rotateShooting = false; - ammoType = AmmoTypes.powerHigh; + ammoType = new PowerAmmoType(3500); ammoCapacity = 40; //clip size is massive due to energy field @@ -2099,7 +2100,7 @@ public class UnitTypes implements ContentList{ accel = 0.2f; rotateSpeed = 1.1f; rotateShooting = false; - ammoType = AmmoTypes.powerHigh; + ammoType = new PowerAmmoType(4500); trailLength = 70; trailX = 23f; diff --git a/core/src/mindustry/core/ContentLoader.java b/core/src/mindustry/core/ContentLoader.java index e00fec3061..f74ae47f07 100644 --- a/core/src/mindustry/core/ContentLoader.java +++ b/core/src/mindustry/core/ContentLoader.java @@ -34,7 +34,6 @@ public class ContentLoader{ new StatusEffects(), new Liquids(), new Bullets(), - new AmmoTypes(), new UnitTypes(), new Blocks(), new Loadouts(), diff --git a/core/src/mindustry/core/Control.java b/core/src/mindustry/core/Control.java index d5f6343190..936fc15ea1 100644 --- a/core/src/mindustry/core/Control.java +++ b/core/src/mindustry/core/Control.java @@ -203,7 +203,7 @@ public class Control implements ApplicationListener, Loadable{ if(showLandAnimation){ //delay player respawn so animation can play. - player.deathTimer = -70f; + player.deathTimer = -80f; //TODO this sounds pretty bad due to conflict if(settings.getInt("musicvol") > 0){ Musics.land.stop(); @@ -212,7 +212,7 @@ public class Control implements ApplicationListener, Loadable{ } app.post(() -> ui.hudfrag.showLand()); - renderer.showLaunch(); + renderer.showLanding(); Time.run(coreLandDuration, () -> { Fx.launch.at(core); diff --git a/core/src/mindustry/core/Renderer.java b/core/src/mindustry/core/Renderer.java index b0ba92f5ae..e728149e15 100644 --- a/core/src/mindustry/core/Renderer.java +++ b/core/src/mindustry/core/Renderer.java @@ -453,7 +453,7 @@ public class Renderer implements ApplicationListener{ clampScale(); } - public void showLaunch(){ + public void showLanding(){ landscale = minZoomScl; landTime = coreLandDuration; cloudSeed = Mathf.random(1f); diff --git a/core/src/mindustry/ctype/ContentType.java b/core/src/mindustry/ctype/ContentType.java index e62377628c..8dfffce5e3 100644 --- a/core/src/mindustry/ctype/ContentType.java +++ b/core/src/mindustry/ctype/ContentType.java @@ -16,7 +16,7 @@ public enum ContentType{ typeid_UNUSED, error, planet, - ammo; + ammo_UNUSED; public static final ContentType[] all = values(); } diff --git a/core/src/mindustry/mod/ClassMap.java b/core/src/mindustry/mod/ClassMap.java index 99c62e1d15..778bb894ad 100644 --- a/core/src/mindustry/mod/ClassMap.java +++ b/core/src/mindustry/mod/ClassMap.java @@ -1,6 +1,8 @@ package mindustry.mod; import arc.struct.*; +import mindustry.type.ammo.*; + /** Generated class. Maps simple class names to concrete classes. For use in JSON mods. */ @SuppressWarnings("deprecation") public class ClassMap{ @@ -52,9 +54,8 @@ public class ClassMap{ classes.put("Research", mindustry.game.Objectives.Research.class); classes.put("SectorComplete", mindustry.game.Objectives.SectorComplete.class); classes.put("AmmoType", mindustry.type.AmmoType.class); - classes.put("AmmoTypes", mindustry.type.AmmoTypes.class); - classes.put("ItemAmmoType", mindustry.type.AmmoTypes.ItemAmmoType.class); - classes.put("PowerAmmoType", mindustry.type.AmmoTypes.PowerAmmoType.class); + classes.put("ItemAmmoType", ItemAmmoType.class); + classes.put("PowerAmmoType", PowerAmmoType.class); classes.put("Category", mindustry.type.Category.class); classes.put("ErrorContent", mindustry.type.ErrorContent.class); classes.put("Item", mindustry.type.Item.class); diff --git a/core/src/mindustry/mod/ContentParser.java b/core/src/mindustry/mod/ContentParser.java index 262249efa9..5c4d48cecd 100644 --- a/core/src/mindustry/mod/ContentParser.java +++ b/core/src/mindustry/mod/ContentParser.java @@ -29,7 +29,7 @@ import mindustry.gen.*; import mindustry.graphics.*; import mindustry.mod.Mods.*; import mindustry.type.*; -import mindustry.type.AmmoTypes.*; +import mindustry.type.ammo.*; import mindustry.type.weather.*; import mindustry.world.*; import mindustry.world.blocks.units.*; @@ -97,9 +97,12 @@ public class ContentParser{ return result; }); put(AmmoType.class, (type, data) -> { - if(data.isString()){ - return field(AmmoTypes.class, data); - } + //string -> item + //if liquid ammo support is added, this should scan for liquids as well + if(data.isString()) return find(ContentType.item, data.asString()); + //number -> power + if(data.isNumber()) return new PowerAmmoType(data.asFloat()); + var bc = resolve(data.getString("type", ""), ItemAmmoType.class); data.remove("type"); AmmoType result = make(bc); @@ -357,16 +360,6 @@ public class ContentParser{ if(!value.has("sector") || !value.get("sector").isNumber()) throw new RuntimeException("SectorPresets must have a sector number."); return new SectorPreset(name, locate(ContentType.planet, value.getString("planet", "serpulo")), value.getInt("sector")); - }, - ContentType.ammo, (TypeParser)(mod, name, value) -> { - if(value.isString()){ - return (AmmoType)field(AmmoTypes.class, value.asString()); - } - - AmmoType item = make(resolve(value.getString("type", null), ItemAmmoType.class)); - currentContent = item; - read(() -> readFields(item, value)); - return item; } ); diff --git a/core/src/mindustry/type/AmmoType.java b/core/src/mindustry/type/AmmoType.java index 45fd8e06bc..78e89fd0d4 100644 --- a/core/src/mindustry/type/AmmoType.java +++ b/core/src/mindustry/type/AmmoType.java @@ -1,29 +1,12 @@ package mindustry.type; import arc.graphics.*; -import mindustry.ctype.*; import mindustry.gen.*; -import mindustry.graphics.*; /** Type of ammo that a unit uses. */ -public class AmmoType extends Content{ - public String icon = Iconc.itemCopper + ""; - public Color color = Pal.ammo; - public Color barColor = Pal.ammo; - public float range = 85f; - - public AmmoType(char icon, Color color){ - this.icon = icon + ""; - this.color = color; - } - - public AmmoType(){ - } - - public void resupply(Unit unit){} - - @Override - public ContentType getContentType(){ - return ContentType.ammo; - } +public interface AmmoType{ + String icon(); + Color color(); + Color barColor(); + void resupply(Unit unit); } diff --git a/core/src/mindustry/type/AmmoTypes.java b/core/src/mindustry/type/AmmoTypes.java deleted file mode 100644 index fb50fcaa17..0000000000 --- a/core/src/mindustry/type/AmmoTypes.java +++ /dev/null @@ -1,101 +0,0 @@ -package mindustry.type; - -import mindustry.content.*; -import mindustry.ctype.*; -import mindustry.entities.*; -import mindustry.gen.*; -import mindustry.graphics.*; - -public class AmmoTypes implements ContentList{ - public static AmmoType - powerLow, - power, - powerHigh, - copper, - graphite, - coal, - thorium; - - @Override - public void load(){ - powerLow = new PowerAmmoType(500); - power = new PowerAmmoType(1000); - powerHigh = new PowerAmmoType(2000); - copper = new ItemAmmoType(Items.copper); - graphite = new ItemAmmoType(Items.graphite); - coal = new ItemAmmoType(Items.coal); - thorium = new ItemAmmoType(Items.thorium); - } - - public static class PowerAmmoType extends AmmoType{ - public float totalPower = 1000; - - public PowerAmmoType(){ - super(Iconc.power, Pal.powerLight); - barColor = color; - } - - public PowerAmmoType(float totalPower){ - this(); - this.totalPower = totalPower; - } - - @Override - public void resupply(Unit unit){ - float range = unit.hitSize + this.range; - - Building build = Units.closestBuilding(unit.team, unit.x, unit.y, range, u -> u.block.consumes.hasPower() && u.block.consumes.getPower().buffered); - - if(build != null){ - float amount = build.power.status * build.block.consumes.getPower().capacity; - float powerPerAmmo = totalPower / unit.type.ammoCapacity; - float ammoRequired = unit.type.ammoCapacity - unit.ammo; - float powerRequired = ammoRequired * powerPerAmmo; - float powerTaken = Math.min(amount, powerRequired); - - if(powerTaken > 1){ - build.power.status -= powerTaken / build.block.consumes.getPower().capacity; - unit.ammo += powerTaken / powerPerAmmo; - - Fx.itemTransfer.at(build.x, build.y, Math.max(powerTaken / 100f, 1f), Pal.power, unit); - } - } - } - } - - public static class ItemAmmoType extends AmmoType{ - public int ammoPerItem = 15; - public Item item; - - public ItemAmmoType(Item item){ - this.item = item; - this.color = item.color; - } - - public ItemAmmoType(){ - } - - @Override - public void resupply(Unit unit){ - //do not resupply when it would waste resources - if(unit.type.ammoCapacity - unit.ammo < ammoPerItem) return; - - float range = unit.hitSize + this.range; - - Building build = Units.closestBuilding(unit.team, unit.x, unit.y, range, u -> u.block.allowResupply && u.items.has(item)); - - if(build != null){ - Fx.itemTransfer.at(build.x, build.y, ammoPerItem / 2f, item.color, unit); - unit.ammo = Math.min(unit.ammo + ammoPerItem, unit.type.ammoCapacity); - build.items.remove(item, 1); - } - } - - @Override - public void load(){ - if(item != null){ - icon = item.emoji(); - } - } - } -} diff --git a/core/src/mindustry/type/UnitType.java b/core/src/mindustry/type/UnitType.java index cd095d0acc..5e1d44e367 100644 --- a/core/src/mindustry/type/UnitType.java +++ b/core/src/mindustry/type/UnitType.java @@ -24,6 +24,7 @@ import mindustry.game.*; import mindustry.gen.*; import mindustry.graphics.*; import mindustry.graphics.MultiPacker.*; +import mindustry.type.ammo.*; import mindustry.ui.*; import mindustry.world.*; import mindustry.world.blocks.environment.*; @@ -97,7 +98,7 @@ public class UnitType extends UnlockableContent{ public int itemCapacity = -1; public int ammoCapacity = -1; - public AmmoType ammoType = AmmoTypes.copper; + public AmmoType ammoType = new ItemAmmoType(Items.copper); public int mineTier = -1; public float buildSpeed = -1f, mineSpeed = 1f; public Sound mineSound = Sounds.minebeam; @@ -195,7 +196,7 @@ public class UnitType extends UnlockableContent{ bars.row(); if(state.rules.unitAmmo){ - bars.add(new Bar(ammoType.icon + " " + Core.bundle.get("stat.ammo"), ammoType.barColor, () -> unit.ammo / ammoCapacity)); + bars.add(new Bar(ammoType.icon() + " " + Core.bundle.get("stat.ammo"), ammoType.barColor(), () -> unit.ammo / ammoCapacity)); bars.row(); } diff --git a/core/src/mindustry/type/ammo/ItemAmmoType.java b/core/src/mindustry/type/ammo/ItemAmmoType.java new file mode 100644 index 0000000000..6263209e75 --- /dev/null +++ b/core/src/mindustry/type/ammo/ItemAmmoType.java @@ -0,0 +1,57 @@ +package mindustry.type.ammo; + +import arc.graphics.*; +import mindustry.content.*; +import mindustry.entities.*; +import mindustry.gen.*; +import mindustry.graphics.*; +import mindustry.type.*; + +public class ItemAmmoType implements AmmoType{ + public float range = 85f; + public int ammoPerItem = 15; + public Item item; + + public ItemAmmoType(Item item){ + this.item = item; + } + + public ItemAmmoType(Item item, int ammoPerItem){ + this.item = item; + this.ammoPerItem = ammoPerItem; + } + + public ItemAmmoType(){ + } + + @Override + public String icon(){ + return item.emoji(); + } + + @Override + public Color color(){ + return item.color; + } + + @Override + public Color barColor(){ + return Pal.ammo; + } + + @Override + public void resupply(Unit unit){ + //do not resupply when it would waste resources + if(unit.type.ammoCapacity - unit.ammo < ammoPerItem) return; + + float range = unit.hitSize + this.range; + + Building build = Units.closestBuilding(unit.team, unit.x, unit.y, range, u -> u.block.allowResupply && u.items.has(item)); + + if(build != null){ + Fx.itemTransfer.at(build.x, build.y, ammoPerItem / 2f, item.color, unit); + unit.ammo = Math.min(unit.ammo + ammoPerItem, unit.type.ammoCapacity); + build.items.remove(item, 1); + } + } +} diff --git a/core/src/mindustry/type/ammo/PowerAmmoType.java b/core/src/mindustry/type/ammo/PowerAmmoType.java new file mode 100644 index 0000000000..49d0b4dbb5 --- /dev/null +++ b/core/src/mindustry/type/ammo/PowerAmmoType.java @@ -0,0 +1,58 @@ +package mindustry.type.ammo; + +import arc.graphics.*; +import mindustry.content.*; +import mindustry.entities.*; +import mindustry.gen.*; +import mindustry.graphics.*; +import mindustry.type.*; + +public class PowerAmmoType implements AmmoType{ + public float range = 85f; + public float totalPower = 1000; + + public PowerAmmoType(float totalPower){ + this.totalPower = totalPower; + } + + public PowerAmmoType(){ + + } + + @Override + public String icon(){ + return Iconc.power + ""; + } + + @Override + public Color color(){ + return Pal.powerLight; + } + + @Override + public Color barColor(){ + return Pal.powerLight; + } + + @Override + public void resupply(Unit unit){ + float range = unit.hitSize + this.range; + + Building build = Units.closestBuilding(unit.team, unit.x, unit.y, range, u -> u.block.consumes.hasPower() && u.block.consumes.getPower().buffered); + + if(build != null){ + float amount = build.power.status * build.block.consumes.getPower().capacity; + float powerPerAmmo = totalPower / unit.type.ammoCapacity; + float ammoRequired = unit.type.ammoCapacity - unit.ammo; + float powerRequired = ammoRequired * powerPerAmmo; + float powerTaken = Math.min(amount, powerRequired); + + if(powerTaken > 1){ + build.power.status -= powerTaken / build.block.consumes.getPower().capacity; + unit.ammo += powerTaken / powerPerAmmo; + + Fx.itemTransfer.at(build.x, build.y, Math.max(powerTaken / 100f, 1f), Pal.power, unit); + } + } + } +} diff --git a/core/src/mindustry/ui/dialogs/PlanetDialog.java b/core/src/mindustry/ui/dialogs/PlanetDialog.java index 00f29b0a39..229bc9aa9b 100644 --- a/core/src/mindustry/ui/dialogs/PlanetDialog.java +++ b/core/src/mindustry/ui/dialogs/PlanetDialog.java @@ -921,6 +921,7 @@ public class PlanetDialog extends BaseDialog implements PlanetInterfaceRenderer{ zoom = 0.5f; ui.hudfrag.showLaunchDirect(); + //TODO animation; 140 is fine Time.runTask(launchDuration, () -> control.playSector(from, sector)); }); } diff --git a/core/src/mindustry/ui/fragments/HudFragment.java b/core/src/mindustry/ui/fragments/HudFragment.java index 9b857b1ce2..49b262aaa0 100644 --- a/core/src/mindustry/ui/fragments/HudFragment.java +++ b/core/src/mindustry/ui/fragments/HudFragment.java @@ -553,19 +553,6 @@ public class HudFragment extends Fragment{ Core.scene.add(image); } - public void showLaunch(){ - Image image = new Image(); - image.color.a = 0f; - image.setFillParent(true); - image.actions(Actions.fadeIn(40f / 60f)); - image.update(() -> { - if(state.isMenu()){ - image.remove(); - } - }); - Core.scene.add(image); - } - public void showLand(){ Image image = new Image(); image.color.a = 1f; @@ -726,7 +713,7 @@ public class HudFragment extends Fragment{ t.add(new SideBar(() -> player.unit().healthf(), () -> true, true)).width(bw).growY().padRight(pad); t.image(() -> player.icon()).scaling(Scaling.bounded).grow().maxWidth(54f); t.add(new SideBar(() -> player.dead() ? 0f : player.displayAmmo() ? player.unit().ammof() : player.unit().healthf(), () -> !player.displayAmmo(), false)).width(bw).growY().padLeft(pad).update(b -> { - b.color.set(player.displayAmmo() ? player.dead() || player.unit() instanceof BlockUnitc ? Pal.ammo : player.unit().type.ammoType.color : Pal.health); + b.color.set(player.displayAmmo() ? player.dead() || player.unit() instanceof BlockUnitc ? Pal.ammo : player.unit().type.ammoType.color() : Pal.health); }); t.getChildren().get(1).toFront(); diff --git a/gradle.properties b/gradle.properties index 1366866c20..b48fdbacb0 100644 --- a/gradle.properties +++ b/gradle.properties @@ -10,4 +10,4 @@ kapt.include.compile.classpath=false kotlin.stdlib.default.dependency=false #needed for android compilation android.useAndroidX=true -archash=6e9fd338866c05cd42ec20f26ec7fa7c3a25d6d5 +archash=a9dedf9345fe888e54ab2be3c56bf8d4d2aeb2b8