Ejemplo n.º 1
0
    private static string TooltipForDupe(Chore.Precondition.Context context, ChoreConsumer choreConsumer, int rank)
    {
        bool   flag             = context.IsPotentialSuccess();
        string text             = (!flag) ? UI.DETAILTABS.BUILDING_CHORES.DUPE_TOOLTIP_FAILED : UI.DETAILTABS.BUILDING_CHORES.DUPE_TOOLTIP_SUCCEEDED;
        float  num              = 0f;
        int    personalPriority = choreConsumer.GetPersonalPriority(context.chore.choreType);

        num += (float)(personalPriority * 10);
        int priority_value = context.chore.masterPriority.priority_value;

        num += (float)priority_value;
        float num2 = (float)context.priority / 10000f;

        num += num2;
        text = text.Replace("{Description}", (!((Object)context.chore.driver == (Object)choreConsumer.choreDriver)) ? UI.DETAILTABS.BUILDING_CHORES.DUPE_TOOLTIP_DESC_INACTIVE : UI.DETAILTABS.BUILDING_CHORES.DUPE_TOOLTIP_DESC_ACTIVE);
        string newValue  = GameUtil.ChoreGroupsForChoreType(context.chore.choreType);
        string newValue2 = UI.UISIDESCREENS.MINIONTODOSIDESCREEN.TOOLTIP_NA.text;

        if (flag && context.chore.choreType.groups.Length > 0)
        {
            ChoreGroup choreGroup = context.chore.choreType.groups[0];
            for (int i = 1; i < context.chore.choreType.groups.Length; i++)
            {
                if (choreConsumer.GetPersonalPriority(choreGroup) < choreConsumer.GetPersonalPriority(context.chore.choreType.groups[i]))
                {
                    choreGroup = context.chore.choreType.groups[i];
                }
            }
            newValue2 = choreGroup.Name;
        }
        text = text.Replace("{Name}", choreConsumer.name);
        text = text.Replace("{Errand}", GameUtil.GetChoreName(context.chore, context.data));
        if (flag)
        {
            text = text.Replace("{Rank}", rank.ToString());
            text = text.Replace("{Groups}", newValue);
            text = text.Replace("{BestGroup}", newValue2);
            string text2 = text;
            JobsTableScreen.PriorityInfo priorityInfo = JobsTableScreen.priorityInfo[personalPriority];
            text = text2.Replace("{PersonalPriority}", priorityInfo.name.text);
            text = text.Replace("{PersonalPriorityValue}", (personalPriority * 10).ToString());
            text = text.Replace("{Building}", context.chore.gameObject.GetProperName());
            text = text.Replace("{BuildingPriority}", priority_value.ToString());
            text = text.Replace("{TypePriority}", num2.ToString());
            return(text.Replace("{TotalPriority}", num.ToString()));
        }
        string text3 = text;

        Chore.PreconditionInstance preconditionInstance = context.chore.GetPreconditions()[context.failedPreconditionId];
        return(text3.Replace("{FailedPrecondition}", preconditionInstance.description));
    }
    private static string TooltipForChore(Chore.Precondition.Context context, ChoreConsumer choreConsumer)
    {
        bool   flag = context.chore.masterPriority.priority_class == PriorityScreen.PriorityClass.basic || context.chore.masterPriority.priority_class == PriorityScreen.PriorityClass.high;
        string text;

        switch (context.chore.masterPriority.priority_class)
        {
        case PriorityScreen.PriorityClass.idle:
            text = UI.UISIDESCREENS.MINIONTODOSIDESCREEN.TOOLTIP_IDLE;
            break;

        case PriorityScreen.PriorityClass.personalNeeds:
            text = UI.UISIDESCREENS.MINIONTODOSIDESCREEN.TOOLTIP_PERSONAL;
            break;

        case PriorityScreen.PriorityClass.topPriority:
            text = UI.UISIDESCREENS.MINIONTODOSIDESCREEN.TOOLTIP_EMERGENCY;
            break;

        case PriorityScreen.PriorityClass.compulsory:
            text = UI.UISIDESCREENS.MINIONTODOSIDESCREEN.TOOLTIP_COMPULSORY;
            break;

        default:
            text = UI.UISIDESCREENS.MINIONTODOSIDESCREEN.TOOLTIP_NORMAL;
            break;
        }
        float num  = 0f;
        int   num2 = (int)context.chore.masterPriority.priority_class * 100;

        num += (float)num2;
        int num3 = flag ? choreConsumer.GetPersonalPriority(context.chore.choreType) : 0;

        num += (float)(num3 * 10);
        int num4 = flag ? context.chore.masterPriority.priority_value : 0;

        num += (float)num4;
        float num5 = (float)context.priority / 10000f;

        num += num5;
        text = text.Replace("{Description}", (!((Object)context.chore.driver == (Object)choreConsumer.choreDriver)) ? UI.UISIDESCREENS.MINIONTODOSIDESCREEN.TOOLTIP_DESC_INACTIVE : UI.UISIDESCREENS.MINIONTODOSIDESCREEN.TOOLTIP_DESC_ACTIVE);
        text = text.Replace("{IdleDescription}", (!((Object)context.chore.driver == (Object)choreConsumer.choreDriver)) ? UI.UISIDESCREENS.MINIONTODOSIDESCREEN.TOOLTIP_IDLEDESC_INACTIVE : UI.UISIDESCREENS.MINIONTODOSIDESCREEN.TOOLTIP_IDLEDESC_ACTIVE);
        string     newValue   = GameUtil.ChoreGroupsForChoreType(context.chore.choreType);
        ChoreGroup choreGroup = BestPriorityGroup(context, choreConsumer);

        text = text.Replace("{Name}", choreConsumer.name);
        text = text.Replace("{Errand}", GameUtil.GetChoreName(context.chore, context.data));
        text = text.Replace("{Groups}", newValue);
        text = text.Replace("{BestGroup}", (choreGroup == null) ? context.chore.choreType.Name : choreGroup.Name);
        text = text.Replace("{ClassPriority}", num2.ToString());
        string text2 = text;

        JobsTableScreen.PriorityInfo priorityInfo = JobsTableScreen.priorityInfo[num3];
        text = text2.Replace("{PersonalPriority}", priorityInfo.name.text);
        text = text.Replace("{PersonalPriorityValue}", (num3 * 10).ToString());
        text = text.Replace("{Building}", context.chore.gameObject.GetProperName());
        text = text.Replace("{BuildingPriority}", num4.ToString());
        text = text.Replace("{TypePriority}", num5.ToString());
        return(text.Replace("{TotalPriority}", num.ToString()));
    }
    private static ChoreGroup BestPriorityGroup(Chore.Precondition.Context context, ChoreConsumer choreConsumer)
    {
        ChoreGroup choreGroup = null;

        if (context.chore.choreType.groups.Length > 0)
        {
            choreGroup = context.chore.choreType.groups[0];
            for (int i = 1; i < context.chore.choreType.groups.Length; i++)
            {
                if (choreConsumer.GetPersonalPriority(choreGroup) < choreConsumer.GetPersonalPriority(context.chore.choreType.groups[i]))
                {
                    choreGroup = context.chore.choreType.groups[i];
                }
            }
        }
        return(choreGroup);
    }
