Example #1
0
    private void LoadValue(IAssignableIdentity minion, GameObject widget_go)
    {
        if (!((UnityEngine.Object)widget_go == (UnityEngine.Object)null))
        {
            PrioritizationGroupTableColumn prioritizationGroupTableColumn = GetWidgetColumn(widget_go) as PrioritizationGroupTableColumn;
            ChoreGroup choreGroup = prioritizationGroupTableColumn.userData as ChoreGroup;
            TableRow   widgetRow  = GetWidgetRow(widget_go);
            switch (widgetRow.rowType)
            {
            case TableRow.RowType.Header:
                InitializeHeader(choreGroup, widget_go);
                break;

            case TableRow.RowType.Default:
            case TableRow.RowType.Minion:
            case TableRow.RowType.StoredMinon:
            {
                IPersonalPriorityManager priorityManager = GetPriorityManager(widgetRow);
                bool flag = priorityManager.IsChoreGroupDisabled(choreGroup);
                HierarchyReferences component = widget_go.GetComponent <HierarchyReferences>();
                KImage kImage = component.GetReference("FG") as KImage;
                kImage.raycastTarget = flag;
                ToolTip toolTip = component.GetReference("FGToolTip") as ToolTip;
                toolTip.enabled = flag;
                break;
            }
            }
            IPersonalPriorityManager priorityManager2 = GetPriorityManager(widgetRow);
            if (priorityManager2 != null)
            {
                UpdateWidget(widget_go, choreGroup, priorityManager2);
            }
        }
    }
Example #2
0
    private void ChangeRowPriority(object widget_go_obj, int delta)
    {
        GameObject widget_go = widget_go_obj as GameObject;

        if (widget_go_obj != null)
        {
            TableRow widgetRow = GetWidgetRow(widget_go);
            if (widgetRow.rowType == TableRow.RowType.Header)
            {
                Debug.Assert(false);
            }
            else
            {
                IPersonalPriorityManager priorityManager = GetPriorityManager(widgetRow);
                foreach (TableColumn value in columns.Values)
                {
                    PrioritizationGroupTableColumn prioritizationGroupTableColumn = value as PrioritizationGroupTableColumn;
                    if (prioritizationGroupTableColumn != null)
                    {
                        ChoreGroup chore_group = prioritizationGroupTableColumn.userData as ChoreGroup;
                        GameObject widget      = widgetRow.GetWidget(prioritizationGroupTableColumn);
                        ChangePersonalPriority(priorityManager, chore_group, delta, false);
                        UpdateWidget(widget, chore_group, priorityManager);
                    }
                }
            }
        }
    }
Example #3
0
    private void ChangeColumnPriority(object widget_go_obj, int new_priority)
    {
        GameObject widget_go = widget_go_obj as GameObject;

        if (widget_go_obj != null)
        {
            TableRow widgetRow = GetWidgetRow(widget_go);
            if (widgetRow.rowType != 0)
            {
                Debug.Assert(false);
            }
            PrioritizationGroupTableColumn prioritizationGroupTableColumn = GetWidgetColumn(widget_go) as PrioritizationGroupTableColumn;
            ChoreGroup choreGroup = prioritizationGroupTableColumn.userData as ChoreGroup;
            foreach (TableRow row in rows)
            {
                IPersonalPriorityManager priorityManager = GetPriorityManager(row);
                if (priorityManager != null)
                {
                    priorityManager.SetPersonalPriority(choreGroup, new_priority);
                    GameObject widget = row.GetWidget(prioritizationGroupTableColumn);
                    UpdateWidget(widget, choreGroup, priorityManager);
                }
            }
        }
    }
