Exemplo n.º 1
0
 /// <summary>
 /// Queues a dig on the cell if it is not already queued for digging.
 /// </summary>
 /// <param name="cell">The cell which should be dug once it solidifies.</param>
 public void QueueDig(int cell, PrioritySetting priority)
 {
     if (!digCells.ContainsKey(cell))
     {
         digCells.Add(cell, priority);
     }
 }
Exemplo n.º 2
0
 public Chore(ChoreType chore_type, ChoreProvider chore_provider, bool run_until_complete, Action <Chore> on_complete, Action <Chore> on_begin, Action <Chore> on_end, PriorityScreen.PriorityClass priority_class, int priority_value, bool is_preemptable, bool allow_in_context_menu, int priority_mod, bool add_to_daily_report, ReportManager.ReportType report_type)
 {
     if (priority_value == 2147483647)
     {
         priority_class = PriorityScreen.PriorityClass.topPriority;
         priority_value = 2;
     }
     if (priority_value < 1 || priority_value > 9)
     {
         Debug.LogErrorFormat("Priority Value Out Of Range: {0}", priority_value);
     }
     masterPriority = new PrioritySetting(priority_class, priority_value);
     priorityMod    = priority_mod;
     id             = ++nextId;
     if ((UnityEngine.Object)chore_provider == (UnityEngine.Object)null)
     {
         chore_provider = GlobalChoreProvider.Instance;
         DebugUtil.Assert((UnityEngine.Object)chore_provider != (UnityEngine.Object)null);
     }
     choreType        = chore_type;
     runUntilComplete = run_until_complete;
     onComplete       = on_complete;
     onEnd            = on_end;
     onBegin          = on_begin;
     IsPreemptable    = is_preemptable;
     AddPrecondition(ChorePreconditions.instance.IsValid, null);
     AddPrecondition(ChorePreconditions.instance.IsPermitted, null);
     AddPrecondition(ChorePreconditions.instance.IsPreemptable, null);
     AddPrecondition(ChorePreconditions.instance.HasUrge, null);
     AddPrecondition(ChorePreconditions.instance.IsMoreSatisfyingEarly, null);
     AddPrecondition(ChorePreconditions.instance.IsMoreSatisfyingLate, null);
     AddPrecondition(ChorePreconditions.instance.IsOverrideTargetNullOrMe, null);
     chore_provider.AddChore(this);
 }
Exemplo n.º 3
0
            public static void SetToolPrioritySetting(InterfaceTool tool, PrioritySetting prioritySetting)
            {
                if (tool is BuildTool || tool is BaseUtilityBuildTool)
                {
                    ProductInfoScreen productInfoScreen = null;
                    if (BuildMenu.Instance != null)
                    {
                        productInfoScreen = _buildProductInfoScreen.GetValue(BuildMenu.Instance) as ProductInfoScreen;
                    }
                    else if (PlanScreen.Instance != null)
                    {
                        productInfoScreen = _planProductInfoScreen.GetValue(PlanScreen.Instance) as ProductInfoScreen;
                    }

                    if (productInfoScreen == null)
                    {
                        return;
                    }

                    productInfoScreen.materialSelectionPanel.PriorityScreen.SetScreenPriority(prioritySetting);
                }
                else
                {
                    ToolMenu.Instance.PriorityScreen.SetScreenPriority(prioritySetting);
                }
            }
Exemplo n.º 4
0
    protected override void OnDragTool(int cell, int distFromOrigin)
    {
        PrioritySetting lastSelectedPriority = ToolMenu.Instance.PriorityScreen.GetLastSelectedPriority();
        int             num = 0;

        for (int i = 0; i < 39; i++)
        {
            GameObject gameObject = Grid.Objects[cell, i];
            if ((Object)gameObject != (Object)null)
            {
                if ((bool)gameObject.GetComponent <Pickupable>())
                {
                    ObjectLayerListItem objectLayerListItem = gameObject.GetComponent <Pickupable>().objectLayerListItem;
                    while (objectLayerListItem != null)
                    {
                        GameObject gameObject2 = objectLayerListItem.gameObject;
                        objectLayerListItem = objectLayerListItem.nextItem;
                        if (!((Object)gameObject2 == (Object)null) && !((Object)gameObject2.GetComponent <MinionIdentity>() != (Object)null) && TryPrioritizeGameObject(gameObject2, lastSelectedPriority))
                        {
                            num++;
                        }
                    }
                }
                else if (TryPrioritizeGameObject(gameObject, lastSelectedPriority))
                {
                    num++;
                }
            }
        }
        if (num > 0)
        {
            PriorityScreen.PlayPriorityConfirmSound(lastSelectedPriority);
        }
    }
