/// <summary> /// Handles the <see cref="IStatCollection{T}.StatChanged"/> event for the stat collections in this class. /// </summary> void StatCollection_StatChanged(IStatCollection <StatType> sender, StatCollectionStatChangedEventArgs <StatType> e) { Debug.Assert(sender.StatCollectionType != StatCollectionType.Modified, "ItemEntity does not use StatCollectionType.Modified."); var field = e.StatType.GetDatabaseField(sender.StatCollectionType); SynchronizeField(field, e.NewValue); }
/// <summary> /// Handles when the <see cref="Character"/>'s base stats change. /// </summary> /// <param name="sender">The <see cref="IStatCollection{TStatType}"/> the event came from.</param> /// <param name="e">The <see cref="StatCollectionStatChangedEventArgs{StatType}"/> instance containing the event data.</param> void BaseStatChangedHandler(IStatCollection<StatType> sender, StatCollectionStatChangedEventArgs<StatType> e) { _updateModStats = true; OnBaseStatChanged(e.StatType, e.OldValue, e.NewValue); }
/// <summary> /// Handles the <see cref="IStatCollection{T}.StatChanged"/> event for the stat collections in this class. /// </summary> void StatCollection_StatChanged(IStatCollection<StatType> sender, StatCollectionStatChangedEventArgs<StatType> e) { Debug.Assert(sender.StatCollectionType != StatCollectionType.Modified, "ItemEntity does not use StatCollectionType.Modified."); var field = e.StatType.GetDatabaseField(sender.StatCollectionType); SynchronizeField(field, e.NewValue); }
/// <summary> /// Handles when the <see cref="Character"/>'s mod stats change. /// </summary> /// <param name="sender">The <see cref="IStatCollection{TStatType}"/> the event came from.</param> /// <param name="e">The <see cref="StatCollectionStatChangedEventArgs{StatType}"/> instance containing the event data.</param> void ModStatChangedHandler(IStatCollection<StatType> sender, StatCollectionStatChangedEventArgs<StatType> e) { _updateModStats = true; // Ensure the HP and MP are valid switch (e.StatType) { case StatType.MaxMP: if (MP > e.NewValue) MP = (int)e.NewValue; break; case StatType.MaxHP: if (HP > e.NewValue) HP = (int)e.NewValue; break; } // Update the attack rate if (e.StatType == StatType.Agi) _attackTimeout = Math.Max(GameData.AttackTimeoutMin, GameData.AttackTimeoutDefault - ModStats[StatType.Agi] * 2); OnModStatChanged(e.StatType, e.OldValue, e.NewValue); }