Skip to content

Commit

Permalink
dscgfrsghdjtfykfdhdf
Browse files Browse the repository at this point in the history
  • Loading branch information
Twcash committed Aug 18, 2024
1 parent 0b7a466 commit 00ae727
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 69 deletions.
63 changes: 5 additions & 58 deletions src/aquarion/world/blocks/ConsumeRT.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import aquarion.world.graphs.RTGraph;
import aquarion.world.interfaces.HasRT;
import aquarion.world.meta.AquaStat;
import aquarion.world.meta.RTModule;
import arc.math.Mathf;
import arc.util.Time;
import mindustry.gen.*;
Expand All @@ -17,65 +18,11 @@ public class ConsumeRT extends Consume {
public ConsumeRT(float amount) {
this.amount = amount;
}

public HasRT cast(Building build) {
try {
return (HasRT) build;
} catch (ClassCastException e) {
throw new IllegalArgumentException("Building is not a HasRT instance", e);
}
}

@Override
public void display(Stats stats) {
stats.add(AquaStat.requiredRT, "@ to @ @", min, max, AquaStat.rotationUnits.localized());
}

@Override
public float efficiency(Building build) {
if (build instanceof HasRT b) {
float currentPower = b.rTGraph().getTotalRotationPower();
return Mathf.clamp((currentPower - amount) / amount);
}
return 0f;
}

@Override
public void update(Building build) {
if (build instanceof HasRT next) {
float consumption = amount * efficiencyMultiplier(build) * Time.delta;
float consumed = pull(next);
next.rotationPower().rotationPower -= consumed; // Reduce the rotation power
}
}


@Override
public float efficiencyMultiplier(Building build) {
if (build instanceof HasRT b) {
float currentPower = b.rTGraph().getTotalRotationPower();
float ratio = Mathf.map(currentPower, amount, amount * 2, 0, 1);
return 1f - ratio; // Adjusted to reduce efficiency as power is consumed
}
return 0f;
@Override public float efficiency(Building build) {
return build instanceof HasRT b ? Mathf.clamp(Math.abs(b.rotationPower) - amount) : 0f;
}

public float pull(HasRT build) {
RTGraph graph = build.rTGraph();
float availablePower = graph.getTotalRotationPower();
final float[] consumed = {Math.min(amount, availablePower)};
graph.getBuildings().each(b -> {
if (consumed[0] > 0) {
float toRemove = Math.min(amount, b.rotationPower().rotationPower);
b.rotationPower().rotationPower -= toRemove;
consumed[0] -= toRemove;
}
});
return amount - consumed[0]; // Return the amount of power that was actually consumed
@Override public float efficiencyMultiplier(Building build) {
return build instanceof HasRT b ? 1f + Mathf.map(Math.abs(b.rotationPower), amount, amount, 0, 1) : 0f;
}

public Consume consumeRT() {
stableRT = true;
return this;
}
}
4 changes: 0 additions & 4 deletions src/aquarion/world/blocks/rotPower/RTWallCrafter.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
import aquarion.world.meta.RTConfig;
import aquarion.world.meta.RTModule;
import arc.Core;
import arc.math.Mathf;
import arc.math.geom.Geometry;
import arc.util.Strings;
import arc.util.io.Reads;
import arc.util.io.Writes;
Expand All @@ -17,8 +15,6 @@
import mindustry.world.meta.StatUnit;
import mindustry.world.meta.StatValues;

import static mindustry.Vars.tilesize;

public class RTWallCrafter extends WallCrafter {
public RTConfig rtConfig = new RTConfig();

Expand Down
4 changes: 4 additions & 0 deletions src/aquarion/world/interfaces/HasRT.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,9 @@ default RTGraph rTGraph() {
} default void onRTupdate() {

}
default RTGraph graph() {
return rotationPower().graph;
}


}
9 changes: 2 additions & 7 deletions src/aquarion/world/meta/RTModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,9 @@
*/
public class RTModule extends BlockModule {
public RTGraph graph = new aquarion.world.graphs.RTGraph();
public float rotationPower = 0;
@Override
public void read(Reads read) {
rotationPower = read.f();
}
public float rotationPower;

@Override
public void write(Writes write) {
write.f(rotationPower);
public void write(Writes writes) {
}
}

0 comments on commit 00ae727

Please sign in to comment.