Exemplo n.º 5
0
 private void OnClick(PrioritySetting priority)
 {
     if (onClick != null)
     {
         onClick(priority);
     }
 }
Exemplo n.º 6
0
 protected void SetPrioritizable(Prioritizable prioritizable)
 {
     if ((UnityEngine.Object)prioritizable != (UnityEngine.Object)null && prioritizable.IsPrioritizable())
     {
         this.prioritizable = prioritizable;
         masterPriority     = prioritizable.GetMasterPriority();
         prioritizable.onPriorityChanged = (Action <PrioritySetting>)Delegate.Combine(prioritizable.onPriorityChanged, new Action <PrioritySetting>(OnMasterPriorityChanged));
     }
 }
Exemplo n.º 7
0
        private static float AdjustedValue(PrioritySetting setting)
        {
            if (setting.priority_class == PriorityZero.PriorityZeroClass)
            {
                return(1);
            }

            return(setting.priority_value + 1);
        }
Exemplo n.º 8
0
 private void OnPriorityChanged(PrioritySetting priority)
 {
     building.RunOnArea(delegate(int cell)
     {
         Diggable diggable = Diggable.GetDiggable(cell);
         if ((UnityEngine.Object)diggable != (UnityEngine.Object)null)
         {
             diggable.GetComponent <Prioritizable>().SetMasterPriority(priority);
         }
     });
 }
Exemplo n.º 9
0
 private void OnDeserialized()
 {
     if (masterPriority != -2147483648)
     {
         masterPrioritySetting = new PrioritySetting(PriorityScreen.PriorityClass.basic, 5);
         masterPriority        = -2147483648;
     }
     if (SaveLoader.Instance.GameInfo.IsVersionExactly(7, 2) && conversions.TryGetValue(masterPrioritySetting, out PrioritySetting value))
     {
         masterPrioritySetting = value;
     }
 }
Exemplo n.º 10
0
 public void SetMasterPriority(PrioritySetting priority)
 {
     if (!priority.Equals(masterPrioritySetting))
     {
         masterPrioritySetting = priority;
         if (onPriorityChanged != null)
         {
             onPriorityChanged(masterPrioritySetting);
         }
         RefreshHighPriorityNotification();
     }
 }
    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);
                }
            };
        }
    }
Exemplo n.º 12
0
            /// <summary>
            /// Classifies yellow alert sweeps as 11 effective priority ahead of all others
            /// in the 1-9 range.
            /// </summary>
            /// <param name="setting">The current item priority setting.</param>
            /// <returns>The priority level to use for sorting.</returns>
            private static int GetComputedPriority(PrioritySetting setting)
            {
                int priority;

                if (setting.priority_class == PriorityScreen.PriorityClass.topPriority)
                {
                    priority = 11;
                }
                else
                {
                    priority = setting.priority_value;
                }
                return(priority);
            }
        private bool TryPrioritizeGameObject(GameObject target, PrioritySetting priority)
        {
            if (MultiToolParameterMenu.Instance.IsActiveLayer(GetFilterLayerFromGameObject(target)))
            {
                Prioritizable prioritizable = target.GetComponent <Prioritizable>();

                if (prioritizable != null && prioritizable.showIcon && prioritizable.IsPrioritizable())
                {
                    prioritizable.SetMasterPriority(priority);
                    return(true);
                }
            }
            return(false);
        }
Exemplo n.º 14
0
    private bool TryPrioritizeGameObject(GameObject target, PrioritySetting priority)
    {
        string filterLayerFromGameObject = GetFilterLayerFromGameObject(target);

        if (IsActiveLayer(filterLayerFromGameObject))
        {
            Prioritizable component = target.GetComponent <Prioritizable>();
            if ((Object)component != (Object)null && component.showIcon && component.IsPrioritizable())
            {
                component.SetMasterPriority(priority);
                return(true);
            }
        }
        return(false);
    }
Exemplo n.º 15
0
        /// <summary>
        /// Marks a debris item to be swept if it matches the filters.
        /// </summary>
        /// <param name="content">The item to sweep.</param>
        /// <param name="priority">The priority to set the sweep errand.</param>
        private void MarkForClear(GameObject content, PrioritySetting priority)
        {
            var cc = content.GetComponent <Clearable>();

            if (cc != null && cc.isClearable && cachedTypes.Contains(content.PrefabID()))
            {
                // Parameter is whether to force, not remove sweep errand!
                cc.MarkForClear(false);
                var pr = content.GetComponent <Prioritizable>();
                if (pr != null)
                {
                    pr.SetMasterPriority(priority);
                }
            }
        }
