2021-04-08 20:09:59 +08:00
|
|
|
|
using ET;
|
|
|
|
|
using ET.EventType;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Text;
|
|
|
|
|
|
|
|
|
|
namespace ET
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
public class UserComponentAwakeSystem : AwakeSystem<UserComponent>
|
|
|
|
|
{
|
|
|
|
|
public override void Awake(UserComponent self)
|
|
|
|
|
{
|
|
|
|
|
self.Awake();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static class UserComponentSystem
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 查询缓存或数据库
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="self"></param>
|
|
|
|
|
/// <param name="id"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public static async ETTask<User> Query(this UserComponent self, long id)
|
|
|
|
|
{
|
2021-04-11 19:50:39 +08:00
|
|
|
|
User player = self.Get(id);
|
2021-04-08 20:09:59 +08:00
|
|
|
|
if (player == null)
|
|
|
|
|
{
|
|
|
|
|
player = await UserHelper.Query(id);
|
|
|
|
|
if (player == null)
|
|
|
|
|
{
|
|
|
|
|
Log.Error($"[ERROR] user == null where id = {id}");
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
return player;
|
|
|
|
|
}
|
|
|
|
|
return player;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static async ETTask<User> Save(this UserComponent self, User player)
|
|
|
|
|
{
|
|
|
|
|
await DBComponent.Instance.Save(player);
|
|
|
|
|
return player;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|