public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) { if (!CanConvertFrom(context, value?.GetType())) { return(null); } var map = (context as MapContext).Instance as Map; var alliesMask = new AlliesMask(0); var allies = (value as string).Split(','); foreach (var ally in allies) { if (map.Houses.Where(h => h.Type.Equals(ally)).FirstOrDefault() is House house) { alliesMask.Set(house.Type.ID); } } return(alliesMask); }
public House(HouseType type) { Type = type; Allies = new AlliesMask(1 << Type.ID); }