Skip to content
This repository has been archived by the owner on Jul 12, 2023. It is now read-only.

Commit

Permalink
B39
Browse files Browse the repository at this point in the history
  • Loading branch information
NiTiSon committed May 2, 2022
1 parent 5550352 commit 09ce6fc
Show file tree
Hide file tree
Showing 9 changed files with 87 additions and 23 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified core/assets-raw/sprites/blocks/turrets/slt.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 5 additions & 2 deletions core/src/nitis/gravillaso/content/GRBlocks.java
Original file line number Diff line number Diff line change
Expand Up @@ -797,11 +797,14 @@ Items.phaseFabric, new ShrapnelBulletType(){{
requirements(Category.turret, ItemStack.with(Items.lead, 240, Items.graphite, 190, Items.metaglass, 110, Items.surgeAlloy, 70, GRItems.magneturn, 45));
size = 3;
range = 320f;
consumes.power(8.5f);
consumesPower = true;
powerUse = 12f;
requiredGravity = 720f;
minGravity = 160f;
requiredGravityToAbsorbLasers = 320f;
shootType = new GraviBullet(98) {{
shootY = -6;
coolantMultiplier = 3.5f;
shootType = new GraviBullet(72) {{
speed = 7.5f;
}};
}};
Expand Down
2 changes: 1 addition & 1 deletion core/src/nitis/gravillaso/content/GRStatusEffects.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
public class GRStatusEffects implements ContentList {

public static StatusEffect
broken,pressure;
broken, pressure;

@Override
public void load() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@

import arc.Core;
import arc.func.Func;
import arc.graphics.g2d.Draw;
import arc.graphics.g2d.TextureRegion;
import arc.math.Mathf;
import arc.struct.Seq;
import arc.util.io.Reads;
import arc.util.io.Writes;
import mindustry.Vars;
import mindustry.entities.Units;
import mindustry.entities.bullet.BulletType;
import mindustry.gen.Building;
import mindustry.graphics.Drawf;
Expand All @@ -25,7 +28,9 @@
public class GravityTurret extends PowerTurret {
public float requiredGravity = 160f;
public float minGravity = 20f;

/**Shoot position at Y */
public float shootY = 0f;
public TextureRegion gravityRegion;
public float requiredGravityToAbsorbLasers = 120f;
public GravityTurret(String name) {
super(name);
Expand All @@ -34,6 +39,12 @@ public GravityTurret(String name) {
update = true;
}

@Override
public void load() {
super.load();
gravityRegion = Core.atlas.find(this.name + "-gravity", "error");
}

@Override
public void drawPlace(int x, int y, int rotation, boolean valid) {
super.drawPlace(x, y, rotation, valid);
Expand Down Expand Up @@ -86,7 +97,7 @@ public void setBars() {
bars.add("gravity-module", e -> {
Func<Building,Float> rat = (building) -> {
if (e instanceof GravityTurretBuild gravityTurret) {
return gravityTurret.calculateGravity();
return gravityTurret.gravityRatio();
}
return 0f;
};
Expand All @@ -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<GravityProvider> gravityProviders = new Seq<>();
Expand All @@ -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() {
Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
@@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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){
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package nitis.gravillaso.world.blocks.gravity;

public interface GravityProvider {
public float getGravity();
float getGravity();
}
2 changes: 1 addition & 1 deletion mod.hjson
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 09ce6fc

Please sign in to comment.