Neco/LandView/LandViewUtils.cs
/// <summary>
/// Gets the smallest district (by area) From the list of potential containers that contains the given Item.<br/>
/// This method is meant for finding the smallest district that contains a plot
/// </summary>
/// <param name="AllDistricts"></param>
/// <param name="Item"></param>
/// <returns>the item, or null if none was found</returns>
Gets the smallest district (by area) From the list of potential containers that contains the given Item.
This method is meant for finding the smallest district that contains a plot
Gets the smallest district ( by area ) From the list of potential containers that contains the given Item . This method is meant for finding the smallest district that contains a plot
public static District GetSmallestDistrictContaining(ICollection<District> AllDistricts, LandViewItem Item) {
            List<District> Containers = new();
            foreach (var Container in AllDistricts) {
                if (Contains(Container, Item)) { Containers.Add(Container); }
            }
            if (Containers.Count == 0) { return null; }
            if (Containers.Count == 1) { return Containers.First(); }
            return Containers.Aggregate((curMin, x) => (curMin == null || x.Area() < curMin.Area() ? x : curMin));
        }
public static District GetSmallestDistrictContaining ( ICollection < District > AllDistricts , LandViewItem Item ) { List < District > Containers = new ( ) ; foreach ( var Container in AllDistricts ) { if ( Contains ( Container , Item ) ) { Containers . Add ( Container ) ; } } if ( Containers . Count == 0 ) { return null ; } if ( Containers . Count == 1 ) { return Containers . First ( ) ; } return Containers . Aggregate ( ( curMin , x ) => ( curMin == null || x . Area ( ) < curMin . Area ( ) ? x : curMin ) ) ; }
Gets the smallest district (by area) From the list of potential containers that contains the given Item.
Gets the smallest district ( by area ) From the list of potential containers that contains the given Item .
//Now then: //If there are no containers, return null //If there is one container, return that container //if there is mroe than one, return the container that 
the item, or null if none was found
the item or null if none was found
AllDistricts
ICollection<District>
None
Item
LandViewItem
None