Example #4
0
 private void ChangePersonalPriority(IPersonalPriorityManager priority_mgr, ChoreGroup chore_group, int delta, bool wrap_around)
 {
     if (priority_mgr.IsChoreGroupDisabled(chore_group))
     {
         KMonoBehaviour.PlaySound(GlobalAssets.GetSound("Negative", false));
     }
     else
     {
         int personalPriority = priority_mgr.GetPersonalPriority(chore_group);
         personalPriority += delta;
         if (wrap_around)
         {
             personalPriority %= 6;
             if (personalPriority < 0)
             {
                 personalPriority += 6;
             }
         }
         personalPriority = Mathf.Clamp(personalPriority, 0, 5);
         priority_mgr.SetPersonalPriority(chore_group, personalPriority);
         if (delta > 0)
         {
             KMonoBehaviour.PlaySound(GlobalAssets.GetSound("HUD_Click", false));
         }
         else
         {
             KMonoBehaviour.PlaySound(GlobalAssets.GetSound("HUD_Click_Deselect", false));
         }
     }
 }
 private void SetJobEveryone(bool state, ChoreGroup chore_group)
 {
     foreach (CrewJobsEntry entryObject in EntryObjects)
     {
         entryObject.consumer.SetPermittedByUser(chore_group, state);
     }
 }
    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()));
    }
    public int GetAssociatedSkillLevel(ChoreGroup group)
    {
        Klei.AI.Attributes attributes = this.GetAttributes();
        float value = attributes.GetValue(group.attribute.Id);

        return((int)value);
    }
Example #8
0
 public ChoreType(string id, ResourceSet parent, string[] chore_groups, string urge, string name, string status_message, string tooltip, IEnumerable <Tag> interrupt_exclusion, int implicit_priority, int explicit_priority)
     : base(id, parent, name)
 {
     statusItem = new StatusItem(id, status_message, tooltip, string.Empty, StatusItem.IconType.Info, NotificationType.Neutral, false, OverlayModes.None.ID, 129022);
     statusItem.resolveStringCallback = ResolveStringCallback;
     tags.Add(TagManager.Create(id));
     interruptExclusion = new HashSet <Tag>(interrupt_exclusion);
     Db.Get().DuplicantStatusItems.Add(statusItem);
     groups = new ChoreGroup[chore_groups.Length];
     for (int i = 0; i < groups.Length; i++)
     {
         ChoreGroup choreGroup = Db.Get().ChoreGroups.Get(chore_groups[i]);
         if (!choreGroup.choreTypes.Contains(this))
         {
             choreGroup.choreTypes.Add(this);
         }
         groups[i] = choreGroup;
     }
     if (!string.IsNullOrEmpty(urge))
     {
         this.urge = Db.Get().Urges.Get(urge);
     }
     priority         = implicit_priority;
     explicitPriority = explicit_priority;
 }
    protected override void PositionColumnTitles()
    {
        base.PositionColumnTitles();
        int childCount = ColumnTitlesContainer.childCount;

        for (int i = 0; i < childCount; i++)
        {
            if (i < choreGroups.Count)
            {
                Toggle sortToggle = ColumnTitlesContainer.GetChild(i).Find("Title").GetComponentInChildren <Toggle>();
                ColumnTitlesContainer.GetChild(i).rectTransform().localScale = Vector3.one;
                ChoreGroup       chore_group = choreGroups[i];
                ImageToggleState toggleImage = sortToggle.GetComponentInChildren <ImageToggleState>(true);
                sortToggle.group = sortToggleGroup;
                sortToggle.onValueChanged.AddListener(delegate
                {
                    bool playSound = false;
                    if ((UnityEngine.Object)lastSortToggle == (UnityEngine.Object)sortToggle)
                    {
                        playSound = true;
                    }
                    SortByEffectiveness(chore_group, !sortToggle.isOn, playSound);
                    lastSortToggle   = sortToggle;
                    lastSortReversed = !sortToggle.isOn;
                    ResetSortToggles(sortToggle);
                    if (sortToggle.isOn)
                    {
                        toggleImage.SetActive();
                    }
                    else
                    {
                        toggleImage.SetInactive();
                    }
                });
            }
            ToolTip JobTooltip = ColumnTitlesContainer.GetChild(i).GetComponent <ToolTip>();
            ToolTip toolTip    = JobTooltip;
            toolTip.OnToolTip = (Func <string>)Delegate.Combine(toolTip.OnToolTip, (Func <string>)(() => GetJobTooltip(JobTooltip.gameObject)));
            Button componentInChildren = ColumnTitlesContainer.GetChild(i).GetComponentInChildren <Button>();
            EveryoneToggles.Add(componentInChildren, everyoneToggleState.on);
        }
        for (int j = 0; j < choreGroups.Count; j++)
        {
            ChoreGroup chore_group2 = choreGroups[j];
            Button     b            = EveryoneToggles.Keys.ElementAt(j);
            EveryoneToggles.Keys.ElementAt(j).onClick.AddListener(delegate
            {
                ToggleJobEveryone(b, chore_group2);
            });
        }
        Button key = EveryoneToggles.ElementAt(EveryoneToggles.Count - 1).Key;

        key.transform.parent.Find("Title").gameObject.GetComponentInChildren <Toggle>().gameObject.SetActive(false);
        key.onClick.AddListener(delegate
        {
            ToggleAllTasksEveryone();
        });
        EveryoneAllTaskToggle = new KeyValuePair <Button, everyoneToggleState>(key, EveryoneAllTaskToggle.Value);
    }
