/// <summary> /// 通过Buff配置表的id移除buff /// </summary> /// <param name="self"></param> /// <param name="id"></param> public static void RemoveByConfigId(this BuffComponent self, int id) { BuffConfig config = BuffConfigCategory.Instance.Get(id); if (self.Groups.ContainsKey(config.Group)) { Buff buff = self.GetChild <Buff>(self.Groups[config.Group].Id); if (buff.ConfigId == id) { self.Groups.Remove(buff.Config.Group); buff?.Dispose(); } } }
/// <summary> /// 通过Buff配置表的id取 /// </summary> /// <param name="self"></param> /// <param name="id"></param> /// <returns></returns> public static Buff GetByConfigId(this BuffComponent self, int id) { BuffConfig config = BuffConfigCategory.Instance.Get(id); if (self.Groups.ContainsKey(config.Group)) { Buff buff = self.GetChild <Buff>(self.Groups[config.Group].Id); if (buff.ConfigId == id) { return(buff); } } return(null); }
/// <summary> /// 通过Buff的唯一Id移除 /// </summary> /// <param name="self"></param> /// <param name="id"></param> public static void Remove(this BuffComponent self, long id) { Buff buff = self.GetChild <Buff>(id); if (buff == null) { return; } EventSystem.Instance.Publish(new EventType.AfterRemoveBuff() { Buff = buff }); self.Groups.Remove(buff.Config.Group); buff.Dispose(); }
/// <summary> /// 通过Buff的唯一Id取 /// </summary> /// <param name="self"></param> /// <param name="id"></param> /// <returns></returns> public static Buff Get(this BuffComponent self, long id) { Buff buff = self.GetChild <Buff>(id); return(buff); }