Ejemplo n.º 1
0
        protected virtual void ApplyItemPetSummon(Item item, short level, int exp)
        {
            if (IsDead() || !IsServer || item == null || level <= 0)
            {
                return;
            }
            // Clear all summoned pets
            CharacterSummon tempSummon;

            for (int i = 0; i < Summons.Count; ++i)
            {
                tempSummon = summons[i];
                if (tempSummon.type != SummonType.Pet)
                {
                    continue;
                }
                summons.RemoveAt(i);
                tempSummon.UnSummon(this);
            }
            // Summon new pet
            CharacterSummon newSummon = CharacterSummon.Create(SummonType.Pet, item.DataId);

            newSummon.Summon(this, level, 0f, exp);
            summons.Add(newSummon);
        }
Ejemplo n.º 2
0
    public static CharacterSummon Create(SummonType type, int dataId)
    {
        var newSummon = new CharacterSummon();

        newSummon.type   = type;
        newSummon.dataId = dataId;
        return(newSummon);
    }
Ejemplo n.º 3
0
 public void CreateCharacterSummon(string characterId, CharacterSummon characterSummon)
 {
     ExecuteNonQuery("INSERT INTO charactersummon (id, characterId, type, dataId, summonRemainsDuration, level, exp, currentHp, currentMp) VALUES (@id, @characterId, @type, @dataId, @summonRemainsDuration, @level, @exp, @currentHp, @currentMp)",
                     new SqliteParameter("@id", characterId + "_" + characterSummon.type + "_" + characterSummon.dataId),
                     new SqliteParameter("@characterId", characterId),
                     new SqliteParameter("@type", (byte)characterSummon.type),
                     new SqliteParameter("@dataId", characterSummon.dataId),
                     new SqliteParameter("@summonRemainsDuration", characterSummon.summonRemainsDuration),
                     new SqliteParameter("@level", characterSummon.level),
                     new SqliteParameter("@exp", characterSummon.exp),
                     new SqliteParameter("@currentHp", characterSummon.currentHp),
                     new SqliteParameter("@currentMp", characterSummon.currentMp));
 }
Ejemplo n.º 4
0
    public void GetObjectData(System.Object obj,
                              SerializationInfo info, StreamingContext context)
    {
        CharacterSummon data = (CharacterSummon)obj;

        info.AddValue("type", (byte)data.type);
        info.AddValue("dataId", data.dataId);
        info.AddValue("summonRemainsDuration", data.summonRemainsDuration);
        info.AddValue("level", data.Level);
        info.AddValue("exp", data.Exp);
        info.AddValue("currentHp", data.CurrentHp);
        info.AddValue("currentMp", data.CurrentMp);
    }
Ejemplo n.º 5
0
    public System.Object SetObjectData(System.Object obj,
                                       SerializationInfo info, StreamingContext context,
                                       ISurrogateSelector selector)
    {
        CharacterSummon data = (CharacterSummon)obj;

        data.type   = (SummonType)info.GetByte("type");
        data.dataId = info.GetInt32("dataId");
        data.summonRemainsDuration = info.GetSingle("summonRemainsDuration");
        data.level     = info.GetInt16("level");
        data.exp       = info.GetInt32("exp");
        data.currentHp = info.GetInt32("currentHp");
        data.currentMp = info.GetInt32("currentMp");
        obj            = data;
        return(obj);
    }
Ejemplo n.º 6
0
 private bool ReadCharacterSummon(MySqlDataReader reader, out CharacterSummon result)
 {
     if (reader.Read())
     {
         result        = new CharacterSummon();
         result.type   = (SummonType)reader.GetByte(0);
         result.dataId = reader.GetInt32(1);
         result.summonRemainsDuration = reader.GetFloat(2);
         result.level     = reader.GetInt16(3);
         result.exp       = reader.GetInt32(4);
         result.currentHp = reader.GetInt32(5);
         result.currentMp = reader.GetInt32(6);
         return(true);
     }
     result = CharacterSummon.Empty;
     return(false);
 }