Example #10
0
    private string OnSortHovered(object widget_go_obj)
    {
        GameObject widget_go = widget_go_obj as GameObject;
        PrioritizationGroupTableColumn prioritizationGroupTableColumn = GetWidgetColumn(widget_go) as PrioritizationGroupTableColumn;
        ChoreGroup choreGroup = prioritizationGroupTableColumn.userData as ChoreGroup;

        return(UI.JOBSSCREEN.SORT_TOOLTIP.ToString().Replace("{Job}", choreGroup.Name));
    }
 public int GetPersonalPriority(ChoreGroup group)
 {
     if (defaultPersonalPriorities.TryGetValue(group.IdHash, out int value))
     {
         return(value);
     }
     value = 3;
     return(value);
 }
    public int GetPersonalPriority(ChoreGroup group)
    {
        int value = 3;

        if (choreGroupPriorities.TryGetValue(group.IdHash, out PriorityInfo value2))
        {
            value = value2.priority;
        }
        return(Mathf.Clamp(value, 0, 5));
    }
Example #13
0
    private string HoverChangeColumnPriorityButton(object widget_go_obj)
    {
        GameObject widget_go = widget_go_obj as GameObject;
        PrioritizationGroupTableColumn prioritizationGroupTableColumn = GetWidgetColumn(widget_go) as PrioritizationGroupTableColumn;
        ChoreGroup choreGroup            = prioritizationGroupTableColumn.userData as ChoreGroup;
        LocString  hEADER_CHANGE_TOOLTIP = UI.JOBSSCREEN.HEADER_CHANGE_TOOLTIP;
        string     text = hEADER_CHANGE_TOOLTIP.ToString();

        return(text.Replace("{Job}", choreGroup.Name));
    }
