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
Hmm - have you considered just bailing out if stats.getFleetMember() and stats.getEntity() both return null? IIRC that would only happen in some edge cases and it's more of a safety precaution to check for this rather than a case where it's required for things to work.
i can't bail out here, unfortunately. the member data that i need determines whether to reduce OP costs of weapons or not, and the second call to "applyEffectsBeforeShipCreation" only happens if "affectsOPCosts" on the hullmod returns true. to help illustrate this i added some logging which shows that the first call doesn't have a stats.getFleetMember or a stats.getEntity return value, so it must loop:
Spoiler
568942 [Thread-3] INFO extrasystemreloaded.util.FleetMemberUtils - finding member for stats
568942 [Thread-3] INFO extrasystemreloaded.util.FleetMemberUtils - must loop for variant stats!
568942 [Thread-3] INFO extrasystemreloaded.util.FleetMemberUtils - finding member for stats
568942 [Thread-3] INFO extrasystemreloaded.util.FleetMemberUtils - was in a fleet member
it seems the hitching isn't an issue any more, oddly enough, as i gave the upgrade to around 15 ships and didn't notice it while jumping around the market. the hitching was the main reason why i brought up this issue, however i still think it's weird the first stats object from the first call never has the fleet member set