Exemplo n.º 16
0
        /// <summary>
        /// Marks a debris item to be swept if it matches the filters.
        /// </summary>
        /// <param name="content">The item to sweep.</param>
        /// <param name="priority">The priority to set the sweep errand.</param>
        private void MarkForClear(GameObject content, PrioritySetting priority)
        {
            var cc = content.GetComponent <Clearable>();

            if (cc != null && cc.isClearable && (cachedAll || cachedTypes.Contains(content.
                                                                                   PrefabID())))
            {
                // In beta branch a new optional parameter was added
                cc.MarkForClear(false);
                var pr = content.GetComponent <Prioritizable>();
                if (pr != null)
                {
                    pr.SetMasterPriority(priority);
                }
            }
        }
Exemplo n.º 17
0
 public void Set(Chore chore, ChoreConsumerState consumer_state, bool is_attempting_override, object data = null)
 {
     masterPriority    = chore.masterPriority;
     priority          = 0;
     priorityMod       = chore.priorityMod;
     consumerPriority  = 0;
     interruptPriority = 0;
     cost                   = 0;
     this.chore             = chore;
     consumerState          = consumer_state;
     failedPreconditionId   = -1;
     isAttemptingOverride   = is_attempting_override;
     this.data              = data;
     choreTypeForPermission = chore.choreType;
     SetPriority(chore);
 }
Exemplo n.º 18
0
 private void RefreshButton(PriorityButton b, PrioritySetting priority, bool play_sound)
 {
     if (b.priority == priority)
     {
         b.toggle.Select();
         b.toggle.isOn = true;
         if (play_sound)
         {
             b.toggle.soundPlayer.Play(0);
         }
     }
     else
     {
         b.toggle.isOn = false;
     }
 }
        public HandleVector <int> .Handle AddPickupable(Pickupable pickupable)
        {
            byte   foodQuality = 5;
            Edible component   = pickupable.GetComponent <Edible>();

            if ((Object)component != (Object)null)
            {
                foodQuality = (byte)component.GetQuality();
            }
            byte          masterPriority = 0;
            Prioritizable prioritizable  = null;

            if ((Object)pickupable.storage != (Object)null)
            {
                prioritizable = pickupable.storage.prioritizable;
                if ((Object)prioritizable != (Object)null)
                {
                    PrioritySetting masterPriority2 = prioritizable.GetMasterPriority();
                    masterPriority = (byte)masterPriority2.priority_value;
                }
            }
            Rottable.Instance sMI = pickupable.GetSMI <Rottable.Instance>();
            byte freshness        = 0;

            if (!sMI.IsNullOrStopped())
            {
                freshness = QuantizeRotValue(sMI.RotValue);
            }
            KPrefabID component2 = pickupable.GetComponent <KPrefabID>();
            TagBits   rhs        = new TagBits(ref disallowedTagMask);

            component2.AndTagBits(ref rhs);
            HandleVector <int> .Handle handle = fetchables.Allocate(new Fetchable
            {
                pickupable     = pickupable,
                foodQuality    = foodQuality,
                freshness      = freshness,
                masterPriority = masterPriority,
                tagBitsHash    = rhs.GetHashCode()
            });
            if (!sMI.IsNullOrStopped())
            {
                rotUpdaters[handle] = sMI;
            }
            return(handle);
        }