Example #14
0
    private void OnPriorityPress(ChoreGroup chore_group)
    {
        bool   flag = consumer.IsPermittedByUser(chore_group) ? true : false;
        string name = "HUD_Click";

        if (flag)
        {
            name = "HUD_Click_Deselect";
        }
        KMonoBehaviour.PlaySound(GlobalAssets.GetSound(name, false));
        consumer.SetPermittedByUser(chore_group, !consumer.IsPermittedByUser(chore_group));
    }
    public void Apply(Chore.Precondition.Context context)
    {
        ChoreConsumer consumer = context.consumerState.consumer;

        if (targetChore != context.chore || !object.ReferenceEquals(context.chore.target, lastChoreTarget) || !(context.chore.masterPriority == lastPrioritySetting))
        {
            targetChore         = context.chore;
            lastChoreTarget     = context.chore.target;
            lastPrioritySetting = context.chore.masterPriority;
            string choreName = GameUtil.GetChoreName(context.chore, context.data);
            string text      = GameUtil.ChoreGroupsForChoreType(context.chore.choreType);
            string text2     = UI.UISIDESCREENS.MINIONTODOSIDESCREEN.CHORE_TARGET;
            text2 = text2.Replace("{Target}", (!((Object)context.chore.target.gameObject == (Object)consumer.gameObject)) ? context.chore.target.gameObject.GetProperName() : UI.UISIDESCREENS.MINIONTODOSIDESCREEN.SELF_LABEL.text);
            if (text != null)
            {
                text2 = text2.Replace("{Groups}", text);
            }
            string     text3      = (context.chore.masterPriority.priority_class != 0) ? string.Empty : context.chore.masterPriority.priority_value.ToString();
            Sprite     sprite     = (context.chore.masterPriority.priority_class != 0) ? null : prioritySprites[context.chore.masterPriority.priority_value - 1];
            ChoreGroup choreGroup = BestPriorityGroup(context, consumer);
            icon.sprite = ((choreGroup == null) ? null : Assets.GetSprite(choreGroup.sprite));
            label.SetText(choreName);
            subLabel.SetText(text2);
            priorityLabel.SetText(text3);
            priorityIcon.sprite = sprite;
            moreLabel.text      = string.Empty;
            GetComponent <ToolTip>().SetSimpleTooltip(TooltipForChore(context, consumer));
            KButton componentInChildren = GetComponentInChildren <KButton>();
            componentInChildren.ClearOnClick();
            if ((Object)componentInChildren.bgImage != (Object)null)
            {
                componentInChildren.bgImage.colorStyleSetting = ((!((Object)context.chore.driver == (Object)consumer.choreDriver)) ? buttonColorSettingStandard : buttonColorSettingCurrent);
                componentInChildren.bgImage.ApplyColorStyleSetting();
            }
            GameObject gameObject = context.chore.target.gameObject;
            componentInChildren.ClearOnPointerEvents();
            componentInChildren.GetComponentInChildren <KButton>().onClick += delegate
            {
                if (context.chore != null && !context.chore.target.isNull)
                {
                    Vector3 position  = context.chore.target.gameObject.transform.position;
                    float   x         = position.x;
                    Vector3 position2 = context.chore.target.gameObject.transform.position;
                    float   y         = position2.y + 1f;
                    Vector3 position3 = CameraController.Instance.transform.position;
                    Vector3 pos       = new Vector3(x, y, position3.z);
                    CameraController.Instance.SetTargetPos(pos, 10f, true);
                }
            };
        }
    }
Example #16
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 void ToggleJobEveryone(Button button, ChoreGroup chore_group)
    {
        string name = "HUD_Click_Deselect";

        if (EveryoneToggles[button] != everyoneToggleState.on)
        {
            name = "HUD_Click";
        }
        KMonoBehaviour.PlaySound(GlobalAssets.GetSound(name, false));
        foreach (CrewJobsEntry entryObject in EntryObjects)
        {
            entryObject.consumer.SetPermittedByUser(chore_group, EveryoneToggles[button] != everyoneToggleState.on);
        }
    }
 public void SetPermittedByUser(ChoreGroup chore_group, bool is_allowed)
 {
     if (is_allowed)
     {
         if (userDisabledChoreGroups.Remove(chore_group.IdHash))
         {
             choreRulesChanged.Signal();
         }
     }
     else if (!userDisabledChoreGroups.Contains(chore_group.IdHash))
     {
         userDisabledChoreGroups.Add(chore_group.IdHash);
         choreRulesChanged.Signal();
     }
 }
 public void SetPermittedByTraits(ChoreGroup chore_group, bool is_enabled)
 {
     if (is_enabled)
     {
         if (traitDisabledChoreGroups.Remove(chore_group.IdHash))
         {
             choreRulesChanged.Signal();
         }
     }
     else if (!traitDisabledChoreGroups.Contains(chore_group.IdHash))
     {
         traitDisabledChoreGroups.Add(chore_group.IdHash);
         choreRulesChanged.Signal();
     }
 }
    private void SortByEffectiveness(ChoreGroup chore_group, bool reverse, bool playSound)
    {
        if (playSound)
        {
            KMonoBehaviour.PlaySound(GlobalAssets.GetSound("HUD_Click", false));
        }
        List <CrewJobsEntry> list = new List <CrewJobsEntry>(EntryObjects);

        list.Sort(delegate(CrewJobsEntry a, CrewJobsEntry b)
        {
            float value  = a.Identity.GetAttributes().GetValue(chore_group.attribute.Id);
            float value2 = b.Identity.GetAttributes().GetValue(chore_group.attribute.Id);
            return(value.CompareTo(value2));
        });
        ReorderEntries(list, reverse);
    }
Example #21
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();
    }
