public FetchList2 CreateFetchList()
            {
                var fetchList = new FetchList2(master.storage, Db.Get().ChoreTypes.DoctorFetch);

                fetchList.Add(GlomConfig.ID, requiredFetchTags, null, 1f, FetchOrder2.OperationalRequirement.Functional);
                return(fetchList);
            }
    private void OnFilterChanged(Tag[] tags)
    {
        KBatchedAnimController component = root.GetComponent <KBatchedAnimController>();
        bool flag = tags != null && tags.Length != 0;

        component.TintColour = ((!flag) ? noFilterTint : filterTint);
        if (fetchList != null)
        {
            fetchList.Cancel(string.Empty);
            fetchList = null;
        }
        float maxCapacityMinusStorageMargin = GetMaxCapacityMinusStorageMargin();
        float amountStored = GetAmountStored();
        float num          = Mathf.Max(0f, maxCapacityMinusStorageMargin - amountStored);

        if (num > 0f && flag)
        {
            num       = Mathf.Max(0f, GetMaxCapacity() - amountStored);
            fetchList = new FetchList2(storage, choreType);
            fetchList.ShowStatusItem = false;
            fetchList.Add(tags, requiredTags, forbiddenTags, num, FetchOrder2.OperationalRequirement.Functional);
            fetchList.Submit(OnFetchComplete, false);
        }
        root.GetComponent <KSelectable>().ToggleStatusItem(noFilterStatusItem, !flag, this);
    }
Exemple #3
0
        private void SetFetchList()
        {
            fetchList = new FetchList2(storage, Db.Get().ChoreTypes.BuildFetch);
            Tag   insulation = ElementLoader.FindElementByHash(SimHashes.SuperInsulator).tag;
            float massNeeded = MassToInsulate - StoredInsulation();

            fetchList.Add(insulation, null, null, MassToInsulate);
            MaterialNeeds.Instance.UpdateNeed(insulation, massNeeded);
            submittedNeedAmount = massNeeded;
            fetchList.Submit(onFetchComplete, true);
            Prioritizable.AddRef(gameObject);
        }
Exemple #4
0
    private void UpdateFetches(DictionaryPool <Tag, float, ComplexFabricator> .PooledDictionary missingAmounts)
    {
        ChoreType byHash = Db.Get().ChoreTypes.GetByHash(fetchChoreTypeIdHash);

        foreach (KeyValuePair <Tag, float> missingAmount in missingAmounts)
        {
            if (missingAmount.Value >= PICKUPABLETUNING.MINIMUM_PICKABLE_AMOUNT && !HasPendingFetch(missingAmount.Key))
            {
                FetchList2 fetchList  = new FetchList2(inStorage, byHash);
                FetchList2 fetchList2 = fetchList;
                Tag        key        = missingAmount.Key;
                float      value      = missingAmount.Value;
                fetchList2.Add(key, null, null, value, FetchOrder2.OperationalRequirement.None);
                fetchList.ShowStatusItem = false;
                fetchList.Submit(OnFetchComplete, false);
                fetchListList.Add(fetchList);
            }
        }
    }
 private void UpdateFetchList()
 {
     if (this.paused)
     {
         return;
     }
     if (this.fetchList != null && this.fetchList.IsComplete)
     {
         this.fetchList = null;
     }
     if (!this.OperationalRequirementsMet())
     {
         if (this.fetchList != null)
         {
             this.fetchList.Cancel("Operational requirements");
             this.fetchList = null;
         }
     }
     else if (this.fetchList == null)
     {
         float massAvailable = this.storage.GetMassAvailable(this.requestedItemTag);
         if (massAvailable < this.refillMass)
         {
             float num = this.capacity - massAvailable;
             num = Mathf.Max(PICKUPABLETUNING.MINIMUM_PICKABLE_AMOUNT, num);
             ChoreType byHash = Db.Get().ChoreTypes.GetByHash(this.choreTypeIDHash);
             this.fetchList = new FetchList2(this.storage, byHash);
             this.fetchList.ShowStatusItem = this.ShowStatusItem;
             this.fetchList.MinimumAmount[this.requestedItemTag] = Mathf.Max(PICKUPABLETUNING.MINIMUM_PICKABLE_AMOUNT, this.minimumMass);
             FetchList2 arg_12B_0 = this.fetchList;
             Tag[]      tags      = new Tag[]
             {
                 this.requestedItemTag
             };
             float amount = num;
             arg_12B_0.Add(tags, null, null, amount, FetchOrder2.OperationalRequirement.None);
             this.fetchList.Submit(null, false);
         }
     }
 }
 private void UpdateFetchList()
 {
     if (!paused)
     {
         if (this.fetchList != null && this.fetchList.IsComplete)
         {
             this.fetchList = null;
         }
         if (!OperationalRequirementsMet())
         {
             if (this.fetchList != null)
             {
                 this.fetchList.Cancel("Operational requirements");
                 this.fetchList = null;
             }
         }
         else if (this.fetchList == null)
         {
             float massAvailable = storage.GetMassAvailable(requestedItemTag);
             if (massAvailable < refillMass)
             {
                 float b = capacity - massAvailable;
                 b = Mathf.Max(PICKUPABLETUNING.MINIMUM_PICKABLE_AMOUNT, b);
                 ChoreType byHash = Db.Get().ChoreTypes.GetByHash(choreTypeIDHash);
                 this.fetchList = new FetchList2(storage, byHash);
                 this.fetchList.ShowStatusItem = ShowStatusItem;
                 this.fetchList.MinimumAmount[requestedItemTag] = Mathf.Max(PICKUPABLETUNING.MINIMUM_PICKABLE_AMOUNT, minimumMass);
                 FetchList2 fetchList = this.fetchList;
                 Tag[]      tags      = new Tag[1]
                 {
                     requestedItemTag
                 };
                 float amount = b;
                 fetchList.Add(tags, null, null, amount, FetchOrder2.OperationalRequirement.None);
                 this.fetchList.Submit(null, false);
             }
         }
     }
 }
