Exemplo n.º 1
0
        //     var slotsUsed = ApparelSlotMaker.Create(body, wornApparel);
        //     foreach (var def in Utility.apparelDefs.Where(t => t.IsApparel && !slotsUsed.Intersects(ApparelSlotMaker.Create(body, t))))
        //         yield return def;

        public static List <Tuple <Item, Tag> > WornApparelFor(BodyDef def, List <Tuple <Item, Tag, int> > apparels)
        {
            var         wornApparels     = new List <Tuple <Item, Tag> >();
            ApparelSlot wornApparelSlots = null;

            foreach (var(apparel, tag, _) in apparels.OrderBy(app => app.Item3))
            {
                // can obviously wear it if we aren't wearing anything
                if (wornApparelSlots == null)
                {
                    wornApparelSlots = ApparelSlotMaker.Create(def, apparel.Def);
                    wornApparels.Add(new Tuple <Item, Tag>(apparel, tag));
                    continue;
                }

                var apparelSlots = ApparelSlotMaker.Create(def, apparel.Def);

                if (!wornApparelSlots.Intersects(apparelSlots))
                {
                    wornApparels.Add(new Tuple <Item, Tag>(apparel, tag));

                    wornApparelSlots = ApparelSlotMaker.Create(def, wornApparels.Select(kv => kv.Item1.Def));
                }
            }
            return(wornApparels);
        }
Exemplo n.º 2
0
        public static IEnumerable <ThingDef> ApparelCanFitOnBody(BodyDef body, List <ThingDef> wornApparel)
        {
            var slotsUsed = ApparelSlotMaker.Create(body, wornApparel);

            foreach (var def in Utility.apparelDefs.Where(t => t.IsApparel && !slotsUsed.Intersects(ApparelSlotMaker.Create(body, t))))
            {
                yield return(def);
            }
        }