Skip to content

Commit 82634d3

Browse files
authored
Merge pull request #13 from MindustryVN/dev
Dev
2 parents dea4f31 + 4b3edaf commit 82634d3

File tree

2 files changed

+21
-47
lines changed

2 files changed

+21
-47
lines changed

src/main/java/com/neko/gamemode/catali/CataliInterfaceService.java

Lines changed: 19 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public class CataliInterfaceService {
5454
// ------------------------------------------------------------------------------
5555

5656
// !-----------------!
57-
// + COMMON MENU +
57+
// + COMMON MENU +
5858
// !-----------------!
5959

6060
public void showWelcomeMenu(Player p) {
@@ -72,7 +72,7 @@ public void showWelcomeMenu(Player p) {
7272
}
7373

7474
// !-----------------!
75-
// + UPGRADE MENU +
75+
// + UPGRADE MENU +
7676
// !-----------------!
7777

7878
public void showCommonUpgradeMenu(Player leader, CataliTeam team) {
@@ -88,8 +88,7 @@ public void showCommonUpgradeMenu(Player leader, CataliTeam team) {
8888
.row(trans.tr("catali_common_upgrade_healing", leader),
8989
trans.tr("catali_common_upgrade_exp", leader))
9090
.actions(p -> showCommonUpgradeMenu(leader, team, CataliCommonUpgrade.HEALING),
91-
p -> showCommonUpgradeMenu(leader, team,
92-
CataliCommonUpgrade.EXPENRIENCE))
91+
p -> showCommonUpgradeMenu(leader, team, CataliCommonUpgrade.EXPENRIENCE))
9392

9493
.row(trans.tr("common_close", leader))
9594
.actions(CommonUtils::doNothing)
@@ -132,8 +131,7 @@ public void showRareUpgradeMenu(Player leader, CataliTeam team) {
132131
.setMessage(trans.tr("catali_rare_upgrade_message", leader))
133132

134133
.row(trans.tr("catali_rare_upgrade_unit", leader))
135-
.action(p -> eventPublisher
136-
.publishEvent(new CataliEvents.CataliSpawnRareUpgrade(team)))
134+
.action(p -> eventPublisher.publishEvent(new CataliEvents.CataliSpawnRareUpgrade(team)))
137135

138136
.row(trans.tr("catali_rare_upgrade_tier", leader))
139137
.action(p -> showRareUpgradeTierSelectUnitToUpgradeMenu(leader, team))
@@ -164,12 +162,10 @@ private void showRareUpgradeTierSelectUnitToUpgradeMenu(Player leader, CataliTea
164162
.setMessage(trans.tr("catali_rare_upgrade_tier_select_unit_message", leader))
165163

166164
.rows(IntStream.range(0, (unitNameList.size() + 1) / 2)
167-
.mapToObj(i -> unitNameList.subList(i * 2,
168-
Math.min(i * 2 + 2, unitNameList.size())))
165+
.mapToObj(i -> unitNameList.subList(i * 2, Math.min(i * 2 + 2, unitNameList.size())))
169166
.collect(Collectors.toList()))
170167
.actions(availableUnitsToUpgrade.stream()
171-
.map(u -> (Consumer<Player>) p -> showRareUpgradeTierSelectUpgradeToMenu(
172-
p, team, u))
168+
.map(u -> (Consumer<Player>) p -> showRareUpgradeTierSelectUpgradeToMenu(p, team, u))
173169
.toList())
174170

175171
.row(trans.tr("common_back", leader), trans.tr("common_close", leader))
@@ -193,13 +189,11 @@ private void showRareUpgradeTierSelectUpgradeToMenu(Player leader, CataliTeam te
193189
.setMessage(trans.tr("catali_rare_upgrade_tier_select_upgrade_message", leader))
194190

195191
.rows(IntStream.range(0, (unitNameList.size() + 1) / 2)
196-
.mapToObj(i -> unitNameList.subList(i * 2,
197-
Math.min(i * 2 + 2, unitNameList.size())))
192+
.mapToObj(i -> unitNameList.subList(i * 2, Math.min(i * 2 + 2, unitNameList.size())))
198193
.collect(Collectors.toList()))
199194
.actions(availableUnitsUpgradeTo
200195
.stream().map(u -> (Consumer<Player>) p -> eventPublisher
201-
.publishEvent(new CataliEvents.CataliTierRareUpgrade(
202-
team, unit, u)))
196+
.publishEvent(new CataliEvents.CataliTierRareUpgrade(team, unit, u)))
203197
.toList())
204198

205199
.row(trans.tr("common_back", leader), trans.tr("common_close", leader))
@@ -227,12 +221,10 @@ private void showRareUpgradBuffSelectUnitToUpgradeMenu(Player leader, CataliTeam
227221
.setMessage(trans.tr("catali_rare_upgrade_buff_select_unit_message", leader))
228222

229223
.rows(IntStream.range(0, (unitNameList.size() + 1) / 2)
230-
.mapToObj(i -> unitNameList.subList(i * 2,
231-
Math.min(i * 2 + 2, unitNameList.size())))
224+
.mapToObj(i -> unitNameList.subList(i * 2, Math.min(i * 2 + 2, unitNameList.size())))
232225
.collect(Collectors.toList()))
233226
.actions(availableUnitsToUpgrade.stream()
234-
.map(u -> (Consumer<Player>) p -> showRareUpgradBuffSelectBuffToUpgradeMenu(
235-
p, team, u))
227+
.map(u -> (Consumer<Player>) p -> showRareUpgradBuffSelectBuffToUpgradeMenu(p, team, u))
236228
.toList())
237229

238230
.row(trans.tr("common_back", leader), trans.tr("common_close", leader))
@@ -249,20 +241,16 @@ private void showRareUpgradBuffSelectBuffToUpgradeMenu(Player leader, CataliTeam
249241
.row(StatusEffects.overclock.emoji() + " Overclock",
250242
StatusEffects.boss.emoji() + " Boss")
251243
.actions(p -> eventPublisher.publishEvent(
252-
new CataliEvents.CataliBuffRareUpgrade(team, unit,
253-
StatusEffects.overclock)),
244+
new CataliEvents.CataliBuffRareUpgrade(team, unit, StatusEffects.overclock)),
254245
p -> eventPublisher.publishEvent(
255-
new CataliEvents.CataliBuffRareUpgrade(team, unit,
256-
StatusEffects.boss)))
246+
new CataliEvents.CataliBuffRareUpgrade(team, unit, StatusEffects.boss)))
257247

258248
.row(StatusEffects.overdrive.emoji() + " Overdrive",
259249
StatusEffects.fast.emoji() + " Fast")
260250
.actions(p -> eventPublisher.publishEvent(
261-
new CataliEvents.CataliBuffRareUpgrade(team, unit,
262-
StatusEffects.overdrive)),
251+
new CataliEvents.CataliBuffRareUpgrade(team, unit, StatusEffects.overdrive)),
263252
p -> eventPublisher.publishEvent(
264-
new CataliEvents.CataliBuffRareUpgrade(team, unit,
265-
StatusEffects.fast)))
253+
new CataliEvents.CataliBuffRareUpgrade(team, unit, StatusEffects.fast)))
266254

267255
.row(trans.tr("common_back", leader), trans.tr("common_close", leader))
268256
.actions(p -> showRareUpgradBuffSelectUnitToUpgradeMenu(p, team),
@@ -272,7 +260,7 @@ private void showRareUpgradBuffSelectBuffToUpgradeMenu(Player leader, CataliTeam
272260
}
273261

274262
// !-----------------!
275-
// + TEAM MENU +
263+
// + TEAM MENU +
276264
// !-----------------!
277265

278266
public void showJoinTeamMenu(Player player) {
@@ -344,7 +332,7 @@ public void showAssignNextLeaderMenu(Player leader, CataliTeam team) {
344332
}
345333

346334
// !------------!
347-
// + MESSAGE +
335+
// + MESSAGE +
348336
// !------------!
349337

350338
public void sendCataliPlayedMessage(Player p) {
@@ -384,7 +372,7 @@ public void sendCataliRequestRejectedBeforeMessage(Player p) {
384372
}
385373

386374
// !-----------------!
387-
// + EVENT MESSAGE +
375+
// + EVENT MESSAGE +
388376
// !-----------------!
389377

390378
public void sendCataliTeamCreatedMessage(CataliTeam team) {
@@ -400,7 +388,7 @@ public void sendCataliTeamDestroyedMessage(CataliTeam team) {
400388
}
401389

402390
// !-----------------!
403-
// + EVENT TOAST +
391+
// + EVENT TOAST +
404392
// !-----------------!
405393

406394
public void sendCataliUnitDestroyedToast(CataliTeam team, UnitType unit, CataliTeam unitFrom) {
@@ -415,7 +403,7 @@ public void sendCataliLevelUpToast(CataliTeam team) {
415403
}
416404

417405
// !-----------------!
418-
// + MESSAGE GETTER +
406+
// + MESSAGE GETTER +
419407
// !-----------------!
420408

421409
public String getCataliPlayHint(Player player) {

src/main/java/com/neko/gamemode/catali/spawner/CataliBlockSpawnerService.java

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@
66
import java.util.List;
77
import java.util.Set;
88
import java.util.concurrent.ThreadLocalRandom;
9-
import java.util.concurrent.atomic.AtomicInteger;
109

11-
import org.springframework.context.event.EventListener;
1210
import org.springframework.stereotype.Service;
1311

1412
import arc.Core;
@@ -20,7 +18,6 @@
2018
import mindustry.Vars;
2119
import mindustry.content.Blocks;
2220
import mindustry.content.Items;
23-
import mindustry.game.EventType.BuildingBulletDestroyEvent;
2421
import mindustry.gen.Groups;
2522
import mindustry.world.Block;
2623

@@ -37,20 +34,17 @@ public class CataliBlockSpawnerService implements CataliLifecycle {
3734
private static final int[] dy4 = { 0, 1, 0, -1 };
3835

3936
private boolean isLoaded = false;
40-
private AtomicInteger spawnedTilesCount = new AtomicInteger(0);
4137

4238
// ----------------------------------------------------
4339

4440
@Override
4541
public void onLoaded() {
4642
setLoaded(true);
47-
spawnedTilesCount.set(0);
4843
}
4944

5045
@Override
5146
public void onUnloaded() {
5247
setLoaded(false);
53-
spawnedTilesCount.set(0);
5448
}
5549

5650
// !----------------------!
@@ -62,7 +56,7 @@ public void onRefresh() {
6256
}
6357

6458
var maxTotalTilesToSpawn = Math.max(0, (int) Math.min(CataliConfig.MAX_SPAWN_TILES_PER_REFRESH,
65-
Vars.world.width() * Vars.world.height() * CataliConfig.BLOCK_FILL_RATE - spawnedTilesCount.get()));
59+
Vars.world.width() * Vars.world.height() * CataliConfig.BLOCK_FILL_RATE - Groups.build.size()));
6660
if (maxTotalTilesToSpawn <= 0)
6761
return;
6862

@@ -79,12 +73,6 @@ public void onRefresh() {
7973
Core.app.post(() -> blocksPosToSpawn.forEach(pos -> spawnBlock(blockToSpawn, pos)));
8074
}
8175

82-
@EventListener(BuildingBulletDestroyEvent.class)
83-
public void listen(BuildingBulletDestroyEvent e) {
84-
var tileUsed = e.build.block.size * e.build.block.size;
85-
spawnedTilesCount.updateAndGet(current -> Math.max(0, current - tileUsed));
86-
}
87-
8876
// !---------------------------!
8977

9078
private void spawnBlock(Block block, Vec2 pos) {
@@ -93,11 +81,9 @@ private void spawnBlock(Block block, Vec2 pos) {
9381

9482
try {
9583
MindustryWorldUtils.spawnBlock(block, CataliConfig.BLOCK_TEAM, pos.scl(Vars.tilesize), b -> {
96-
int tilesUsed = block.size * block.size;
97-
spawnedTilesCount.addAndGet(tilesUsed);
98-
9984
if (b.block == Blocks.thoriumReactor)
10085
b.items.add(Items.thorium, 30);
86+
b.block.update = true;
10187
});
10288
} catch (Exception e) {
10389
log.error("Spawn block failed for {} x={},y={}", block.name, (int) pos.x, (int) pos.y, e);

0 commit comments

Comments
 (0)