/
NLObP
/
AAEmu
Обзор
Документация
Войти
/
NLObP
/
AAEmu
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
develop
AAEmu.Game/GameData/DamageModifiersGameData .cs
64 строки
2 KB
Roger Barreto
Collection expressions check + blank lines update (#1110)
11 дек 2024, 19:38
Не верифицирован
11 дек 2024, 19:38
0ce5643
Код
Авторство
О чём код?
using System.Collections.Generic; using AAEmu.Commons.Utils; using AAEmu.Game.Core.Managers; using AAEmu.Game.GameData.Framework; using AAEmu.Game.Models.Game.Skills.Effects; using AAEmu.Game.Models.Game.Skills.Templates; using AAEmu.Game.Models.Game.Units; using AAEmu.Game.Utils.DB; using Microsoft.Data.Sqlite; namespace AAEmu.Game.GameData; [GameData] public class DamageModifierGameData : Singleton<DamageModifierGameData>, IGameDataLoader { private Dictionary<uint, List<BonusTemplate>> __damageModifiers; public List<BonusTemplate> GetModifiersForBuff(uint ownerId) { return __damageModifiers.TryGetValue(ownerId, out var modifier) ? modifier : []; } public void Load(SqliteConnection connection) { __damageModifiers = []; using (var command = connection.CreateCommand()) { command.CommandText = "SELECT * FROM unit_modifiers WHERE owner_type = 'DamageEffect'"; command.Prepare(); using (var sqliteReader = command.ExecuteReader()) using (var reader = new SQLiteWrapperReader(sqliteReader)) { while (reader.Read()) { var ownerId = reader.GetUInt32("owner_id"); var template = new BonusTemplate() { Attribute = (UnitAttribute)reader.GetUInt32("unit_attribute_id"), ModifierType = (UnitModifierType)reader.GetUInt32("unit_modifier_type_id"), Value = reader.GetInt32("value"), LinearLevelBonus = reader.GetInt32("linear_level_bonus") }; if (!__damageModifiers.ContainsKey(ownerId)) __damageModifiers.Add(ownerId, []); __damageModifiers[ownerId].Add(template); } } } } public void PostLoad() { foreach (var mod in __damageModifiers) { var de = SkillManager.Instance.GetEffectTemplate(mod.Key, "DamageEffect") as DamageEffect; if (de != null) { de.Bonuses = mod.Value; } } } }