Ejemplo n.º 4
0
    private void OnSortClicked(object widget_go_obj)
    {
        GameObject widget_go = widget_go_obj as GameObject;
        PrioritizationGroupTableColumn prioritizationGroupTableColumn = GetWidgetColumn(widget_go) as PrioritizationGroupTableColumn;
        ChoreGroup chore_group = prioritizationGroupTableColumn.userData as ChoreGroup;

        if (active_sort_column == prioritizationGroupTableColumn)
        {
            sort_is_reversed = !sort_is_reversed;
        }
        active_sort_column = prioritizationGroupTableColumn;
        active_sort_method = delegate(IAssignableIdentity a, IAssignableIdentity b)
        {
            MinionIdentity minionIdentity  = a as MinionIdentity;
            MinionIdentity minionIdentity2 = b as MinionIdentity;
            if ((UnityEngine.Object)minionIdentity == (UnityEngine.Object)null && (UnityEngine.Object)minionIdentity2 == (UnityEngine.Object)null)
            {
                return(0);
            }
            if ((UnityEngine.Object)minionIdentity == (UnityEngine.Object)null)
            {
                return(-1);
            }
            if ((UnityEngine.Object)minionIdentity2 == (UnityEngine.Object)null)
            {
                return(1);
            }
            ChoreConsumer component  = minionIdentity.GetComponent <ChoreConsumer>();
            ChoreConsumer component2 = minionIdentity2.GetComponent <ChoreConsumer>();
            if (component.IsChoreGroupDisabled(chore_group))
            {
                return(1);
            }
            if (component2.IsChoreGroupDisabled(chore_group))
            {
                return(-1);
            }
            int personalPriority  = component.GetPersonalPriority(chore_group);
            int personalPriority2 = component2.GetPersonalPriority(chore_group);
            if (personalPriority == personalPriority2)
            {
                return(minionIdentity.name.CompareTo(minionIdentity2.name));
            }
            return(personalPriority2 - personalPriority);
        };
        SortRows();
    }
