using System.Collections.Generic; using System.Linq; namespace ET.Server { [FriendOf(typeof (PlayerSkillComponent))] public static class PlayerSkillComponentSystem { public class PlayerSkillComponentAwakeSystem: AwakeSystem { protected override void Awake(PlayerSkillComponent self) { Log.Info($"创建玩家技能组件..."); WNPlayer player = self.GetParent(); self.Data = new PlayerSkillInfo(); self.Data.Skills = new List(); // 初始化技能数据 CharacterConfig config = CharacterConfigCategory.Instance.Get(player.GetPro()); if (config != null && config.InitSkillList.Count > 0) { foreach (Struct.IntIntData intIntData in config.InitSkillList.Where(intIntData => intIntData != null)) { self.Data.Skills.Add(new Struct.PlayerSkillBaseData(intIntData.value1, intIntData.value2, true, 0L)); } } // 初始化战斗服缓存数据 self.ToJson4BattleServerSkills = self.ToJson4BattleServerSkills(); } } public class PlayerSkillComponentDestroySystem: DestroySystem { protected override void Destroy(PlayerSkillComponent self) { } } /// /// 被动技能, 发给bs /// /// /// private static IEnumerable GetPassiveSkillInfoBS(this PlayerSkillComponent self) { List list = new List(); foreach (SkillConfig prop in SkillConfigCategory.Instance.GetAll().Values.Where(prop => prop != null)) { if (prop.ProId != self.GetParent().GetPro() || prop.SkillType != (int)SkillType.PLAYER_PASSIVE) { continue; } Struct.SkillInfo info = new (); info.type = prop.SkillType; info.id = prop.Id; info.level = 1; info.skillTime = 0L; info.cdTime = 0; info.flag = 0; info.autoLaunch = false; list.Add(info); } return list; } /// /// 战斗服数据 /// /// /// private static List ToJson4BattleServerSkills(this PlayerSkillComponent self) { List skills = new List(); foreach (Struct.PlayerSkillBaseData skill in self.Data.Skills.Where(skill => skill != null)) { if (!skill.unlock) { continue; } SkillConfig prop = SkillConfigCategory.Instance.Get(skill.id); if (prop != null && !SkillHelper.IsPassive(prop)) { skills.Add(SkillHelper.NewSkillInfo(skill)); } } // 被动技能战斗服信息 skills.AddRange(self.GetPassiveSkillInfoBS()); return skills; } } }