This commit is contained in:
Anuken
2025-04-04 13:39:22 -04:00
parent 0082855292
commit 01a7b6e68f
4 changed files with 24 additions and 12 deletions

View File

@@ -1358,6 +1358,7 @@ keybind.shoot.name = Shoot
keybind.zoom.name = Zoom keybind.zoom.name = Zoom
keybind.menu.name = Menu keybind.menu.name = Menu
keybind.pause.name = Pause keybind.pause.name = Pause
keybind.skip_wave.name = Skip Wave
keybind.pause_building.name = Pause/Resume Building keybind.pause_building.name = Pause/Resume Building
keybind.minimap.name = Minimap keybind.minimap.name = Minimap
keybind.planet_map.name = Planet Map keybind.planet_map.name = Planet Map

View File

@@ -85,6 +85,7 @@ public enum Binding implements KeyBind{
menu(Vars.android ? KeyCode.back : KeyCode.escape), menu(Vars.android ? KeyCode.back : KeyCode.escape),
fullscreen(KeyCode.f11), fullscreen(KeyCode.f11),
pause(KeyCode.space), pause(KeyCode.space),
skip_wave(KeyCode.unset),
minimap(KeyCode.m), minimap(KeyCode.m),
research(KeyCode.j), research(KeyCode.j),
planet_map(KeyCode.n), planet_map(KeyCode.n),

View File

@@ -758,11 +758,7 @@ public class UnitType extends UnlockableContent implements Senseable{
} }
} }
@CallSuper protected void checkEntityMapping(){
@Override
public void init(){
super.init();
if(constructor == null) throw new IllegalArgumentException(Strings.format(""" if(constructor == null) throw new IllegalArgumentException(Strings.format("""
No constructor set up for unit '@': Assign `constructor = [your unit constructor]`. Vanilla defaults are: No constructor set up for unit '@': Assign `constructor = [your unit constructor]`. Vanilla defaults are:
"flying": UnitEntity::create "flying": UnitEntity::create
@@ -777,7 +773,7 @@ public class UnitType extends UnlockableContent implements Senseable{
"crawl": CrawlUnit::create "crawl": CrawlUnit::create
""", name)); """, name));
// Often modders improperly only sets `constructor = ...` without mapping. Try to mitigate for that. // Often modders improperly only sets `constructor = ...` without mapping. Try to mitigate that.
// In most cases, if the constructor is a Vanilla class, things should work just fine. // In most cases, if the constructor is a Vanilla class, things should work just fine.
if(EntityMapping.map(name) == null) EntityMapping.nameMap.put(name, constructor); if(EntityMapping.map(name) == null) EntityMapping.nameMap.put(name, constructor);
@@ -787,17 +783,25 @@ public class UnitType extends UnlockableContent implements Senseable{
int classId = example.classId(); int classId = example.classId();
if( if(
// Check if `classId()` even points to a valid constructor... // Check if `classId()` even points to a valid constructor...
EntityMapping.map(classId) == null || EntityMapping.map(classId) == null ||
// ...or if the class doesn't register itself and uses the ID of its base class. // ...or if the class doesn't register itself and uses the ID of its base class.
classId != ((Entityc)EntityMapping.map(classId).get()).classId() classId != ((Entityc)EntityMapping.map(classId).get()).classId()
){ ){
String type = example.getClass().getSimpleName(); String type = example.getClass().getSimpleName();
throw new IllegalArgumentException(Strings.format(""" throw new IllegalArgumentException(Strings.format("""
Invalid class ID for `@` detected (found: @). Fix it by: Invalid class ID for `@` detected (found: @). Potential fixes:
- Register with `EntityMapping.register("some-unique-name", @::new)` to get an ID, and store it somewhere. - Register with `EntityMapping.register("some-unique-name", @::new)` to get an ID, and store it somewhere.
- Override `@#classId()` to return that ID. - Override `@#classId()` to return that ID.
""", type, classId, type, type)); """, type, classId, type, type));
} }
}
@CallSuper
@Override
public void init(){
super.init();
checkEntityMapping();
allowLegStep = example instanceof Legsc || example instanceof Crawlc; allowLegStep = example instanceof Legsc || example instanceof Crawlc;

View File

@@ -30,8 +30,6 @@ import mindustry.type.*;
import mindustry.ui.*; import mindustry.ui.*;
import mindustry.world.*; import mindustry.world.*;
import mindustry.world.blocks.environment.*; import mindustry.world.blocks.environment.*;
import mindustry.world.blocks.storage.*;
import mindustry.world.blocks.storage.CoreBlock.*;
import mindustry.world.meta.*; import mindustry.world.meta.*;
import static mindustry.Vars.*; import static mindustry.Vars.*;
@@ -286,6 +284,14 @@ public class HudFragment{
}); });
toggleMenus(); toggleMenus();
} }
if(Core.input.keyTap(Binding.skip_wave) && canSkipWave()){
if(net.client() && player.admin){
Call.adminRequest(player, AdminAction.wave, null);
}else{
logic.skipWave();
}
}
}); });
Table wavesMain, editorMain; Table wavesMain, editorMain;