OnBestGearLoadoutApplied
Tracking Issue: #676
Tags: events
The XComGameState_Unit::ApplyBestGearLoadout
does not perform CanAddItemToInventory checks when it picks the best gear for the soldier,
so if one of the selected items by that function cannot be equipped due to an override in CanAddItemToInventory_CH,
the inventory slot will remain empty. This event passes along the Unit State whenever this function is called,
so the mods can use their arbitrary conditions to decide what is the actual best gear loadout is for a unit.
OnBestGearLoadoutApplied event
Param | Value |
---|---|
EventID | OnBestGearLoadoutApplied |
EventData | XComGameState_Unit |
EventSource | XComGameState_Unit |
NewGameState | yes |
Listener template
static function EventListenerReturn OnOnBestGearLoadoutApplied(Object EventData, Object EventSource, XComGameState GameState, Name EventID, Object CallbackObject)
{
local XComGameState_Unit UnitState;
UnitState = XComGameState_Unit(EventData);
// Your code here
return ELR_NoInterrupt;
}
// This EventFn requires the Event Listener to use an ELD_Immediate deferral.
static function EventListenerReturn OnBestGearLoadoutApplied_Listener(Object EventData, Object EventSource, XComGameState NewGameState, Name Event, Object CallbackData)
{
local XComGameState_Unit UnitState;
// This gets you Unit State from History.
UnitState = XComGameState_Unit(EventData);
// Here you can *read* the Unit State.
// Get the Unit State from the pending New Game State.
UnitState = XComGameState_Unit(NewGameState.GetGameStateForObjectID(UnitState.ObjectID));
// Now you can make changes to the Unit State, such as changing its equipment based on arbitrary conditions.
}