i have a hullmod that depends on some FleetMemberAPI values, and to get that i would usually use MutableShipStatsAPI.getFleetMember(). when i added a "affectsOPCosts" override set to true, the method applyEffectsBeforeShipCreation was called twice, and the second time has a MutableShipStatsAPI that doesn't have a fleet member assigned to it. (as a side note: i'm pretty sure this MutableShipStatsAPI object is the one that you can find under ShipVariantAPI.getStatsForOpCosts())
is there a way to easily get the fleetmember that doesn't involve looping through every single ship in a fleet and its variant and all of its modules' variants to look for a specific MutableShipStatsAPI object? if i have the hullmod on a lot of ships (tried with 8 ) the game noticably hitches whenever these hullmods run applyEffectsBeforeShipCreation because of the method.
this is what i needed to do as a result, and what also causes the hitching
Spoiler
if(stats.getFleetMember() != null)
return stats.getFleetMember();
if(stats.getEntity() instanceof ShipAPI) {
ShipAPI ship = (ShipAPI) stats.getEntity();
if(ship.getFleetMember() != null) {
return ship.getFleetMember();
}
}
FleetMemberAPI fm = null;
for(FleetMemberAPI member : Global.getSector().getPlayerFleet().getFleetData().getMembersListCopy()) {
if(member.isFighterWing()) continue;
if(member.getStats() == stats) {
fm = member;
} else if (member.getVariant().getStatsForOpCosts() != null) {
if (member.getVariant().getStatsForOpCosts() == stats) {
fm = member;
} else if (member.getVariant().getStatsForOpCosts().getEntity() != null && member.getVariant().getStatsForOpCosts().getEntity() == stats.getEntity()) {
fm = member;
}
}
if(fm != null) break;
if (member.getVariant().getModuleSlots() != null && !member.getVariant().getModuleSlots().isEmpty()) {
for(String variantId : member.getVariant().getModuleSlots()) {
ShipVariantAPI variant = member.getVariant().getModuleVariant(variantId);
if(variant.getStatsForOpCosts() == stats) {
fm = member;
} else if (member.getVariant().getStatsForOpCosts().getEntity() != null && stats.getEntity() == variant.getStatsForOpCosts().getEntity()) {
fm = member;
}
if(fm != null) break;
}
}
if(fm != null) break;
}
i worked around this issue by using a Map that i clear when the player exits the market, but it's still annoying that i had to go through so much effort.
i'm having an issue now where
the fleet screen shows i have free OP after applying the hullmod through a dialog, but clicking into
the refit screen does not show the free OP