Example #1
0
    private IEnumerator DoLoad(int npc_model_id, int layer, bool need_shadow, bool enable_light_probes, SHADER_TYPE shader_type, Action callback)
    {
        loadingQueue = new LoadingQueue(this);
        string     model_name = ResourceName.GetNPCModel(npc_model_id);
        LoadObject lo_model   = loadingQueue.LoadAndInstantiate(RESOURCE_CATEGORY.NPC_MODEL, model_name);
        string     anim_name  = ResourceName.GetNPCAnim(npc_model_id);
        LoadObject lo_anim    = loadingQueue.Load(RESOURCE_CATEGORY.NPC_ANIM, anim_name, new string[1]
        {
            anim_name + "Ctrl"
        }, false);

        if (loadingQueue.IsLoading())
        {
            yield return((object)loadingQueue.Wait());
        }
        model = lo_model.Realizes(this.get_transform(), layer);
        if (model != null)
        {
            head   = Utility.Find(model, "Head");
            facial = model.GetComponentInChildren <NPCFacial>();
            if (facial != null)
            {
                facial.animNode = Utility.Find(model, "Face");
            }
            animator = model.GetComponentInChildren <Animator>();
            if (lo_anim != null && animator != null)
            {
                animator.set_runtimeAnimatorController(lo_anim.loadedObjects[0].obj as RuntimeAnimatorController);
            }
        }
        PlayerLoader.SetLightProbes(model, enable_light_probes);
        renderers = model.GetComponentsInChildren <Renderer>();
        int j = 0;

        for (int i = renderers.Length; j < i; j++)
        {
            if (renderers[j] is SkinnedMeshRenderer)
            {
                (renderers[j] as SkinnedMeshRenderer).set_localBounds(BOUNDS);
            }
        }
        switch (shader_type)
        {
        case SHADER_TYPE.LIGHTWEIGHT:
            ShaderGlobal.ChangeWantLightweightShader(renderers);
            break;

        case SHADER_TYPE.UI:
            ShaderGlobal.ChangeWantUIShader(renderers);
            break;
        }
        if (need_shadow)
        {
            shadow = PlayerLoader.CreateShadow(this.get_transform(), true, -1, shader_type == SHADER_TYPE.LIGHTWEIGHT);
        }
        coroutine = null;
        callback?.Invoke();
    }
Example #2
0
    public static IEnumerator InitRoopEffect(LoadingQueue queue, Transform equipItemRoot, SHADER_TYPE shaderType = SHADER_TYPE.NORMAL)
    {
        EffectPlayProcessor processor = equipItemRoot.get_gameObject().GetComponentInChildren <EffectPlayProcessor>();

        if (processor != null && processor.effectSettings != null)
        {
            int j = 0;
            for (int len = processor.effectSettings.Length; j < len; j++)
            {
                if (!string.IsNullOrEmpty(processor.effectSettings[j].effectName))
                {
                    queue.CacheEffect(RESOURCE_CATEGORY.EFFECT_ACTION, processor.effectSettings[j].effectName);
                }
            }
        }
        yield return((object)queue.Wait());

        if (processor != null)
        {
            List <Transform> trans = processor.PlayEffect("InitRoop", null);
            if (trans != null)
            {
                for (int i = 0; i < trans.Count; i++)
                {
                    Utility.SetLayerWithChildren(trans[i], equipItemRoot.get_gameObject().get_layer());
                    if (shaderType != 0)
                    {
                        Renderer[] rs = trans[i].GetComponentsInChildren <Renderer>();
                        switch (shaderType)
                        {
                        case SHADER_TYPE.LIGHTWEIGHT:
                            ShaderGlobal.ChangeWantLightweightShader(rs);
                            break;

                        case SHADER_TYPE.UI:
                            ShaderGlobal.ChangeWantUIShader(rs);
                            break;
                        }
                    }
                }
            }
        }
    }
