Skip to content

Commit

Permalink
add caching for the next wave info
Browse files Browse the repository at this point in the history
  • Loading branch information
xzxADIxzx committed Mar 4, 2025
1 parent 156e885 commit 9b42695
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
23 changes: 23 additions & 0 deletions src/java/schema/tools/Units.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import arc.func.*;
import arc.struct.*;
import arc.util.*;
import mindustry.content.*;
import mindustry.entities.*;
import mindustry.entities.abilities.*;
import mindustry.game.EventType.*;
Expand Down Expand Up @@ -33,6 +34,11 @@ public class Units {
/** Current shield or null if absent. */
private ShieldArcAbility arcShield;

/** Summary health and shield of all units on the next wave. */
public float waveHealth, waveShield;
/** Total amount of units and bosses on the next wave. */
public ObjectIntMap<UnitType> waveUnits = new ObjectIntMap<>(), waveBosses = new ObjectIntMap<>();

public Units() {
Events.on(WorldLoadEvent.class, e -> draw = true);
Events.on(UnitChangeEvent.class, e -> {
Expand Down Expand Up @@ -81,4 +87,21 @@ public void draw(Cons<Drawc> cons) {

/** Returns the percentage health of the force field. */
public float shieldf() { return shield() / maxShield; }

/** Refreshes the information about the next wave. */
public void refreshWaveInfo() {
waveHealth = waveShield = 0f;
waveUnits.clear();
waveBosses.clear();

state.rules.spawns.each(g -> g.type != null, g -> {
int amount = g.getSpawned(state.wave - 1);
if (amount == 0) return;

waveHealth += g.type.health * amount;
waveShield += g.getShield(state.wave - 1);

(g.effect == StatusEffects.boss ? waveBosses : waveUnits).put(g.type, amount);
});
}
}
2 changes: 1 addition & 1 deletion src/resources/bundles/bundle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
update.name = [red]\u26A0[] Schema is outdated!
update.info = Your version of the mod is [accent]outdated[].\nThis annoying dialog can be turned off in settings.\n\n[gray]The current version is v{0} while the latest is v{1}[]
update.info = Your version of the mod is [accent]outdated[].\nThis annoying dialog can be turned off in settings.\n\n[disabled]The current version is v{0} while the latest is v{1}[]

# dialogs

Expand Down

0 comments on commit 9b42695

Please sign in to comment.