Example #22
0
    private void UpdateWidget(GameObject widget_go, ChoreGroup chore_group, IPersonalPriorityManager priority_mgr)
    {
        int  fgIndex = 0;
        int  value   = 0;
        bool flag    = priority_mgr.IsChoreGroupDisabled(chore_group);

        if (!flag)
        {
            value = priority_mgr.GetPersonalPriority(chore_group);
        }
        value = Mathf.Clamp(value, 0, 5);
        for (int i = 0; i < JobsTableScreen.priorityInfo.Count - 1; i++)
        {
            PriorityInfo priorityInfo = JobsTableScreen.priorityInfo[i];
            if (priorityInfo.priority == value)
            {
                fgIndex = i;
                break;
            }
        }
        OptionSelector component  = widget_go.GetComponent <OptionSelector>();
        int            num        = priority_mgr?.GetAssociatedSkillLevel(chore_group) ?? 0;
        Color32        fillColour = new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, 128);

        if (num > 0)
        {
            float num2 = (float)(num - skillLevelLow);
            num2      /= (float)(skillLevelHigh - skillLevelLow);
            fillColour = Color32.Lerp(skillOutlineColourLow, skillOutlineColourHigh, num2);
        }
        component.ConfigureItem(flag, new OptionSelector.DisplayOptionInfo
        {
            bgOptions  = null,
            fgOptions  = prioritySprites,
            bgIndex    = 0,
            fgIndex    = fgIndex,
            fillColour = fillColour
        });
        ToolTip componentInChildren = widget_go.transform.GetComponentInChildren <ToolTip>();

        if ((UnityEngine.Object)componentInChildren != (UnityEngine.Object)null)
        {
            componentInChildren.toolTip      = HoverPersonalPriority(widget_go);
            componentInChildren.forceRefresh = true;
        }
    }
 public void SetPersonalPriority(ChoreGroup group, int value)
 {
     if (group.choreTypes != null)
     {
         value = Mathf.Clamp(value, 0, 5);
         if (!choreGroupPriorities.TryGetValue(group.IdHash, out PriorityInfo value2))
         {
             value2.priority = 3;
         }
         choreGroupPriorities[group.IdHash] = new PriorityInfo
         {
             priority = value
         };
         UpdateChoreTypePriorities(group, value);
         SetPermittedByUser(group, value != 0);
     }
 }
    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);
    }
    private string GetJobTooltip(GameObject go)
    {
        ToolTip component = go.GetComponent <ToolTip>();

        component.ClearMultiStringTooltip();
        OverviewColumnIdentity component2 = go.GetComponent <OverviewColumnIdentity>();

        if (component2.columnID != "AllTasks")
        {
            ChoreGroup choreGroup = Db.Get().ChoreGroups.Get(component2.columnID);
            component.AddMultiStringTooltip(component2.Column_DisplayName, TextStyle_JobTooltip_Title);
            component.AddMultiStringTooltip(choreGroup.description, TextStyle_JobTooltip_Description);
            component.AddMultiStringTooltip("\n", TextStyle_JobTooltip_Description);
            component.AddMultiStringTooltip(UI.TOOLTIPS.JOBSSCREEN_ATTRIBUTES, TextStyle_JobTooltip_Description);
            component.AddMultiStringTooltip("•  " + choreGroup.attribute.Name, TextStyle_JobTooltip_RelevantAttributes);
        }
        return(string.Empty);
    }
Example #26
0
    private void ChangePersonalPriority(object widget_go_obj, int delta)
    {
        GameObject widget_go = widget_go_obj as GameObject;

        if (widget_go_obj != null)
        {
            TableRow widgetRow = GetWidgetRow(widget_go);
            if (widgetRow.rowType == TableRow.RowType.Header)
            {
                Debug.Assert(false);
            }
            PrioritizationGroupTableColumn prioritizationGroupTableColumn = GetWidgetColumn(widget_go) as PrioritizationGroupTableColumn;
            ChoreGroup chore_group = prioritizationGroupTableColumn.userData as ChoreGroup;
            IPersonalPriorityManager priorityManager = GetPriorityManager(widgetRow);
            ChangePersonalPriority(priorityManager, chore_group, delta, true);
            UpdateWidget(widget_go, chore_group, priorityManager);
        }
    }
