Beispiel #1
0
    void Initialize()
    {
        UMAInstance();

        gameObject = new GameObject(objectName);
        UpdateVec();

        umaContext = UMAContext.FindInstance();
        UMAGenerator generator = umaContext.umaGenerator;

        umaDynamicAvatar = gameObject.AddComponent <UMADynamicAvatar>();
        umaDynamicAvatar.Initialize();

        UMAData umaData = umaDynamicAvatar.umaData;

        umaDynamicAvatar.umaGenerator = generator;
        umaData.umaGenerator          = generator;

        UMATextRecipe recipe = UMATextRecipe.CreateInstance <UMATextRecipe>();

        recipe.Load(umaData.umaRecipe, umaContext);
        umaDynamicAvatar.umaRecipe = recipe;
        umaData.AddAdditionalRecipes(new UMARecipeBase[] { umaContext.umaTextRecipe }, umaContext);
        umaData.OnCharacterCreated   += CharacterCreated;
        umaData.OnCharacterUpdated   += CharacterUpdated;
        umaData.OnCharacterDestroyed += CharacterDestroyed;

        if (isExpress)
        {
            expressionPlayer = gameObject.AddComponent <UMAExpressionPlayer>();
            expressionPlayer.overrideMecanimEyes = true;
            expressionPlayer.overrideMecanimHead = true;
            expressionPlayer.overrideMecanimJaw  = true;
            expressionPlayer.overrideMecanimNeck = true;
        }

        umaData.umaRecipe.slotDataList = new SlotData[100];
        UMADnaHumanoid umaDna         = new UMADnaHumanoid();
        UMADnaTutorial umaTutorialDNA = new UMADnaTutorial();

        umaData.umaRecipe.AddDna(umaDna);
        umaData.umaRecipe.AddDna(umaTutorialDNA);

        ICharacterSlotOverly characterSlotOverlay = new CharacterSlotOverly(umaDynamicAvatar);

        characterAnim = new CharacterAnim(umaDynamicAvatar);
        //characterDna = new CharacterDna(umaDna, umaData, characterAnim, characterData);
        characterBase  = new CharacterBase(resType, characterSlotOverlay, umaData, umaDynamicAvatar, characterData);
        characterCloth = new CharacterCloth(resType, characterData, characterSlotOverlay, this, characterBase);
    }
Beispiel #2
0
        public void SetComponentDrawable(int index, string name, string tex, GameFileCache gfc)
        {
            if (string.IsNullOrEmpty(name))
            {
                DrawableNames[index] = null;
                Drawables[index]     = null;
                Textures[index]      = null;
                Expressions[index]   = null;
                return;
            }

            MetaHash namehash = JenkHash.GenHash(name.ToLowerInvariant());
            Drawable d        = null;

            if (Ydd?.Dict != null)
            {
                Ydd.Dict.TryGetValue(namehash, out d);
            }
            if ((d == null) && (DrawableFilesDict != null))
            {
                RpfFileEntry file = null;
                if (DrawableFilesDict.TryGetValue(namehash, out file))
                {
                    var ydd = gfc.GetFileUncached <YddFile>(file);
                    while ((ydd != null) && (!ydd.Loaded))
                    {
                        Thread.Sleep(1);//kinda hacky
                        gfc.TryLoadEnqueue(ydd);
                    }
                    if (ydd?.Drawables?.Length > 0)
                    {
                        d = ydd.Drawables[0];//should only be one in this dict
                    }
                }
            }

            MetaHash texhash = JenkHash.GenHash(tex.ToLowerInvariant());
            Texture  t       = null;

            if (Ytd?.TextureDict?.Dict != null)
            {
                Ytd.TextureDict.Dict.TryGetValue(texhash, out t);
            }
            if ((t == null) && (TextureFilesDict != null))
            {
                RpfFileEntry file = null;
                if (TextureFilesDict.TryGetValue(texhash, out file))
                {
                    var ytd = gfc.GetFileUncached <YtdFile>(file);
                    while ((ytd != null) && (!ytd.Loaded))
                    {
                        Thread.Sleep(1);//kinda hacky
                        gfc.TryLoadEnqueue(ytd);
                    }
                    if (ytd?.TextureDict?.Textures?.data_items.Length > 0)
                    {
                        t = ytd.TextureDict.Textures.data_items[0];//should only be one in this dict
                    }
                }
            }

            CharacterCloth cc = null;

            if (Yld?.Dict != null)
            {
                Yld.Dict.TryGetValue(namehash, out cc);
            }
            if ((cc == null) && (ClothFilesDict != null))
            {
                RpfFileEntry file = null;
                if (ClothFilesDict.TryGetValue(namehash, out file))
                {
                    var yld = gfc.GetFileUncached <YldFile>(file);
                    while ((yld != null) && (!yld.Loaded))
                    {
                        Thread.Sleep(1);//kinda hacky
                        gfc.TryLoadEnqueue(yld);
                    }
                    if (yld?.ClothDictionary?.Clothes?.data_items?.Length > 0)
                    {
                        cc = yld.ClothDictionary.Clothes.data_items[0];//should only be one in this dict
                    }
                }
            }
            ClothInstance c = null;

            if (cc != null)
            {
                c = new ClothInstance();
                c.Init(cc, Skeleton);
            }

            Expression e = null;

            if (Yed?.ExprMap != null)
            {
                Yed.ExprMap.TryGetValue(namehash, out e);
            }


            if (d != null)
            {
                Drawables[index] = d.ShallowCopy() as Drawable;
            }
            if (t != null)
            {
                Textures[index] = t;
            }
            if (c != null)
            {
                Clothes[index] = c;
            }
            if (e != null)
            {
                Expressions[index] = e;
            }

            DrawableNames[index] = name;
        }