Exemple #7
0
 private static void InjectForbiddenTag(FetchList2 fetchList, Tag tag, Tag[] required_tags, Tag[] forbidden_tags, float amount, FetchOrder2.OperationalRequirement operationalRequirement)
 {
     forbidden_tags = (forbidden_tags ?? new Tag[0]).AddItem(GameTags.CharmedArtifact).ToArray();
     fetchList.Add(tag, required_tags, forbidden_tags, amount, operationalRequirement);
 }
Exemple #8
0
    protected override void OnSpawn()
    {
        base.OnSpawn();
        Subscribe(2127324410, OnCancelDelegate);
        if ((UnityEngine.Object)rotatable != (UnityEngine.Object)null)
        {
            MarkArea();
        }
        this.fetchList = new FetchList2(storage, Db.Get().ChoreTypes.BuildFetch);
        PrimaryElement component = GetComponent <PrimaryElement>();
        Element        element   = ElementLoader.GetElement(SelectedElementsTags[0]);

        Debug.Assert(element != null, "Missing primary element for Constructable");
        component.ElementID = element.id;
        float num3 = component.Temperature = (component.Temperature = 293.15f);

        Recipe.Ingredient[] allIngredients = Recipe.GetAllIngredients(selectedElementsTags);
        foreach (Recipe.Ingredient ingredient in allIngredients)
        {
            FetchList2 fetchList = this.fetchList;
            Tag        tag       = ingredient.tag;
            num3 = ingredient.amount;
            fetchList.Add(tag, null, null, num3, FetchOrder2.OperationalRequirement.None);
            MaterialNeeds.Instance.UpdateNeed(ingredient.tag, ingredient.amount);
        }
        if (!building.Def.IsTilePiece)
        {
            base.gameObject.layer = LayerMask.NameToLayer("Construction");
        }
        building.RunOnArea(delegate(int offset_cell)
        {
            if ((UnityEngine.Object)base.gameObject.GetComponent <ConduitBridge>() == (UnityEngine.Object)null)
            {
                GameObject gameObject2 = Grid.Objects[offset_cell, 7];
                if ((UnityEngine.Object)gameObject2 != (UnityEngine.Object)null)
                {
                    gameObject2.DeleteObject();
                }
            }
        });
        if (IsReplacementTile)
        {
            GameObject gameObject = null;
            if (building.Def.ReplacementLayer != ObjectLayer.NumLayers)
            {
                int cell = Grid.PosToCell(base.transform.GetPosition());
                gameObject = Grid.Objects[cell, (int)building.Def.ReplacementLayer];
                if ((UnityEngine.Object)gameObject == (UnityEngine.Object)null || (UnityEngine.Object)gameObject == (UnityEngine.Object)base.gameObject)
                {
                    Grid.Objects[cell, (int)building.Def.ReplacementLayer] = base.gameObject;
                    if ((UnityEngine.Object)base.gameObject.GetComponent <SimCellOccupier>() != (UnityEngine.Object)null)
                    {
                        int renderLayer = LayerMask.NameToLayer("Overlay");
                        World.Instance.blockTileRenderer.AddBlock(renderLayer, building.Def, IsReplacementTile, SimHashes.Void, cell);
                    }
                    TileVisualizer.RefreshCell(cell, building.Def.TileLayer, building.Def.ReplacementLayer);
                }
                else
                {
                    Debug.LogError("multiple replacement tiles on the same cell!");
                    Util.KDestroyGameObject(base.gameObject);
                }
            }
        }
        bool flag = building.Def.BuildingComplete.GetComponent <Ladder>();

        waitForFetchesBeforeDigging = (flag || (bool)building.Def.BuildingComplete.GetComponent <SimCellOccupier>() || (bool)building.Def.BuildingComplete.GetComponent <Door>() || (bool)building.Def.BuildingComplete.GetComponent <LiquidPumpingStation>());
        if (flag)
        {
            int x     = 0;
            int y     = 0;
            int cell2 = Grid.PosToCell(this);
            Grid.CellToXY(cell2, out x, out y);
            int y2 = y - 3;
            ladderDetectionExtents = new Extents(x, y2, 1, 5);
            ladderParititonerEntry = GameScenePartitioner.Instance.Add("Constructable.OnNearbyBuildingLayerChanged", base.gameObject, ladderDetectionExtents, GameScenePartitioner.Instance.objectLayers[1], OnNearbyBuildingLayerChanged);
            OnNearbyBuildingLayerChanged(null);
        }
        this.fetchList.Submit(OnFetchListComplete, true);
        PlaceDiggables();
        ReachabilityMonitor.Instance instance = new ReachabilityMonitor.Instance(this);
        instance.StartSM();
        Subscribe(493375141, OnRefreshUserMenuDelegate);
        Prioritizable component2 = GetComponent <Prioritizable>();
        Prioritizable obj        = component2;

        obj.onPriorityChanged = (Action <PrioritySetting>)Delegate.Combine(obj.onPriorityChanged, new Action <PrioritySetting>(OnPriorityChanged));
        OnPriorityChanged(component2.GetMasterPriority());
    }