CTT/Server/Hotfix/Game/System/Battle/BattleIdleMapSystem.cs

37 lines
1.2 KiB
C#
Raw Normal View History

2021-04-08 20:09:59 +08:00
using System;
using System.Collections.Generic;
namespace ET
{
public static class BattleIdleMapSystem
{
public static void Create(this BattleIdleMap self, long leaderId, int sceneId)
{
Team team = TeamComponent.Instance.Get(leaderId);
if (team == null)
{
Log.Error($"team is null where id is {leaderId}");
return;
}
AutoBattleIdleComponent autoBattleIdle = EntityFactory.CreateWithParent<AutoBattleIdleComponent, Team>(self, team);
autoBattleIdle.Init(sceneId);
self.dic[leaderId] = autoBattleIdle;
}
public static AutoBattleIdleComponent Get(this BattleIdleMap self, long leaderId)
{
2021-04-11 19:50:39 +08:00
self.dic.TryGetValue(leaderId, out AutoBattleIdleComponent autoBattleIdle);
2021-04-08 20:09:59 +08:00
return autoBattleIdle;
}
public static void Remove(this BattleIdleMap self, long leaderId)
{
2021-04-11 19:50:39 +08:00
if (self.dic.TryGetValue(leaderId, out AutoBattleIdleComponent autoBattleIdle))
2021-04-08 20:09:59 +08:00
{
autoBattleIdle.Dispose();
}
self.dic.Remove(leaderId);
}
}
}