private void ConduitUpdate(float dt) { bool flag = false; SolidConduitFlow conduitFlow = GetConduitFlow(); if (IsConnected) { SolidConduitFlow.ConduitContents contents = conduitFlow.GetContents(utilityCell); if (contents.pickupableHandle.IsValid() && (alwaysConsume || operational.IsOperational)) { float num = (!(capacityTag != GameTags.Any)) ? storage.MassStored() : storage.GetMassAvailable(capacityTag); float num2 = Mathf.Min(storage.capacityKg, capacityKG); float num3 = Mathf.Max(0f, num2 - num); if (num3 > 0f) { Pickupable pickupable = conduitFlow.GetPickupable(contents.pickupableHandle); if (pickupable.PrimaryElement.Mass <= num3 || pickupable.PrimaryElement.Mass > num2) { Pickupable pickupable2 = conduitFlow.RemovePickupable(utilityCell); if ((bool)pickupable2) { storage.Store(pickupable2.gameObject, true, false, true, false); flag = true; } } } } } storage.storageNetworkID = GetConnectedNetworkID(); consuming = flag; }
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; } } } }
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); } }
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); } }
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); }
protected override void ConduitTick(float delta) { if (!AlwaysConsume && !operational.IsOperational) { return; } IConduitFlow conduitFlow = GetConduitManager(); if (ConduitType != ConduitType.Solid) { ConduitFlow mngr = conduitFlow as ConduitFlow; ConduitFlow.ConduitContents contents = mngr.GetContents(portCell); if (contents.mass <= 0) { return; } Element element = ElementLoader.FindElementByHash(contents.element); bool matchesTag = StoreTag == GameTags.Any || element.HasTag(StoreTag); float rateAmount = ConsumptionRate * delta; float maxTake = 0f; float storageContains = storage.MassStored(); float storageLeft = storage.capacityKg - storageContains; float portContains = StoreTag == GameTags.Any ? storageContains : storage.GetMassAvailable(StoreTag); float portLeft = MaximumStore - portContains; maxTake = Mathf.Min(storageLeft, portLeft); maxTake = Mathf.Min(rateAmount, maxTake); float removed = 0f; if (maxTake > 0f) { ConduitFlow.ConduitContents removedContents = mngr.RemoveElement(portCell, maxTake); removed = removedContents.mass; LastConsumedElement = removedContents.element; float ratio = removed / contents.mass; if (!matchesTag) { BuildingHP.DamageSourceInfo damage = new BuildingHP.DamageSourceInfo { damage = 1, source = BUILDINGS.DAMAGESOURCES.BAD_INPUT_ELEMENT, popString = UI.GAMEOBJECTEFFECTS.DAMAGE_POPS.WRONG_ELEMENT }; Trigger((int)GameHashes.DoBuildingDamage, damage); if (WrongElement == WrongElementResult.Dump) { int buildingCell = Grid.PosToCell(_parent.transform.GetPosition()); SimMessages.AddRemoveSubstance(buildingCell, contents.element, CellEventLogger.Instance.ConduitConsumerWrongElement, removed, contents.temperature, contents.diseaseIdx, contents.diseaseIdx); return; } } if (ConduitType == ConduitType.Gas) { if (!element.IsGas) { Debug.LogWarning($"[MultIO] Gas input port attempted to consume non gass: {element.id.ToString()}"); } else { storage.AddGasChunk(element.id, removed, contents.temperature, contents.diseaseIdx, contents.diseaseCount, KeepZeroMassObject, false); } } else if (ConduitType == ConduitType.Liquid) { if (!element.IsLiquid) { Debug.LogWarning($"[MultIO] Liquid input port attempted to consume non liquid: {element.id.ToString()}"); } else { storage.AddLiquid(element.id, removed, contents.temperature, contents.diseaseIdx, contents.diseaseCount, KeepZeroMassObject, false); } } } } else { SolidConduitFlow mngr = conduitFlow as SolidConduitFlow; SolidConduitFlow.ConduitContents contents = mngr.GetContents(portCell); if (contents.pickupableHandle.IsValid() && (AlwaysConsume || operational.IsOperational)) { float stored = StoreTag == GameTags.Any ? storage.MassStored() : storage.GetMassAvailable(StoreTag); float maxStorage = Mathf.Min(storage.capacityKg, MaximumStore); float availableStorage = Mathf.Max(0f, maxStorage - stored); if (availableStorage > 0f) { Pickupable tmp = mngr.GetPickupable(contents.pickupableHandle); bool matchesTag = StoreTag == GameTags.Any || tmp.HasTag(StoreTag); if (matchesTag) { if (tmp.PrimaryElement.Mass <= stored || tmp.PrimaryElement.Mass > maxStorage) { Pickupable take = mngr.RemovePickupable(portCell); if (take != null) { storage.Store(take.gameObject, true); } } } else { Pickupable take = mngr.RemovePickupable(portCell); take.transform.SetPosition(Grid.CellToPos(portCell)); //TODO: Add a PopFX. Likely will not do damage. } } } } }