Ejemplo n.º 7
0
        protected virtual void NetFuncUnSummon(PackedUInt objectId)
        {
            int index = this.IndexOfSummon(objectId);

            if (index < 0)
            {
                return;
            }

            CharacterSummon summon = Summons[index];

            if (summon.type != SummonType.Pet)
            {
                return;
            }

            Summons.RemoveAt(index);
            summon.UnSummon(this);
        }
Ejemplo n.º 8
0
        private bool ReadCharacterSummon(SQLiteRowsReader reader, out CharacterSummon result, bool resetReader = true)
        {
            if (resetReader)
            {
                reader.ResetReader();
            }

            if (reader.Read())
            {
                result        = new CharacterSummon();
                result.type   = (SummonType)reader.GetSByte("type");
                result.dataId = reader.GetInt32("dataId");
                result.summonRemainsDuration = reader.GetFloat("summonRemainsDuration");
                result.level     = (short)reader.GetInt32("level");
                result.exp       = reader.GetInt32("exp");
                result.currentHp = reader.GetInt32("currentHp");
                result.currentMp = reader.GetInt32("currentMp");
                return(true);
            }
            result = CharacterSummon.Empty;
            return(false);
        }
Ejemplo n.º 9
0
        protected virtual void ApplySkillSummon(Skill skill, short level)
        {
            if (IsDead() || !IsServer || skill == null || level <= 0)
            {
                return;
            }
            int i = 0;
            int amountEachTime = skill.summon.amountEachTime.GetAmount(level);

            for (i = 0; i < amountEachTime; ++i)
            {
                CharacterSummon newSummon = CharacterSummon.Create(SummonType.Skill, skill.DataId);
                newSummon.Summon(this, skill.summon.level.GetAmount(level), skill.summon.duration.GetAmount(level));
                summons.Add(newSummon);
            }
            int count = 0;

            for (i = 0; i < summons.Count; ++i)
            {
                if (summons[i].dataId == skill.DataId)
                {
                    ++count;
                }
            }
            int             maxStack       = skill.summon.maxStack.GetAmount(level);
            int             unSummonAmount = count > maxStack ? count - maxStack : 0;
            CharacterSummon tempSummon;

            for (i = unSummonAmount; i > 0; --i)
            {
                int summonIndex = this.IndexOfSummon(skill.DataId, SummonType.Skill);
                tempSummon = summons[summonIndex];
                if (summonIndex >= 0)
                {
                    summons.RemoveAt(summonIndex);
                    tempSummon.UnSummon(this);
                }
            }
        }
        private async UniTaskVoid SetPlayerReadyRoutine(long connectionId, string userId, string selectCharacterId)
        {
            CharacterResp characterResp = await DbServiceClient.ReadCharacterAsync(new ReadCharacterReq()
            {
                UserId      = userId,
                CharacterId = selectCharacterId
            });

            PlayerCharacterData playerCharacterData = characterResp.CharacterData;

            // If data is empty / cannot find character, disconnect user
            if (playerCharacterData == null)
            {
                if (LogError)
                {
                    Logging.LogError(LogTag, "Cannot find select character: " + selectCharacterId + " for user: "******"Cannot find player character with entity Id: " + playerCharacterData.EntityId);
                    }
                    Transport.ServerDisconnect(connectionId);
                }
                else
                {
                    // Prepare saving location for this character
                    string  savingCurrentMapName  = playerCharacterData.CurrentMapName;
                    Vector3 savingCurrentPosition = playerCharacterData.CurrentPosition;

                    if (IsInstanceMap())
                    {
                        playerCharacterData.CurrentPosition = MapInstanceWarpToPosition;
                        if (MapInstanceWarpOverrideRotation)
                        {
                            playerCharacterData.CurrentRotation = MapInstanceWarpToRotation;
                        }
                    }

                    // Spawn character entity and set its data
                    Quaternion characterRotation = Quaternion.identity;
                    if (CurrentGameInstance.DimensionType == DimensionType.Dimension3D)
                    {
                        characterRotation = Quaternion.Euler(playerCharacterData.CurrentRotation);
                    }
                    GameObject spawnObj = Instantiate(entityPrefab.gameObject, playerCharacterData.CurrentPosition, characterRotation);
                    BasePlayerCharacterEntity playerCharacterEntity = spawnObj.GetComponent <BasePlayerCharacterEntity>();
                    playerCharacterData.CloneTo(playerCharacterEntity);
                    Assets.NetworkSpawn(spawnObj, 0, connectionId);

                    // Set currencies
                    // Gold
                    GoldResp getGoldResp = await DbServiceClient.GetGoldAsync(new GetGoldReq()
                    {
                        UserId = userId
                    });

                    playerCharacterEntity.UserGold = getGoldResp.Gold;
                    // Cash
                    CashResp getCashResp = await DbServiceClient.GetCashAsync(new GetCashReq()
                    {
                        UserId = userId
                    });

                    playerCharacterEntity.UserCash = getCashResp.Cash;

                    // Prepare saving location for this character
                    if (IsInstanceMap())
                    {
                        instanceMapCurrentLocations.TryAdd(playerCharacterEntity.ObjectId, new KeyValuePair <string, Vector3>(savingCurrentMapName, savingCurrentPosition));
                    }

                    // Set user Id
                    playerCharacterEntity.UserId = userId;

                    // Load user level
                    GetUserLevelResp getUserLevelResp = await DbServiceClient.GetUserLevelAsync(new GetUserLevelReq()
                    {
                        UserId = userId
                    });

                    playerCharacterEntity.UserLevel = getUserLevelResp.UserLevel;

                    // Load party data, if this map-server does not have party data
                    if (playerCharacterEntity.PartyId > 0)
                    {
                        if (!ServerPartyHandlers.ContainsParty(playerCharacterEntity.PartyId))
                        {
                            await LoadPartyRoutine(playerCharacterEntity.PartyId);
                        }
                        PartyData party;
                        if (ServerPartyHandlers.TryGetParty(playerCharacterEntity.PartyId, out party))
                        {
                            ServerGameMessageHandlers.SendSetPartyData(playerCharacterEntity.ConnectionId, party);
                            ServerGameMessageHandlers.SendAddPartyMembersToOne(playerCharacterEntity.ConnectionId, party);
                        }
                        else
                        {
                            playerCharacterEntity.ClearParty();
                        }
                    }

                    // Load guild data, if this map-server does not have guild data
                    if (playerCharacterEntity.GuildId > 0)
                    {
                        if (!ServerGuildHandlers.ContainsGuild(playerCharacterEntity.GuildId))
                        {
                            await LoadGuildRoutine(playerCharacterEntity.GuildId);
                        }
                        GuildData guild;
                        if (ServerGuildHandlers.TryGetGuild(playerCharacterEntity.GuildId, out guild))
                        {
                            playerCharacterEntity.GuildName = guild.guildName;
                            playerCharacterEntity.GuildRole = guild.GetMemberRole(playerCharacterEntity.Id);
                            ServerGameMessageHandlers.SendSetGuildData(playerCharacterEntity.ConnectionId, guild);
                            ServerGameMessageHandlers.SendAddGuildMembersToOne(playerCharacterEntity.ConnectionId, guild);
                            ServerGameMessageHandlers.SendSetGuildMessage(playerCharacterEntity.ConnectionId, guild);
                            ServerGameMessageHandlers.SendSetGuildRolesToOne(playerCharacterEntity.ConnectionId, guild);
                            ServerGameMessageHandlers.SendSetGuildMemberRolesToOne(playerCharacterEntity.ConnectionId, guild);
                            ServerGameMessageHandlers.SendSetGuildSkillLevelsToOne(playerCharacterEntity.ConnectionId, guild);
                            ServerGameMessageHandlers.SendSetGuildGold(playerCharacterEntity.ConnectionId, guild);
                            ServerGameMessageHandlers.SendSetGuildLevelExpSkillPoint(playerCharacterEntity.ConnectionId, guild);
                        }
                        else
                        {
                            playerCharacterEntity.ClearGuild();
                        }
                    }

                    // Summon saved summons
                    for (int i = 0; i < playerCharacterEntity.Summons.Count; ++i)
                    {
                        CharacterSummon summon = playerCharacterEntity.Summons[i];
                        summon.Summon(playerCharacterEntity, summon.Level, summon.summonRemainsDuration, summon.Exp, summon.CurrentHp, summon.CurrentMp);
                        playerCharacterEntity.Summons[i] = summon;
                    }

                    // Summon saved mount entity
                    if (GameInstance.VehicleEntities.ContainsKey(playerCharacterData.MountDataId))
                    {
                        playerCharacterEntity.Mount(GameInstance.VehicleEntities[playerCharacterData.MountDataId]);
                    }

                    // Force make caches, to calculate current stats to fill empty slots items
                    playerCharacterEntity.ForceMakeCaches();
                    playerCharacterEntity.FillEmptySlots();

                    // Notify clients that this character is spawn or dead
                    if (!playerCharacterEntity.IsDead())
                    {
                        playerCharacterEntity.CallAllOnRespawn();
                    }
                    else
                    {
                        playerCharacterEntity.CallAllOnDead();
                    }

                    // Register player character entity to the server
                    RegisterPlayerCharacter(connectionId, playerCharacterEntity);
                }
            }
        }
