/// <summary> /// Get the flood boct list. /// </summary> public static List <Boct> GetFloodBoctList(Boct target, Boct head) { // Debug.Log("[GetFloodBoctList]"); var sameDepthBoctList = new List <Boct>(); BoctTools.FindSameDepthBoct(target.Depth, head, sameDepthBoctList); // Debug.Log("SameDepthBoct: " + sameDepthBoctList.Count); var sameMaterialBoctList = sameDepthBoctList.Where(b => b.MaterialId == target.MaterialId).ToList <Boct>(); // Debug.Log("SameMaterialBoct: " + sameMaterialBoctList.Count); // Debug.Log("Dictionary"); var dic = BoctTools.ToDictionary(sameMaterialBoctList); //foreach (var kv in dic) //{ // Debug.Log(kv.Key + " " + kv.Value.ToString()); //} // Remove target. dic.Remove(target.AddressString); var output = new List <Boct>(); output.Add(target); var searchList = new List <Boct>(); searchList.Add(target); while (searchList.Count > 0) { var b = searchList[0]; searchList.RemoveAt(0); for (int i = 0; i < 6; i++) { var address = BoctAddressTools.GetAdjoiningBoctAddress(b.Address, i); if (address == null) { continue; } var addressString = BoctAddressTools.ToString(address); // Debug.Log("Address" + i + ": " + addressString); if (dic.ContainsKey(addressString)) { output.Add(dic[addressString]); searchList.Add(dic[addressString]); dic.Remove(addressString); } } } return(output); }
public static Boct GetAdjoiningBoct(Boct b, int face, BoctModel model) { var adjoiningAddress = BoctAddressTools.GetAdjoiningBoctAddress(b.Address, face); if (adjoiningAddress == null) { return(null); } else { return(model.Find(adjoiningAddress)); } }