private void RebalanceFetches() { TreeFilterable component = GetComponent <TreeFilterable>(); Tag[] tags = component.GetTags(); ChoreType creatureFetch = Db.Get().ChoreTypes.CreatureFetch; Storage component2 = GetComponent <Storage>(); int num = creatureLimit - storedCreatureCount; int count = fetches.Count; int num2 = 0; int num3 = 0; int num4 = 0; int num5 = 0; for (int num6 = fetches.Count - 1; num6 >= 0; num6--) { if (fetches[num6].IsComplete()) { fetches.RemoveAt(num6); num2++; } } int num7 = 0; for (int i = 0; i < fetches.Count; i++) { if (!fetches[i].InProgress) { num7++; } } if (num7 == 0 && fetches.Count < num) { FetchOrder2 fetchOrder = new FetchOrder2(creatureFetch, tags, requiredFetchTags, null, component2, 1f, FetchOrder2.OperationalRequirement.Operational, 0); fetchOrder.Submit(OnFetchComplete, false, OnFetchBegun); fetches.Add(fetchOrder); num3++; } int num8 = fetches.Count - num; int num9 = fetches.Count - 1; while (num9 >= 0 && num8 > 0) { if (!fetches[num9].InProgress) { fetches[num9].Cancel("fewer creatures in room"); fetches.RemoveAt(num9); num8--; num4++; } num9--; } while (num8 > 0 && fetches.Count > 0) { fetches[fetches.Count - 1].Cancel("fewer creatures in room"); fetches.RemoveAt(fetches.Count - 1); num8--; num5++; } }
public void Add(Tag[] tags, Tag[] required_tags = null, Tag[] forbidden_tags = null, float amount = 1f, FetchOrder2.OperationalRequirement operationalRequirementDEPRECATED = FetchOrder2.OperationalRequirement.None) { foreach (Tag key in tags) { if (!MinimumAmount.ContainsKey(key)) { MinimumAmount[key] = amount; } } FetchOrder2 item = new FetchOrder2(choreType, tags, required_tags, forbidden_tags, Destination, amount, operationalRequirementDEPRECATED, PriorityMod); FetchOrders.Add(item); }
private void OnFetchOrderComplete(FetchOrder2 fetch_order, Pickupable fetched_item) { FetchOrders.Remove(fetch_order); if (FetchOrders.Count == 0) { if (OnComplete != null) { OnComplete(); } FetchListStatusItemUpdater.instance.RemoveFetchList(this); ClearStatus(); } }
public void UpdateRemaining() { Remaining.Clear(); for (int i = 0; i < FetchOrders.Count; i++) { FetchOrder2 fetchOrder = FetchOrders[i]; for (int j = 0; j < fetchOrder.Tags.Length; j++) { Tag key = fetchOrder.Tags[j]; float value = 0f; Remaining.TryGetValue(key, out value); Remaining[key] = value + fetchOrder.AmountWaitingToFetch(); } } }
private void OnFetchBegun(FetchOrder2 fetchOrder, Pickupable fetchedItem) { RebalanceFetches(); }
private void OnFetchComplete(FetchOrder2 fetchOrder, Pickupable fetchedItem) { RebalanceFetches(); }