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

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

View File

@@ -758,11 +758,7 @@ public class UnitType extends UnlockableContent implements Senseable{
}
}
@CallSuper
@Override
public void init(){
super.init();
protected void checkEntityMapping(){
if(constructor == null) throw new IllegalArgumentException(Strings.format("""
No constructor set up for unit '@': Assign `constructor = [your unit constructor]`. Vanilla defaults are:
"flying": UnitEntity::create
@@ -777,7 +773,7 @@ public class UnitType extends UnlockableContent implements Senseable{
"crawl": CrawlUnit::create
""", 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.
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();
if(
// Check if `classId()` even points to a valid constructor...
EntityMapping.map(classId) == null ||
// ...or if the class doesn't register itself and uses the ID of its base class.
classId != ((Entityc)EntityMapping.map(classId).get()).classId()
EntityMapping.map(classId) == null ||
// ...or if the class doesn't register itself and uses the ID of its base class.
classId != ((Entityc)EntityMapping.map(classId).get()).classId()
){
String type = example.getClass().getSimpleName();
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.
- Override `@#classId()` to return that ID.
""", type, classId, type, type));
}
}
@CallSuper
@Override
public void init(){
super.init();
checkEntityMapping();
allowLegStep = example instanceof Legsc || example instanceof Crawlc;

View File

@@ -30,8 +30,6 @@ import mindustry.type.*;
import mindustry.ui.*;
import mindustry.world.*;
import mindustry.world.blocks.environment.*;
import mindustry.world.blocks.storage.*;
import mindustry.world.blocks.storage.CoreBlock.*;
import mindustry.world.meta.*;
import static mindustry.Vars.*;
@@ -286,6 +284,14 @@ public class HudFragment{
});
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;