// Token: 0x060004CD RID: 1229 RVA: 0x00019434 File Offset: 0x00017634 protected override void OnAbilityAdded(Ability9 entity) { try { ActiveAbility activeAbility; if (entity.IsControllable && entity.Owner.CanUseAbilities && entity.Owner.IsAlly(this.owner) && (activeAbility = (entity as ActiveAbility)) != null) { Unit9 abilityOwner = entity.Owner; Morphling morphling = entity.Owner as Morphling; if (morphling != null && morphling.IsMorphed) { ControllableUnit controllableUnit; Type type; if (this.unitTypes.TryGetValue(morphling.MorphedHero.Name, out type)) { controllableUnit = this.controllableUnits.Find((ControllableUnit x) => x.Handle == abilityOwner.Handle && x.GetType() == type); if (controllableUnit == null) { controllableUnit = (ControllableUnit)Activator.CreateInstance(type, new object[] { abilityOwner, this.abilitySleeper, this.orbwalkSleeper[abilityOwner.Handle], base.GetUnitMenu(abilityOwner) }); controllableUnit.FailSafe = base.BaseHero.FailSafe; controllableUnit.MorphedUnitName = morphling.MorphedHero.Name; foreach (ActiveAbility ability in (from x in abilityOwner.Abilities where x.IsItem select x).OfType <ActiveAbility>()) { controllableUnit.AddAbility(ability, base.BaseHero.ComboMenus, base.BaseHero.MoveComboModeMenu); } this.controllableUnits.Add(controllableUnit); } } else { controllableUnit = this.controllableUnits.Find((ControllableUnit x) => x.Handle == abilityOwner.Handle && x is DynamicUnit); if (controllableUnit == null) { controllableUnit = new DynamicUnit(abilityOwner, this.abilitySleeper, this.orbwalkSleeper[abilityOwner.Handle], base.GetUnitMenu(abilityOwner), base.BaseHero) { FailSafe = base.BaseHero.FailSafe, MorphedUnitName = morphling.MorphedHero.Name }; foreach (ActiveAbility ability2 in (from x in abilityOwner.Abilities where x.IsItem select x).OfType <ActiveAbility>()) { controllableUnit.AddAbility(ability2, base.BaseHero.ComboMenus, base.BaseHero.MoveComboModeMenu); } this.controllableUnits.Add(controllableUnit); } } if (activeAbility.IsItem) { IEnumerable <ControllableUnit> controllableUnits = this.controllableUnits; Func <ControllableUnit, bool> predicate; Func <ControllableUnit, bool> < > 9__4; if ((predicate = < > 9__4) == null) { predicate = (< > 9__4 = ((ControllableUnit x) => x.Handle == abilityOwner.Handle)); } using (IEnumerator <ControllableUnit> enumerator2 = controllableUnits.Where(predicate).GetEnumerator()) { while (enumerator2.MoveNext()) { ControllableUnit controllableUnit2 = enumerator2.Current; controllableUnit2.AddAbility(activeAbility, base.BaseHero.ComboMenus, base.BaseHero.MoveComboModeMenu); } goto IL_3D3; } } controllableUnit.AddAbility(activeAbility, base.BaseHero.ComboMenus, base.BaseHero.MoveComboModeMenu); IL_3D3 :; } else { if (activeAbility.IsItem) { IEnumerable <ControllableUnit> controllableUnits2 = this.controllableUnits; Func <ControllableUnit, bool> predicate2; Func <ControllableUnit, bool> < > 9__5; if ((predicate2 = < > 9__5) == null) { predicate2 = (< > 9__5 = ((ControllableUnit x) => x.Handle == abilityOwner.Handle)); } using (IEnumerator <ControllableUnit> enumerator2 = controllableUnits2.Where(predicate2).GetEnumerator()) { while (enumerator2.MoveNext()) { ControllableUnit controllableUnit3 = enumerator2.Current; controllableUnit3.AddAbility(activeAbility, base.BaseHero.ComboMenus, base.BaseHero.MoveComboModeMenu); } goto IL_488; } } ControllableUnit controllableUnit4 = this.controllableUnits.Find((ControllableUnit x) => x.Handle == entity.Owner.Handle); if (controllableUnit4 != null) { controllableUnit4.AddAbility(activeAbility, base.BaseHero.ComboMenus, base.BaseHero.MoveComboModeMenu); } IL_488 :; } } } catch (Exception ex) { Logger.Error(ex, null); } }
protected override void OnAbilityAdded(Ability9 entity) { try { if (!entity.IsControllable || entity.IsFake || !entity.Owner.IsAlly(this.owner.Team) || !(entity is ActiveAbility activeAbility)) { return; } var abilityOwner = entity.Owner; var morph = entity.Owner as Morphling; if (morph?.IsMorphed == true) { ControllableUnit morphedUnit; if (this.unitTypes.TryGetValue(morph.MorphedHero.Name, out var type)) { morphedUnit = this.controllableUnits.Find(x => x.Handle == abilityOwner.Handle && x.GetType() == type); if (morphedUnit == null) { morphedUnit = (ControllableUnit)Activator.CreateInstance( type, abilityOwner, this.abilitySleeper, this.orbwalkSleeper[abilityOwner.Handle], this.GetUnitMenu(abilityOwner)); morphedUnit.FailSafe = this.BaseHero.FailSafe; morphedUnit.MorphedUnitName = morph.MorphedHero.Name; foreach (var item in abilityOwner.Abilities.Where(x => x.IsItem).OfType <ActiveAbility>()) { morphedUnit.AddAbility(item, this.BaseHero.ComboMenus, this.BaseHero.MoveComboModeMenu); } this.controllableUnits.Add(morphedUnit); } } else { morphedUnit = this.controllableUnits.Find(x => x.Handle == abilityOwner.Handle && x is DynamicUnit); if (morphedUnit == null) { morphedUnit = new DynamicUnit( abilityOwner, this.abilitySleeper, this.orbwalkSleeper[abilityOwner.Handle], this.GetUnitMenu(abilityOwner), this.BaseHero) { FailSafe = this.BaseHero.FailSafe, MorphedUnitName = morph.MorphedHero.Name }; foreach (var item in abilityOwner.Abilities.Where(x => x.IsItem).OfType <ActiveAbility>()) { morphedUnit.AddAbility(item, this.BaseHero.ComboMenus, this.BaseHero.MoveComboModeMenu); } this.controllableUnits.Add(morphedUnit); } } if (activeAbility.IsItem) { foreach (var controllableUnit in this.controllableUnits.Where(x => x.Handle == abilityOwner.Handle)) { controllableUnit.AddAbility(activeAbility, this.BaseHero.ComboMenus, this.BaseHero.MoveComboModeMenu); } } else { morphedUnit.AddAbility(activeAbility, this.BaseHero.ComboMenus, this.BaseHero.MoveComboModeMenu); } return; } if (activeAbility.IsItem) { foreach (var controllable in this.controllableUnits.Where(x => x.Handle == abilityOwner.Handle)) { controllable.AddAbility(activeAbility, this.BaseHero.ComboMenus, this.BaseHero.MoveComboModeMenu); } } else { var controllable = this.controllableUnits.Find(x => x.Handle == entity.Owner.Handle); controllable?.AddAbility(activeAbility, this.BaseHero.ComboMenus, this.BaseHero.MoveComboModeMenu); } } catch (Exception e) { Logger.Error(e); } }