zxl
/
CTT
forked from Cal/CTT
1
0
Fork 0
CTT/Server/Model/Game/Entity/Battle/PK/PKTeamComponent.cs

39 lines
1.0 KiB
C#
Raw Normal View History

2021-04-08 20:09:59 +08:00
using System;
using System.Collections.Generic;
using System.Text;
namespace ET
{
public class PKTeamComponent:Entity
{
public static PKTeamComponent Instance{ get; set; }
private Dictionary<long, PKTeam> PKTeamDic = new Dictionary<long, PKTeam>();
public void Add(PKTeam team)
{
PKTeamDic.Add(team.teamA.LeaderId, team);
PKTeamDic.Add(team.teamB.LeaderId, team);
}
public PKTeam Get(long leaderId)
{
PKTeamDic.TryGetValue(leaderId, out var team);
return team;
}
public void Remove(long leaderId)
{
PKTeam pKTeam = Get(leaderId);
if(pKTeam==null)
Log.Error($"pkTeam == null where leaderId = {leaderId}");
PKTeamDic.Remove(pKTeam.teamA.LeaderId);
PKTeamDic.Remove(pKTeam.teamB.LeaderId);
pKTeam.Dispose();
}
public void Clear()
{
PKTeamDic.Clear();
}
}
}