Beispiel #1
0
        public static HaulLocation DefaultHaulLocation(this ThingDef thingDef, bool haulCrates = false)
        {
            // there is a more elegant way to do this, but I'll do that later.

            if (haulCrates && thingDef.IsCrate())
            {
                return(HaulLocation.ToCarriers);
            }

            if (!thingDef.EverHaulable)
            {
                return(HaulLocation.None);
            }

            if (trashThingDefHashes.Contains(thingDef.GetHashCode()))
            {
                return(HaulLocation.ToTrash);
            }

            var categories = thingDef.thingCategories;

            foreach (var cat in categories)
            {
                if (carrierThingCategoryDefHashes.Contains(cat.GetHashCode()))
                {
                    return(HaulLocation.ToCarriers);
                }

                if (trashThingCategoryDefHashes.Contains(cat.GetHashCode()))
                {
                    return(HaulLocation.ToTrash);
                }

                foreach (var parentCat in cat.Parents)
                {
                    if (carrierThingCategoryDefHashes.Contains(parentCat.GetHashCode()))
                    {
                        return(HaulLocation.ToCarriers);
                    }

                    if (trashThingCategoryDefHashes.Contains(parentCat.GetHashCode()))
                    {
                        return(HaulLocation.ToTrash);
                    }
                }
            }

            return(HaulLocation.None);
        }