public static IEnumerator LoadTimelineResources(TimelineAsset timelineAsset)
        {
            if (!(null == timelineAsset))
            {
                int outputTrackCount = timelineAsset.get_outputTrackCount();
                if (outputTrackCount != 0)
                {
                    List <IEnumerator> loadRoutine = ListPool <IEnumerator> .Get(outputTrackCount);

                    foreach (TrackAsset outputTrack in timelineAsset.GetOutputTracks())
                    {
                        foreach (TimelineClip clip in outputTrack.GetClips())
                        {
                            ITimelineResourcesProvider timelineResourcesProvider = clip.get_asset() as ITimelineResourcesProvider;
                            if (timelineResourcesProvider != null)
                            {
                                loadRoutine.Add(timelineResourcesProvider.LoadResources());
                            }
                        }
                    }
                    yield return(EnumeratorUtility.ParallelRecursiveImmediateSafeExecution(loadRoutine.ToArray()));

                    ListPool <IEnumerator> .Release(loadRoutine);
                }
            }
        }
        public static IEnumerator LoadAll <T>(ICollection <T> effects) where T : ScriptableEffect
        {
            int count = effects.Count;

            switch (count)
            {
            case 0:
                yield break;

            case 1:
                foreach (T effect in effects)
                {
                    yield return(effect.Load());
                }
                yield break;
            }
            IEnumerator[] array = new IEnumerator[count];
            int           num   = 0;

            foreach (T effect2 in effects)
            {
                array[num] = effect2.Load();
                num++;
            }
            yield return(EnumeratorUtility.ParallelRecursiveImmediateSafeExecution(array));
        }
Exemple #3
0
        public void CollectAsyncTest()
        {
            var testAsync = EnumeratorUtility.CollectAsync(DoTest_2());

            Assert.IsNotNull(testAsync);

            var testEnum = EnumeratorUtility.Collect(testAsync,
                                                     state =>
            {
                if (state == null)
                {
                    return;
                }
                Console.WriteLine(state);
            },
                                                     () =>
            {
                Console.WriteLine("Conplete");
            });

            Assert.IsNotNull(testEnum);
            while (testEnum.MoveNext())
            {
            }
        }
 public override IEnumerator UpdateView(FightStatus fightStatus)
 {
     if (fightStatus.TryGetEntity(concernedEntity, out PlayerStatus entityStatus))
     {
         AbstractPlayerUIRework view = entityStatus.view;
         if (null != view)
         {
             int           count = moves.Count;
             IEnumerator[] array = new IEnumerator[count];
             for (int i = 0; i < count; i++)
             {
                 SpellMovement spellMovement = moves[i];
                 if (spellMovement.From == Ankama.Cube.Protocols.FightCommonProtocol.SpellMovementZone.Hand)
                 {
                     int spellInstanceId = spellMovement.Spell.SpellInstanceId;
                     array[i] = view.RemoveSpell(spellInstanceId, i);
                 }
                 else if (spellMovement.To == Ankama.Cube.Protocols.FightCommonProtocol.SpellMovementZone.Hand)
                 {
                     array[i] = view.AddSpell(spellMovement.Spell, i);
                 }
             }
             yield return(EnumeratorUtility.ParallelRecursiveImmediateSafeExecution(array));
         }
     }
     else
     {
         Log.Error(FightEventErrors.PlayerNotFound(concernedEntity), 112, "C:\\BuildAgents\\AgentB\\work\\cub_client_win64_develop\\client\\DofusCube.Unity\\Assets\\Core\\Code\\Fight\\Events\\SpellsMovedEvent.cs");
     }
     FightLogicExecutor.FireUpdateView(fightStatus.fightId, EventCategory.SpellsMoved);
 }
