Example #1
0
            public override int Compare(CompanionData x, CompanionData y)
            {
                if (x == y)
                {
                    return(0);
                }
                if (x == null)
                {
                    return(1);
                }
                if (y == null)
                {
                    return(-1);
                }
                CaracId caracId  = CaracId.Armor;
                int     value    = int.MaxValue;
                CaracId caracId2 = CaracId.Armor;
                int     value2   = int.MaxValue;

                foreach (Cost item in x.definition.cost)
                {
                    ElementPointsCost elementPointsCost = item as ElementPointsCost;
                    if (elementPointsCost != null)
                    {
                        caracId = elementPointsCost.element;
                        elementPointsCost.value.GetValue(null, out value);
                        break;
                    }
                }
                foreach (Cost item2 in y.definition.cost)
                {
                    ElementPointsCost elementPointsCost2 = item2 as ElementPointsCost;
                    if (elementPointsCost2 != null)
                    {
                        caracId2 = elementPointsCost2.element;
                        elementPointsCost2.value.GetValue(null, out value2);
                        break;
                    }
                }
                if (CaracId.Armor != caracId && caracId2 != CaracId.Armor)
                {
                    if (caracId != caracId2)
                    {
                        return(caracId - caracId2);
                    }
                    return(value - value2);
                }
                return(x.definition.get_id() - y.definition.get_id());
            }
Example #2
0
        private bool IsCompanionValid(object obj)
        {
            CompanionData companionData = obj as CompanionData;

            if (companionData == null)
            {
                return(false);
            }
            IReadOnlyList <Cost> cost = companionData.definition.cost;
            int i = 0;

            for (int count = cost.Count; i < count; i++)
            {
                ElementPointsCost elementPointsCost = cost[i] as ElementPointsCost;
                if (elementPointsCost != null && !m_caracIdsEnableToggle.Contains(elementPointsCost.element))
                {
                    return(false);
                }
            }
            return(ValidateSearchText(companionData, companionData.definition));
        }
        private static void PreviewCosts(IReadOnlyList <Cost> costs, DynamicValueFightContext context)
        {
            LocalPlayerUIRework localPlayerUI = FightUIRework.instance.GetLocalPlayerUI(s_playerCasting);

            for (int i = 0; i < costs.Count; i++)
            {
                Cost cost = costs[i];
                if (cost == null)
                {
                    continue;
                }
                ActionPointsCost actionPointsCost;
                int value3;
                if ((actionPointsCost = (cost as ActionPointsCost)) == null)
                {
                    if (!(cost is DrainActionPointsCost))
                    {
                        ElementPointsCost elementPointsCost;
                        if ((elementPointsCost = (cost as ElementPointsCost)) == null)
                        {
                            DrainElementsPoints drainElementsPoints;
                            if ((drainElementsPoints = (cost as DrainElementsPoints)) == null)
                            {
                                ReservePointsCost reservePointsCost;
                                int value;
                                if ((reservePointsCost = (cost as ReservePointsCost)) == null)
                                {
                                    if (cost is DrainReservePointsCost)
                                    {
                                        localPlayerUI.PreviewReservePoints(0, ValueModifier.Set);
                                    }
                                }
                                else if (reservePointsCost.value.GetValue(context, out value))
                                {
                                    localPlayerUI.PreviewReservePoints(value, ValueModifier.Add);
                                }
                            }
                            else
                            {
                                DrainElementsPoints drainElementsPoints2 = drainElementsPoints;
                                int count = drainElementsPoints2.elements.Count;
                                for (int j = 0; j < count; j++)
                                {
                                    PreviewElementaryPoints(localPlayerUI, drainElementsPoints2.elements[j], 0, ValueModifier.Set);
                                }
                            }
                        }
                        else
                        {
                            ElementPointsCost elementPointsCost2 = elementPointsCost;
                            if (elementPointsCost2.value.GetValue(context, out int value2))
                            {
                                PreviewElementaryPoints(localPlayerUI, elementPointsCost2.element, value2, ValueModifier.Add);
                            }
                        }
                    }
                    else
                    {
                        localPlayerUI.PreviewActionPoints(0, ValueModifier.Set);
                    }
                }
                else if (actionPointsCost.value.GetValue(context, out value3))
                {
                    localPlayerUI.PreviewActionPoints(value3, ValueModifier.Add);
                }
            }
        }