Exemplo n.º 20
0
 public Context(Chore chore, ChoreConsumerState consumer_state, bool is_attempting_override, object data = null)
 {
     masterPriority    = chore.masterPriority;
     personalPriority  = consumer_state.consumer.GetPersonalPriority(chore.choreType);
     priority          = 0;
     priorityMod       = chore.priorityMod;
     consumerPriority  = 0;
     interruptPriority = 0;
     cost                   = 0;
     this.chore             = chore;
     consumerState          = consumer_state;
     failedPreconditionId   = -1;
     isAttemptingOverride   = is_attempting_override;
     this.data              = data;
     choreTypeForPermission = chore.choreType;
     skipMoreSatisfyingEarlyPrecondition = ((UnityEngine.Object)RootMenu.Instance != (UnityEngine.Object)null && RootMenu.Instance.IsBuildingChorePanelActive());
     SetPriority(chore);
 }
        public void UpdateStorage(HandleVector <int> .Handle fetchable_handle, Storage storage)
        {
            Fetchable     data           = fetchables.GetData(fetchable_handle);
            byte          masterPriority = 0;
            Prioritizable prioritizable  = null;
            Pickupable    pickupable     = data.pickupable;

            if ((Object)pickupable.storage != (Object)null)
            {
                prioritizable = pickupable.storage.prioritizable;
                if ((Object)prioritizable != (Object)null)
                {
                    PrioritySetting masterPriority2 = prioritizable.GetMasterPriority();
                    masterPriority = (byte)masterPriority2.priority_value;
                }
            }
            data.masterPriority = masterPriority;
            fetchables.SetData(fetchable_handle, data);
        }
 public static void MarkForCapture(Vector2 min, Vector2 max, bool mark)
 {
     foreach (Capturable item in Components.Capturables.Items)
     {
         Vector2 vector = Grid.PosToXY(item.transform.GetPosition());
         if (vector.x >= min.x && vector.x < max.x && vector.y >= min.y && vector.y < max.y)
         {
             if (item.allowCapture)
             {
                 PrioritySetting lastSelectedPriority = ToolMenu.Instance.PriorityScreen.GetLastSelectedPriority();
                 item.MarkForCapture(mark, lastSelectedPriority);
             }
             else if (mark)
             {
                 PopFXManager.Instance.SpawnFX(PopFXManager.Instance.sprite_Negative, UI.TOOLS.CAPTURE.NOT_CAPTURABLE, null, item.transform.GetPosition(), 1.5f, false, false);
             }
         }
     }
 }
    public void CollectChores(ChoreConsumerState consumer_state, List <Chore.Precondition.Context> succeeded, List <Chore.Precondition.Context> failed_contexts)
    {
        ChoreType transport        = Db.Get().ChoreTypes.Transport;
        int       personalPriority = consumer_state.consumer.GetPersonalPriority(transport);
        int       priority         = (!Game.Instance.advancedPersonalPriorities) ? transport.priority : transport.explicitPriority;

        CollectSortedClearables(consumer_state.navigator, markedClearables, sortedClearables);
        bool flag = false;

        foreach (SortedClearable sortedClearable in sortedClearables)
        {
            SortedClearable            current        = sortedClearable;
            Pickupable                 pickupable     = current.pickupable;
            PrioritySetting            masterPriority = current.masterPriority;
            Chore.Precondition.Context item           = default(Chore.Precondition.Context);
            item.personalPriority = personalPriority;
            KPrefabID kPrefabID = pickupable.KPrefabID;
            kPrefabID.UpdateTagBits();
            foreach (GlobalChoreProvider.Fetch fetch in GlobalChoreProvider.Instance.fetches)
            {
                GlobalChoreProvider.Fetch current2 = fetch;
                if (kPrefabID.HasAnyTags_AssumeLaundered(ref current2.chore.tagBits))
                {
                    item.Set(current2.chore, consumer_state, false, pickupable);
                    item.choreTypeForPermission = transport;
                    item.RunPreconditions();
                    if (item.IsSuccess())
                    {
                        item.masterPriority    = masterPriority;
                        item.priority          = priority;
                        item.interruptPriority = transport.interruptPriority;
                        succeeded.Add(item);
                        flag = true;
                        break;
                    }
                }
            }
            if (flag)
            {
                break;
            }
        }
    }
        public void Update()
        {
            PrioritySetting selectedPriority = ToolMenu.Instance.PriorityScreen.GetLastSelectedPriority();

            int offset = 0;

            if (selectedPriority.priority_class >= PriorityScreen.PriorityClass.high)
            {
                offset += 9;
            }

            Texture2D    cursor       = PrioritizeTool.Instance.cursors[offset + selectedPriority.priority_value - 1];
            MeshRenderer meshRenderer = visualizer.GetComponentInChildren <MeshRenderer>();

            if (meshRenderer != null)
            {
                meshRenderer.material.mainTexture = cursor;
            }
        }
Exemplo n.º 25
0
    public static void PlayPriorityConfirmSound(PrioritySetting priority)
    {
        EventInstance instance = KFMOD.BeginOneShot(GlobalAssets.GetSound("Priority_Tool_Confirm", false), Vector3.zero);

        if (instance.isValid())
        {
            float num = 0f;
            if (priority.priority_class >= PriorityClass.high)
            {
                num += 10f;
            }
            if (priority.priority_class >= PriorityClass.topPriority)
            {
                num = num;
            }
            num += (float)priority.priority_value;
            instance.setParameterValue("priority", num);
            KFMOD.EndOneShot(instance);
        }
    }
 public void MarkForCapture(bool mark, PrioritySetting priority)
 {
     mark = (mark && IsCapturable());
     if (markedForCapture && !mark)
     {
         Prioritizable.RemoveRef(base.gameObject);
     }
     else if (!markedForCapture && mark)
     {
         Prioritizable.AddRef(base.gameObject);
         Prioritizable component = GetComponent <Prioritizable>();
         if ((bool)component)
         {
             component.SetMasterPriority(priority);
         }
     }
     markedForCapture = mark;
     UpdateStatusItem();
     UpdateChore();
 }
