protected virtual List <MultiTiledObject> FluidGraphSearchInputTanksThatCanAcceptThisFluid(Fluid L) { List <MultiTiledObject> fluidSources = new List <MultiTiledObject>(); List <MultiTiledComponent> searchedComponents = new List <MultiTiledComponent>(); List <MultiTiledComponent> entitiesToSearch = new List <MultiTiledComponent>(); entitiesToSearch.AddRange(this.GetNeighboringFluidManagers()); searchedComponents.Add(this); while (entitiesToSearch.Count > 0) { MultiTiledComponent searchComponent = entitiesToSearch[0]; entitiesToSearch.Remove(searchComponent); if (searchedComponents.Contains(searchComponent)) { continue; } else { searchedComponents.Add(searchComponent); entitiesToSearch.AddRange(searchComponent.GetNeighboringFluidManagers()); if (searchComponent.containerObject.info.fluidManager.canRecieveThisFluid(L)) { fluidSources.Add(searchComponent.containerObject); } } } return(fluidSources); }
/// <summary> /// Searches a network of fluid managers to see if any of these fluid managers have an output tank with the corresponding fluid. /// </summary> /// <param name="L"></param> /// <returns></returns> protected virtual List <MultiTiledObject> FluidGraphSearchForFluidFromOutputTanks(Fluid L) { List <MultiTiledObject> fluidSources = new List <MultiTiledObject>(); HashSet <Guid> searchedComponents = new HashSet <Guid>(); Queue <MultiTiledComponent> entitiesToSearch = new Queue <MultiTiledComponent>(); HashSet <Guid> searchedObjects = new HashSet <Guid>(); foreach (MultiTiledComponent tile in this.GetNeighboringFluidManagers()) { entitiesToSearch.Enqueue(tile); } //entitiesToSearch.AddRange(this.GetNeighboringFluidManagers()); searchedComponents.Add(this.guid); while (entitiesToSearch.Count > 0) { MultiTiledComponent searchComponent = entitiesToSearch.Dequeue(); //entitiesToSearch.Remove(searchComponent); if (searchedComponents.Contains(searchComponent.guid)) { continue; } /* * else if (searchedObjects.Contains(searchComponent.containerObject)) * { * continue; * } */ else { searchedComponents.Add(searchComponent.guid); searchedObjects.Add(searchComponent.containerObject.guid); List <MultiTiledComponent> neighbors = searchComponent.GetNeighboringFluidManagers(); foreach (MultiTiledComponent tile in neighbors) { if (searchedObjects.Contains(tile.containerObject.guid) || searchedComponents.Contains(tile.guid)) { continue; } else { entitiesToSearch.Enqueue(tile); } } if (searchComponent.containerObject.info.fluidManager.doesThisOutputTankContainThisFluid(L)) { fluidSources.Add(searchComponent.containerObject); //ModCore.log("Found a tank that contains this fluid!"); } } } return(fluidSources); }