Example #27
0
    private void InitializeHeader(ChoreGroup chore_group, GameObject widget_go)
    {
        HierarchyReferences component           = widget_go.GetComponent <HierarchyReferences>();
        HierarchyReferences hierarchyReferences = component.GetReference("PrioritizationWidget") as HierarchyReferences;
        GameObject          items_root          = hierarchyReferences.GetReference("ItemPanel").gameObject;

        if (items_root.transform.childCount <= 0)
        {
            items_root.SetActive(false);
            LocText locText = component.GetReference("Label") as LocText;
            locText.text = chore_group.Name;
            KButton    kButton    = component.GetReference("PrioritizeButton") as KButton;
            Selectable selectable = items_root.GetComponent <Selectable>();
            kButton.onClick += delegate
            {
                selectable.Select();
                items_root.SetActive(true);
            };
            GameObject gameObject = hierarchyReferences.GetReference("ItemTemplate").gameObject;
            for (int num = 5; num >= 0; num--)
            {
                PriorityInfo priorityInfo = GetPriorityInfo(num);
                if (priorityInfo.name != null)
                {
                    GameObject          gameObject2 = Util.KInstantiateUI(gameObject, items_root, true);
                    KButton             component2  = gameObject2.GetComponent <KButton>();
                    HierarchyReferences component3  = gameObject2.GetComponent <HierarchyReferences>();
                    KImage  kImage       = component3.GetReference("Icon") as KImage;
                    LocText locText2     = component3.GetReference("Label") as LocText;
                    int     new_priority = num;
                    component2.onClick += delegate
                    {
                        ChangeColumnPriority(widget_go, new_priority);
                        UnityEngine.EventSystems.EventSystem.current.SetSelectedGameObject(null);
                    };
                    kImage.sprite = priorityInfo.sprite;
                    locText2.text = priorityInfo.name;
                }
            }
        }
    }
    public bool IsChoreGroupDisabled(ChoreGroup chore_group)
    {
        bool   result    = false;
        Traits component = base.gameObject.GetComponent <Traits>();

        foreach (Trait trait in component.TraitList)
        {
            if (trait.disabledChoreGroups != null)
            {
                ChoreGroup[] disabledChoreGroups = trait.disabledChoreGroups;
                foreach (ChoreGroup choreGroup in disabledChoreGroups)
                {
                    if (choreGroup.IdHash == chore_group.IdHash)
                    {
                        result = true;
                        break;
                    }
                }
            }
        }
        return(result);
    }
Example #29
0
    private void CreateChoreButton(ChoreGroup chore_group)
    {
        GameObject gameObject = Util.KInstantiateUI(Prefab_JobPriorityButton, base.transform.gameObject, false);

        gameObject.GetComponent <OverviewColumnIdentity>().columnID           = chore_group.Id;
        gameObject.GetComponent <OverviewColumnIdentity>().Column_DisplayName = chore_group.Name;
        PriorityButton priorityButton = default(PriorityButton);

        priorityButton.button              = gameObject.GetComponent <Button>();
        priorityButton.border              = gameObject.transform.GetChild(1).GetComponent <Image>();
        priorityButton.baseBorderColor     = priorityButton.border.color;
        priorityButton.background          = gameObject.transform.GetChild(0).GetComponent <Image>();
        priorityButton.baseBackgroundColor = priorityButton.background.color;
        priorityButton.choreGroup          = chore_group;
        priorityButton.ToggleIcon          = gameObject.transform.GetChild(2).gameObject;
        priorityButton.tooltip             = gameObject.GetComponent <ToolTip>();
        priorityButton.tooltip.OnToolTip   = (() => OnPriorityButtonTooltip(priorityButton));
        priorityButton.button.onClick.AddListener(delegate
        {
            OnPriorityPress(chore_group);
        });
        PriorityButtons.Add(priorityButton);
    }
    public bool IsPermittedOrEnabled(ChoreType chore_type, Chore chore)
    {
        if (chore_type.groups.Length == 0)
        {
            return(true);
        }
        bool flag  = false;
        bool flag2 = true;

        for (int i = 0; i < chore_type.groups.Length; i++)
        {
            ChoreGroup chore_group = chore_type.groups[i];
            if (!IsPermittedByTraits(chore_group))
            {
                flag2 = false;
            }
            if (IsPermittedByUser(chore_group))
            {
                flag = true;
            }
        }
        return(flag && flag2);
    }