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 IOEntity FindGravitySource(ref Vector3 worldHandlePosition, int depth, bool ignoreSelf) { if (depth <= 0) { return(null); } if (!ignoreSelf && IsGravitySource) { worldHandlePosition = base.transform.TransformPoint(outputs[0].handlePosition); return(this); } IOSlot[] array = inputs; for (int i = 0; i < array.Length; i++) { IOEntity iOEntity = array[i].connectedTo.Get(base.isServer); if (iOEntity != null) { if (iOEntity.IsGravitySource) { worldHandlePosition = iOEntity.transform.TransformPoint(iOEntity.outputs[0].handlePosition); return(iOEntity); } iOEntity = iOEntity.FindGravitySource(ref worldHandlePosition, depth - 1, false); if (iOEntity != null) { worldHandlePosition = iOEntity.transform.TransformPoint(iOEntity.outputs[0].handlePosition); return(iOEntity); } } } return(null); }