Exemple #1
0
        public IEnumerator LoadResources()
        {
            switch (m_resourceLoadingState)
            {
            case ResourceLoadingState.Loaded:
                break;

            case ResourceLoadingState.Loading:
                do
                {
                    yield return(null);
                }while (m_resourceLoadingState == ResourceLoadingState.Loading);
                break;

            default:
                throw new ArgumentOutOfRangeException();

            case ResourceLoadingState.None:
            {
                if (!FightSpellEffectFactory.isReady)
                {
                    break;
                }
                m_resourceLoadingState = ResourceLoadingState.Loading;
                int spellEffectReferenceCount = m_spellEffectData.Count;
                int count = ((Dictionary <SpellEffectKey, AssetReference>)m_spellEffectOverrideReferences).Count;
                int num   = spellEffectReferenceCount + count;
                AssetLoadRequest <SpellEffect>[] loadRequests = new AssetLoadRequest <SpellEffect> [num];
                IEnumerator[] spellEffectLoadRequests         = new IEnumerator[num];
                int           i;
                for (i = 0; i < spellEffectReferenceCount; i++)
                {
                    string spellEffect = m_spellEffectData[i].spellEffect;
                    if (spellEffect.Length > 0)
                    {
                        loadRequests[i] = AssetManager.LoadAssetAsync <SpellEffect>(spellEffect, "core/spells/effects");
                        continue;
                    }
                    Log.Warning($"Spell named '{this.get_displayName()}' has an unassigned spell effect at index {i}.", 118, "C:\\BuildAgents\\AgentB\\work\\cub_client_win64_develop\\client\\DofusCube.Unity\\Assets\\Core\\Code\\Data\\Spells\\SpellDefinition.cs");
                    loadRequests[i] = null;
                }
                foreach (AssetReference value in ((Dictionary <SpellEffectKey, AssetReference>)m_spellEffectOverrideReferences).Values)
                {
                    AssetReference current = value;
                    if (current.get_hasValue())
                    {
                        loadRequests[i] = current.LoadFromAssetBundleAsync <SpellEffect>("core/spells/effects");
                    }
                    else
                    {
                        loadRequests[i] = null;
                    }
                    i++;
                }
                yield return(EnumeratorUtility.ParallelRecursiveSafeExecution((IEnumerator[])loadRequests));

                SpellEffect[] spellEffects = new SpellEffect[spellEffectReferenceCount];
                for (i = 0; i < spellEffectReferenceCount; i++)
                {
                    AssetLoadRequest <SpellEffect> val = loadRequests[i];
                    if (val == null)
                    {
                        spellEffects[i] = null;
                        continue;
                    }
                    if (AssetManagerError.op_Implicit(val.get_error()) == 0)
                    {
                        spellEffectLoadRequests[i] = (spellEffects[i] = val.get_asset()).Load();
                        continue;
                    }
                    spellEffects[i] = null;
                    Log.Error($"Could not load spell effect for spell {this.get_name()}: {val.get_error()}", 159, "C:\\BuildAgents\\AgentB\\work\\cub_client_win64_develop\\client\\DofusCube.Unity\\Assets\\Core\\Code\\Data\\Spells\\SpellDefinition.cs");
                }
                Dictionary <SpellEffectKey, SpellEffect> spellEffectOverrides = new Dictionary <SpellEffectKey, SpellEffect>(((Dictionary <SpellEffectKey, AssetReference>)m_spellEffectOverrideReferences).Count, SpellEffectKeyComparer.instance);
                foreach (SpellEffectKey key in ((Dictionary <SpellEffectKey, AssetReference>)m_spellEffectOverrideReferences).Keys)
                {
                    AssetLoadRequest <SpellEffect> val2 = loadRequests[i];
                    if (val2 == null)
                    {
                        spellEffectOverrides.Add(key, null);
                    }
                    else if (AssetManagerError.op_Implicit(val2.get_error()) == 0)
                    {
                        SpellEffect asset = val2.get_asset();
                        spellEffectOverrides.Add(key, asset);
                        spellEffectLoadRequests[i] = asset.Load();
                    }
                    else
                    {
                        spellEffectOverrides.Add(key, null);
                        Log.Error($"Could not load spell effect override for key {key} for spell {this.get_name()}: {val2.get_error()}", 183, "C:\\BuildAgents\\AgentB\\work\\cub_client_win64_develop\\client\\DofusCube.Unity\\Assets\\Core\\Code\\Data\\Spells\\SpellDefinition.cs");
                    }
                    i++;
                }
                yield return(EnumeratorUtility.ParallelRecursiveImmediateSafeExecution(spellEffectLoadRequests));

                m_spellEffects         = spellEffects;
                m_spellEffectOverrides = spellEffectOverrides;
                m_resourceLoadingState = ResourceLoadingState.Loaded;
                FightSpellEffectFactory.NotifySpellDefinitionLoaded(this);
                break;
            }
            }
        }