public override void Apply(string guid) { Action<Damage> preventDamage = null; Attachment titanArmor = new Attachment() { Effect = this, RemainingCharges = Charges(), OnDestroy = () => { DamagePrevention.PreventDamage -= preventDamage; } }; preventDamage = (Damage damage) => { if (damage.Target == guid && damage.Magnitude > 0) { titanArmor.SpendCharge(); damage.Magnitude = 0; } }; DamagePrevention.PreventDamage += preventDamage; GameState.Attach(guid, titanArmor, Slot.Chest); GameState.AddWeight(guid, Weight()); }
public override void Apply(string guid) { Action<Damage> onDamage = null; Attachment self = new Attachment() { Effect = this, RemainingCharges = NumCharges(), OnDestroy = () => { DamageProvider.DamageBoost -= onDamage; } }; onDamage = (Damage damage) => { if (damage.Source == guid) { if (!TemplateStatus.Templating) { self.SpendCharge(); } damage.Magnitude += DamageIncrease(); } }; DamageProvider.DamageBoost += onDamage; GameState.Attach(guid, self, Slot.Arm); }