static public void Postfix(UnitAbilityResourceCollection __instance, BlueprintScriptableObject blueprint, ref UnitDescriptor ___m_Owner) { if ((blueprint as BlueprintAbilityResource) == ArcaneReservoir.resource) { int arcanist_level = ___m_Owner.Progression.GetClassLevel(ArcanistClass.arcanist); __instance.Spend(blueprint, arcanist_level / 2 + arcanist_level % 2); } //resource used as special counters. Should not be restored after rest. if ((blueprint as BlueprintAbilityResource) == SpellResistanceDrain.drained_arcane_points_res) { __instance.Spend(blueprint, 5); } }
static void Postfix(UnitAbilityResourceCollection __instance, BlueprintScriptableObject blueprint, int amount) { var owner = Helpers.GetField <UnitDescriptor>(__instance, "m_Owner"); var connected_resource = owner?.Get <UnitPartConnectResource>()?.getConnectedResource(blueprint as BlueprintAbilityResource); if (connected_resource == null) { return; } __instance.Spend(connected_resource, amount); }
static void Postfix(UnitAbilityResourceCollection __instance, BlueprintScriptableObject blueprint, int amount) { var owner = Helpers.GetField <UnitDescriptor>(__instance, "m_Owner"); var connected_resources = owner?.Get <UnitPartConnectResource>()?.getConnectedResource(blueprint as BlueprintAbilityResource); if (connected_resources == null || connected_resources.Length == 0) { return; } connected_resources = connected_resources.OrderByDescending(c => __instance.GetResourceAmount(c)).ToArray(); var max_resource_id = 0; while (amount > 0) { var next_resource_id = (max_resource_id + 1) % connected_resources.Length; if (__instance.GetResourceAmount(connected_resources[next_resource_id]) > __instance.GetResourceAmount(connected_resources[max_resource_id])) { max_resource_id = next_resource_id; } __instance.Spend(connected_resources[max_resource_id], 1); amount--; } }