Musashi1584 / RPGO

4 stars 7 forks source link

Weapon Restriction fixes #58

Closed Iridar closed 4 years ago

Iridar commented 4 years ago

OnBestGeLoadoutApplied_Listener now uses ELD_OnStateSubmitted deferral, and applies only to RPGO soldiers, and only if weapon restrictions are enabled.

Different state submission method for the RPGOSpecializationsAssigned event to make it possible for the OnBestGeLoadoutApplied_Listener to listen to that event using the ELD_OnStateSubmitted deferral. It does not appear to trigger at all when using AddGameStateToHistory().

OnBestGeLoadoutApplied_Listener now listens to rjSquadSelect_UpdateData event instead of the OnBestGearLoadoutApplied. This is necessary due to differences between Make Weapons Available buttons in the base game, and Unequip Barracks in RJSS. The first one automatically re-equips the soldier with fitting equipment, which makes the OnBestGeLoadoutApplied_Listener unnecessary and harmful, causing the item duplication bug.

So special handling is necessary only for RJSS's Unequip Barracks, which simply strips soldiers of their gear. For now using rjSquadSelect_UpdateData is enough for basic function, but it's preferable to add a new event into RJSS that triggers specifically when clicking that button.