Exemple #5
0
        protected IEnumerator Load(params AudioReferenceWithParameters[] audioReferences)
        {
            int num       = audioReferences.Length;
            int bankCount = 0;

            if (num == 0)
            {
                m_initializationState = InitializationState.Loaded;
                yield break;
            }
            string[] array = new string[num];
            for (int i = 0; i < num; i++)
            {
                AudioReferenceWithParameters val = audioReferences[i];
                if (!val.get_isValid() || !AudioManager.TryGetDefaultBankName(AudioReferenceWithParameters.op_Implicit(val), out string bankName))
                {
                    continue;
                }
                int num2 = 0;
                while (true)
                {
                    if (num2 < bankCount)
                    {
                        if (bankName.Equals(array[num2]))
                        {
                            break;
                        }
                        num2++;
                        continue;
                    }
                    array[bankCount] = bankName;
                    int num3 = bankCount + 1;
                    bankCount = num3;
                    break;
                }
            }
            if (bankCount == 0)
            {
                m_initializationState = InitializationState.Error;
                yield break;
            }
            AudioBankLoadRequest[] bankLoadRequests = new AudioBankLoadRequest[bankCount];
            for (int j = 0; j < bankCount; j++)
            {
                bankLoadRequests[j] = AudioManager.LoadBankAsync(array[j]);
            }
            m_bankLoadRequests    = bankLoadRequests;
            m_initializationState = InitializationState.Loading;
            yield return(EnumeratorUtility.ParallelRecursiveImmediateSafeExecution((IEnumerator[])bankLoadRequests));

            for (int k = 0; k < bankCount; k++)
            {
                if (AssetManagerError.op_Implicit(bankLoadRequests[k].error) == 0)
                {
                    m_initializationState = InitializationState.Loaded;
                    yield break;
                }
            }
            m_initializationState = InitializationState.Error;
        }
 public override IEnumerator UpdateView(FightStatus fightStatus)
 {
     if (fightStatus.TryGetEntity(concernedEntity, out PlayerStatus entityStatus))
     {
         AbstractPlayerUIRework view = entityStatus.view;
         if (!(null != view))
         {
             yield break;
         }
         int count = companionDefId.Count;
         if (count > 0)
         {
             IEnumerator[] array = new IEnumerator[count];
             for (int i = 0; i < count; i++)
             {
                 array[i] = view.AddCompanion(companionDefId[i], levels[i], i);
             }
             yield return(EnumeratorUtility.ParallelRecursiveImmediateSafeExecution(array));
         }
     }
     else
     {
         Log.Error(FightEventErrors.PlayerNotFound(concernedEntity), 59, "C:\\BuildAgents\\AgentB\\work\\cub_client_win64_develop\\client\\DofusCube.Unity\\Assets\\Core\\Code\\Fight\\Events\\CompanionAddedInReserveEvent.cs");
     }
 }
        public IEnumerator BuildGodList()
        {
            List <string> list = new List <string>();

            m_playableGods.Clear();
            God god = (PlayerData.instance == null) ? God.Iop : PlayerData.instance.god;
            int num = -1;

            foreach (GodDefinition value in RuntimeData.godDefinitions.Values)
            {
                if (value.playable)
                {
                    m_playableGods.Add(value);
                    list.Add(RuntimeData.FormattedText(value.i18nNameId));
                }
            }
            m_playableGods.Sort(new GodComparer());
            int num2 = 0;

            foreach (GodDefinition playableGod in m_playableGods)
            {
                if (playableGod.god == god)
                {
                    num = num2;
                }
                num2++;
            }
            if (m_ribbonItems == null)
            {
                m_ribbonItems = new List <GodSelectionRibbonItem>();
            }
            IEnumerator[] array = new IEnumerator[m_playableGods.Count];
            for (int i = 0; i < m_playableGods.Count; i++)
            {
                GodDefinition          definition = m_playableGods[i];
                GodSelectionRibbonItem godSelectionRibbonItem;
                if (m_ribbonItems.Count > i)
                {
                    godSelectionRibbonItem = m_ribbonItems[i];
                }
                else
                {
                    godSelectionRibbonItem = Object.Instantiate <GodSelectionRibbonItem>(m_godUiPrefab, m_godUiPrefab.get_transform().get_parent());
                    m_ribbonItems.Add(godSelectionRibbonItem);
                }
                godSelectionRibbonItem.get_gameObject().SetActive(true);
                godSelectionRibbonItem.Initialise(this, definition);
                array[i] = godSelectionRibbonItem.GetLoadingRoutine();
                if (i == num)
                {
                    godSelectionRibbonItem.ForceSelect();
                }
                SetRibbonItemScale(godSelectionRibbonItem);
            }
            yield return(EnumeratorUtility.ParallelExecution(array));

            m_godUiPrefab.get_gameObject().SetActive(false);
        }
