CTT/Server/Hotfix/Game/Handler/Team/C2M_QuitTeamHandler.cs

37 lines
910 B
C#
Raw Normal View History

2021-04-08 20:09:59 +08:00
using System;
using System.Linq;
namespace ET
{
[ActorMessageHandler]
public class C2M_QuitTeamHandler : AMActorLocationRpcHandler<Unit,C2M_QuitTeam, M2C_QuitTeam>
{
protected override async ETTask Run(Unit unit, C2M_QuitTeam request, M2C_QuitTeam response, Action reply)
{
Team team = TeamComponent.Instance.Get(unit.TeamLeaderId);
if(team==null)
{
Log.Error($"team == null where id = {unit.TeamLeaderId}");
reply();
return;
}
if (team.TeamState == TeamState.Fight)
{
response.Message = "战斗中,不能进行此操作!";
reply();
return;
}
if(team.MemberCount == 1)
{
response.Message = "无效操作!";
reply();
return;
}
TeamComponent.Instance.QuitTeam(unit, team);
reply();
await ETTask.CompletedTask;
}
}
}