protected async override void OnDestroy()
        {
            // Save immediately
#if UNITY_STANDALONE && !CLIENT_BUILD
            if (IsServer)
            {
                foreach (BasePlayerCharacterEntity playerCharacter in ServerUserHandlers.GetPlayerCharacters())
                {
                    if (playerCharacter == null)
                    {
                        continue;
                    }
                    await DbServiceClient.UpdateCharacterAsync(new UpdateCharacterReq()
                    {
                        CharacterData = playerCharacter.CloneTo(new PlayerCharacterData())
                    });
                }
                string mapName = CurrentMapInfo.Id;
                foreach (BuildingEntity buildingEntity in ServerBuildingHandlers.GetBuildings())
                {
                    if (buildingEntity == null)
                    {
                        continue;
                    }
                    await DbServiceClient.UpdateBuildingAsync(new UpdateBuildingReq()
                    {
                        MapName      = mapName,
                        BuildingData = buildingEntity.CloneTo(new BuildingSaveData())
                    });
                }
            }
#endif
            base.OnDestroy();
        }
        private void GiveGuildBattleRewardTo(int winnerGuildId)
        {
            GuildWarMapInfo mapInfo = CurrentMapInfo as GuildWarMapInfo;
            string          mailTitle;
            string          mailContent;
            int             rewardGold;

            CurrencyAmount[] rewardCurrencies;
            ItemAmount[]     rewardItems;
            Mail             tempMail;

            foreach (IPlayerCharacterData participant in ServerUserHandlers.GetPlayerCharacters())
            {
                if (participant.GuildId == winnerGuildId)
                {
                    mailTitle        = mapInfo.winMailTitle;
                    mailContent      = mapInfo.winMailContent;
                    rewardGold       = mapInfo.winRewardGold;
                    rewardCurrencies = mapInfo.winRewardCurrencies;
                    rewardItems      = mapInfo.winRewardItems;
                }
                else
                {
                    mailTitle        = mapInfo.participantMailTitle;
                    mailContent      = mapInfo.participantMailContent;
                    rewardGold       = mapInfo.participantRewardGold;
                    rewardCurrencies = mapInfo.participantRewardCurrencies;
                    rewardItems      = mapInfo.participantRewardItems;
                }
                tempMail = new Mail()
                {
                    SenderId   = guildWarMailSenderId,
                    SenderName = guildWarMailSenderName,
                    ReceiverId = participant.UserId,
                    Title      = mailTitle,
                    Content    = mailContent,
                    Gold       = rewardGold,
                };
                foreach (CurrencyAmount currencyAmount in rewardCurrencies)
                {
                    if (currencyAmount.currency == null)
                    {
                        continue;
                    }
                    tempMail.Currencies.Add(CharacterCurrency.Create(currencyAmount.currency.DataId, currencyAmount.amount));
                }
                foreach (ItemAmount itemAmount in rewardItems)
                {
                    if (itemAmount.item == null)
                    {
                        continue;
                    }
                    tempMail.Items.Add(CharacterItem.Create(itemAmount.item, 1, itemAmount.amount));
                }
                ServerMailHandlers.SendMail(tempMail);
            }
        }
        private async UniTaskVoid SaveCharactersRoutine()
        {
            if (savingCharacters.Count == 0)
            {
                int            i     = 0;
                List <UniTask> tasks = new List <UniTask>();
                foreach (BasePlayerCharacterEntity playerCharacterEntity in ServerUserHandlers.GetPlayerCharacters())
                {
                    if (playerCharacterEntity == null)
                    {
                        continue;
                    }
                    tasks.Add(SaveCharacter(playerCharacterEntity));
                    ++i;
                }
                await UniTask.WhenAll(tasks);

                if (LogInfo)
                {
                    Logging.Log(LogTag, "Saved " + i + " character(s)");
                }
            }
        }
        private void ExpelLoserGuilds(int winnerGuildId)
        {
            // Teleport other guild characters to other map (for now, teleport to respawn position)
            List <IPlayerCharacterData> otherGuildCharacters = new List <IPlayerCharacterData>(ServerUserHandlers.GetPlayerCharacters());

            for (int i = 0; i < otherGuildCharacters.Count; ++i)
            {
                if (otherGuildCharacters[i].GuildId <= 0 ||
                    otherGuildCharacters[i].GuildId != winnerGuildId)
                {
                    WarpCharacter(WarpPortalType.Default,
                                  otherGuildCharacters[i] as BasePlayerCharacterEntity,
                                  otherGuildCharacters[i].RespawnMapName,
                                  otherGuildCharacters[i].RespawnPosition,
                                  false, Vector3.zero);
                }
            }
        }