|
本帖最后由 holy 于 2021-9-25 19:10 编辑
想搞一个根据去除飞行甲板数量增加舰船装甲的插件MOD
因为不懂程序,所以找了一个类似的插件抄了一下,但是报错了。。。
实在搞不懂哪里不对。。。求大佬们帮忙看下。。。
public class fighterpower extends BaseHullMod {
private final float ARMOR_BONUS = 50f;
public static float WingsNums(ShipAPI ship) {
int originalBayCount = (int)ship.getMutableStats().getNumFighterBays().getBaseValue();
return originalBayCount;
}
public void applyEffectsBeforeShipCreation(HullSize hullSize, MutableShipStatsAPI stats, String id) {
stats.getNumFighterBays().modifyFlat(id, 0f);
stats.getNumFighterBays().modifyMult(id, 0f);
stats.getArmorBonus().modifyFlat(id,ARMOR_BONUS * WingsNums(ship));
}
public boolean isApplicableToShip(ShipAPI ship) {
return ship != null &&ship.getHullSpec().getBuiltInWings().size() > 0 &&
!ship.isFrigate() && ship.getHullSpec().getFighterBays() >= 2 &&
!ship.getVariant().hasHullMod(HullMods.CONVERTED_BAY) &&
!ship.getVariant().hasHullMod(HullMods.PHASE_FIELD);
}
public String getUnapplicableReason(ShipAPI ship) {
if (ship.getHullSpec().getBuiltInWings().size() > 0)return "无法移除内置战机";
if (ship != null && ship.isFrigate()) return "无法安装在护卫舰上";
if (ship != null && ship.getVariant().hasHullMod(HullMods.CONVERTED_BAY)) return "改装甲板无法移除";
if (ship != null && ship.getHullSpec().getFighterBays() < 1) return "舰船无法移除飞行甲板";
}
public String getDescriptionParam(int index, HullSize hullSize, ShipAPI ship) {
if (index == 0) return "" + (Float) WingsNums(ship) + "%";
return null;
}
}
|
|