Ejemplo n.º 11
0
 public async UniTask CreateCharacterSummon(MySqlConnection connection, MySqlTransaction transaction, int idx, string characterId, CharacterSummon characterSummon)
 {
     await ExecuteNonQuery(connection, transaction, "INSERT INTO charactersummon (id, characterId, type, dataId, summonRemainsDuration, level, exp, currentHp, currentMp) VALUES (@id, @characterId, @type, @dataId, @summonRemainsDuration, @level, @exp, @currentHp, @currentMp)",
                           new MySqlParameter("@id", characterId + "_" + characterSummon.type + "_" + idx),
                           new MySqlParameter("@characterId", characterId),
                           new MySqlParameter("@type", (byte)characterSummon.type),
                           new MySqlParameter("@dataId", characterSummon.dataId),
                           new MySqlParameter("@summonRemainsDuration", characterSummon.summonRemainsDuration),
                           new MySqlParameter("@level", characterSummon.level),
                           new MySqlParameter("@exp", characterSummon.exp),
                           new MySqlParameter("@currentHp", characterSummon.currentHp),
                           new MySqlParameter("@currentMp", characterSummon.currentMp));
 }
Ejemplo n.º 12
0
    public static T DeserializeCharacterData <T>(this T characterData, NetDataReader reader) where T : IPlayerCharacterData
    {
        var tempCharacterData = new PlayerCharacterData();

        tempCharacterData.Id              = reader.GetString();
        tempCharacterData.DataId          = reader.GetInt();
        tempCharacterData.EntityId        = reader.GetInt();
        tempCharacterData.CharacterName   = reader.GetString();
        tempCharacterData.Level           = reader.GetShort();
        tempCharacterData.Exp             = reader.GetInt();
        tempCharacterData.CurrentHp       = reader.GetInt();
        tempCharacterData.CurrentMp       = reader.GetInt();
        tempCharacterData.CurrentStamina  = reader.GetInt();
        tempCharacterData.CurrentFood     = reader.GetInt();
        tempCharacterData.CurrentWater    = reader.GetInt();
        tempCharacterData.StatPoint       = reader.GetShort();
        tempCharacterData.SkillPoint      = reader.GetShort();
        tempCharacterData.Gold            = reader.GetInt();
        tempCharacterData.PartyId         = reader.GetInt();
        tempCharacterData.GuildId         = reader.GetInt();
        tempCharacterData.GuildRole       = reader.GetByte();
        tempCharacterData.SharedGuildExp  = reader.GetInt();
        tempCharacterData.CurrentMapName  = reader.GetString();
        tempCharacterData.CurrentPosition = new Vector3(reader.GetFloat(), reader.GetFloat(), reader.GetFloat());
        tempCharacterData.RespawnMapName  = reader.GetString();
        tempCharacterData.RespawnPosition = new Vector3(reader.GetFloat(), reader.GetFloat(), reader.GetFloat());
        tempCharacterData.LastUpdate      = reader.GetInt();
        int count = 0;

        count = reader.GetByte();
        for (var i = 0; i < count; ++i)
        {
            var entry = new CharacterAttribute();
            entry.Deserialize(reader);
            tempCharacterData.Attributes.Add(entry);
        }
        count = reader.GetByte();
        for (var i = 0; i < count; ++i)
        {
            var entry = new CharacterBuff();
            entry.Deserialize(reader);
            tempCharacterData.Buffs.Add(entry);
        }
        count = reader.GetByte();
        for (var i = 0; i < count; ++i)
        {
            var entry = new CharacterSkill();
            entry.Deserialize(reader);
            tempCharacterData.Skills.Add(entry);
        }
        count = reader.GetByte();
        for (var i = 0; i < count; ++i)
        {
            var entry = new CharacterSkillUsage();
            entry.Deserialize(reader);
            tempCharacterData.SkillUsages.Add(entry);
        }
        count = reader.GetByte();
        for (var i = 0; i < count; ++i)
        {
            var entry = new CharacterSummon();
            entry.Deserialize(reader);
            tempCharacterData.Summons.Add(entry);
        }
        count = reader.GetByte();
        for (var i = 0; i < count; ++i)
        {
            var entry = new CharacterItem();
            entry.Deserialize(reader);
            tempCharacterData.EquipItems.Add(entry);
        }
        count = reader.GetShort();
        for (var i = 0; i < count; ++i)
        {
            var entry = new CharacterItem();
            entry.Deserialize(reader);
            tempCharacterData.NonEquipItems.Add(entry);
        }
        count = reader.GetByte();
        for (var i = 0; i < count; ++i)
        {
            var entry = new CharacterHotkey();
            entry.Deserialize(reader);
            tempCharacterData.Hotkeys.Add(entry);
        }
        count = reader.GetByte();
        for (var i = 0; i < count; ++i)
        {
            var entry = new CharacterQuest();
            entry.Deserialize(reader);
            tempCharacterData.Quests.Add(entry);
        }
        var equipWeapons = new EquipWeapons();

        equipWeapons.Deserialize(reader);
        tempCharacterData.EquipWeapons = equipWeapons;
        DevExtUtils.InvokeStaticDevExtMethods(ClassType, "DeserializeCharacterData", characterData, reader);

        tempCharacterData.ValidateCharacterData();
        tempCharacterData.CloneTo(characterData);
        return(characterData);
    }
        public override void DeserializeClientReadyExtra(LiteNetLibIdentity playerIdentity, long connectionId, NetDataReader reader)
        {
            if (LogDev)
            {
                Debug.Log("[LanRpgNetworkManager] Deserializing client ready extra");
            }
            PlayerCharacterData       playerCharacterData = new PlayerCharacterData().DeserializeCharacterData(reader);
            BasePlayerCharacterEntity entityPrefab        = playerCharacterData.GetEntityPrefab() as BasePlayerCharacterEntity;

            // If it is not allow this character data, disconnect user
            if (entityPrefab == null)
            {
                Debug.LogError("[LanRpgNetworkManager] Cannot find player character with entity Id: " + playerCharacterData.EntityId);
                return;
            }
            if (!CurrentMapInfo.Id.Equals(playerCharacterData.CurrentMapName))
            {
                playerCharacterData.CurrentPosition = teleportPosition.HasValue ? teleportPosition.Value : CurrentMapInfo.startPosition;
            }
            GameObject spawnObj = Instantiate(entityPrefab.gameObject, playerCharacterData.CurrentPosition, Quaternion.identity);
            BasePlayerCharacterEntity playerCharacterEntity = spawnObj.GetComponent <BasePlayerCharacterEntity>();

            playerCharacterData.CloneTo(playerCharacterEntity);
            Assets.NetworkSpawn(spawnObj, 0, connectionId);

            // Set user Id
            playerCharacterEntity.UserId = playerCharacterEntity.Id;

            // Enable GM commands in Singleplayer / LAN mode
            // TODO: Don't use fixed user level
            if (enableGmCommands == EnableGmCommandType.Everyone)
            {
                playerCharacterEntity.UserLevel = 1;
            }

            // Load world / storage for first character (host)
            if (playerCharacters.Count == 0)
            {
                if (enableGmCommands == EnableGmCommandType.HostOnly)
                {
                    playerCharacterEntity.UserLevel = 1;
                }

                // Load and Spawn buildings
                worldSaveData.LoadPersistentData(playerCharacterEntity.Id, playerCharacterEntity.CurrentMapName);
                foreach (BuildingSaveData building in worldSaveData.buildings)
                {
                    CreateBuildingEntity(building, true);
                }
                // Load storage data
                storageSaveData.LoadPersistentData(playerCharacterEntity.Id);
                foreach (StorageCharacterItem storageItem in storageSaveData.storageItems)
                {
                    StorageId storageId = new StorageId(storageItem.storageType, storageItem.storageOwnerId);
                    if (!storageItems.ContainsKey(storageId))
                    {
                        storageItems[storageId] = new List <CharacterItem>();
                    }
                    storageItems[storageId].Add(storageItem.characterItem);
                }
                // Spawn harvestables
                HarvestableSpawnArea[] harvestableSpawnAreas = FindObjectsOfType <HarvestableSpawnArea>();
                foreach (HarvestableSpawnArea harvestableSpawnArea in harvestableSpawnAreas)
                {
                    harvestableSpawnArea.SpawnAll();
                }
            }

            // Summon saved summons
            for (int i = 0; i < playerCharacterEntity.Summons.Count; ++i)
            {
                CharacterSummon summon = playerCharacterEntity.Summons[i];
                summon.Summon(playerCharacterEntity, summon.Level, summon.summonRemainsDuration, summon.Exp, summon.CurrentHp, summon.CurrentMp);
                playerCharacterEntity.Summons[i] = summon;
            }

            // Notify clients that this character is spawn or dead
            if (!playerCharacterEntity.IsDead())
            {
                playerCharacterEntity.RequestOnRespawn();
            }
            else
            {
                playerCharacterEntity.RequestOnDead();
            }

            // Register player, will use registered player to send chat / player messages
            RegisterPlayerCharacter(connectionId, playerCharacterEntity);
        }