Ejemplo n.º 5
0
 private HierarchyReferences PriorityGroupForPriority(ChoreConsumer choreConsumer, Chore chore)
 {
     foreach (Tuple <PriorityScreen.PriorityClass, int, HierarchyReferences> priorityGroup in priorityGroups)
     {
         if (priorityGroup.first == chore.masterPriority.priority_class)
         {
             if (chore.masterPriority.priority_class != 0)
             {
                 return(priorityGroup.third);
             }
             if (priorityGroup.second == choreConsumer.GetPersonalPriority(chore.choreType))
             {
                 return(priorityGroup.third);
             }
         }
     }
     return(null);
 }
    private void AddChoreEntry(Chore chore)
    {
        HierarchyReferences choreEntry = GetChoreEntry(GameUtil.GetChoreName(chore, null), chore.choreType, choreGroup.GetReference <RectTransform>("EntriesContainer"));
        FetchChore          fetchChore = chore as FetchChore;

        ListPool <Chore.Precondition.Context, BuildingChoresPanel> .PooledList pooledList = ListPool <Chore.Precondition.Context, BuildingChoresPanel> .Allocate();

        foreach (MinionIdentity item in Components.LiveMinionIdentities.Items)
        {
            pooledList.Clear();
            ChoreConsumer component = item.GetComponent <ChoreConsumer>();
            Chore.Precondition.Context         context = default(Chore.Precondition.Context);
            ChoreConsumer.PreconditionSnapshot lastPreconditionSnapshot = component.GetLastPreconditionSnapshot();
            if (lastPreconditionSnapshot.doFailedContextsNeedSorting)
            {
                lastPreconditionSnapshot.failedContexts.Sort();
                lastPreconditionSnapshot.doFailedContextsNeedSorting = false;
            }
            pooledList.AddRange(lastPreconditionSnapshot.failedContexts);
            pooledList.AddRange(lastPreconditionSnapshot.succeededContexts);
            int num  = -1;
            int num2 = 0;
            for (int num3 = pooledList.Count - 1; num3 >= 0; num3--)
            {
                Chore.Precondition.Context context2 = pooledList[num3];
                if ((UnityEngine.Object)context2.chore.driver != (UnityEngine.Object)null)
                {
                    Chore.Precondition.Context context3 = pooledList[num3];
                    if ((UnityEngine.Object)context3.chore.driver != (UnityEngine.Object)component.choreDriver)
                    {
                        continue;
                    }
                }
                bool flag = pooledList[num3].IsPotentialSuccess();
                if (flag)
                {
                    num2++;
                }
                Chore.Precondition.Context context4       = pooledList[num3];
                FetchAreaChore             fetchAreaChore = context4.chore as FetchAreaChore;
                Chore.Precondition.Context context5       = pooledList[num3];
                if (context5.chore == chore || (fetchChore != null && fetchAreaChore != null && fetchAreaChore.smi.SameDestination(fetchChore)))
                {
                    num     = ((!flag) ? 2147483647 : num2);
                    context = pooledList[num3];
                    break;
                }
            }
            if (num >= 0)
            {
                DupeEntryDatas.Add(new DupeEntryData
                {
                    consumer         = component,
                    context          = context,
                    personalPriority = component.GetPersonalPriority(chore.choreType),
                    rank             = num
                });
            }
        }
        pooledList.Recycle();
        DupeEntryDatas.Sort();
        foreach (DupeEntryData dupeEntryData in DupeEntryDatas)
        {
            GetDupeEntry(dupeEntryData, choreEntry.GetReference <RectTransform>("DupeContainer"));
        }
        DupeEntryDatas.Clear();
    }