/// <summary>The compose.</summary> /// <param name="skill">The skill.</param> public override void Compose(IAbilitySkill skill) { base.Compose(skill); var skillAddedObserver = new DataObserver <IAbilitySkill>( add => { if (add.IsItem && add.SourceItem.Id == AbilityId.item_ultimate_scepter) { skill.AddPart <IModifierGenerator>( abilitySkill => new ModifierGenerator(skill) { Workers = new List <ModifierGeneratorWorker> { new ModifierGeneratorWorker( "modifier_centaur_stampede", modifier => modifier.AssignModifierEffectApplier( new ModifierEffectApplier(modifier) { Workers = new List <IEffectApplierWorker> { new DamageReductionEffectApplierWorker ( modifier, false, abilityModifier => 0.6) } }), false, true, true) } }); } }); skillAddedObserver.Subscribe(skill.Owner.SkillBook.SkillAdded); skill.DisposeNotifier.Subscribe(() => skillAddedObserver.Dispose()); }
public virtual void Initialize() { if (this.Skill.AbilityInfo.DamageString != null) { if (this.Skill.AbilityInfo.DamageScepterString != null) { if (this.Skill.Owner.SourceUnit.HasModifier("modifier_item_ultimate_scepter_consumed")) { this.RawDamageWorkerAssign = unit => new StringDataAghaDamageCalculatorWorker( this.Skill, unit, this.DamageWorkerAssign(unit)); } else if (this.Skill.Owner.SourceUnit.HasModifier("modifier_item_ultimate_scepter")) { this.RawDamageWorkerAssign = unit => new StringDataAghaDamageCalculatorWorker( this.Skill, unit, this.DamageWorkerAssign(unit)); var observer = new DataObserver <IAbilitySkill>(); observer.OnNextAction = remove => { if (remove.IsItem && remove.SourceItem.Id == AbilityId.item_ultimate_scepter) { this.RawDamageWorkerAssign = unit => new StringDataDamageCalculatorWorker( this.Skill, unit, this.DamageWorkerAssign(unit)); observer.Dispose(); } }; observer.Subscribe(this.Skill.Owner.SkillBook.SkillRemoved); this.Skill.DisposeNotifier.Subscribe(() => observer.Dispose()); } } else { this.RawDamageWorkerAssign = unit => new StringDataDamageCalculatorWorker(this.Skill, unit, this.DamageWorkerAssign(unit)); } } else { this.RawDamageWorkerAssign = unit => new GetDamageCalculatorWorker(this.Skill, unit, this.DamageWorkerAssign(unit)); } if (this.DamageType == DamageType.Magical) { this.DamageWorkerAssign = unit => new MagicalSkillDamageCalculatorWorker(this.Skill, unit); } else if (this.DamageType == DamageType.Physical) { this.DamageWorkerAssign = unit => new PhysicalSkillDamageCalculatorWorker(this.Skill, unit); } else if (this.DamageType == DamageType.Pure) { this.DamageWorkerAssign = unit => new PureSkillDamageCalculatorWorker(this.Skill, unit); } else { this.DamageWorkerAssign = unit => new HealthRemovalSkillDamageCalculatorWorker(this.Skill, unit); } }