From 0582ba1c47968c76db85a02a0c27745705b8bd36 Mon Sep 17 00:00:00 2001 From: Anuken Date: Sat, 7 Jan 2023 11:23:55 -0500 Subject: [PATCH] Oct now has an octagon shield --- core/src/mindustry/content/UnitTypes.java | 2 +- .../entities/abilities/ForceFieldAbility.java | 21 +++++++++++++++---- gradle.properties | 2 +- 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/core/src/mindustry/content/UnitTypes.java b/core/src/mindustry/content/UnitTypes.java index 68169fcc50..f2a94de5ae 100644 --- a/core/src/mindustry/content/UnitTypes.java +++ b/core/src/mindustry/content/UnitTypes.java @@ -1468,7 +1468,7 @@ public class UnitTypes{ buildBeamOffset = 43; ammoCapacity = 1; - abilities.add(new ForceFieldAbility(140f, 4f, 7000f, 60f * 8), new RepairFieldAbility(130f, 60f * 2, 140f)); + abilities.add(new ForceFieldAbility(140f, 4f, 7000f, 60f * 8, 8, 0f), new RepairFieldAbility(130f, 60f * 2, 140f)); }}; //endregion diff --git a/core/src/mindustry/entities/abilities/ForceFieldAbility.java b/core/src/mindustry/entities/abilities/ForceFieldAbility.java index 2a95adb4b2..0a310b7008 100644 --- a/core/src/mindustry/entities/abilities/ForceFieldAbility.java +++ b/core/src/mindustry/entities/abilities/ForceFieldAbility.java @@ -22,6 +22,10 @@ public class ForceFieldAbility extends Ability{ public float max = 200f; /** Cooldown after the shield is broken, in ticks. */ public float cooldown = 60f * 5; + /** Sides of shield polygon. */ + public int sides = 6; + /** Rotation of shield. */ + public float rotation = 0f; /** State. */ protected float radiusScale, alpha; @@ -30,7 +34,7 @@ public class ForceFieldAbility extends Ability{ private static Unit paramUnit; private static ForceFieldAbility paramField; private static final Cons shieldConsumer = trait -> { - if(trait.team != paramUnit.team && trait.type.absorbable && Intersector.isInsideHexagon(paramUnit.x, paramUnit.y, realRad * 2f, trait.x(), trait.y()) && paramUnit.shield > 0){ + if(trait.team != paramUnit.team && trait.type.absorbable && Intersector.isInRegularPolygon(paramField.sides, paramUnit.x, paramUnit.y, realRad, paramField.rotation, trait.x(), trait.y()) && paramUnit.shield > 0){ trait.absorb(); Fx.absorb.at(trait); @@ -53,6 +57,15 @@ public class ForceFieldAbility extends Ability{ this.cooldown = cooldown; } + public ForceFieldAbility(float radius, float regen, float max, float cooldown, int sides, float rotation){ + this.radius = radius; + this.regen = regen; + this.max = max; + this.cooldown = cooldown; + this.sides = sides; + this.rotation = rotation; + } + ForceFieldAbility(){} @Override @@ -85,13 +98,13 @@ public class ForceFieldAbility extends Ability{ Draw.color(unit.team.color, Color.white, Mathf.clamp(alpha)); if(Vars.renderer.animateShields){ - Fill.poly(unit.x, unit.y, 6, realRad); + Fill.poly(unit.x, unit.y, sides, realRad, rotation); }else{ Lines.stroke(1.5f); Draw.alpha(0.09f); - Fill.poly(unit.x, unit.y, 6, radius); + Fill.poly(unit.x, unit.y, sides, radius, rotation); Draw.alpha(1f); - Lines.poly(unit.x, unit.y, 6, radius); + Lines.poly(unit.x, unit.y, sides, radius, rotation); } } } diff --git a/gradle.properties b/gradle.properties index 98272271fd..33345ea5db 100644 --- a/gradle.properties +++ b/gradle.properties @@ -25,4 +25,4 @@ org.gradle.caching=true #used for slow jitpack builds; TODO see if this actually works org.gradle.internal.http.socketTimeout=100000 org.gradle.internal.http.connectionTimeout=100000 -archash=b32576ca09 +archash=1d7a035858