How to check which body part an apparel covers?

Started by Friedmutant, February 04, 2015, 12:55:41 AM

Previous topic - Next topic

Friedmutant


I have a building subclassing Building_Storage() that only stores apparel.  I need to know what body part the allowed ThingDefs cover.  I've got this much so far, but I am stuck on making a BodyPartRecord.  I'm not sure I even need to make one, but  thingDef.apparel.CoversBodyPart looks promising since it returns a bool, and it takes a BodyPartRecord.


...
        BodyPartRecord torsoPart = new BodyPartRecord ();
foreach (ThingDef thingDef in settings.allowances.thingDefs)
{
Log.Warning ("Checking " + thingDef.label);
if (thingDef.apparel.CoversBodyPart(torsoPart))
{
// do something with thingDef
}
    }
        ...


This code is valid, but you can see that torsoPart is just worthless to me as it currently stands.

Thanks in advance!

Rikiki

You may try to modify your torsoPart BodyPartRecord like this. I think it lacks any BodyPartGroupDef in its groups list member:
BodyPartRecord torsoPart = new BodyPartRecord();
torsoPart.groups.Add(BodyPartGroupDefOf.Torso);

Friedmutant

Thank you again Rikiki.  I struggled with how to define those records.