develope
Cal 2021-09-25 21:04:37 +08:00
parent 130ba02824
commit bf98618722
3 changed files with 31 additions and 23 deletions

View File

@ -15,28 +15,38 @@ namespace ET
{
Unit unit = EntityFactory.CreateWithId<Unit>(domain, id);
PlayerData data = await DBComponent.Instance.Query<PlayerData>(id);
unit.AddComponent(data);
if (data)
unit.AddComponent(data);
Character character = await DBComponent.Instance.Query<Character>(id);
unit.AddComponent(character);
if (character)
unit.AddComponent(character);
NumericComponent num = await DBComponent.Instance.Query<NumericComponent>(id);
unit.AddComponent(num);
if (num)
unit.AddComponent(num);
UnitSkillComponent unitSkill = await DBComponent.Instance.Query<UnitSkillComponent>(id);
unit.AddComponent(unitSkill);
if (unitSkill)
unit.AddComponent(unitSkill);
//!玩家设置
UserSetting setting = await DBComponent.Instance.Query<UserSetting>(id);
unit.AddComponent(setting);
if (setting)
unit.AddComponent(setting);
//!任务
UnitTask unitTask = await DBComponent.Instance.Query<UnitTask>(id);
unit.AddComponent(unitTask);
if (unitTask)
unit.AddComponent(unitTask);
//!背包
Bag bag = await DBComponent.Instance.Query<Bag>(id);
unit.AddComponent(bag);
if (bag)
unit.AddComponent(bag);
UnitScene unitScene = await DBComponent.Instance.Query<UnitScene>(id);
unit.AddComponent(unitScene);
if (unitScene)
unit.AddComponent(unitScene);
StarSoulBag starSoulBag = await DBComponent.Instance.Query<StarSoulBag>(id);
unit.AddComponent(starSoulBag);
if (starSoulBag)
unit.AddComponent(starSoulBag);
Pet pet = await DBComponent.Instance.Query<Pet>(id);
unit.AddComponent(pet);
if (pet)
unit.AddComponent(pet);
unit.AddComponent<Combat>();
return unit;
@ -96,7 +106,8 @@ namespace ET
long mapInstanceId = StartSceneConfigCategory.Instance.GetBySceneName(zone, SceneType.UserCache.ToString()).SceneId;
MessageHelper.SendActor(mapInstanceId, new M2U_WriteComponent() { Id = t.Id, type = typeof (T).Name, component = t });
}
public static void SaveComponenet<T>(int zone,T t) where T : Entity
public static void SaveComponenet<T>(int zone, T t) where T : Entity
{
if (zone == 0)
{
@ -129,7 +140,7 @@ namespace ET
unitInfo.YAngle = unitScene.YAngle;
}
public static async ETTask AddComponentFromDB(Unit unit,int jobId)
public static async ETTask AddComponentFromDB(Unit unit, int jobId)
{
int zone = unit.DomainZone();
long id = unit.Id;
@ -150,7 +161,7 @@ namespace ET
character = unit.AddComponent<Character>();
else
unit.AddComponent(character);
var num = await UnitHelper.Query<NumericComponent>(zone, id);
if (num == null)
{
@ -231,8 +242,9 @@ namespace ET
{
bag.InitBag();
}
bag.CheckSlot();
Store store = await StoreComponent.Instance.Query(unit.Id);
//!初始化仓库
if (store == null)
@ -250,9 +262,8 @@ namespace ET
public static async ETTask SendUnitInfo(Unit unit)
{
Log.Debug($"【{ UserComponent.Instance.Get(unit.Id)?.NickName} ({ unit.Id})】已经进入游戏");
Log.Debug($"【{UserComponent.Instance.Get(unit.Id)?.NickName} ({unit.Id})】已经进入游戏");
PlayerData data = unit.GetComponent<PlayerData>();
var num = unit.GetComponent<NumericComponent>();
CharacterHelper.ResetAddNumeric(unit, num);
@ -263,19 +274,16 @@ namespace ET
Log.Error($"unitScene == null where id = {unit.Id}");
return;
}
if(unitScene.MapId/100 == Sys_SceneId.Scene_BattleIdle)
if (unitScene.MapId / 100 == Sys_SceneId.Scene_BattleIdle)
{
unitScene.MapId = Sys_SceneId.Scene_MainCity * 100 + 1;
}
//!+任务相关
//!+发送Boss消息
Game.EventSystem.Publish(new EventType.AfterEnterGame() { unit = unit });
}
}
}

View File

@ -1 +1 @@
eNolTT0LwjAU3AP5D3Krb3gJQunbpC4OXRwECaEUWkuWBGLEQfrfTe1wcMd9Oa2cYTZ0+GIIE+Qv8IBYtpX0kJZwgTSE+5xfIcWaIdzmz5inc84QV5sFgn4MsVTsVpfiMyzHXYAwXLdxw5ZPhC69Y9kueCW/etLKa/UDI1Imdg==
eNqL5uWKNjQwMNRRqFaKz0xRsgJzlCKVrIwMjIAMXyUrSx0lFyAXyAlLLSrOzM8DKtJR8ssvyUxOVbJSerJj7fPl3S+6mp7uX/1k54T3exqVdJSCUssTi1Ici4qUrKKBBpcA1fkmZuaVADFEyjk/Ly0zXRvCAWqI9wTZbWhgZGCio+ScX5pXAnKBgUGtTmxtrA4vVywvFwA4dDcg