/// <summary> /// Initializes from save object. /// </summary> /// <param name="saveObject">The save object.</param> public void InitFromSaveObject(CharacterStatsSave saveObject) { this.Level = saveObject.Level; this.StatPoints = saveObject.StatBonusCount; dict.Clear(); foreach (StatSave save in saveObject.Stats) { Stat stat = save.CreateObjectFromID(); stat.InitFromSaveObject(save); dict.Add(stat.Type, stat); } // If we're spoofing the stats for a nonparty member, we want to include the equipment bonuses too, // Otherwise buffs that scale off of mod + equip will have the equip portion be 0 // Example: DOT that deals damage based on caster's strength. Caster has a +10 strength sword and casts it on a party member // After a save, we want to maintain the strength bonus. if (isSpoofed) { IDictionary <StatType, int> spoofedEquipment = new Dictionary <StatType, int>(); foreach (EquipmentStatSave save in saveObject.EquipmentBonuses) { spoofedEquipment.Add(save.StatType.Restore(), save.Bonus); } GetEquipmentBonus = (st => spoofedEquipment[st]); } isDoneIniting = true; }
/// <summary> /// Initializes from save object. /// </summary> /// <param name="saveObject">The save object.</param> public void InitFromSaveObject(CharacterStatsSave saveObject) { this.Level = saveObject.Level; this.UnassignedStatPoints = saveObject.UnassignedStatPoints; baseStats.Clear(); foreach (StatSave save in saveObject.BaseStats) { Stat stat = save.CreateObjectFromID(); stat.InitFromSaveObject(save); baseStats.Add(stat.Type, stat); } /** * If we're spoofing the stats for a nonparty member, we want to include the equipment and buff bonuses too, * Otherwise buffs that scale off of mod + equip will have the bonus portion be 0 * Example: DOT that deals damage based on caster's strength. Caster has a +10 strength sword, +10 strength from buffs and casts it on a party member * After a save, we want to maintain the strength bonus. */ if (isSpoofed) { // Spoof equipment bonuses IDictionary <StatType, int> spoofedEquipment = new Dictionary <StatType, int>(); foreach (StatBonusSave save in saveObject.EquipmentBonuses) { spoofedEquipment.Add(save.StatType.Restore(), save.Bonus); } GetFlatEquipmentBonus = (st => spoofedEquipment[st]); // Spoof buff bonuses IDictionary <StatType, int> spoofedBuffs = new Dictionary <StatType, int>(); foreach (StatBonusSave save in saveObject.BuffBonuses) { spoofedBuffs.Add(save.StatType.Restore(), save.Bonus); } GetMultiplicativeBuffBonus = (st => spoofedBuffs[st]); } isDoneIniting = true; }