Example #1
0
        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);
        }
Example #2
0
 public House(HouseType type)
 {
     Type   = type;
     Allies = new AlliesMask(1 << Type.ID);
 }