public ComponentSearchFilter <T> CreateFilter <T>() { ComponentSearchFilter <T> filter = new ComponentSearchFilter <T>(); filter.Init(); OnTriggerEnter2DEvent += filter.OnTriggerEnter2D; OnTriggerExit2DEvent += filter.OnTriggerExit2D; OnTriggerStay2DEvent += filter.OnTriggerStay2D; return(filter); }
private void ComponentFilter(object sender, FilterEventArgs e) { e.Accepted = false; string[] sideRegionSplit = ComponentSearchFilter.Split(null); string side = sideRegionSplit[0].ToLower(); string region = string.Empty; if (sideRegionSplit.Length > 1) { region = sideRegionSplit[1].ToLower(); } bool singleEntry = sideRegionSplit.Length <= 1; if (string.IsNullOrEmpty(side) && singleEntry) { e.Accepted = true; } if (e.Item is Component src && e.Accepted == false) { if (singleEntry) { if (src.Side.ToLower().Contains(side) || src.Region.ToLower().Contains(side) || src.Type.ToLower().Contains(side) || src.GroupName.ToLower() == side) { e.Accepted = true; } } else { if (src.Side.ToLower().Contains(side) && (src.Region.ToLower().Contains(region) || src.GroupName.ToLower() == region)) { e.Accepted = true; } } } }