CTT/Server/Hotfix/Game/Handler/UI/Skill/C2M_LearnSkillHandler.cs

60 lines
1.9 KiB
C#
Executable File

using System;
using System.Collections.Generic;
namespace ET
{
[ActorMessageHandler]
public class C2M_LearnSkillHandler : AMActorLocationRpcHandler<Unit, C2M_LearnSkill, M2C_LearnSkill>
{
protected override async ETTask Run(Unit unit, C2M_LearnSkill request, M2C_LearnSkill response, Action reply)
{
UnitSkillComponent unitSkillComponent = unit.GetComponent<UnitSkillComponent>();
if (unitSkillComponent == null)
{
Log.Error("unitSkillComponent == null");
reply();
return;
}
string ret = unitSkillComponent.LearnSkill(request.SkillId);
if (ret != null)
{
response.Message = ret;
reply();
return;
}
foreach (UnitSkill item in unitSkillComponent.GetLearnedSkills())
{
SkillInfo skillInfo = new SkillInfo()
{
SkillId = (int)item.Id,
SkillLevel = item.Level
};
response.SkillInfoLsit.Add(skillInfo);
}
foreach (UnitSkill item in unitSkillComponent.GetUnlearnedSkills())
{
SkillInfo skillInfo = new SkillInfo()
{
SkillId = (int)item.Id,
SkillLevel = item.Level
};
response.SkillInfoLsit.Add(skillInfo);
}
UserSetting setting = unit.GetComponent<UserSetting>();
if (setting == null)
{
Log.Error("setting == null");
reply();
return;
}
LinkedList<int> arr = setting.GetAutoSkills();
foreach (int item in arr)
{
response.AutoSkillList.Add(item);
}
reply();
await ETTask.CompletedTask;
}
}
}