/// <summary> /// Make <see cref="ThingGroupSelector"/> from <paramref name="thing"/>. The selector doen't contain reference to <paramref name="thing"/>. /// </summary> /// <param name="thing"> Source for <see cref="ThingGroupSelector"/>. </param> /// <returns> A <see cref="ThingGroupSelector"/> made from <paramref name="thing"/>. </returns> public static ThingGroupSelector MakeThingGrouopSelector(this Thing thing) { SingleThingSelector singleThingSelector = AwesomeInventoryServiceProvider.MakeInstanceOf <SingleThingSelector>(new[] { thing }); ThingGroupSelector thingSelectors = new ThingGroupSelector(thing.def) { singleThingSelector, }; thingSelectors.SetStackCount(1); return(thingSelectors); }
/// <inheritdoc/> /// <remarks> More stringent selector takes precedence, e.g. Compare will return -1 if x is more stringent. </remarks> public override int Compare(ThingSelector x, ThingSelector y) { if (ReferenceEquals(x, y)) { return(0); } if (x is null) { return(1); } else if (y is null) { return(-1); } SingleThingSelector xSelector = x as SingleThingSelector; SingleThingSelector ySelector = y as SingleThingSelector; return(SingleThingSelector.Comparer.Instance.Compare(xSelector, ySelector)); }