Ejemplo n.º 1
0
        private void ConduitUpdate(float dt)
        {
            bool flag = false;

            if (this.operational.IsOperational)
            {
                SolidConduitFlow flowManager = SolidConduit.GetFlowManager();
                if (!flowManager.HasConduit(this.inputCell) || !flowManager.HasConduit(this.outputCell) ||
                    !flowManager.HasConduit(this.filteredCell) || (!flowManager.IsConduitFull(this.inputCell) ||
                                                                   !flowManager.IsConduitEmpty(this.outputCell) ||
                                                                   !flowManager.IsConduitEmpty(this.filteredCell)))
                {
                    return;
                }

                var acceptedTags = treeFilterable.AcceptedTags;

                Pickupable pickupable = flowManager.RemovePickupable(this.inputCell);
                if (!(bool)((UnityEngine.Object)pickupable))
                {
                    return;
                }

                foreach (var acceptedTag in acceptedTags)
                {
                    if (pickupable.HasTag(acceptedTag))
                    {
                        flowManager.AddPickupable(this.filteredCell, pickupable);
                        return;
                    }
                }

                flowManager.AddPickupable(this.outputCell, pickupable);
                this.operational.SetActive(flag, false);
            }
        }
Ejemplo n.º 2
0
        private void ConduitUpdate(float dt)
        {
            SolidConduitFlow flowManager = SolidConduit.GetFlowManager();

            if (!flowManager.HasConduit(this._inputCell) || !flowManager.HasConduit(this._outputCell) || !flowManager.IsConduitFull(this._inputCell) || (!flowManager.IsConduitEmpty(this._outputCell)))
            {
                return;
            }


            Pickupable pickupable = flowManager.RemovePickupable(_inputCell);

            flowManager.AddPickupable(this._outputCell, pickupable);
            if (!(bool)((UnityEngine.Object)pickupable))
            {
                return;
            }
            if (flowManager.HasConduit(this._filteredCell) && flowManager.IsConduitEmpty(this._filteredCell))
            {
                Pickupable pickupable2 = EntityPrefabs.Instantiate(pickupable);
                flowManager.AddPickupable(this._filteredCell, pickupable2);
            }
            this.operational.SetActive(false, false);
        }
Ejemplo n.º 3
0
 private void ConduitUpdate(float dt)
 {
     dispensing = false;
     if (!(bool)operational || operational.IsOperational)
     {
         SolidConduitFlow flowManager = SolidConduit.GetFlowManager();
         if (flowManager.HasConduit(inputCell) && flowManager.HasConduit(outputCell) && flowManager.IsConduitFull(inputCell) && flowManager.IsConduitEmpty(outputCell))
         {
             Pickupable pickupable = flowManager.RemovePickupable(inputCell);
             if ((bool)pickupable)
             {
                 flowManager.AddPickupable(outputCell, pickupable);
                 dispensing = true;
             }
         }
     }
 }
Ejemplo n.º 4
0
        private void ConduitUpdate(float dt)
        {
            if (this.operational.IsOperational)
            {
                SolidConduitFlow flowManager = SolidConduit.GetFlowManager();
                if (!flowManager.HasConduit(this.inputCell) || !flowManager.HasConduit(this.outputCell) ||
                    !flowManager.IsConduitFull(this.inputCell) || !flowManager.IsConduitEmpty(this.outputCell))
                {
                    return;
                }

                Pickupable pickupable = flowManager.RemovePickupable(this.inputCell);
                if (!(bool)((UnityEngine.Object)pickupable))
                {
                    return;
                }

                flowManager.AddPickupable(this.outputCell, pickupable);

                this.operational.SetActive(false);
            }
        }
Ejemplo n.º 5
0
        private void ConduitUpdate(float dt)
        {
            bool flag = false;

            if ((this.operational.GetFlag(LogicOperationalController.LogicOperationalFlag) && this.IsConnected) || this.alwaysDispense)
            {
                SolidConduitFlow conduitFlow = this.GetConduitFlow();
                if (conduitFlow.HasConduit(this.utilityCell) && conduitFlow.IsConduitEmpty(this.utilityCell))
                {
                    Pickupable suitableItem = this.FindSuitableItem();
                    if ((bool)((UnityEngine.Object)suitableItem))
                    {
                        if ((double)suitableItem.PrimaryElement.Mass > MaxMass)
                        {
                            suitableItem = suitableItem.Take(MaxMass);
                        }
                        conduitFlow.AddPickupable(this.utilityCell, suitableItem);
                        flag = true;
                    }
                }
            }
            this.storage.storageNetworkID = this.GetConnectedNetworkID();
            this.dispensing = flag;
        }
Ejemplo n.º 6
0
        protected override void ConduitTick(float delta)
        {
            UpdateConduitBlockedStatus();
            bool dispensed = false;

            if (!operational.IsOperational && !AlwaysDispense)
            {
                return;
            }
            foreach (GameObject item in storage.items)
            {
                if (item.GetComponent <PrimaryElement>()?.Element.id == SimHashes.Water)
                {
                    item.AddOrGet <Pickupable>();
                }
            }
            PrimaryElement element = FindSuitableElement();

            if (element != null)
            {
                element.KeepZeroMassObject = true;
                IConduitFlow iConduitManager = GetConduitManager();
                if (iConduitManager == null)
                {
                    Debug.LogError($"[MultiIO] OutputPort.ConduitTick(): iConduitManager is null");
                }
                //Solid Conduits do not use the same kind of flow manager, so the code must be separated
                if (ConduitType == ConduitType.Solid)
                {
                    SolidConduitFlow solidManager = iConduitManager as SolidConduitFlow;
                    if (solidManager == null)
                    {
                        Debug.LogError($"[MultiIO] OutputPort.ConduitTick(): solidManager is null");
                    }
                    //Solid conveyor only needs to take elements with a Pikcupable component. The only difference between Water and Bottled Water is a Pikcupable component.
                    Pickupable pickup = element.gameObject.GetComponent <Pickupable>();
                    if (pickup == null)
                    {
                        return;
                    }
                    if (pickup.PrimaryElement.Mass > SolidOutputMax)
                    {
                        pickup = pickup.Take(SolidOutputMax);
                    }
                    solidManager.AddPickupable(portCell, pickup);
                    dispensed = true;
                }
                else if (ConduitType == ConduitType.Liquid || ConduitType == ConduitType.Gas)
                {
                    ConduitFlow conduitManager = iConduitManager as ConduitFlow;
                    if (conduitManager == null)
                    {
                        Debug.LogError($"[MutiIO] OutputPort.ConduitTick(): conduitManager is null");
                        return;
                    }
                    float amountMoved = conduitManager.AddElement(portCell, element.ElementID, element.Mass, element.Temperature, element.DiseaseIdx, element.DiseaseCount);
                    if (amountMoved > 0f)
                    {
                        float movedRatio   = amountMoved / element.Mass;
                        int   movedDisease = (int)(movedRatio * (float)element.DiseaseCount);
                        element.ModifyDiseaseCount(-movedDisease, "ConduitDispenser.ConduitUpdate");
                        element.Mass -= amountMoved;
                        _parent.Trigger((int)GameHashes.OnStorageChange, element.gameObject);
                        dispensed = true;
                    }
                }
            }
            isDispensing = dispensed;
        }