private void CalculateDrain(IOEntity ent, Vector3 fromSlotWorld, int depth, ref int amount, IOEntity lastEntity, ItemDefinition waterType) { if (ent == this || depth <= 0 || ent == null || lastEntity == null || ent is LiquidContainer) { return; } if (!ent.BlockFluidDraining && ent.HasFlag(Flags.On)) { int num = ent.DesiredPower(); amount += num; ent.SetFuelType(waterType, this); connectedList.Add(ent); } if (!ent.AllowLiquidPassthrough(lastEntity, fromSlotWorld)) { return; } IOSlot[] array = ent.outputs; foreach (IOSlot iOSlot in array) { if (iOSlot.connectedTo.Get() != null && iOSlot.connectedTo.Get() != ent) { CalculateDrain(iOSlot.connectedTo.Get(), ent.transform.TransformPoint(iOSlot.handlePosition), depth - 1, ref amount, ent, waterType); } } }
private void CheckPushLiquid(IOEntity connected, Item ourFuel, IOEntity fromSource, int depth) { if (depth <= 0 || ourFuel.amount <= 0) { return; } Vector3 worldHandlePosition = Vector3.zero; IOEntity iOEntity = connected.FindGravitySource(ref worldHandlePosition, IOEntity.backtracking, true); if ((iOEntity != null && !connected.AllowLiquidPassthrough(iOEntity, worldHandlePosition)) || connected == this || ConsiderConnectedTo(connected)) { return; } ContainerIOEntity containerIOEntity; if ((object)(containerIOEntity = connected as ContainerIOEntity) != null && !pushTargets.Contains(containerIOEntity) && containerIOEntity.inventory.CanAcceptItem(ourFuel, 0) == ItemContainer.CanAcceptResult.CanAccept) { pushTargets.Add(containerIOEntity); return; } IOSlot[] array = connected.outputs; foreach (IOSlot iOSlot in array) { IOEntity iOEntity2 = iOSlot.connectedTo.Get(); Vector3 sourceWorldPosition = connected.transform.TransformPoint(iOSlot.handlePosition); if (iOEntity2 != null && iOEntity2 != fromSource && iOEntity2.AllowLiquidPassthrough(connected, sourceWorldPosition)) { CheckPushLiquid(iOEntity2, ourFuel, fromSource, depth - 1); if (pushTargets.Count >= 3) { break; } } } }
public virtual void UpdateOutputs() { if (Interface.CallHook("OnOutputUpdate", this) != null || !ShouldUpdateOutputs() || !ensureOutputsUpdated) { return; } ensureOutputsUpdated = false; using (TimeWarning.New("ProcessIOOutputs")) { for (int i = 0; i < outputs.Length; i++) { IOSlot iOSlot = outputs[i]; bool flag = true; IOEntity iOEntity = iOSlot.connectedTo.Get(); if (!(iOEntity != null)) { continue; } if (ioType == IOType.Fluidic && !DisregardGravityRestrictionsOnLiquid && !iOEntity.DisregardGravityRestrictionsOnLiquid) { using (TimeWarning.New("FluidOutputProcessing")) { if (!iOEntity.AllowLiquidPassthrough(this, base.transform.TransformPoint(iOSlot.handlePosition))) { flag = false; } } } int passthroughAmount = GetPassthroughAmount(i); iOEntity.UpdateFromInput(flag ? passthroughAmount : 0, iOSlot.connectedToSlot); } } }