From 09ce6fc1d65d243b269f55167de70304b945a242 Mon Sep 17 00:00:00 2001 From: NickName73 Date: Mon, 2 May 2022 15:40:04 +0300 Subject: [PATCH] B39 --- .../sprites/blocks/turrets/slt-gravity.png | Bin 0 -> 780 bytes .../assets-raw/sprites/blocks/turrets/slt.png | Bin 1412 -> 1410 bytes .../nitis/gravillaso/content/GRBlocks.java | 7 +- .../gravillaso/content/GRStatusEffects.java | 2 +- .../blocks/defence/turrets/GravityTurret.java | 74 +++++++++++++++--- .../world/blocks/gravity/GravityConsumer.java | 15 +++- .../blocks/gravity/GravityProjector.java | 8 +- .../world/blocks/gravity/GravityProvider.java | 2 +- mod.hjson | 2 +- 9 files changed, 87 insertions(+), 23 deletions(-) create mode 100644 core/assets-raw/sprites/blocks/turrets/slt-gravity.png diff --git a/core/assets-raw/sprites/blocks/turrets/slt-gravity.png b/core/assets-raw/sprites/blocks/turrets/slt-gravity.png new file mode 100644 index 0000000000000000000000000000000000000000..b99eb4853942f17fe094889abd7c5024a1b32fec GIT binary patch literal 780 zcmeAS@N?(olHy`uVBq!ia0vp^2_VeD1|%QND7OGojKx9jP7LeL$-HD>U^?dM;uumf z=k45!nKFhVuIrs&74R$aE@_)Gq2BpGDGSrTa?W*%ye(fQxV`EBa3ZN}uhh$zceP*7 zi?3e#aL&!UlD$2Q$vuY0BtXOr+aKS)9yk6iA-C`UBDurt*N$*~Voqc6Vo?3bsLk|N zHsRkxh7_5G9_9&!3`Tqo#~4poFi5g1JVq95lWW*1wtj<-A3sBZlEw*k7bb?Sf+0_s zofsQtad>@V+{kd?4oB7}#)Aw8=5TaLl!Q{Zj>`&7;Zl>3jwrpZ}?y~j7&(Gh>zt5SUXCMD}Zt+BI z-6`-XI>kuYhu=WU-a_c%*O}{O60;g~emZ)$c*|R_5?mHLEA@1~?BiJ*vg6-OKbBD$ z%OA{^dXhh^Yl59ZblnE8mMaHCp0I1XypUS)wXI9jeun76@-^3ec5?+y;D54a!?|Bf zY-+3l6XiABJ@^->*$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ps@cUaRs%^ zKXYR$fHFxA)WekOz5sg(W&)`2L#R+C;fGjCaI-$ZaviUy1>9}~05%dl!3UfP0Qdu} z*6V1;odBR6-dx}VMw9ZKNS2yX@Mk$GFCFgOfK;RVuw&8_X5_nXdWlGAN4iKWoYV+aN$$-mn { Func rat = (building) -> { if (e instanceof GravityTurretBuild gravityTurret) { - return gravityTurret.calculateGravity(); + return gravityTurret.gravityRatio(); } return 0f; }; @@ -97,6 +108,10 @@ public void setBars() { ); }); } + @Override + public TextureRegion[] icons() { + return new TextureRegion[]{baseRegion, region}; + } public class GravityTurretBuild extends PowerTurretBuild implements GravityConsumer { private final Seq gravityProviders = new Seq<>(); @@ -123,18 +138,26 @@ public void updateTile() { @Override public float range() { - return range * calculateGravity(); + return range * gravityRatio(); } - public float getCurrentGravity() { + @Override + public float gravity() { return currentGravity; } - public float speedMultiplier() { - return calculateGravity(); + + @Override + public float maxGravity() { + return requiredGravity; } - private float calculateGravity() { - return Math.min(Math.max(minGravity, currentGravity) / requiredGravity, 1f); + @Override + public float minGravity() { + return minGravity; + } + + public float speedMultiplier() { + return gravityRatio(); } @Override public boolean absorbLasers() { @@ -145,16 +168,45 @@ public boolean absorbLasers() { protected void bullet(BulletType type, float angle){ float lifeScl = type.scaleVelocity ? Mathf.clamp(Mathf.dst(x + tr.x, y + tr.y, targetPos.x, targetPos.y) / type.range(), minRange / type.range(), range / type.range()) : 1f; BulletType otherType = type.copy(); - otherType.damage *= calculateGravity(); - otherType.create(this, team, x + tr.x, y + tr.y, angle, ( 1f + Mathf.range(velocityInaccuracy) ) * speedMultiplier(), lifeScl); + otherType.damage *= gravityRatio(); + tr.trns(rotation, shootLength + shootY, Mathf.range(xRand)); + otherType.create( + this, + team, + x + tr.x, + y + tr.y, + angle, + ( 1f + Mathf.range(velocityInaccuracy) ) * speedMultiplier(), + lifeScl + ); + } + @Override + protected void findTarget(){ + float _range = range(); + if(targetAir && !targetGround){ + target = Units.bestEnemy(team, x, y, _range, e -> !e.dead() && !e.isGrounded(), unitSort); + }else{ + target = Units.bestTarget(team, x, y, _range, e -> !e.dead() && (e.isGrounded() || targetAir) && (!e.isGrounded() || targetGround), b -> targetGround, unitSort); + + if(target == null && canHeal()){ + target = Units.findAllyTile(team, x, y, _range, b -> b.damaged() && b != this); + } + } } - @Override public void write(Writes write) { super.write(write); } + @Override + public void draw() { + super.draw(); + Draw.alpha(gravityRatio()); + Draw.rect(gravityRegion, x + tr2.x, y + tr2.y, rotation - 90); + Draw.alpha(1f); + } + @Override public void read(Reads read, byte revision) { super.read(read, (byte) 1); diff --git a/core/src/nitis/gravillaso/world/blocks/gravity/GravityConsumer.java b/core/src/nitis/gravillaso/world/blocks/gravity/GravityConsumer.java index 6fb1cf2..2fe23f9 100644 --- a/core/src/nitis/gravillaso/world/blocks/gravity/GravityConsumer.java +++ b/core/src/nitis/gravillaso/world/blocks/gravity/GravityConsumer.java @@ -1,5 +1,18 @@ package nitis.gravillaso.world.blocks.gravity; public interface GravityConsumer { - public void connectGravityProvider(GravityProvider provider); + void connectGravityProvider(GravityProvider provider); + + /** Get max gravity*/ + float maxGravity(); + /** Get minimal gravity (0 by default)*/ + default float minGravity() { + return 0f; + } + /** Get current gravity*/ + float gravity(); + /** Calculate gravity*/ + default float gravityRatio() { + return Math.min(Math.max(minGravity(), gravity()) / maxGravity(), 1f); + } } diff --git a/core/src/nitis/gravillaso/world/blocks/gravity/GravityProjector.java b/core/src/nitis/gravillaso/world/blocks/gravity/GravityProjector.java index 63ccfb5..b8a5a9d 100644 --- a/core/src/nitis/gravillaso/world/blocks/gravity/GravityProjector.java +++ b/core/src/nitis/gravillaso/world/blocks/gravity/GravityProjector.java @@ -78,9 +78,7 @@ public void drawPlace(int x, int y, int rotation, boolean valid){ y * Vars.tilesize + offset, radius, (build) -> build instanceof GravityConsumer, - (build) -> { - Drawf.selected(build, Tmp.c1.set(GRPal.magneturn).a(Mathf.absin(4f, 1f))); - }); + (build) -> Drawf.selected(build, Tmp.c1.set(GRPal.magneturn).a(Mathf.absin(4f, 1f)))); } public class GravityProjectorBuild extends Building implements Ranged, GravityProvider { @@ -125,9 +123,7 @@ public float getGravity() { @Override public void drawSelect() { super.drawSelect(); - getPotentialConnections(this.team, (b,u) -> { - drawConnect(b); - }); + getPotentialConnections(this.team, (b,u) -> drawConnect(b)); } public void drawConnect(Building build){ diff --git a/core/src/nitis/gravillaso/world/blocks/gravity/GravityProvider.java b/core/src/nitis/gravillaso/world/blocks/gravity/GravityProvider.java index 3857ab5..15dd9b8 100644 --- a/core/src/nitis/gravillaso/world/blocks/gravity/GravityProvider.java +++ b/core/src/nitis/gravillaso/world/blocks/gravity/GravityProvider.java @@ -1,5 +1,5 @@ package nitis.gravillaso.world.blocks.gravity; public interface GravityProvider { - public float getGravity(); + float getGravity(); } diff --git a/mod.hjson b/mod.hjson index 9e06d75..9c7d38f 100644 --- a/mod.hjson +++ b/mod.hjson @@ -5,6 +5,6 @@ author: "NickName73 (NiTiS-Dev)" browserAuthor: "NickName73" main: "nitis.gravillaso.GRMod" description: "GRavillaso Mod based to improve basic content & add new things" -version: "2 b38" +version: "2 b39" minGameVersion: "135" java: true \ No newline at end of file