erdelf / AlienRaces

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

Add support for changing body addon graphics based on pawn state #72

Closed sumghai closed 2 years ago

sumghai commented 2 years ago

Summary

Adds a new pawnStateGraphics list node to body add-ons, allowing race modders to (optionally) specify alternative graphics for when an alien race pawn is:

Details

Rationale

MoHAR-powered mods like Race Sleep Face Addon require race modders to make multiple copies of each nominal body add-on for each desired pawn state, and individually configure them to be shown or hidden when specific conditions are met. (e.g. A single left eye would require dedicated add-ons for sleep, downed, dead, drafted etc. states).

This PR implements a more intuitive, HAR-native alternative that can be applied directly to body add-ons, while remaining compatible with the existing hediffGraphics and backstoryGraphics options.

Usage Example

<bodyAddons>
    <li>
        <path>Things/Pawn/ExampleRace/Eyes/EyeLeft</path>
        <bodyPart>left eye</bodyPart>
        <inFrontOfBody>true</inFrontOfBody>
        <alignWithHead>true</alignWithHead>
        <drawnDesiccated>false</drawnDesiccated>
        <drawnInBed>True</drawnInBed>
        <colorChannel>skin</colorChannel>

        <!-- all pawn states are optional -->
        <pawnStateGraphics>
            <dead>Things/Pawn/ExampleRace/Eyes/EyeDeadLeft</dead>
            <downed>Things/Pawn/ExampleRace/Eyes/EyeDownedLeft</downed>
            <sleeping>Things/Pawn/ExampleRace/Eyes/EyeSleepingLeft</sleeping>
        </pawnStateGraphics>

        <offsets>
            <!-- omitted for clarity -->
        </offsets>
    </li>
</bodyAddons>
sumghai commented 2 years ago

Closing for rewrite using enum for pawn state, based on feedback from @erdelf.