Ejemplo n.º 14
0
 public static bool IsEmpty(this CharacterSummon data)
 {
     return(data == null || data.Equals(CharacterSummon.Empty));
 }
Ejemplo n.º 15
0
        private IEnumerator SetPlayerReadyRoutine(long connectionId, string userId, string accessToken, string selectCharacterId)
        {
            // Validate access token
            ValidateAccessTokenJob validateAccessTokenJob = new ValidateAccessTokenJob(Database, userId, accessToken);

            validateAccessTokenJob.Start();
            yield return(StartCoroutine(validateAccessTokenJob.WaitFor()));

            if (!validateAccessTokenJob.result)
            {
                if (LogError)
                {
                    Debug.LogError("[Map Server] Invalid access token for user: "******"[Map Server] Cannot find select character: " + selectCharacterId + " for user: "******"[Map Server] Cannot find player character with entity Id: " + playerCharacterData.EntityId);
                        }
                        Transport.ServerDisconnect(connectionId);
                    }
                    else
                    {
                        // Spawn character entity and set its data
                        LiteNetLibIdentity        identity = Assets.NetworkSpawn(entityPrefab.Identity.HashAssetId, playerCharacterData.CurrentPosition, Quaternion.identity, 0, connectionId);
                        BasePlayerCharacterEntity playerCharacterEntity = identity.GetComponent <BasePlayerCharacterEntity>();
                        playerCharacterData.CloneTo(playerCharacterEntity);

                        // Summon saved summons
                        for (int i = 0; i < playerCharacterEntity.Summons.Count; ++i)
                        {
                            CharacterSummon summon = playerCharacterEntity.Summons[i];
                            summon.Summon(playerCharacterEntity, summon.Level, summon.summonRemainsDuration, summon.Exp, summon.CurrentHp, summon.CurrentMp);
                            playerCharacterEntity.Summons[i] = summon;
                        }

                        // Load user level
                        GetUserLevelJob loadUserLevelJob = new GetUserLevelJob(Database, userId);
                        loadUserLevelJob.Start();
                        yield return(StartCoroutine(loadUserLevelJob.WaitFor()));

                        playerCharacterEntity.UserLevel = loadUserLevelJob.result;

                        // Notify clients that this character is spawn or dead
                        if (!playerCharacterEntity.IsDead())
                        {
                            playerCharacterEntity.RequestOnRespawn();
                        }
                        else
                        {
                            playerCharacterEntity.RequestOnDead();
                        }
                        RegisterPlayerCharacter(connectionId, playerCharacterEntity);

                        // Load party data, if this map-server does not have party data
                        if (playerCharacterEntity.PartyId > 0)
                        {
                            if (!parties.ContainsKey(playerCharacterEntity.PartyId))
                            {
                                yield return(StartCoroutine(LoadPartyRoutine(playerCharacterEntity.PartyId)));
                            }
                            if (parties.ContainsKey(playerCharacterEntity.PartyId))
                            {
                                PartyData party = parties[playerCharacterEntity.PartyId];
                                SendCreatePartyToClient(playerCharacterEntity.ConnectionId, party);
                                SendAddPartyMembersToClient(playerCharacterEntity.ConnectionId, party);
                            }
                            else
                            {
                                playerCharacterEntity.ClearParty();
                            }
                        }

                        // Load guild data, if this map-server does not have guild data
                        if (playerCharacterEntity.GuildId > 0)
                        {
                            if (!guilds.ContainsKey(playerCharacterEntity.GuildId))
                            {
                                yield return(StartCoroutine(LoadGuildRoutine(playerCharacterEntity.GuildId)));
                            }
                            if (guilds.ContainsKey(playerCharacterEntity.GuildId))
                            {
                                GuildData guild = guilds[playerCharacterEntity.GuildId];
                                playerCharacterEntity.GuildRole = guild.GetMemberRole(playerCharacterEntity.Id);
                                SendCreateGuildToClient(playerCharacterEntity.ConnectionId, guild);
                                SendAddGuildMembersToClient(playerCharacterEntity.ConnectionId, guild);
                                SendSetGuildMessageToClient(playerCharacterEntity.ConnectionId, guild);
                                SendSetGuildRolesToClient(playerCharacterEntity.ConnectionId, guild);
                                SendSetGuildMemberRolesToClient(playerCharacterEntity.ConnectionId, guild);
                                SendSetGuildSkillLevelsToClient(playerCharacterEntity.ConnectionId, guild);
                                SendGuildLevelExpSkillPointToClient(playerCharacterEntity.ConnectionId, guild);
                            }
                            else
                            {
                                playerCharacterEntity.ClearGuild();
                            }
                        }

                        // Set user data to map server
                        UserCharacterData userData = new UserCharacterData();
                        userData.userId        = userId;
                        userData.id            = playerCharacterEntity.Id;
                        userData.characterName = playerCharacterEntity.CharacterName;
                        userData.dataId        = playerCharacterEntity.DataId;
                        userData.level         = playerCharacterEntity.Level;
                        userData.currentHp     = playerCharacterEntity.CurrentHp;
                        userData.maxHp         = playerCharacterEntity.CacheMaxHp;
                        userData.currentMp     = playerCharacterEntity.CurrentMp;
                        userData.maxMp         = playerCharacterEntity.CacheMaxMp;
                        usersById[userData.id] = userData;

                        // Add map user to central server and chat server
                        UpdateMapUser(CentralAppServerRegister, UpdateUserCharacterMessage.UpdateType.Add, userData);
                        if (ChatNetworkManager.IsClientConnected)
                        {
                            UpdateMapUser(ChatNetworkManager.Client, UpdateUserCharacterMessage.UpdateType.Add, userData);
                        }

                        LiteNetLibPlayer player = Players[connectionId];
                        foreach (LiteNetLibIdentity spawnedObject in Assets.SpawnedObjects.Values)
                        {
                            if (spawnedObject.ConnectionId == player.ConnectionId)
                            {
                                continue;
                            }

                            if (spawnedObject.ShouldAddSubscriber(player))
                            {
                                spawnedObject.AddSubscriber(player);
                            }
                        }
                    }
                }
            }
        }