Exemple #8
0
            private void SendFightEventGroupToExecution(FightStatus activeFightStatus)
            {
                int count = s_eventGroupBuffer.Count;

                if (count == 1)
                {
                    FightEvent fightEvent = s_eventGroupBuffer[0];
                    try
                    {
                        if (fightEvent.SynchronizeExecution())
                        {
                            Execute(SetupSynchronizationBarrier());
                            IEnumerator enumerator = fightEvent.UpdateView(activeFightStatus);
                            if (enumerator != null)
                            {
                                Execute(enumerator);
                            }
                            Execute(ReleaseSynchronizationBarrier());
                        }
                        else
                        {
                            IEnumerator enumerator2 = fightEvent.UpdateView(activeFightStatus);
                            if (enumerator2 != null)
                            {
                                Execute(enumerator2);
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        Log.Error($"Exception occured while event {fightEvent.eventType} #{fightEvent.eventId} updated fight view.", 255, "C:\\BuildAgents\\AgentB\\work\\cub_client_win64_develop\\client\\DofusCube.Unity\\Assets\\Core\\Code\\Fight\\FightLogicExecutor.Instance.cs");
                        Debug.LogException(ex);
                    }
                }
                else
                {
                    IEnumerator[] array = new IEnumerator[count];
                    for (int i = 0; i < count; i++)
                    {
                        FightEvent fightEvent2 = s_eventGroupBuffer[i];
                        try
                        {
                            array[i] = fightEvent2.UpdateView(activeFightStatus);
                        }
                        catch (Exception ex2)
                        {
                            Log.Error($"Exception occured while event {fightEvent2.eventType} #{fightEvent2.eventId} updated fight view.", 273, "C:\\BuildAgents\\AgentB\\work\\cub_client_win64_develop\\client\\DofusCube.Unity\\Assets\\Core\\Code\\Fight\\FightLogicExecutor.Instance.cs");
                            Debug.LogException(ex2);
                        }
                    }
                    IEnumerator action = EnumeratorUtility.ParallelRecursiveImmediateExecution(array);
                    Execute(action);
                }
                s_eventGroupBuffer.Clear();
            }
Exemple #9
0
        public IEnumerator LoadTimelineResources()
        {
            m_referenceCounter++;
            switch (m_timelineResourcesLoadState)
            {
            case TimelineResourceLoadingState.Loaded:
            case TimelineResourceLoadingState.Failed:
                break;

            case TimelineResourceLoadingState.Loading:
                while (m_timelineResourcesLoadState == TimelineResourceLoadingState.Loading)
                {
                    yield return(null);
                }
                break;

            default:
                throw new ArgumentOutOfRangeException();

            case TimelineResourceLoadingState.None:
            {
                m_timelineResourcesLoadState = TimelineResourceLoadingState.Loading;
                List <IEnumerator> loadRoutines = ListPool <IEnumerator> .Get(4);

                try
                {
                    m_timelineAssetDictionary.GatherLoadRoutines(loadRoutines);
                    if (null != m_spawnEffect)
                    {
                        loadRoutines.Add(m_spawnEffect.Load());
                    }
                    if (null != m_deathEffect)
                    {
                        loadRoutines.Add(m_deathEffect.Load());
                    }
                    GatherAdditionalResourcesLoadingRoutines(loadRoutines);
                }
                catch (Exception ex)
                {
                    Debug.LogException(ex);
                    m_timelineResourcesLoadState = TimelineResourceLoadingState.Failed;
                }
                yield return(EnumeratorUtility.ParallelRecursiveImmediateSafeExecution(loadRoutines.ToArray()));

                ListPool <IEnumerator> .Release(loadRoutines);

                m_timelineResourcesLoadState = TimelineResourceLoadingState.Loaded;
                break;
            }
            }
        }
Exemple #10
0
        public void MoveNextBoth()
        {
            int lengthComparison;

            using (var x = Enumerable.Empty <int>().GetEnumerator())
                using (var y = Enumerable.Empty <int>().GetEnumerator())
                {
                    Assert.IsFalse(EnumeratorUtility.MoveNextBoth(x, y, out lengthComparison));
                    Assert.AreEqual(0, lengthComparison);
                }

            using (var x = Enumerable.Empty <int>().GetEnumerator())
                using (var y = EnumerableUtility.Yield(42).GetEnumerator())
                {
                    Assert.IsFalse(EnumeratorUtility.MoveNextBoth(x, y, out lengthComparison));
                    Assert.AreEqual(-1, Math.Sign(lengthComparison));
                }

            using (var x = EnumerableUtility.Yield(42).GetEnumerator())
                using (var y = Enumerable.Empty <int>().GetEnumerator())
                {
                    Assert.IsFalse(EnumeratorUtility.MoveNextBoth(x, y, out lengthComparison));
                    Assert.AreEqual(1, Math.Sign(lengthComparison));
                }

            using (var x = EnumerableUtility.Yield(42).GetEnumerator())
                using (var y = EnumerableUtility.Yield(55).GetEnumerator())
                {
                    Assert.IsTrue(EnumeratorUtility.MoveNextBoth(x, y, out lengthComparison));
                    Assert.AreEqual(0, lengthComparison);
                    Assert.IsFalse(EnumeratorUtility.MoveNextBoth(x, y, out lengthComparison));
                    Assert.AreEqual(0, lengthComparison);
                }

            using (var x = EnumerableUtility.Yield(42, 45, 48, 49).GetEnumerator())
                using (var y = EnumerableUtility.Yield(55, 56, 57, 58, 59).GetEnumerator())
                {
                    for (int i = 0; i < 4; i++)
                    {
                        Assert.IsTrue(EnumeratorUtility.MoveNextBoth(x, y, out lengthComparison));
                        Assert.AreEqual(0, lengthComparison);
                    }

                    Assert.IsFalse(EnumeratorUtility.MoveNextBoth(x, y, out lengthComparison));
                    Assert.AreEqual(-1, Math.Sign(lengthComparison));
                }
        }
Exemple #11
0
        public void CollectTest1()
        {
            var testEnum = EnumeratorUtility.Collect(
                new IEnumerator[] { DoTest_0(), DoTest_1() },
                state =>
            {
                if (state == null)
                {
                    return;
                }
                Console.WriteLine(state);
            },
                () =>
            {
                Console.WriteLine("Conplete");
            });

            Assert.IsNotNull(testEnum);
            while (testEnum.MoveNext())
            {
            }
        }
        private static IEnumerator PreloadEffectAssets <K, V>(SerializableDictionaryLogic <K, AssetReference> effects, Dictionary <K, V> effectCache, string bundleName) where V : ScriptableEffect
        {
            int count = ((Dictionary <K, AssetReference>)effects).Count;

            if (count != 0)
            {
                AssetLoadRequest <V>[] loadRequests = new AssetLoadRequest <V> [count];
                int num = 0;
                foreach (AssetReference value in ((Dictionary <K, AssetReference>)effects).Values)
                {
                    AssetReference current = value;
                    if (current.get_hasValue())
                    {
                        loadRequests[num] = current.LoadFromAssetBundleAsync <V>(bundleName);
                    }
                    num++;
                }
                yield return(EnumeratorUtility.ParallelRecursiveImmediateExecution((IEnumerator[])loadRequests));

                num = 0;
                foreach (K key in ((Dictionary <K, AssetReference>)effects).Keys)
                {
                    AssetLoadRequest <V> val = loadRequests[num];
                    num++;
                    if (val != null)
                    {
                        if (AssetManagerError.op_Implicit(val.get_error()) != 0)
                        {
                            Log.Error($"Failed to load effect for '{key}': {val.get_error()}", 608, "C:\\BuildAgents\\AgentB\\work\\cub_client_win64_develop\\client\\DofusCube.Unity\\Assets\\Core\\Code\\Fight\\FightSpellEffectFactory.cs");
                        }
                        else
                        {
                            effectCache.Add(key, val.get_asset());
                        }
                    }
                }
            }
        }
Exemple #13
0
        public override IEnumerator UpdateView(FightStatus fightStatus)
        {
            int      positionCount = positions.Count;
            FightMap current       = FightMap.current;

            if (null != current)
            {
                IEnumerator[] array = new IEnumerator[positionCount];
                if (addWarning)
                {
                    for (int i = 0; i < positionCount; i++)
                    {
                        CellCoord cellCoord = positions[i];
                        Direction direction = (Direction)directions[i];
                        array[i] = current.AddMonsterSpawnCell(cellCoord.X, cellCoord.Y, direction);
                    }
                }
                else
                {
                    for (int j = 0; j < positionCount; j++)
                    {
                        CellCoord cellCoord2 = positions[j];
                        array[j] = current.RemoveMonsterSpawnCell(cellCoord2.X, cellCoord2.Y);
                    }
                }
                yield return(EnumeratorUtility.ParallelRecursiveImmediateSafeExecution(array));
            }
            for (int k = 0; k < positionCount; k++)
            {
                Vector2Int       position = (Vector2Int)positions[k];
                ICharacterObject characterObject;
                if (fightStatus.TryGetEntityAt(position, out ICharacterEntity character) && (characterObject = (character.view as ICharacterObject)) != null)
                {
                    characterObject.CheckParentCellIndicator();
                }
            }
        }
        /// <summary>
        /// Compares two sequences of elements and returns a value indicating whether one is less than, equal to,
        /// or greater than the other.
        /// </summary>
        /// <param name="x">The first sequence of elements to compare.</param>
        /// <param name="y">The second sequence of elements to compare.</param>
        /// <returns>
        /// A signed integer that indicates the relative values of <paramref name="x"/> and <paramref name="y"/>,
        /// as shown in the following table:
        /// <list type="table">
        /// <listheader>
        /// <term>Value</term>
        /// <term>Meaning</term>
        /// </listheader>
        /// <item>
        /// <term>Less than zero</term>
        /// <term><paramref name="x"/> is less than <paramref name="y"/>.</term>
        /// </item>
        /// <item>
        /// <term>Zero</term>
        /// <term><paramref name="x"/> is equal to <paramref name="y"/>.</term>
        /// </item>
        /// <item>
        /// <term>Greater than zero</term>
        /// <term><paramref name="x"/> is greater than <paramref name="y"/>.</term>
        /// </item>
        /// </list>
        /// </returns>
        protected override int CompareNonNull(IEnumerable <TElement> x, IEnumerable <TElement> y)
        {
            // Optimization for in-memory collections:
            // If the current sequence comparison is Shortlex or SameLength,
            // then attempt to perform a length comparison without enumerating the sequences.
            if (_lengthDominated)
            {
                int xCount, yCount;
                if (x.TryFastCount(out xCount) &&
                    y.TryFastCount(out yCount))
                {
                    int countComparison = xCount.CompareTo(yCount);
                    if (countComparison != 0)
                    {
                        // Shortlex returns immediately for sequences of different lengths,
                        // whilst SameLength throws immediately for such sequences.
                        if (_comparisonType == SequenceComparison.Shortlex)
                        {
                            return(countComparison);
                        }
                        if (_comparisonType == SequenceComparison.SameLength)
                        {
                            throw new ArgumentException("The sequences to be compared do not have the same number of elements.");
                        }
                    }
                }
            }

            // For an example of how to use enumerators, refer to the source code for the Enumerable.SequenceEqual method.
            // http://referencesource.microsoft.com/#System.Core/System/Linq/Enumerable.cs,9bdd6ef7ba6a5615

            // Get enumerators to iterate through both sequences in sync.
            using (IEnumerator <TElement> xEnumerator = x.GetEnumerator())
                using (IEnumerator <TElement> yEnumerator = y.GetEnumerator())
                {
                    // Advance both enumerators to their next element, until at least one passes the end of its sequence.
                    int lengthComparison;
                    while (EnumeratorUtility.MoveNextBoth(xEnumerator, yEnumerator, out lengthComparison))
                    {
                        // Compare the current pair of elements across the two sequences,
                        // seeking element inequality.
                        int elementComparison = _elementComparer.Compare(xEnumerator.Current, yEnumerator.Current);
                        if (elementComparison != 0)
                        {
                            // If the current sequence comparison is Shortlex or SameLength,
                            // then length inequality needs to be given precedence over element inequality.
                            if (_lengthDominated)
                            {
                                // Advance both enumerators until at least one passes the end of its sequence.
                                while (EnumeratorUtility.MoveNextBoth(xEnumerator, yEnumerator, out lengthComparison))
                                {
                                    ;
                                }

                                // If one sequence was shorter than the other, then use the length comparison result.
                                // Such logic is implemented after the outer while loop.
                                if (lengthComparison != 0)
                                {
                                    break;
                                }
                            }

                            // If the current sequence comparison is Lexicographical,
                            // or the sequences have been found to share the same length,
                            // then return the non-zero element comparison result.
                            return(elementComparison);
                        }
                    }

                    // This point is only reached if at least one sequence ended without finding any unequal pair of elements;
                    // or an unequal pair of elements was found, but the unequal lengths of the sequences dominates the result.

                    // If the current sequence comparison is SameLength,
                    // then throw exception for sequences of different lengths.
                    if (lengthComparison != 0 && _comparisonType == SequenceComparison.SameLength)
                    {
                        throw new ArgumentException("The sequences to be compared do not have the same number of elements.");
                    }

                    // Return the length comparison result.
                    return(lengthComparison);
                }
        }
        public override IEnumerator UpdateView(FightStatus fightStatus)
        {
            if (fightStatus.TryGetEntity(concernedEntity, out PlayerStatus playerStatus))
            {
                if (playerStatus.TryGetSpell(spellInstanceId, out SpellStatus spellStatus))
                {
                    SpellDefinition definition = spellStatus.definition;
                    if (!(null != definition))
                    {
                        yield break;
                    }
                    yield return(definition.LoadResources());

                    ICastTargetDefinition castTarget        = definition.castTarget;
                    CastTargetContext     castTargetContext = castTarget.CreateCastTargetContext(fightStatus, concernedEntity, DynamicValueHolderType.Spell, spellDefId, spellLevel, 0);
                    int count = targets.Count;
                    for (int j = 0; j < count; j++)
                    {
                        castTargetContext.SelectTarget(targets[j].ToTarget(fightStatus));
                    }
                    if (count > 0 && !playerStatus.isLocalPlayer)
                    {
                        CellObject targetedCell = GetTargetedCell(fightStatus, targets[0]);
                        yield return(FightUIRework.ShowPlayingSpell(spellStatus, targetedCell));
                    }
                    List <SpellEffectInstantiationData> spellEffectData = (List <SpellEffectInstantiationData>)definition.spellEffectData;
                    int spellEffectCount = spellEffectData.Count;
                    if (spellEffectCount > 0)
                    {
                        List <IEnumerator> routineList = ListPool <IEnumerator> .Get();

                        int num;
                        for (int i = 0; i < spellEffectCount; i = num)
                        {
                            SpellEffect spellEffect = definition.GetSpellEffect(i);
                            if (!(null == spellEffect))
                            {
                                SpellEffectInstantiationData spellEffectInstantiationData = spellEffectData[i];
                                spellEffectInstantiationData.PreComputeDelayOverDistance(castTargetContext);
                                foreach (Vector2Int item3 in spellEffectInstantiationData.EnumerateInstantiationPositions(castTargetContext))
                                {
                                    IEnumerator item = FightSpellEffectFactory.PlaySpellEffect(spellEffect, item3, spellEffectInstantiationData, castTargetContext);
                                    routineList.Add(item);
                                }
                                foreach (IsoObject item4 in spellEffectInstantiationData.EnumerateInstantiationObjectTargets(castTargetContext))
                                {
                                    IEnumerator item2 = FightSpellEffectFactory.PlaySpellEffect(spellEffect, item4, spellEffectInstantiationData, castTargetContext);
                                    routineList.Add(item2);
                                }
                                yield return(EnumeratorUtility.ParallelRecursiveImmediateSafeExecution(routineList.ToArray()));

                                routineList.Clear();
                            }
                            num = i + 1;
                        }
                        ListPool <IEnumerator> .Release(routineList);
                    }
                    FightSpellEffectFactory.SetupSpellEffectOverrides(definition, fightStatus.fightId, eventId);
                }
                else
                {
                    Log.Error($"Could not find spell with instance id {spellInstanceId} for player with id {concernedEntity}.", 128, "C:\\BuildAgents\\AgentB\\work\\cub_client_win64_develop\\client\\DofusCube.Unity\\Assets\\Core\\Code\\Fight\\Events\\PlaySpellEvent.cs");
                }
            }
            else
            {
                Log.Error(FightEventErrors.PlayerNotFound(concernedEntity), 133, "C:\\BuildAgents\\AgentB\\work\\cub_client_win64_develop\\client\\DofusCube.Unity\\Assets\\Core\\Code\\Fight\\Events\\PlaySpellEvent.cs");
            }
        }
Exemple #16
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;
            }
            }
        }
