using Fantasy.Entitas.Interface;

namespace NB.Gate;

public class GateUnitSessionComponentSystem : DestroySystem<GateUnitSessionComponent>
{
    protected override void Destroy(GateUnitSessionComponent self)
    {
        var gateUnitManageComponent = self.Scene.GetComponent<GateUnitManageComponent>();
        if (gateUnitManageComponent != null)
        {
            _ = gateUnitManageComponent.Offline(self.AccountID, self.SessionId);
        }

        self.AccountID = 0;
    }
}