diff --git a/annotations/src/main/resources/revisions/block/3.json b/annotations/src/main/resources/revisions/block/3.json new file mode 100644 index 0000000000..75c7a4a245 --- /dev/null +++ b/annotations/src/main/resources/revisions/block/3.json @@ -0,0 +1 @@ +{version:3,fields:[{name:ammo,type:float},{name:armor,type:float},{name:controller,type:mindustry.entities.units.UnitController},{name:elevation,type:float},{name:flag,type:double},{name:health,type:float},{name:isShooting,type:boolean},{name:mineTile,type:mindustry.world.Tile},{name:mounts,type:"mindustry.entities.units.WeaponMount[]"},{name:rotation,type:float},{name:shield,type:float},{name:spawnedByCore,type:boolean},{name:stack,type:mindustry.type.ItemStack},{name:statuses,type:arc.struct.Seq},{name:team,type:mindustry.game.Team},{name:type,type:mindustry.type.UnitType},{name:x,type:float},{name:y,type:float}]} \ No newline at end of file diff --git a/annotations/src/main/resources/revisions/corvus/3.json b/annotations/src/main/resources/revisions/corvus/3.json new file mode 100644 index 0000000000..75c7a4a245 --- /dev/null +++ b/annotations/src/main/resources/revisions/corvus/3.json @@ -0,0 +1 @@ +{version:3,fields:[{name:ammo,type:float},{name:armor,type:float},{name:controller,type:mindustry.entities.units.UnitController},{name:elevation,type:float},{name:flag,type:double},{name:health,type:float},{name:isShooting,type:boolean},{name:mineTile,type:mindustry.world.Tile},{name:mounts,type:"mindustry.entities.units.WeaponMount[]"},{name:rotation,type:float},{name:shield,type:float},{name:spawnedByCore,type:boolean},{name:stack,type:mindustry.type.ItemStack},{name:statuses,type:arc.struct.Seq},{name:team,type:mindustry.game.Team},{name:type,type:mindustry.type.UnitType},{name:x,type:float},{name:y,type:float}]} \ No newline at end of file diff --git a/annotations/src/main/resources/revisions/flare/3.json b/annotations/src/main/resources/revisions/flare/3.json new file mode 100644 index 0000000000..75c7a4a245 --- /dev/null +++ b/annotations/src/main/resources/revisions/flare/3.json @@ -0,0 +1 @@ +{version:3,fields:[{name:ammo,type:float},{name:armor,type:float},{name:controller,type:mindustry.entities.units.UnitController},{name:elevation,type:float},{name:flag,type:double},{name:health,type:float},{name:isShooting,type:boolean},{name:mineTile,type:mindustry.world.Tile},{name:mounts,type:"mindustry.entities.units.WeaponMount[]"},{name:rotation,type:float},{name:shield,type:float},{name:spawnedByCore,type:boolean},{name:stack,type:mindustry.type.ItemStack},{name:statuses,type:arc.struct.Seq},{name:team,type:mindustry.game.Team},{name:type,type:mindustry.type.UnitType},{name:x,type:float},{name:y,type:float}]} \ No newline at end of file diff --git a/annotations/src/main/resources/revisions/mace/3.json b/annotations/src/main/resources/revisions/mace/3.json new file mode 100644 index 0000000000..811f101bd5 --- /dev/null +++ b/annotations/src/main/resources/revisions/mace/3.json @@ -0,0 +1 @@ +{version:3,fields:[{name:ammo,type:float},{name:armor,type:float},{name:baseRotation,type:float},{name:controller,type:mindustry.entities.units.UnitController},{name:elevation,type:float},{name:flag,type:double},{name:health,type:float},{name:isShooting,type:boolean},{name:mineTile,type:mindustry.world.Tile},{name:mounts,type:"mindustry.entities.units.WeaponMount[]"},{name:rotation,type:float},{name:shield,type:float},{name:spawnedByCore,type:boolean},{name:stack,type:mindustry.type.ItemStack},{name:statuses,type:arc.struct.Seq},{name:team,type:mindustry.game.Team},{name:type,type:mindustry.type.UnitType},{name:x,type:float},{name:y,type:float}]} \ No newline at end of file diff --git a/annotations/src/main/resources/revisions/oct/2.json b/annotations/src/main/resources/revisions/oct/2.json new file mode 100644 index 0000000000..87371c85dd --- /dev/null +++ b/annotations/src/main/resources/revisions/oct/2.json @@ -0,0 +1 @@ +{version:2,fields:[{name:ammo,type:float},{name:armor,type:float},{name:controller,type:mindustry.entities.units.UnitController},{name:elevation,type:float},{name:flag,type:double},{name:health,type:float},{name:isShooting,type:boolean},{name:mineTile,type:mindustry.world.Tile},{name:mounts,type:"mindustry.entities.units.WeaponMount[]"},{name:payloads,type:arc.struct.Seq},{name:plans,type:arc.struct.Queue},{name:rotation,type:float},{name:shield,type:float},{name:spawnedByCore,type:boolean},{name:stack,type:mindustry.type.ItemStack},{name:statuses,type:arc.struct.Seq},{name:team,type:mindustry.game.Team},{name:type,type:mindustry.type.UnitType},{name:x,type:float},{name:y,type:float}]} \ No newline at end of file diff --git a/annotations/src/main/resources/revisions/risso/3.json b/annotations/src/main/resources/revisions/risso/3.json new file mode 100644 index 0000000000..75c7a4a245 --- /dev/null +++ b/annotations/src/main/resources/revisions/risso/3.json @@ -0,0 +1 @@ +{version:3,fields:[{name:ammo,type:float},{name:armor,type:float},{name:controller,type:mindustry.entities.units.UnitController},{name:elevation,type:float},{name:flag,type:double},{name:health,type:float},{name:isShooting,type:boolean},{name:mineTile,type:mindustry.world.Tile},{name:mounts,type:"mindustry.entities.units.WeaponMount[]"},{name:rotation,type:float},{name:shield,type:float},{name:spawnedByCore,type:boolean},{name:stack,type:mindustry.type.ItemStack},{name:statuses,type:arc.struct.Seq},{name:team,type:mindustry.game.Team},{name:type,type:mindustry.type.UnitType},{name:x,type:float},{name:y,type:float}]} \ No newline at end of file diff --git a/annotations/src/main/resources/revisions/spiroct/3.json b/annotations/src/main/resources/revisions/spiroct/3.json new file mode 100644 index 0000000000..364fdca813 --- /dev/null +++ b/annotations/src/main/resources/revisions/spiroct/3.json @@ -0,0 +1 @@ +{version:3,fields:[{name:ammo,type:float},{name:armor,type:float},{name:controller,type:mindustry.entities.units.UnitController},{name:elevation,type:float},{name:flag,type:double},{name:health,type:float},{name:isShooting,type:boolean},{name:mineTile,type:mindustry.world.Tile},{name:mounts,type:"mindustry.entities.units.WeaponMount[]"},{name:plans,type:arc.struct.Queue},{name:rotation,type:float},{name:shield,type:float},{name:spawnedByCore,type:boolean},{name:stack,type:mindustry.type.ItemStack},{name:statuses,type:arc.struct.Seq},{name:team,type:mindustry.game.Team},{name:type,type:mindustry.type.UnitType},{name:x,type:float},{name:y,type:float}]} \ No newline at end of file diff --git a/core/assets/sounds/minebeam.ogg b/core/assets/sounds/minebeam.ogg new file mode 100644 index 0000000000..27f75a8531 Binary files /dev/null and b/core/assets/sounds/minebeam.ogg differ diff --git a/core/assets/sounds/pew.ogg b/core/assets/sounds/pew.ogg index eb960f5537..6a15b963e3 100644 Binary files a/core/assets/sounds/pew.ogg and b/core/assets/sounds/pew.ogg differ diff --git a/core/src/mindustry/ai/types/LogicAI.java b/core/src/mindustry/ai/types/LogicAI.java index da86af9f59..20650efe53 100644 --- a/core/src/mindustry/ai/types/LogicAI.java +++ b/core/src/mindustry/ai/types/LogicAI.java @@ -104,9 +104,7 @@ public class LogicAI extends AIController{ //look where moving if there's nothing to aim at if(!shoot){ - if(unit.moving()){ - unit.lookAt(unit.vel().angle()); - } + unit.lookAt(unit.prefRotation()); }else if(unit.hasWeapons()){ //if there is, look at the object unit.lookAt(unit.mounts[0].aimX, unit.mounts[0].aimY); } diff --git a/core/src/mindustry/content/UnitTypes.java b/core/src/mindustry/content/UnitTypes.java index ed1fe92341..c5dcea0d42 100644 --- a/core/src/mindustry/content/UnitTypes.java +++ b/core/src/mindustry/content/UnitTypes.java @@ -21,7 +21,7 @@ public class UnitTypes implements ContentList{ public static @EntityDef({Unitc.class, Mechc.class}) UnitType mace, dagger, crawler, fortress, scepter, reign; //mech + builder + miner - public static @EntityDef({Unitc.class, Mechc.class, Builderc.class, Minerc.class}) UnitType nova, pulsar, quasar; + public static @EntityDef({Unitc.class, Mechc.class, Builderc.class}) UnitType nova, pulsar, quasar; //mech public static @EntityDef({Unitc.class, Mechc.class}) UnitType vela; @@ -33,16 +33,13 @@ public class UnitTypes implements ContentList{ public static @EntityDef({Unitc.class, Legsc.class, Builderc.class}) UnitType spiroct, arkyid, toxopid; //air (no special traits) - public static @EntityDef({Unitc.class}) UnitType flare, eclipse, horizon, zenith, antumbra; - - //air + mining - public static @EntityDef({Unitc.class, Minerc.class}) UnitType mono; + public static @EntityDef({Unitc.class}) UnitType flare, eclipse, horizon, zenith, antumbra, mono; //air + building + mining - public static @EntityDef({Unitc.class, Builderc.class, Minerc.class}) UnitType poly; + public static @EntityDef({Unitc.class, Builderc.class}) UnitType poly; //air + building + mining + payload - public static @EntityDef({Unitc.class, Builderc.class, Minerc.class, Payloadc.class}) UnitType mega; + public static @EntityDef({Unitc.class, Builderc.class, Payloadc.class}) UnitType mega; //air + building + payload public static @EntityDef({Unitc.class, Builderc.class, Payloadc.class}) UnitType quad; @@ -51,7 +48,7 @@ public class UnitTypes implements ContentList{ public static @EntityDef({Unitc.class, Builderc.class, Payloadc.class, AmmoDistributec.class}) UnitType oct; //air + building + mining - public static @EntityDef({Unitc.class, Builderc.class, Minerc.class}) UnitType alpha, beta, gamma; + public static @EntityDef({Unitc.class, Builderc.class,}) UnitType alpha, beta, gamma; //water public static @EntityDef({Unitc.class, WaterMovec.class}) UnitType risso, minke, bryde, sei, omura; @@ -1214,7 +1211,7 @@ public class UnitTypes implements ContentList{ reload = 30f; ejectEffect = Fx.none; recoil = 2f; - shootSound = Sounds.pew; + shootSound = Sounds.missile; shots = 1; velocityRnd = 0.5f; inaccuracy = 15f; @@ -1230,6 +1227,7 @@ public class UnitTypes implements ContentList{ smokeEffect = Fx.hitLaser; hitEffect = despawnEffect = Fx.hitLaser; frontColor = Color.white; + hitSound = Sounds.none; healPercent = 5.5f; collidesTeam = true; diff --git a/core/src/mindustry/entities/comp/MinerComp.java b/core/src/mindustry/entities/comp/MinerComp.java index 77a6e0433d..37a0fd2393 100644 --- a/core/src/mindustry/entities/comp/MinerComp.java +++ b/core/src/mindustry/entities/comp/MinerComp.java @@ -16,8 +16,8 @@ import mindustry.world.*; import static mindustry.Vars.*; @Component -abstract class MinerComp implements Itemsc, Posc, Teamc, Rotc, Drawc, Unitc{ - @Import float x, y, rotation; +abstract class MinerComp implements Itemsc, Posc, Teamc, Rotc, Drawc{ + @Import float x, y, rotation, hitSize; @Import UnitType type; transient float mineTimer; @@ -28,7 +28,7 @@ abstract class MinerComp implements Itemsc, Posc, Teamc, Rotc, Drawc, Unitc{ } public boolean offloadImmediately(){ - return isPlayer(); + return this.self().isPlayer(); } boolean mining(){ @@ -87,13 +87,17 @@ abstract class MinerComp implements Itemsc, Posc, Teamc, Rotc, Drawc, Unitc{ mineTimer = 0f; } } + + if(!headless){ + loops.play(type.mineSound, this, type.mineSoundVolume); + } } } @Override public void draw(){ if(!mining()) return; - float focusLen = hitSize() / 2f + Mathf.absin(Time.time(), 1.1f, 0.5f); + float focusLen = hitSize / 2f + Mathf.absin(Time.time(), 1.1f, 0.5f); float swingScl = 12f, swingMag = tilesize / 8f; float flashScl = 0.3f; diff --git a/core/src/mindustry/entities/comp/UnitComp.java b/core/src/mindustry/entities/comp/UnitComp.java index 0f3f968d3a..4c199542c3 100644 --- a/core/src/mindustry/entities/comp/UnitComp.java +++ b/core/src/mindustry/entities/comp/UnitComp.java @@ -31,7 +31,7 @@ import mindustry.world.blocks.payloads.*; import static mindustry.Vars.*; @Component(base = true) -abstract class UnitComp implements Healthc, Physicsc, Hitboxc, Statusc, Teamc, Itemsc, Rotc, Unitc, Weaponsc, Drawc, Boundedc, Syncc, Shieldc, Commanderc, Displayable, Senseable, Ranged{ +abstract class UnitComp implements Healthc, Physicsc, Hitboxc, Statusc, Teamc, Itemsc, Rotc, Unitc, Weaponsc, Drawc, Boundedc, Syncc, Shieldc, Commanderc, Displayable, Senseable, Ranged, Minerc{ @Import boolean hovering, dead; @Import float x, y, rotation, elevation, maxHealth, drag, armor, hitSize, health, ammo, minFormationSpeed; @@ -88,11 +88,12 @@ abstract class UnitComp implements Healthc, Physicsc, Hitboxc, Statusc, Teamc, I public float prefRotation(){ if(this instanceof Builderc builder && builder.activelyBuilding()){ return angleTo(builder.buildPlan()); - }else if(this instanceof Minerc miner && miner.mineTile() != null){ - return angleTo(miner.mineTile()); - }else{ + }else if(mineTile() != null){ + return angleTo(mineTile()); + }else if(moving()){ return vel().angle(); } + return rotation; } @Override diff --git a/core/src/mindustry/entities/units/AIController.java b/core/src/mindustry/entities/units/AIController.java index a861c81060..d3a7fb9ba2 100644 --- a/core/src/mindustry/entities/units/AIController.java +++ b/core/src/mindustry/entities/units/AIController.java @@ -65,9 +65,7 @@ public class AIController implements UnitController{ if(unit.isFlying()){ unit.wobble(); - if(unit.moving()){ - unit.lookAt(unit.vel.angle()); - } + unit.lookAt(unit.prefRotation()); } } diff --git a/core/src/mindustry/input/DesktopInput.java b/core/src/mindustry/input/DesktopInput.java index 45dbfb6bea..3dd48dad58 100644 --- a/core/src/mindustry/input/DesktopInput.java +++ b/core/src/mindustry/input/DesktopInput.java @@ -482,8 +482,8 @@ public class DesktopInput extends InputHandler{ deleting = true; }else if(selected != null){ //only begin shooting if there's no cursor event - if(!tileTapped(selected.build) && !tryTapPlayer(Core.input.mouseWorld().x, Core.input.mouseWorld().y) && (player.builder().plans().size == 0 || !player.builder().updateBuilding()) && !droppingItem && - !tryBeginMine(selected) && player.miner().mineTile() == null && !Core.scene.hasKeyboard()){ + if(!tileTapped(selected.build) && !tryTapPlayer(Core.input.mouseWorld().x, Core.input.mouseWorld().y) && !player.builder().activelyBuilding() && !droppingItem && + !tryBeginMine(selected) && player.miner().mineTile() == null && !Core.scene.hasKeyboard()){ player.shooting = shouldShoot; } }else if(!Core.scene.hasKeyboard()){ //if it's out of bounds, shooting is just fine @@ -621,9 +621,7 @@ public class DesktopInput extends InputHandler{ if(aimCursor){ unit.lookAt(mouseAngle); }else{ - if(!movement.isZero()){ - unit.lookAt(unit.vel.isZero() ? movement.angle() : unit.vel.angle()); - } + unit.lookAt(unit.prefRotation()); } if(omni){ diff --git a/core/src/mindustry/input/InputHandler.java b/core/src/mindustry/input/InputHandler.java index f52f6bed59..47d0723c25 100644 --- a/core/src/mindustry/input/InputHandler.java +++ b/core/src/mindustry/input/InputHandler.java @@ -931,11 +931,11 @@ public abstract class InputHandler implements InputProcessor, GestureListener{ boolean canMine(Tile tile){ return !Core.scene.hasMouse() - && tile.drop() != null - && player.miner().validMine(tile) - && !(tile.floor().playerUnmineable && tile.overlay().itemDrop == null) - && player.unit().acceptsItem(tile.drop()) - && tile.block() == Blocks.air; + && tile.drop() != null + && player.miner().validMine(tile) + && !(tile.floor().playerUnmineable && tile.overlay().itemDrop == null) + && player.unit().acceptsItem(tile.drop()) + && tile.block() == Blocks.air; } /** Returns the tile at the specified MOUSE coordinates. */ @@ -1042,7 +1042,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{ } public boolean canShoot(){ - return block == null && !onConfigurable() && !isDroppingItem() && !(player.builder().updateBuilding() && player.builder().isBuilding()) && + return block == null && !onConfigurable() && !isDroppingItem() && !player.builder().activelyBuilding() && !(player.unit() instanceof Mechc && player.unit().isFlying()); } diff --git a/core/src/mindustry/input/MobileInput.java b/core/src/mindustry/input/MobileInput.java index 3e1aadd2f7..92c069b597 100644 --- a/core/src/mindustry/input/MobileInput.java +++ b/core/src/mindustry/input/MobileInput.java @@ -866,9 +866,7 @@ public class MobileInput extends InputHandler implements GestureListener{ if(aimCursor){ unit.lookAt(mouseAngle); }else{ - if(unit.moving()){ - unit.lookAt(unit.vel.angle()); - } + unit.lookAt(unit.prefRotation()); } if(payloadTarget != null && unit instanceof Payloadc pay){ diff --git a/core/src/mindustry/type/UnitType.java b/core/src/mindustry/type/UnitType.java index 3c2cc4a1be..97902e48b2 100644 --- a/core/src/mindustry/type/UnitType.java +++ b/core/src/mindustry/type/UnitType.java @@ -81,6 +81,8 @@ public class UnitType extends UnlockableContent{ public AmmoType ammoType = AmmoTypes.copper; public int mineTier = -1; public float buildSpeed = 1f, mineSpeed = 1f; + public Sound mineSound = Sounds.minebeam; + public float mineSoundVolume = 0.6f; /** This is a VERY ROUGH estimate of unit DPS. */ public float dpsEstimate = -1;