-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
335 additions
and
93 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
package aquarion.world.blocks; | ||
|
||
import aquarion.world.graphs.RTGraph; | ||
import aquarion.world.interfaces.HasRT; | ||
import aquarion.world.meta.AquaStat; | ||
import arc.math.Mathf; | ||
import arc.util.Time; | ||
import mindustry.gen.*; | ||
import mindustry.world.consumers.*; | ||
import mindustry.world.meta.*; | ||
|
||
public class ConsumeRT extends Consume { | ||
public float min, max; | ||
public boolean stableRT = false; | ||
public float amount; | ||
|
||
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; | ||
} | ||
|
||
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 | ||
} | ||
|
||
public Consume consumeRT() { | ||
stableRT = true; | ||
return this; | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package aquarion.world.graphs; | ||
|
||
import arc.func.*; | ||
import arc.struct.*; | ||
import arc.struct.ObjectMap.*; | ||
import mindustry.gen.*; | ||
|
||
|
||
public class EntityMapping { | ||
public static int customUnits; | ||
public static ObjectIntMap<Class<? extends Entityc>> idMap = new ObjectIntMap<>(); | ||
public static Entry<Class<? extends Entityc>, Prov<? extends Entityc>>[] entities = new Entry[]{ | ||
entry(GraphUpdater.class, GraphUpdater::new) | ||
}; | ||
|
||
private static <T extends Entityc> Entry<Class<T>, Prov<T>> entry(Class<T> name, Prov<T> prov) { | ||
Entry<Class<T>, Prov<T>> out = new Entry<>(); | ||
out.key = name; | ||
out.value = prov; | ||
return out; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package aquarion.world.graphs; | ||
|
||
import arc.util.Nullable; | ||
|
||
public abstract class Graph { | ||
public final @Nullable GraphUpdater entity; | ||
|
||
public Graph() { | ||
entity = new GraphUpdater(); | ||
entity.graph = this; | ||
} | ||
|
||
public void addGraph() { | ||
entity.add(); | ||
} | ||
public void removeGraph() { | ||
entity.remove(); | ||
} | ||
|
||
public abstract void update(); | ||
} |
Oops, something went wrong.