Example #3
0
    private IEnumerator DoLoad(int body_id, int anim_id, float scale, string base_effect, string base_effect_node, bool need_shadow, bool enable_light_probes, bool need_anim_event_res_cache, SHADER_TYPE shader_type, int layer, string foundation_name, bool need_stamp_effect, bool will_stock, OnCompleteLoad callback)
    {
        Enemy enemy = this.get_gameObject().GetComponent <Enemy>();

        if (enemy != null)
        {
            int id = enemy.id;
        }
        bodyID    = body_id;
        bodyScale = scale;
        bool is_boss = false;

        if (enemy != null)
        {
            is_boss = enemy.isBoss;
            if (enemy.controller != null)
            {
                enemy.controller.set_enabled(false);
            }
            if (enemy.packetReceiver != null)
            {
                enemy.packetReceiver.SetStopPacketUpdate(true);
            }
            enemy.OnLoadStart();
        }
        string    body_name = ResourceName.GetEnemyBody(body_id);
        string    mate_name = ResourceName.GetEnemyMaterial(body_id);
        string    anim_name = ResourceName.GetEnemyAnim(anim_id);
        Transform _this     = this.get_transform();

        isLoading = true;
        LoadingQueue load_queue = new LoadingQueue(this);
        LoadObject   lo_body    = load_queue.LoadAndInstantiate(RESOURCE_CATEGORY.ENEMY_MODEL, body_name);
        LoadObject   lo_mate    = (mate_name == null) ? null : load_queue.Load(RESOURCE_CATEGORY.ENEMY_MATERIAL, body_name, new string[1]
        {
            mate_name
        }, false);
        LoadObject lo_anim = load_queue.Load(RESOURCE_CATEGORY.ENEMY_ANIM, anim_name, new string[2]
        {
            anim_name + "Ctrl",
            anim_name + "Event"
        }, false);

        if (!string.IsNullOrEmpty(base_effect))
        {
            load_queue.CacheEffect(RESOURCE_CATEGORY.EFFECT_ACTION, base_effect);
        }
        LoadObject lo_foundation = null;

        if (!string.IsNullOrEmpty(foundation_name))
        {
            if (!MonoBehaviourSingleton <GlobalSettingsManager> .I.uiModelRendering.enableEnemyModelFoundationFromQuestStage)
            {
                foundation_name = "FST011";
            }
            lo_foundation = load_queue.LoadAndInstantiate(RESOURCE_CATEGORY.FOUNDATION_MODEL, foundation_name);
        }
        yield return((object)load_queue.Wait());

        body = lo_body.Realizes(_this, (layer != -1) ? layer : 11);
        if (layer == -1)
        {
            this.get_gameObject().set_layer(10);
        }
        body.set_localPosition(Vector3.get_zero());
        body.set_localRotation(Quaternion.get_identity());
        renderersBody = body.get_gameObject().GetComponentsInChildren <Renderer>();
        if (lo_mate != null && lo_mate.loadedObject != null && renderersBody.Length == 1)
        {
            Material mate = lo_mate.loadedObject as Material;
            if (mate != null)
            {
                renderersBody[0].set_sharedMaterial(mate);
            }
        }
        if (enemy != null)
        {
            enemy.body = body;
        }
        body.set_localScale(Vector3.Scale(body.get_localScale(), new Vector3(scale, scale, scale)));
        animator = body.get_gameObject().GetComponent <Animator>();
        if (animator != null && lo_anim.loadedObjects != null)
        {
            animator.set_runtimeAnimatorController(lo_anim.loadedObjects[0].obj);
            if (lo_anim.loadedObjects.Length >= 2 && lo_anim.loadedObjects[1] != null)
            {
                this.animEventData = (lo_anim.loadedObjects[1].obj as AnimEventData);
            }
            if (enemy != null)
            {
                body.get_gameObject().AddComponent <StageObjectProxy>().stageObject = enemy;
                enemy.animEventData = this.animEventData;
            }
        }
        if (!string.IsNullOrEmpty(base_effect))
        {
            string node_name = base_effect_node;
            if (string.IsNullOrEmpty(node_name))
            {
                node_name = "Root";
            }
            Transform node             = Utility.Find(body, node_name);
            Transform effect_transform = EffectManager.GetEffect(base_effect, node);
            if (effect_transform != null)
            {
                baseEffect = effect_transform;
                if (layer != -1)
                {
                    Utility.SetLayerWithChildren(effect_transform, layer);
                }
            }
        }
        if (shader_type == SHADER_TYPE.LIGHTWEIGHT)
        {
            ShaderGlobal.ChangeWantLightweightShader(renderersBody);
        }
        if (is_boss)
        {
            materialParamsList = new List <MaterialParams>();
            Shader.PropertyToID("_RimPower");
            Shader.PropertyToID("_RimWidth");
            Shader.PropertyToID("_Vanish_flag");
            Shader.PropertyToID("_Vanish_rate");
            Utility.MaterialForEach(renderersBody, delegate(Material material)
            {
                if (material != null)
                {
                    MaterialParams materialParams = new MaterialParams
                    {
                        material = material
                    };
                    if (materialParams.hasRimPower = material.HasProperty(((_003CDoLoad_003Ec__Iterator228) /*Error near IL_062d: stateMachine*/)._003CID_RIM_POWER_003E__16))
                    {
                        materialParams.defaultRimPower = material.GetFloat(((_003CDoLoad_003Ec__Iterator228) /*Error near IL_062d: stateMachine*/)._003CID_RIM_POWER_003E__16);
                    }
                    if (materialParams.hasRimWidth = material.HasProperty(((_003CDoLoad_003Ec__Iterator228) /*Error near IL_062d: stateMachine*/)._003CID_RIM_WIDTH_003E__17))
                    {
                        materialParams.defaultRimWidth = material.GetFloat(((_003CDoLoad_003Ec__Iterator228) /*Error near IL_062d: stateMachine*/)._003CID_RIM_WIDTH_003E__17);
                    }
                    materialParams.hasVanishFlag = material.HasProperty(((_003CDoLoad_003Ec__Iterator228) /*Error near IL_062d: stateMachine*/)._003CID_VANISH_FLAG_003E__18);
                    materialParams.hasVanishRate = material.HasProperty(((_003CDoLoad_003Ec__Iterator228) /*Error near IL_062d: stateMachine*/)._003CID_VANISH_RATE_003E__19);
                    ((_003CDoLoad_003Ec__Iterator228) /*Error near IL_062d: stateMachine*/)._003C_003Ef__this.materialParamsList.Add(materialParams);
                }
            });
        }
        int l = 0;

        for (int k = renderersBody.Length; l < k; l++)
        {
            renderersBody[l].set_useLightProbes(enable_light_probes);
        }
        EnemyParam param = body.get_gameObject().GetComponent <EnemyParam>();

        body.get_gameObject().SetActive(false);
        if (need_anim_event_res_cache && animator != null && lo_anim.loadedObjects != null && lo_anim.loadedObjects[1] != null)
        {
            AnimEventData tmpAnimEventData = lo_anim.loadedObjects[1].obj as AnimEventData;
            if (tmpAnimEventData != null)
            {
                if (enemy == null)
                {
                    load_queue.CacheAnimDataUseResource(tmpAnimEventData, null, null);
                }
                else
                {
                    LoadingQueue  loadingQueue  = load_queue;
                    AnimEventData animEventData = tmpAnimEventData;
                    Enemy         enemy2        = enemy;
                    loadingQueue.CacheAnimDataUseResource(animEventData, ((Character)enemy2).EffectNameAnalyzer, enemy.continusAtkEventDataList);
                }
                PreSetAnimationEventDataParamToEnemy(tmpAnimEventData, enemy);
            }
        }
        AnimEventData.ResidentEffectData[] residentEffectList = null;
        if (this.animEventData != null)
        {
            residentEffectList = this.animEventData.residentEffectDataList;
            if (residentEffectList != null)
            {
                int numEffect3 = residentEffectList.Length;
                for (int ef3 = 0; ef3 < numEffect3; ef3++)
                {
                    if (!string.IsNullOrEmpty(residentEffectList[ef3].effectName))
                    {
                        load_queue.CacheEffect(RESOURCE_CATEGORY.EFFECT_ACTION, residentEffectList[ef3].effectName);
                    }
                }
            }
        }
        if (param != null)
        {
            if (enemy != null || need_stamp_effect)
            {
                StageObject.StampInfo[] stampInfos = param.stampInfos;
                foreach (StageObject.StampInfo info4 in stampInfos)
                {
                    load_queue.CacheEffect(RESOURCE_CATEGORY.EFFECT_ACTION, info4.effectName);
                }
            }
            if (param.isHide)
            {
                FieldMapTable.GatherPointViewTableData viewData = Singleton <FieldMapTable> .I.GetGatherPointViewData(param.gatherPointViewId);

                if (viewData != null)
                {
                    if (!string.IsNullOrEmpty(viewData.targetEffectName))
                    {
                        load_queue.CacheEffect(RESOURCE_CATEGORY.EFFECT_ACTION, viewData.targetEffectName);
                    }
                    if (!string.IsNullOrEmpty(viewData.gatherEffectName))
                    {
                        load_queue.CacheEffect(RESOURCE_CATEGORY.EFFECT_ACTION, viewData.gatherEffectName);
                    }
                }
            }
            SystemEffectSetting sysEffectSetting2 = param.residentEffectSetting;
            if (sysEffectSetting2 != null)
            {
                SystemEffectSetting.Data[] effectDataList = sysEffectSetting2.effectDataList;
                if (effectDataList != null)
                {
                    int numEffect2 = effectDataList.Length;
                    for (int ef2 = 0; ef2 < numEffect2; ef2++)
                    {
                        if (!string.IsNullOrEmpty(effectDataList[ef2].effectName))
                        {
                            load_queue.CacheEffect(RESOURCE_CATEGORY.EFFECT_ACTION, effectDataList[ef2].effectName);
                        }
                    }
                }
            }
        }
        if (load_queue.IsLoading())
        {
            yield return((object)load_queue.Wait());
        }
        if (enemy != null)
        {
            if (param != null)
            {
                EnemyTable.EnemyData data           = enemy.enemyTableData;
                AttackHitInfo[]      attackHitInfos = param.attackHitInfos;
                foreach (AttackHitInfo temp_info in attackHitInfos)
                {
                    AttackHitInfo info = temp_info;
                    if (!string.IsNullOrEmpty(data.convertRegionKey))
                    {
                        string          convert_name          = info.name + "_" + data.convertRegionKey;
                        AttackHitInfo[] convertAttackHitInfos = param.convertAttackHitInfos;
                        foreach (AttackHitInfo convert_info in convertAttackHitInfos)
                        {
                            if (convert_info.name == convert_name)
                            {
                                info = convert_info;
                                break;
                            }
                        }
                    }
                    if (info.hitSEID != 0)
                    {
                        load_queue.CacheSE(info.hitSEID, null);
                    }
                    load_queue.CacheEffect(RESOURCE_CATEGORY.EFFECT_ACTION, info.hitEffectName);
                    load_queue.CacheEffect(RESOURCE_CATEGORY.EFFECT_ACTION, info.remainEffectName);
                    load_queue.CacheBulletDataUseResource(info.bulletData, null);
                    RestraintInfo restInfo = temp_info.restraintInfo;
                    if (restInfo.enable && !string.IsNullOrEmpty(restInfo.effectName))
                    {
                        load_queue.CacheEffect(RESOURCE_CATEGORY.EFFECT_ACTION, restInfo.effectName);
                        load_queue.CacheEffect(RESOURCE_CATEGORY.EFFECT_ACTION, "ef_btl_target_flick");
                        if (temp_info.toPlayer.reactionType != 0)
                        {
                            Log.Error(LOG.INGAME, "Can't use reactionType with RestraintInfo!! " + temp_info.name);
                        }
                    }
                    GrabInfo grabInfo = temp_info.grabInfo;
                    if (grabInfo != null && grabInfo.enable && temp_info.toPlayer.reactionType != 0)
                    {
                        Log.Error(LOG.INGAME, "Can't use reactionType with GrabInfo!! " + temp_info.name);
                    }
                    InkSplashInfo inkSplashInfo = temp_info.inkSplashInfo;
                    if (inkSplashInfo != null && inkSplashInfo.duration > 0f)
                    {
                        load_queue.CacheEffect(RESOURCE_CATEGORY.EFFECT_ACTION, "ef_btl_pl_blind_01");
                        load_queue.CacheEffect(RESOURCE_CATEGORY.EFFECT_ACTION, "ef_btl_pl_blind_02");
                        load_queue.CacheEffect(RESOURCE_CATEGORY.EFFECT_ACTION, "ef_btl_target_flick");
                    }
                }
                AttackContinuationInfo[] attackContinuationInfos = param.attackContinuationInfos;
                foreach (AttackContinuationInfo temp_info2 in attackContinuationInfos)
                {
                    AttackContinuationInfo info2 = temp_info2;
                    if (!string.IsNullOrEmpty(data.convertRegionKey))
                    {
                        string convert_name2 = info2.name + "_" + data.convertRegionKey;
                        AttackContinuationInfo[] convertAttackContinuationInfos = param.convertAttackContinuationInfos;
                        foreach (AttackContinuationInfo convert_info2 in convertAttackContinuationInfos)
                        {
                            if (convert_info2.name == convert_name2)
                            {
                                info2 = convert_info2;
                                break;
                            }
                        }
                    }
                    load_queue.CacheBulletDataUseResource(info2.bulletData, null);
                }
                Enemy.RegionInfo[] regionInfos = param.regionInfos;
                foreach (Enemy.RegionInfo temp_info3 in regionInfos)
                {
                    Enemy.RegionInfo info3 = temp_info3;
                    if (!string.IsNullOrEmpty(data.convertRegionKey))
                    {
                        string             convert_name3      = info3.name + "_" + data.convertRegionKey;
                        Enemy.RegionInfo[] convertRegionInfos = param.convertRegionInfos;
                        foreach (Enemy.RegionInfo convert_info3 in convertRegionInfos)
                        {
                            if (convert_info3.name == convert_name3)
                            {
                                info3 = convert_info3;
                                break;
                            }
                        }
                    }
                    load_queue.CacheEffect(RESOURCE_CATEGORY.EFFECT_ACTION, info3.breakEffect.effectName);
                }
                if (Singleton <EnemyHitMaterialTable> .IsValid())
                {
                    int j = 0;
                    for (int len2 = param.regionInfos.Length; j < len2 + 1; j++)
                    {
                        string hit_material_name = (j >= len2) ? param.baseHitMaterialName : param.regionInfos[j].hitMaterialName;
                        if (!string.IsNullOrEmpty(hit_material_name))
                        {
                            EnemyHitMaterialTable.MaterialData check_data = Singleton <EnemyHitMaterialTable> .I.GetData(hit_material_name);

                            if (check_data != null)
                            {
                                load_queue.CacheEffect(RESOURCE_CATEGORY.EFFECT_ACTION, check_data.addEffectName);
                                int[] typeSEIDs = check_data.typeSEIDs;
                                foreach (int type_se_id in typeSEIDs)
                                {
                                    if (type_se_id != 0)
                                    {
                                        load_queue.CacheSE(type_se_id, null);
                                    }
                                }
                            }
                        }
                    }
                }
            }
            if (MonoBehaviourSingleton <InGameSettingsManager> .IsValid())
            {
                load_queue.CacheEffect(RESOURCE_CATEGORY.EFFECT_ACTION, MonoBehaviourSingleton <GlobalSettingsManager> .I.linkResources.enemyParalyzeHitEffectName);
                load_queue.CacheEffect(RESOURCE_CATEGORY.EFFECT_ACTION, MonoBehaviourSingleton <GlobalSettingsManager> .I.linkResources.enemyPoisonHitEffectName);
            }
            load_queue.CacheEffect(RESOURCE_CATEGORY.EFFECT_ACTION, "ef_btl_enm_shock_01");
            load_queue.CacheEffect(RESOURCE_CATEGORY.EFFECT_ACTION, "ef_btl_enm_fire_01");
            load_queue.CacheEffect(RESOURCE_CATEGORY.EFFECT_ACTION, "ef_btl_pl_movedown_01");
            EffectPlayProcessor processor = body.get_gameObject().GetComponent <EffectPlayProcessor>();
            if (processor != null && processor.effectSettings != null)
            {
                enemy.effectPlayProcessor = processor;
                int i = 0;
                for (int len = processor.effectSettings.Length; i < len; i++)
                {
                    if (!string.IsNullOrEmpty(processor.effectSettings[i].effectName))
                    {
                        load_queue.CacheEffect(RESOURCE_CATEGORY.EFFECT_ACTION, processor.effectSettings[i].effectName);
                    }
                }
            }
            if (load_queue.IsLoading())
            {
                yield return((object)load_queue.Wait());
            }
        }
        body.get_gameObject().SetActive(true);
        if (residentEffectList != null)
        {
            int numEffect = residentEffectList.Length;
            for (int ef = 0; ef < numEffect; ef++)
            {
                AnimEventData.ResidentEffectData effectData = residentEffectList[ef];
                if (!string.IsNullOrEmpty(effectData.effectName) && !string.IsNullOrEmpty(effectData.linkNodeName))
                {
                    Transform parentTrans = Utility.Find(body.get_transform(), effectData.linkNodeName);
                    if (parentTrans == null)
                    {
                        parentTrans = body.get_transform();
                    }
                    Transform effectTrans = EffectManager.GetEffect(effectData.effectName, parentTrans);
                    if (effectTrans != null)
                    {
                        if (layer != -1)
                        {
                            Utility.SetLayerWithChildren(effectTrans, layer);
                        }
                        Vector3 basisScale = effectTrans.get_localScale();
                        effectTrans.set_localScale(basisScale * effectData.scale);
                        effectTrans.set_localPosition(effectData.offsetPos);
                        effectTrans.set_localRotation(Quaternion.Euler(effectData.offsetRot));
                        ResidentEffectObject residentEffect = effectTrans.get_gameObject().AddComponent <ResidentEffectObject>();
                        residentEffect.Initialize(effectData);
                        if (enemy != null)
                        {
                            enemy.RegisterResidentEffect(residentEffect);
                        }
                    }
                }
            }
        }
        if (param != null)
        {
            SystemEffectSetting sysEffectSetting = param.residentEffectSetting;
            SysEffectCreate(enemy, layer, sysEffectSetting);
        }
        if (need_shadow && param != null && param.shadowSize > 0f)
        {
            shadow = MonoBehaviourSingleton <GlobalSettingsManager> .I.linkResources.CreateShadow(param.shadowSize, param.bodyRadius, bodyScale, true, _this, shader_type == SHADER_TYPE.LIGHTWEIGHT);
        }
        if (enemy != null)
        {
            if (param != null)
            {
                param.SetParam(enemy);
                Object.DestroyImmediate(param);
            }
            if (enemy.controller != null)
            {
                enemy.controller.set_enabled(true);
            }
            enemy.willStock = will_stock;
            enemy.OnLoadComplete();
            if (enemy.packetReceiver != null)
            {
                enemy.packetReceiver.SetStopPacketUpdate(false);
            }
        }
        callback?.Invoke(enemy);
        if (lo_foundation != null)
        {
            foundation = lo_foundation.Realizes(_this, layer);
            foundation.SetParent(_this.get_parent(), true);
        }
        isLoading = false;
    }