static bool Prefix(MadDogPackTactics __instance, RuleCalculateAttackBonus evt) { if (!evt.Target.isFlankedByAttacker(__instance.Owner.Unit)) { return(false); } bool flag = false; foreach (UnitEntityData unitEntityData in evt.Target.CombatState.EngagedBy) { flag = unitEntityData.Descriptor.IsPet && unitEntityData.Descriptor.Master == __instance.Owner.Unit || __instance.Owner.IsPet && (UnitReference)unitEntityData == (UnitEntityData)__instance.Owner.Master; flag = flag && evt.Target.isFlankedByAttacker(unitEntityData); if (flag) { break; } } if (!flag) { return(false); } evt.AddBonus(2, __instance.Fact); return(false); }
internal static void OnEventDidTrigger(MadDogPackTactics madDogPackTacticsInstance, RuleCalculateAttackBonus evt) { Func <UnitEntityData, UnitEntityData, UnitEntityData, bool> packTacticsFlankingConditions = (target, owner, flankingPartner) => (owner.Descriptor.IsPet && owner.Descriptor.Master == flankingPartner) || (flankingPartner.Descriptor.IsPet && flankingPartner.Descriptor.Master == owner); if (evt.Target.IsFlankedByUnit(madDogPackTacticsInstance.Owner.Unit, packTacticsFlankingConditions)) { evt.IncreaseFlankingBonusTo(4); } }
static void Postfix(MadDogPackTactics __instance, RuleCalculateAttackBonus evt) { MadDogPackTacticsPatch.OnEventDidTrigger(__instance, evt); }
static bool Prefix(MadDogPackTactics __instance, RuleCalculateAttackBonus evt) { MadDogPackTacticsPatch.OnEventAboutToTrigger(__instance, evt); return(false); }
internal static void OnEventAboutToTrigger(MadDogPackTactics madDogPackTacticsInstance, RuleCalculateAttackBonus evt) { // do nothing before the attack bonus is calculated }