erdelf / AlienRaces

Rimworld mod alien race framework
MIT License
103 stars 69 forks source link

Multi-stage overrides and fallbacks for apparel textures #83

Closed Aelanna closed 1 year ago

Aelanna commented 1 year ago

Implements racial override and fallback textures for races:

  1. If a path prefix is provided for a race, then all apparel runs through that first. If matching textures are found under the prefixed path, then it uses those.
  2. The vanilla path with the wearer's specific bodytype is checked next. If those textures are found, then everything works as normal.
  3. If there's a specific path override for a specific ThingDef (not shown in above example), that is attempted next.
  4. If the race has set, it runs down the list in order and sees if any of them match the current apparel piece. This will check against body part groups, layers, and/or apparel tags. If you set a fallback but do not provide a texture path, then any apparel that matches this fallback will simply be invisible.
  5. If the race has a bodytype fallback (either or , then it will attempt to substitute the fallback body type in the vanilla-generated texture path and see if that yields any usable textures.
  6. If all else fails, it allows normal vanilla behavior to occur.

An example of the XML applied in <graphicPaths>:

<graphicPaths>
  <apparel>
    <pathPrefix>ARimReborn/Lalafell/</pathPrefix>
    <fallbacks>
      <li>
        <wornGraphicPath>Things/Pawn/Humanlike/Apparel/Jacket/Jacket</wornGraphicPath>
        <layers>
          <li>Shell</li>
        </layers>
      </li>
    </fallbacks>
    <bodyTypeFallback>Thin</bodyTypeFallback>
  </apparel>
</graphicPaths>

A test using the above XML: image

  1. A racial override for a piece of headwear,
  2. A fallback for all Shell layer apparel to a specific graphic, and
  3. A bodytype fallback for all apparel lacking textures for a race's specific bodytype
Aelanna commented 1 year ago

Had to close to change branches, will open new PR