CTT/Server/Hotfix/Game/System/User/BuffLibComponentSystem.cs

42 lines
1.2 KiB
C#
Executable File

using System;
using System.Collections.Generic;
using System.Text;
namespace ET
{
public class BuffLibComponentAwakeSystem : AwakeSystem<BuffLibComponent>
{
public override void Awake(BuffLibComponent self)
{
BuffLibComponent.Instance = self;
}
}
public static class BuffLibComponentSystem
{
public static async ETTask<BuffLib> Query(this BuffLibComponent self,long unitId)
{
if (!self.Dic.TryGetValue(unitId, out BuffLib buffLib))
{
buffLib = await DBComponent.Instance.Query<BuffLib>(unitId);
if (buffLib == null)
{
buffLib = EntityFactory.CreateWithParentAndId<BuffLib>(self, unitId);
}
self.Dic[unitId] = buffLib;
}
return buffLib;
}
public static async ETVoid Save(this BuffLibComponent self,BuffLib buffLib)
{
await DBComponent.Instance.Save(buffLib);
}
public static async ETVoid Remove(this BuffLibComponent self,long unitId,BuffLib lib)
{
lib.Dispose();
self.Dic.Remove(unitId);
await DBComponent.Instance.Remove<BuffLib>(unitId);
}
}
}