51 lines
1.2 KiB
C#
51 lines
1.2 KiB
C#
|
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)
|
|||
|
{
|
|||
|
var player = self.Get(id);
|
|||
|
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;
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
}
|
|||
|
}
|