erdelf / AlienRaces

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

(WIP) Add support for changing body addon graphics based on pawn state #74

Closed sumghai closed 7 months ago

sumghai commented 2 years ago

Summary

WIP Feature - based on #72, rewritten using enum at @erdelf's request

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 existing body add-ons.

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

@erdelf - For reference, here are the conditions needed to trigger each state:

Downed

pawn.Downed && pawn.jobs?.posture != PawnPosture.LayingInBed && downedGraphicExists

Dead

pawn.Dead && deadGraphicExists

Sleeping

!RestUtility.Awake(pawn) && sleepingGraphicExists