erdelf / AlienRaces

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

Multi-stage overrides and fallbacks for apparel textures #84

Closed Aelanna closed 1 year ago

Aelanna commented 1 year ago

Implements racial override and fallback textures for races:

  1. If there's a specific path override for a specific ThingDef (not shown in example below), that takes precedence.
  2. 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 those are used.
  3. The vanilla path with the wearer's specific bodytype is checked next. If those textures are found, then everything works as normal.
  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. This can be used to set a transparent texture to make apparel 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