From f724e5639f67f058c4f6d9fed4c5f5f862792eb8 Mon Sep 17 00:00:00 2001 From: MEEPofFaith <54301439+MEEPofFaith@users.noreply.github.com> Date: Sat, 8 Feb 2025 21:18:02 -0800 Subject: [PATCH 01/11] BuildWeapon call super idk if it matters if name is null, but just in case --- core/src/mindustry/type/weapons/BuildWeapon.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/mindustry/type/weapons/BuildWeapon.java b/core/src/mindustry/type/weapons/BuildWeapon.java index 98d732ee8d..002b26c1ea 100644 --- a/core/src/mindustry/type/weapons/BuildWeapon.java +++ b/core/src/mindustry/type/weapons/BuildWeapon.java @@ -11,7 +11,7 @@ import mindustry.type.*; public class BuildWeapon extends Weapon{ public BuildWeapon(){ - + super(); } public BuildWeapon(String name){ From d7589ca97c7c358072321dbbcd200a95fd22adb2 Mon Sep 17 00:00:00 2001 From: MEEPofFaith <54301439+MEEPofFaith@users.noreply.github.com> Date: Sat, 8 Feb 2025 21:29:30 -0800 Subject: [PATCH 02/11] Make mining beam drawing consistent with build beam drawing --- .../mindustry/entities/comp/MinerComp.java | 32 ++++++++++++++++ core/src/mindustry/type/UnitType.java | 38 +++++-------------- 2 files changed, 42 insertions(+), 28 deletions(-) diff --git a/core/src/mindustry/entities/comp/MinerComp.java b/core/src/mindustry/entities/comp/MinerComp.java index 4e9c28bc3d..a69d7c7fe2 100644 --- a/core/src/mindustry/entities/comp/MinerComp.java +++ b/core/src/mindustry/entities/comp/MinerComp.java @@ -123,4 +123,36 @@ abstract class MinerComp implements Itemsc, Posc, Teamc, Rotc, Drawc{ } } } + + public void drawMining(){ + if(type.drawMineBeam){ + float focusLen = hitSize / 2f + Mathf.absin(Time.time, 1.1f, 0.5f); + float px = x + Angles.trnsx(rotation, focusLen); + float py = y + Angles.trnsy(rotation, focusLen); + + drawMiningBeam(px, py); + } + } + + public void drawMiningBeam(float px, float py){ + if(!mining()) return; + float swingScl = 12f, swingMag = tilesize / 8f; + float flashScl = 0.3f; + + float ex = mineTile.worldx() + Mathf.sin(Time.time + 48, swingScl, swingMag); + float ey = mineTile.worldy() + Mathf.sin(Time.time + 48, swingScl + 2f, swingMag); + + Draw.z(Layer.flyingUnit + 0.1f); + + Draw.color(Color.lightGray, Color.white, 1f - flashScl + Mathf.absin(Time.time, 0.5f, flashScl)); + + Drawf.laser(Core.atlas.find("minelaser"), Core.atlas.find("minelaser-end"), px, py, ex, ey, 0.75f); + + if(isLocal()){ + Lines.stroke(1f, Pal.accent); + Lines.poly(mineTile.worldx(), mineTile.worldy(), 4, tilesize / 2f * Mathf.sqrt2, Time.time); + } + + Draw.color(); + } } diff --git a/core/src/mindustry/type/UnitType.java b/core/src/mindustry/type/UnitType.java index a8d7ddc846..a2145e9ff2 100644 --- a/core/src/mindustry/type/UnitType.java +++ b/core/src/mindustry/type/UnitType.java @@ -113,8 +113,10 @@ public class UnitType extends UnlockableContent implements Senseable{ buildSpeed = -1f, /** Minimum distance from this unit that weapons can target. Prevents units from firing "inside" the unit. */ aimDst = -1f, - /** Visual offset of build beam from front. */ + /** Visual offset of the build beam from the front. */ buildBeamOffset = 3.8f, + /** Visual offset of the mining beam from the front. */ + mineBeamOffset = Float.NEGATIVE_INFINITY, /** WIP: Units of low priority will always be ignored in favor of those with higher priority, regardless of distance. */ targetPriority = 0f, /** Elevation of shadow drawn under this (ground) unit. Visual only. */ @@ -236,6 +238,8 @@ public class UnitType extends UnlockableContent implements Senseable{ squareShape = false, /** if true, this unit will draw its building beam towards blocks. */ drawBuildBeam = true, + /** if true, this unit will draw its mining beam towards blocks */ + drawMineBeam = true, /** if false, the team indicator/cell is not drawn. */ drawCell = true, /** if false, carried items are not drawn. */ @@ -803,6 +807,8 @@ public class UnitType extends UnlockableContent implements Senseable{ }).layer(Layer.debris); } + if(mineBeamOffset == Float.NEGATIVE_INFINITY) mineBeamOffset = hitSize / 2; + for(Ability ab : abilities){ ab.init(this); } @@ -1226,8 +1232,7 @@ public class UnitType extends UnlockableContent implements Senseable{ if(unit.inFogTo(Vars.player.team())) return; unit.drawBuilding(); - - drawMining(unit); + unit.drawMining(); boolean isPayload = !unit.isAdded(); @@ -1339,32 +1344,9 @@ public class UnitType extends UnlockableContent implements Senseable{ return shieldColor == null ? unit.team.color : shieldColor; } - + @Deprecated public void drawMining(Unit unit){ - if(!unit.mining()) return; - float focusLen = unit.hitSize / 2f + Mathf.absin(Time.time, 1.1f, 0.5f); - float swingScl = 12f, swingMag = tilesize / 8f; - float flashScl = 0.3f; - - float px = unit.x + Angles.trnsx(unit.rotation, focusLen); - float py = unit.y + Angles.trnsy(unit.rotation, focusLen); - - float ex = unit.mineTile.worldx() + Mathf.sin(Time.time + 48, swingScl, swingMag); - float ey = unit.mineTile.worldy() + Mathf.sin(Time.time + 48, swingScl + 2f, swingMag); - - Draw.z(Layer.flyingUnit + 0.1f); - - Draw.color(Color.lightGray, Color.white, 1f - flashScl + Mathf.absin(Time.time, 0.5f, flashScl)); - - Draw.alpha(Renderer.unitLaserOpacity); - Drawf.laser(mineLaserRegion, mineLaserEndRegion, px, py, ex, ey, 0.75f); - - if(unit.isLocal()){ - Lines.stroke(1f, Pal.accent); - Lines.poly(unit.mineTile.worldx(), unit.mineTile.worldy(), 4, tilesize / 2f * Mathf.sqrt2, Time.time); - } - - Draw.color(); + unit.drawMining(); } public void drawPayload(T unit){ From 178f98b6ea48df606057011de9e2210e5215839d Mon Sep 17 00:00:00 2001 From: MEEPofFaith <54301439+MEEPofFaith@users.noreply.github.com> Date: Sat, 8 Feb 2025 21:33:43 -0800 Subject: [PATCH 03/11] Mining beam weapon --- .../mindustry/type/weapons/MineWeapon.java | 66 +++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 core/src/mindustry/type/weapons/MineWeapon.java diff --git a/core/src/mindustry/type/weapons/MineWeapon.java b/core/src/mindustry/type/weapons/MineWeapon.java new file mode 100644 index 0000000000..81696f2423 --- /dev/null +++ b/core/src/mindustry/type/weapons/MineWeapon.java @@ -0,0 +1,66 @@ +package mindustry.type.weapons; + +import arc.graphics.g2d.*; +import arc.math.*; +import arc.util.*; +import mindustry.entities.bullet.*; +import mindustry.entities.units.*; +import mindustry.gen.*; +import mindustry.type.*; + +public class MineWeapon extends Weapon{ + public MineWeapon(){ + super(); + } + + public MineWeapon(String name){ + super(name); + } + + { + rotate = true; + noAttack = true; + predictTarget = false; + display = false; + bullet = new BulletType(); + useAttackRange = false; + } + + @Override + public void update(Unit unit, WeaponMount mount){ + mount.shoot = false; + mount.rotate = true; + + //always aim at build plan + if(unit.mining()){ + mount.aimX = unit.mineTile().drawx(); + mount.aimY = unit.mineTile().drawy(); + }else{ + //aim for front + float weaponRotation = unit.rotation - 90 + baseRotation; + mount.aimX = unit.x + Angles.trnsx(unit.rotation - 90, x, y) + Angles.trnsx(weaponRotation, this.shootX, this.shootY); + mount.aimY = unit.y + Angles.trnsy(unit.rotation - 90, x, y) + Angles.trnsy(weaponRotation, this.shootX, this.shootY); + } + + super.update(unit, mount); + } + + @Override + public void draw(Unit unit, WeaponMount mount){ + super.draw(unit, mount); + + if(unit.mining()){ + float + z = Draw.z(), + rotation = unit.rotation - 90, + weaponRotation = rotation + (rotate ? mount.rotation : 0), + wx = unit.x + Angles.trnsx(rotation, x, y) + Angles.trnsx(weaponRotation, 0, -mount.recoil), + wy = unit.y + Angles.trnsy(rotation, x, y) + Angles.trnsy(weaponRotation, 0, -mount.recoil), + px = wx + Angles.trnsx(weaponRotation, shootX, shootY), + py = wy + Angles.trnsy(weaponRotation, shootX, shootY); + + unit.drawMiningBeam(px, py); + Draw.z(z); + } + } +} From 81b576e8d3834ce96df212c389a02bc6f462d0c4 Mon Sep 17 00:00:00 2001 From: MEEPofFaith <54301439+MEEPofFaith@users.noreply.github.com> Date: Sat, 8 Feb 2025 21:38:10 -0800 Subject: [PATCH 04/11] Mine beam wobbles --- core/src/mindustry/type/weapons/MineWeapon.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/core/src/mindustry/type/weapons/MineWeapon.java b/core/src/mindustry/type/weapons/MineWeapon.java index 81696f2423..553c696f2b 100644 --- a/core/src/mindustry/type/weapons/MineWeapon.java +++ b/core/src/mindustry/type/weapons/MineWeapon.java @@ -56,8 +56,9 @@ public class MineWeapon extends Weapon{ weaponRotation = rotation + (rotate ? mount.rotation : 0), wx = unit.x + Angles.trnsx(rotation, x, y) + Angles.trnsx(weaponRotation, 0, -mount.recoil), wy = unit.y + Angles.trnsy(rotation, x, y) + Angles.trnsy(weaponRotation, 0, -mount.recoil), - px = wx + Angles.trnsx(weaponRotation, shootX, shootY), - py = wy + Angles.trnsy(weaponRotation, shootX, shootY); + sY = shootY + Mathf.absin(Time.time, 1.1f, 0.5f), + px = wx + Angles.trnsx(weaponRotation, shootX, sY), + py = wy + Angles.trnsy(weaponRotation, shootX, sY); unit.drawMiningBeam(px, py); Draw.z(z); From 3561562624d5ddebd7ed6b660834724589d2c775 Mon Sep 17 00:00:00 2001 From: MEEPofFaith <54301439+MEEPofFaith@users.noreply.github.com> Date: Sat, 8 Feb 2025 21:41:26 -0800 Subject: [PATCH 05/11] oopsies --- core/src/mindustry/entities/comp/MinerComp.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/mindustry/entities/comp/MinerComp.java b/core/src/mindustry/entities/comp/MinerComp.java index a69d7c7fe2..1f74be8cee 100644 --- a/core/src/mindustry/entities/comp/MinerComp.java +++ b/core/src/mindustry/entities/comp/MinerComp.java @@ -126,7 +126,7 @@ abstract class MinerComp implements Itemsc, Posc, Teamc, Rotc, Drawc{ public void drawMining(){ if(type.drawMineBeam){ - float focusLen = hitSize / 2f + Mathf.absin(Time.time, 1.1f, 0.5f); + float focusLen = type.mineBeamOffset + Mathf.absin(Time.time, 1.1f, 0.5f); float px = x + Angles.trnsx(rotation, focusLen); float py = y + Angles.trnsy(rotation, focusLen); From 78aa3b1848ca09d651ca9933a664e278d7622053 Mon Sep 17 00:00:00 2001 From: MEEPofFaith <54301439+MEEPofFaith@users.noreply.github.com> Date: Sat, 8 Feb 2025 21:43:56 -0800 Subject: [PATCH 06/11] Move back to UnitType --- .../mindustry/entities/comp/MinerComp.java | 10 ------ core/src/mindustry/type/UnitType.java | 33 +++++++++++++++++-- .../mindustry/type/weapons/MineWeapon.java | 2 +- 3 files changed, 31 insertions(+), 14 deletions(-) diff --git a/core/src/mindustry/entities/comp/MinerComp.java b/core/src/mindustry/entities/comp/MinerComp.java index 1f74be8cee..3a8fdee884 100644 --- a/core/src/mindustry/entities/comp/MinerComp.java +++ b/core/src/mindustry/entities/comp/MinerComp.java @@ -124,16 +124,6 @@ abstract class MinerComp implements Itemsc, Posc, Teamc, Rotc, Drawc{ } } - public void drawMining(){ - if(type.drawMineBeam){ - float focusLen = type.mineBeamOffset + Mathf.absin(Time.time, 1.1f, 0.5f); - float px = x + Angles.trnsx(rotation, focusLen); - float py = y + Angles.trnsy(rotation, focusLen); - - drawMiningBeam(px, py); - } - } - public void drawMiningBeam(float px, float py){ if(!mining()) return; float swingScl = 12f, swingMag = tilesize / 8f; diff --git a/core/src/mindustry/type/UnitType.java b/core/src/mindustry/type/UnitType.java index a2145e9ff2..d8ece89575 100644 --- a/core/src/mindustry/type/UnitType.java +++ b/core/src/mindustry/type/UnitType.java @@ -1232,7 +1232,7 @@ public class UnitType extends UnlockableContent implements Senseable{ if(unit.inFogTo(Vars.player.team())) return; unit.drawBuilding(); - unit.drawMining(); + drawMining(unit); boolean isPayload = !unit.isAdded(); @@ -1344,9 +1344,36 @@ public class UnitType extends UnlockableContent implements Senseable{ return shieldColor == null ? unit.team.color : shieldColor; } - @Deprecated public void drawMining(Unit unit){ - unit.drawMining(); + if(drawMineBeam){ + float focusLen = mineBeamOffset + Mathf.absin(Time.time, 1.1f, 0.5f); + float px = unit.x + Angles.trnsx(unit.rotation, focusLen); + float py = unit.y + Angles.trnsy(unit.rotation, focusLen); + + drawMiningBeam(px, py); + } + } + + public void drawMiningBeam(Unit unit, float px, float py){ + if(!unit.mining()) return; + float swingScl = 12f, swingMag = tilesize / 8f; + float flashScl = 0.3f; + + float ex = unit.mineTile.worldx() + Mathf.sin(Time.time + 48, swingScl, swingMag); + float ey = unit.mineTile.worldy() + Mathf.sin(Time.time + 48, swingScl + 2f, swingMag); + + Draw.z(Layer.flyingUnit + 0.1f); + + Draw.color(Color.lightGray, Color.white, 1f - flashScl + Mathf.absin(Time.time, 0.5f, flashScl)); + + Drawf.laser(Core.atlas.find("minelaser"), Core.atlas.find("minelaser-end"), px, py, ex, ey, 0.75f); + + if(unit.isLocal()){ + Lines.stroke(1f, Pal.accent); + Lines.poly(unit.mineTile.worldx(), unit.mineTile.worldy(), 4, tilesize / 2f * Mathf.sqrt2, Time.time); + } + + Draw.color(); } public void drawPayload(T unit){ diff --git a/core/src/mindustry/type/weapons/MineWeapon.java b/core/src/mindustry/type/weapons/MineWeapon.java index 553c696f2b..ed55659a49 100644 --- a/core/src/mindustry/type/weapons/MineWeapon.java +++ b/core/src/mindustry/type/weapons/MineWeapon.java @@ -60,7 +60,7 @@ public class MineWeapon extends Weapon{ px = wx + Angles.trnsx(weaponRotation, shootX, sY), py = wy + Angles.trnsy(weaponRotation, shootX, sY); - unit.drawMiningBeam(px, py); + unit.type.drawMiningBeam(px, py); Draw.z(z); } } From 35972a6fd9dd9caa2973720e421305122ea48f2e Mon Sep 17 00:00:00 2001 From: MEEPofFaith <54301439+MEEPofFaith@users.noreply.github.com> Date: Sat, 8 Feb 2025 21:44:33 -0800 Subject: [PATCH 07/11] oops --- .../mindustry/entities/comp/MinerComp.java | 22 ------------------- 1 file changed, 22 deletions(-) diff --git a/core/src/mindustry/entities/comp/MinerComp.java b/core/src/mindustry/entities/comp/MinerComp.java index 3a8fdee884..4e9c28bc3d 100644 --- a/core/src/mindustry/entities/comp/MinerComp.java +++ b/core/src/mindustry/entities/comp/MinerComp.java @@ -123,26 +123,4 @@ abstract class MinerComp implements Itemsc, Posc, Teamc, Rotc, Drawc{ } } } - - public void drawMiningBeam(float px, float py){ - if(!mining()) return; - float swingScl = 12f, swingMag = tilesize / 8f; - float flashScl = 0.3f; - - float ex = mineTile.worldx() + Mathf.sin(Time.time + 48, swingScl, swingMag); - float ey = mineTile.worldy() + Mathf.sin(Time.time + 48, swingScl + 2f, swingMag); - - Draw.z(Layer.flyingUnit + 0.1f); - - Draw.color(Color.lightGray, Color.white, 1f - flashScl + Mathf.absin(Time.time, 0.5f, flashScl)); - - Drawf.laser(Core.atlas.find("minelaser"), Core.atlas.find("minelaser-end"), px, py, ex, ey, 0.75f); - - if(isLocal()){ - Lines.stroke(1f, Pal.accent); - Lines.poly(mineTile.worldx(), mineTile.worldy(), 4, tilesize / 2f * Mathf.sqrt2, Time.time); - } - - Draw.color(); - } } From 6eb463f5ed294d5678e647839b026662441f6cd7 Mon Sep 17 00:00:00 2001 From: MEEPofFaith <54301439+MEEPofFaith@users.noreply.github.com> Date: Sat, 8 Feb 2025 21:44:56 -0800 Subject: [PATCH 08/11] oops --- core/src/mindustry/type/UnitType.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/mindustry/type/UnitType.java b/core/src/mindustry/type/UnitType.java index d8ece89575..5317cdf638 100644 --- a/core/src/mindustry/type/UnitType.java +++ b/core/src/mindustry/type/UnitType.java @@ -1350,7 +1350,7 @@ public class UnitType extends UnlockableContent implements Senseable{ float px = unit.x + Angles.trnsx(unit.rotation, focusLen); float py = unit.y + Angles.trnsy(unit.rotation, focusLen); - drawMiningBeam(px, py); + drawMiningBeam(unit, px, py); } } From 70e9d6d4f8a1c0334a96b7578dde89df1df5137c Mon Sep 17 00:00:00 2001 From: MEEPofFaith <54301439+MEEPofFaith@users.noreply.github.com> Date: Sat, 8 Feb 2025 21:45:28 -0800 Subject: [PATCH 09/11] oops --- core/src/mindustry/type/weapons/MineWeapon.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/mindustry/type/weapons/MineWeapon.java b/core/src/mindustry/type/weapons/MineWeapon.java index ed55659a49..42a67e6e53 100644 --- a/core/src/mindustry/type/weapons/MineWeapon.java +++ b/core/src/mindustry/type/weapons/MineWeapon.java @@ -60,7 +60,7 @@ public class MineWeapon extends Weapon{ px = wx + Angles.trnsx(weaponRotation, shootX, sY), py = wy + Angles.trnsy(weaponRotation, shootX, sY); - unit.type.drawMiningBeam(px, py); + unit.type.drawMiningBeam(unit, px, py); Draw.z(z); } } From 3e8a40b1e6f5abd76d7e3d30007d40e757b53e87 Mon Sep 17 00:00:00 2001 From: MEEPofFaith <54301439+MEEPofFaith@users.noreply.github.com> Date: Sat, 8 Feb 2025 21:52:31 -0800 Subject: [PATCH 10/11] Mention default value --- core/src/mindustry/type/UnitType.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/mindustry/type/UnitType.java b/core/src/mindustry/type/UnitType.java index 5317cdf638..6cdf2d1b2a 100644 --- a/core/src/mindustry/type/UnitType.java +++ b/core/src/mindustry/type/UnitType.java @@ -115,7 +115,7 @@ public class UnitType extends UnlockableContent implements Senseable{ aimDst = -1f, /** Visual offset of the build beam from the front. */ buildBeamOffset = 3.8f, - /** Visual offset of the mining beam from the front. */ + /** Visual offset of the mining beam from the front. Defaults to half the hitsize. */ mineBeamOffset = Float.NEGATIVE_INFINITY, /** WIP: Units of low priority will always be ignored in favor of those with higher priority, regardless of distance. */ targetPriority = 0f, From 0b09d0438ac0202c280258e60e77ce6ff8ea345d Mon Sep 17 00:00:00 2001 From: Anuken Date: Sun, 9 Feb 2025 11:19:31 -0500 Subject: [PATCH 11/11] I'll do it myself --- core/src/mindustry/type/UnitType.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/core/src/mindustry/type/UnitType.java b/core/src/mindustry/type/UnitType.java index 16e4a5b12e..68513a7f58 100644 --- a/core/src/mindustry/type/UnitType.java +++ b/core/src/mindustry/type/UnitType.java @@ -1366,7 +1366,8 @@ public class UnitType extends UnlockableContent implements Senseable{ Draw.color(Color.lightGray, Color.white, 1f - flashScl + Mathf.absin(Time.time, 0.5f, flashScl)); - Drawf.laser(Core.atlas.find("minelaser"), Core.atlas.find("minelaser-end"), px, py, ex, ey, 0.75f); + Draw.alpha(Renderer.unitLaserOpacity); + Drawf.laser(mineLaserRegion, mineLaserEndRegion, px, py, ex, ey, 0.75f); if(unit.isLocal()){ Lines.stroke(1f, Pal.accent);