示例#1
0
    public void ApplyModel(LobbyPlayerData playerData, CharacterVisualData visualData)
    {
        _model      = playerData;
        _visualData = visualData;

        RefreshView();
    }
示例#2
0
 public void ApplyData(CharacterVisualData data, int playerId)
 {
     _portrait.sprite = data.Portrait;
     Character        = data.Character;
     PlayerId         = playerId;
 }
示例#3
0
        public static IEnumerator SetVisuals(Character character, string visualData)
        {
            var visuals = character.GetComponentInChildren <CharacterVisuals>(true);

            var newData = CharacterVisualData.CreateFromNetworkData(visualData);

            if (newData.SkinIndex == -999)
            {
                yield break;
            }

            float start = Time.time;

            while (!visuals && Time.time - start < 5f)
            {
                yield return(new WaitForSeconds(0.5f));

                visuals = character.GetComponentInChildren <CharacterVisuals>(true);
            }

            yield return(new WaitForSeconds(0.5f));

            if (visuals)
            {
                // disable default visuals
                visuals.transform.Find("HeadWhiteMaleA")?.gameObject.SetActive(false);
                ((ArmorVisuals)At.GetField(visuals, "m_defaultHeadVisuals"))?.gameObject.SetActive(false);
                visuals.transform.Find("MBody0")?.gameObject.SetActive(false);
                visuals.transform.Find("MFeet0")?.gameObject.SetActive(false);

                // failsafe for head index based on skin and gender
                ClampHeadVariation(ref newData.HeadVariationIndex, (int)newData.Gender, newData.SkinIndex);

                // set visual data
                var data = visuals.VisualData;
                data.Gender             = newData.Gender;
                data.SkinIndex          = newData.SkinIndex;
                data.HeadVariationIndex = newData.HeadVariationIndex;
                data.HairColorIndex     = newData.HairColorIndex;
                data.HairStyleIndex     = newData.HairStyleIndex;

                // set to the character too
                character.VisualData = data;

                var presets = CharacterManager.CharacterVisualsPresets;

                // get the skin material
                var mat = (data.Gender == 0) ? presets.MSkins[data.SkinIndex] : presets.FSkins[data.SkinIndex];
                At.SetField(visuals, "m_skinMat", mat);

                // apply the visuals
                var hideface = false;
                var hidehair = false;

                if (visuals.ActiveVisualsHead)
                {
                    hideface = visuals.ActiveVisualsHead.HideFace;
                    hidehair = visuals.ActiveVisualsHead.HideHair;
                }

                //SL.Log("hideface: " + hideface);

                if (!hideface)
                {
                    visuals.LoadCharacterCreationHead(data.SkinIndex, (int)data.Gender, data.HeadVariationIndex);
                }

                if (!hidehair)
                {
                    ApplyHairVisuals(visuals, data.HairStyleIndex, data.HairColorIndex);
                }

                if (!character.Inventory.Equipment.GetEquippedItem(EquipmentSlot.EquipmentSlotIDs.Chest))
                {
                    visuals.LoadCharacterCreationBody((int)data.Gender, data.SkinIndex);
                }

                if (!character.Inventory.Equipment.GetEquippedItem(EquipmentSlot.EquipmentSlotIDs.Foot))
                {
                    visuals.LoadCharacterCreationBoots((int)data.Gender, data.SkinIndex);
                }
            }
            else
            {
                SL.Log("Couldn't get visuals!");
            }
        }