|
在api里找到了WeaponSlotAPI,可以判断是否hardpoint,但直接用报错了
15520 [Thread-3] ERROR com.fs.starfarer.combat.CombatMain - java.lang.RuntimeException: Error loading [data.hullmods.HardPointRange]
java.lang.RuntimeException: Error loading [data.hullmods.HardPointRange]
at com.fs.starfarer.loading.scripts.ScriptStore$3.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: File 'data/hullmods/HardPointRange.java', Line 43, Column 25: Non-abstract class "data.hullmods.HardPointRange$ALLWeaponRangeMod" must implement method "public abstract float com.fs.starfarer.api.combat.listeners.WeaponRangeModifier.getWeaponRangePercentMod(com.fs.starfarer.api.combat.ShipAPI, com.fs.starfarer.api.combat.WeaponAPI)"
at org.codehaus.janino.JavaSourceClassLoader.generateBytecodes(JavaSourceClassLoader.java:226)
at org.codehaus.janino.JavaSourceClassLoader.findClass(JavaSourceClassLoader.java:178)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 2 more
Caused by: org.codehaus.commons.compiler.CompileException: File 'data/hullmods/HardPointRange.java', Line 43, Column 25: Non-abstract class "data.hullmods.HardPointRange$ALLWeaponRangeMod" must implement method "public abstract float com.fs.starfarer.api.combat.listeners.WeaponRangeModifier.getWeaponRangePercentMod(com.fs.starfarer.api.combat.ShipAPI, com.fs.starfarer.api.combat.WeaponAPI)"
at org.codehaus.janino.UnitCompiler.compileError(UnitCompiler.java:10174)
at org.codehaus.janino.UnitCompiler.compile2(UnitCompiler.java:419)
at org.codehaus.janino.UnitCompiler.compile2(UnitCompiler.java:658)
at org.codehaus.janino.UnitCompiler.compile2(UnitCompiler.java:662)
at org.codehaus.janino.UnitCompiler.access$600(UnitCompiler.java:185)
at org.codehaus.janino.UnitCompiler$2.visitMemberClassDeclaration(UnitCompiler.java:350)
at org.codehaus.janino.Java$MemberClassDeclaration.accept(Java.java:1035)
at org.codehaus.janino.UnitCompiler.compile(UnitCompiler.java:354)
at org.codehaus.janino.UnitCompiler.compileDeclaredMemberTypes(UnitCompiler.java:769)
at org.codehaus.janino.UnitCompiler.compile2(UnitCompiler.java:532)
at org.codehaus.janino.UnitCompiler.compile2(UnitCompiler.java:393)
at org.codehaus.janino.UnitCompiler.access$400(UnitCompiler.java:185)
at org.codehaus.janino.UnitCompiler$2.visitPackageMemberClassDeclaration(UnitCompiler.java:347)
at org.codehaus.janino.Java$PackageMemberClassDeclaration.accept(Java.java:1139)
at org.codehaus.janino.UnitCompiler.compile(UnitCompiler.java:354)
at org.codehaus.janino.UnitCompiler.compileUnit(UnitCompiler.java:322)
at org.codehaus.janino.JavaSourceClassLoader.generateBytecodes(JavaSourceClassLoader.java:224)
... 5 more
源码:
public class HardPointRange extends BaseHullMod {
public static float RANGE_MISSILE = 0f;
public static float range_Hardpoint_pct = 100f;
public void applyEffectsAfterShipCreation(ShipAPI ship, MutableShipStatsAPI stats, String id) {
ship.addListener(new ALLWeaponRangeMod());
}
private static class ALLWeaponRangeMod implements WeaponRangeModifier {
public float getWeaponRangeFlatMod(ShipAPI ship, WeaponAPI weapon) {
return 0f;
}
@Override
public float getWeaponRangeMultMod(ShipAPI ship, WeaponAPI weapon) {
return 1f;
}
@Override
public float getWeaponRangePercentMod(ShipAPI ship, WeaponAPI weapon , WeaponSlotAPI weapslot) { //
if (weapslot.isHardpoint() ) { //!(weapon.getType() == WeaponType.MISSILE) &&
return (range_Hardpoint_pct);
} else {
return 0f;
}
return 0f;
}
}
public boolean isApplicableToShip(ShipAPI ship) {
return true;
}
} |
|