コード例 #1
0
        public bool Release(int key, long instanceId, Player player)
        {
            lock (Managers)
            {
                if (!Managers.TryGetValue(key, out List <FieldManager> managerList))
                {
                    return(false);
                }

                FieldManager fieldManager = managerList.FirstOrDefault(x => x.InstanceId == instanceId);
                if (fieldManager == default || fieldManager.Decrement() > 0)
                {
                    return(false);
                }

                //is only called if the leaving player is the last player on the map
                //get the dungeonsession that corresponds with the about to be released instance, in case that the player is in a party (group session) and solo session
                if (GameServer.DungeonManager.IsDungeonUsingFieldInstance(fieldManager, player))
                {
                    return(false);
                }

                return(managerList.Remove(fieldManager));
            }
        }