zxl
/
CTT
forked from Cal/CTT
1
0
Fork 0
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); Unit unit = EntityFactory.CreateWithId<Unit>(domain, id);
PlayerData data = await DBComponent.Instance.Query<PlayerData>(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); Character character = await DBComponent.Instance.Query<Character>(id);
unit.AddComponent(character); if (character)
unit.AddComponent(character);
NumericComponent num = await DBComponent.Instance.Query<NumericComponent>(id); NumericComponent num = await DBComponent.Instance.Query<NumericComponent>(id);
unit.AddComponent(num); if (num)
unit.AddComponent(num);
UnitSkillComponent unitSkill = await DBComponent.Instance.Query<UnitSkillComponent>(id); UnitSkillComponent unitSkill = await DBComponent.Instance.Query<UnitSkillComponent>(id);
unit.AddComponent(unitSkill); if (unitSkill)
unit.AddComponent(unitSkill);
//!玩家设置 //!玩家设置
UserSetting setting = await DBComponent.Instance.Query<UserSetting>(id); UserSetting setting = await DBComponent.Instance.Query<UserSetting>(id);
unit.AddComponent(setting); if (setting)
unit.AddComponent(setting);
//!任务 //!任务
UnitTask unitTask = await DBComponent.Instance.Query<UnitTask>(id); UnitTask unitTask = await DBComponent.Instance.Query<UnitTask>(id);
unit.AddComponent(unitTask); if (unitTask)
unit.AddComponent(unitTask);
//!背包 //!背包
Bag bag = await DBComponent.Instance.Query<Bag>(id); Bag bag = await DBComponent.Instance.Query<Bag>(id);
unit.AddComponent(bag); if (bag)
unit.AddComponent(bag);
UnitScene unitScene = await DBComponent.Instance.Query<UnitScene>(id); UnitScene unitScene = await DBComponent.Instance.Query<UnitScene>(id);
unit.AddComponent(unitScene); if (unitScene)
unit.AddComponent(unitScene);
StarSoulBag starSoulBag = await DBComponent.Instance.Query<StarSoulBag>(id); StarSoulBag starSoulBag = await DBComponent.Instance.Query<StarSoulBag>(id);
unit.AddComponent(starSoulBag); if (starSoulBag)
unit.AddComponent(starSoulBag);
Pet pet = await DBComponent.Instance.Query<Pet>(id); Pet pet = await DBComponent.Instance.Query<Pet>(id);
unit.AddComponent(pet); if (pet)
unit.AddComponent(pet);
unit.AddComponent<Combat>(); unit.AddComponent<Combat>();
return unit; return unit;
@ -96,7 +106,8 @@ namespace ET
long mapInstanceId = StartSceneConfigCategory.Instance.GetBySceneName(zone, SceneType.UserCache.ToString()).SceneId; 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 }); 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) if (zone == 0)
{ {
@ -129,7 +140,7 @@ namespace ET
unitInfo.YAngle = unitScene.YAngle; 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(); int zone = unit.DomainZone();
long id = unit.Id; long id = unit.Id;
@ -150,7 +161,7 @@ namespace ET
character = unit.AddComponent<Character>(); character = unit.AddComponent<Character>();
else else
unit.AddComponent(character); unit.AddComponent(character);
var num = await UnitHelper.Query<NumericComponent>(zone, id); var num = await UnitHelper.Query<NumericComponent>(zone, id);
if (num == null) if (num == null)
{ {
@ -231,8 +242,9 @@ namespace ET
{ {
bag.InitBag(); bag.InitBag();
} }
bag.CheckSlot(); bag.CheckSlot();
Store store = await StoreComponent.Instance.Query(unit.Id); Store store = await StoreComponent.Instance.Query(unit.Id);
//!初始化仓库 //!初始化仓库
if (store == null) if (store == null)
@ -250,9 +262,8 @@ namespace ET
public static async ETTask SendUnitInfo(Unit unit) 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>(); PlayerData data = unit.GetComponent<PlayerData>();
var num = unit.GetComponent<NumericComponent>(); var num = unit.GetComponent<NumericComponent>();
CharacterHelper.ResetAddNumeric(unit, num); CharacterHelper.ResetAddNumeric(unit, num);
@ -263,19 +274,16 @@ namespace ET
Log.Error($"unitScene == null where id = {unit.Id}"); Log.Error($"unitScene == null where id = {unit.Id}");
return; 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; unitScene.MapId = Sys_SceneId.Scene_MainCity * 100 + 1;
} }
//!+任务相关 //!+任务相关
//!+发送Boss消息 //!+发送Boss消息
Game.EventSystem.Publish(new EventType.AfterEnterGame() { unit = unit }); Game.EventSystem.Publish(new EventType.AfterEnterGame() { unit = unit });
} }
} }
} }

View File

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