Ejemplo n.º 1
0
        /// <summary>
        /// Uses the stock game logic to look for a usable item, but starts an efficient
        /// fetch search if it is too small.
        /// </summary>
        /// <param name="chore">The chore which is being completed.</param>
        /// <param name="state">The state of that chore.</param>
        /// <param name="result">The item to be picked up.</param>
        /// <returns>true to use the stock logic, or false to skip the stock method</returns>
        internal bool FindFetchTarget(FetchChore chore, ChoreConsumerState state,
                                      out Pickupable result)
        {
            bool cont = true;

            if (chore.destination != null && !state.hasSolidTransferArm && fmPickups != null)
            {
                // Only use if not a storage fetch (tidy)
                var id = chore.choreType?.Id ?? "";
                if (id != choreTypes.StorageFetch.Id && id != choreTypes.CreatureFetch.Id &&
                    id != choreTypes.FoodFetch.Id)
                {
                    result = FindFetchTarget(chore);
                    cont   = false;
                }
                else
                {
                    result = null;
                }
            }
            else
            {
                result = null;
            }
            return(cont);
        }
 public virtual void CollectChores(ChoreConsumerState consumer_state, List <Chore.Precondition.Context> succeeded, List <Chore.Precondition.Context> failed_contexts)
 {
     for (int i = 0; i < chores.Count; i++)
     {
         Chore chore = chores[i];
         chore.CollectChores(consumer_state, succeeded, failed_contexts, false);
     }
 }
Ejemplo n.º 3
0
 public override void CollectChores(ChoreConsumerState consumer_state, List <Chore.Precondition.Context> succeeded, List <Chore.Precondition.Context> failed_contexts)
 {
     base.CollectChores(consumer_state, succeeded, failed_contexts);
     clearableManager.CollectChores(consumer_state, succeeded, failed_contexts);
     foreach (Fetch fetch in fetches)
     {
         Fetch current = fetch;
         current.chore.CollectChoresFromGlobalChoreProvider(consumer_state, succeeded, failed_contexts, false);
     }
 }
Ejemplo n.º 4
0
            /// <summary>
            /// Applied before FindFetchTarget runs.
            /// </summary>
            internal static bool Prefix(FetchChore __instance, ChoreConsumerState
                                        consumer_state, ref Pickupable __result)
            {
                var  inst = EfficientFetchManager.Instance;
                bool cont = true;

                if (inst != null && options.MinimumAmountPercent > 0)
                {
                    cont = inst.FindFetchTarget(__instance, consumer_state, out __result);
                }
                return(cont);
            }
Ejemplo n.º 5
0
 public virtual void CollectChores(ChoreConsumerState consumer_state, List <Precondition.Context> succeeded_contexts, List <Precondition.Context> failed_contexts, bool is_attempting_override)
 {
     Precondition.Context item = new Precondition.Context(this, consumer_state, is_attempting_override, null);
     item.RunPreconditions();
     if (item.IsSuccess())
     {
         succeeded_contexts.Add(item);
     }
     else
     {
         failed_contexts.Add(item);
     }
 }
Ejemplo n.º 6
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);
 }
    protected override void OnSpawn()
    {
        base.OnSpawn();
        KPrefabID component = GetComponent <KPrefabID>();

        if (choreTable != null)
        {
            choreTableInstance = new ChoreTable.Instance(choreTable, component);
        }
        foreach (ChoreGroup resource in Db.Get().ChoreGroups.resources)
        {
            int personalPriority = GetPersonalPriority(resource);
            UpdateChoreTypePriorities(resource, personalPriority);
            SetPermittedByUser(resource, personalPriority != 0);
        }
        consumerState = new ChoreConsumerState(this);
    }
Ejemplo n.º 8
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 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;
            }
        }
    }