Exemplo n.º 27
0
            public static void Postfix(ref Constructable __instance, ref Building ___building)
            {
                // Check if the building is not a background object
                if (___building.Def.ObjectLayer != ObjectLayer.Building)
                {
                    return;
                }
                PrioritySetting masterPriority = __instance.GetComponent <Prioritizable> ().GetMasterPriority();

                ___building.RunOnArea(delegate(int offset_cell) {
                    GameObject gameObject = Grid.Objects [offset_cell, (int)ObjectLayer.Plants];
                    if (gameObject != null)
                    {
                        // This component should always exist but lets check it just in case
                        if (gameObject.GetComponent <Uprootable> () != null)
                        {
                            gameObject.GetComponent <Uprootable> ().MarkForUproot(true);
                            gameObject.GetComponent <Prioritizable> ().SetMasterPriority(masterPriority);
                        }
                    }
                });
            }
Exemplo n.º 28
0
    public void Update()
    {
        PrioritySetting lastSelectedPriority = ToolMenu.Instance.PriorityScreen.GetLastSelectedPriority();
        int             num = 0;

        if (lastSelectedPriority.priority_class >= PriorityScreen.PriorityClass.high)
        {
            num += 9;
        }
        if (lastSelectedPriority.priority_class >= PriorityScreen.PriorityClass.topPriority)
        {
            num = num;
        }
        num += lastSelectedPriority.priority_value;
        Texture2D    mainTexture         = cursors[num - 1];
        MeshRenderer componentInChildren = visualizer.GetComponentInChildren <MeshRenderer>();

        if ((Object)componentInChildren != (Object)null)
        {
            componentInChildren.material.mainTexture = mainTexture;
        }
    }
Exemplo n.º 29
0
 public void SetScreenPriority(PrioritySetting priority, bool play_sound = false)
 {
     if (!(lastSelectedPriority == priority))
     {
         lastSelectedPriority = priority;
         if (priority.priority_class == PriorityClass.high)
         {
             button_toggleHigh.isOn = true;
         }
         else if (priority.priority_class == PriorityClass.basic)
         {
             button_toggleHigh.isOn = false;
         }
         for (int i = 0; i < buttons_basic.Count; i++)
         {
             buttons_basic[i].priority = new PrioritySetting(button_toggleHigh.isOn ? PriorityClass.high : PriorityClass.basic, i + 1);
             buttons_basic[i].tooltip.SetSimpleTooltip(string.Format((!button_toggleHigh.isOn) ? UI.PRIORITYSCREEN.BASIC : UI.PRIORITYSCREEN.HIGH, i + 1));
             RefreshButton(buttons_basic[i], lastSelectedPriority, play_sound);
         }
         RefreshButton(button_emergency, lastSelectedPriority, play_sound);
     }
 }
        protected override void OnDragTool(int cell, int distFromOrigin)
        {
            PrioritySetting selectedPriority  = ToolMenu.Instance.PriorityScreen.GetLastSelectedPriority();
            int             prioritiesChanged = 0;

            for (int index = 0; index < 40; ++index)
            {
                GameObject gameObject = Grid.Objects[cell, index];

                if (gameObject != null)
                {
                    if (gameObject.GetComponent <Pickupable>())
                    {
                        ObjectLayerListItem objectLayerListItem = gameObject.GetComponent <Pickupable>().objectLayerListItem;

                        while (objectLayerListItem != null)
                        {
                            GameObject currentObject = objectLayerListItem.gameObject;
                            objectLayerListItem = objectLayerListItem.nextItem;

                            if (currentObject != null && !(currentObject.GetComponent <MinionIdentity>() != null && TryPrioritizeGameObject(currentObject, selectedPriority)))
                            {
                                ++prioritiesChanged;
                            }
                        }
                    }

                    else if (TryPrioritizeGameObject(gameObject, selectedPriority))
                    {
                        ++prioritiesChanged;
                    }
                }
            }

            if (prioritiesChanged > 0)
            {
                PriorityScreen.PlayPriorityConfirmSound(selectedPriority);
            }
        }