Exemple #17
0
 public override IEnumerator UpdateView(FightStatus fightStatus)
 {
     if (fightStatus.TryGetEntity(concernedEntity, out FloorMechanismStatus entityStatus))
     {
         if (fightStatus.TryGetEntity(activator, out IEntityWithTeam entityStatus2))
         {
             if (entityStatus2.teamId == entityStatus.teamId)
             {
                 IObjectWithActivation objectWithActivation;
                 if ((objectWithActivation = (entityStatus.view as IObjectWithActivation)) != null)
                 {
                     yield return(objectWithActivation.ActivatedByAlly());
                 }
                 else
                 {
                     Log.Error(FightEventErrors.EntityHasIncompatibleView <IObjectWithActivation>(entityStatus), 26, "C:\\BuildAgents\\AgentB\\work\\cub_client_win64_develop\\client\\DofusCube.Unity\\Assets\\Core\\Code\\Fight\\Events\\FloorMechanismActivationEvent.cs");
                 }
                 yield break;
             }
             IReadOnlyList <int> entitiesInAssemblage = this.entitiesInAssemblage;
             int count = entitiesInAssemblage.Count;
             if (count == 1)
             {
                 IObjectWithActivation objectWithActivation2;
                 if ((objectWithActivation2 = (entityStatus.view as IObjectWithActivation)) != null)
                 {
                     yield return(objectWithActivation2.ActivatedByOpponent());
                 }
                 else
                 {
                     Log.Error(FightEventErrors.EntityHasIncompatibleView <IObjectWithActivation>(entityStatus), 41, "C:\\BuildAgents\\AgentB\\work\\cub_client_win64_develop\\client\\DofusCube.Unity\\Assets\\Core\\Code\\Fight\\Events\\FloorMechanismActivationEvent.cs");
                 }
                 yield break;
             }
             IEnumerator[] array = new IEnumerator[count];
             for (int i = 0; i < count; i++)
             {
                 if (fightStatus.TryGetEntity(entitiesInAssemblage[i], out FloorMechanismStatus entityStatus3))
                 {
                     IObjectWithActivation objectWithActivation3;
                     if ((objectWithActivation3 = (entityStatus3.view as IObjectWithActivation)) != null)
                     {
                         array[i] = objectWithActivation3.ActivatedByOpponent();
                     }
                     else
                     {
                         Log.Error(FightEventErrors.EntityHasIncompatibleView <IObjectWithActivation>(entityStatus3), 57, "C:\\BuildAgents\\AgentB\\work\\cub_client_win64_develop\\client\\DofusCube.Unity\\Assets\\Core\\Code\\Fight\\Events\\FloorMechanismActivationEvent.cs");
                     }
                 }
                 else
                 {
                     Log.Error(FightEventErrors.EntityNotFound <FloorMechanismStatus>(entitiesInAssemblage[i]), 62, "C:\\BuildAgents\\AgentB\\work\\cub_client_win64_develop\\client\\DofusCube.Unity\\Assets\\Core\\Code\\Fight\\Events\\FloorMechanismActivationEvent.cs");
                 }
             }
             yield return(EnumeratorUtility.ParallelRecursiveImmediateSafeExecution(array));
         }
         else
         {
             Log.Error(FightEventErrors.EntityNotFound <IEntityWithTeam>(activator), 72, "C:\\BuildAgents\\AgentB\\work\\cub_client_win64_develop\\client\\DofusCube.Unity\\Assets\\Core\\Code\\Fight\\Events\\FloorMechanismActivationEvent.cs");
         }
     }
     else
     {
         Log.Error($"Could not find entity with id {concernedEntity}.", 77, "C:\\BuildAgents\\AgentB\\work\\cub_client_win64_develop\\client\\DofusCube.Unity\\Assets\\Core\\Code\\Fight\\Events\\FloorMechanismActivationEvent.cs");
     }
 }