Sleep Caskets - KonradHeinser/EBSGFramework GitHub Wiki

Sleep caskets are a variation of the cryptosleep casket code that allows for a bit more flexibility in how what it does. For the most part, the xml is set up the exact same as the cryptosleep casket (I personally just copy pasted that to simplify the process of making my own tests), with only the main differences mentioned below. If any part of it doesn't make sense and isn't mentioned here, take a look at the vanilla cryptosleep casket as a reference

First up is the class, which is non-negotiable, and the extension, which is conditionally negotiable:

        <thingClass>EBSGFramework.Building_SleepCasket</thingClass>

        <modExtensions>
            <li Class="EBSGFramework.EBSGExtension">
            </li>
        </modExtensions>

Within the extension you have these options:

  • startSound : The SoundDef to play when entering
  • endSound : The SoundDef to play when ejected normally
  • filth : The filth to give to the pawn
  • relatedJob : Default (EBSG_EnterSleepCasket) : The JobDef to use to enter the casket. It is strongly recommended that you do not change this unless you are very sure
  • endHediff : A special item that adds hediffs similar to how Hediff Adder handles it, with the only exception being that only one hediff can be added, and no li should be used. This version is only for fleshy beings, and the details of what goes inside it can be found below
  • mechEndHediff : A special item that adds hediffs similar to how Hediff Adder handles it, with the only exception being that only one hediff can be added, and no li should be used. This version is only for mechanoids, and the details of what goes inside it can be found below

endHediff and mechEndHediff contain these tags:

  • hediff : The HediffDef to add. This is required
  • bodyParts : The list of BodyPartDefs to add the hediff to. If left blank, then it will add to the full body
  • onlyIfNew : Default (False) : While True, the hediff won't be added to a pawn/pawn part if the pawn already has it
  • severity : Default (0.5) : The severity to apply/add to the hediff
  • chance : Default (1) : The chances of the hediff actually being added
  • validAges : Default (0~9999) : The range of ages that the pawn must be within for the hediff to be added

In addition to basic fuel and power stuff, this class also allows for requiring nutrition to keep the pawn suspended. If the class sees defaultStorageSettings in the building properties, then it will assume that food is required to keep the pawn suspended. If you want the player to be able to change what kind of food is accepted, you'll need to include ITab_BiosculpterNutritionStorage in inspectorTabs. Below is some of the basic setup stuff for adding nutrition to the building:

        <building>
            <fixedStorageSettings>
                <filter>
                    <categories>
                        <li>Foods</li>
                    </categories>
                    <specialFiltersToDisallow>
                        <li>AllowPlantFood</li>
                    </specialFiltersToDisallow>
                </filter>
            </fixedStorageSettings>
            <defaultStorageSettings>
                <filter>
                    <categories>
                        <li>Foods</li>
                    </categories>
                    <disallowedCategories>
                        <li>EggsFertilized</li>
                    </disallowedCategories>
                    <disallowedThingDefs>
                        <li>MealLavish</li>
                        <li>MealLavish_Veg</li>
                        <li>MealLavish_Meat</li>
                        <li>HemogenPack</li>
                        <li>Chocolate</li>
                    </disallowedThingDefs>
                </filter>
            </defaultStorageSettings>
        </building>

        <inspectorTabs>
            <li>ITab_BiosculpterNutritionStorage</li>
        </inspectorTabs>

Due to how Rimworld handles jobs, you will also need to make a WorkGiverDef for each sleep casket you make, which will look similar to the one below:

    <WorkGiverDef>
        <defName>InsertDefNameHere</defName>
        <label>resupply sleep casket</label>
        <giverClass>EBSGFramework.WorkGiver_HaulNutritionToFoodCasket</giverClass>
        <workType>Hauling</workType>
        <verb>resupply</verb>
        <gerund>resupplying</gerund>
        <priorityInType>109</priorityInType>
        <requiredCapacities>
            <li>Manipulation</li>
        </requiredCapacities>
        <modExtensions>
            <li Class="EBSGFramework.EBSGExtension">
                <relatedThing>InsertCasketDefNameHere</relatedThing>
            </li>
        </modExtensions>
    </WorkGiverDef>

In addition to the class, there is a related comp I made to allow you to make the casket generate energy as long as a pawn is inside. Most of it uses normal power stuff, with the notable exception of two new tags, and a lack of a compClass tag:

        <comps>
            <li Class="EBSGFramework.CompProperties_SleepCasketPower">
                <basePowerConsumption>-1000</basePowerConsumption>
                <transmitsPower>true</transmitsPower>
            </li>
        </comps>

The two new options are these:

  • statFactors : A list of StatDefs that multiply the power gained
  • statDivisors : A list of StatDefs that divide the power gained

This example creates a variation of the cryptosleep casket that generates power when a pawn with psychic sensitivity is inside, and requires regular food deliveries to keep the pawn suspended. It does not need the extension because it does not give filth, hediffs, sounds, or have a special job for entering. Because it does have a nutrition requirement, a WorkGiverDef was also made:

    <ThingDef ParentName="BuildingBase">
        <defName>EBSG_SleepCasket</defName>
        <label>sleep casket</label>
        <description>.</description>
        <thingClass>EBSGFramework.Building_SleepCasket</thingClass>
        <containedPawnsSelectable>true</containedPawnsSelectable>
        <drawerType>MapMeshAndRealTime</drawerType>
        <graphicData>
            <texPath>Things/Building/Ship/ShipCryptosleepCasket</texPath>
            <graphicClass>Graphic_Multi</graphicClass>
            <drawSize>(1, 2)</drawSize>
            <shadowData>
                <volume>(0.83, 0.3, 1.7)</volume>
            </shadowData>
        </graphicData>
        <researchPrerequisites><li>Cryptosleep</li></researchPrerequisites>
        <altitudeLayer>Building</altitudeLayer>
        <passability>PassThroughOnly</passability>
        <pathCost>42</pathCost>
        <blockWind>true</blockWind>
        <fillPercent>0.5</fillPercent>
        <canOverlapZones>false</canOverlapZones>
        <statBases>
            <WorkToBuild>3200</WorkToBuild>
            <MaxHitPoints>250</MaxHitPoints>
            <Flammability>0.5</Flammability>
        </statBases>
        <tickerType>Normal</tickerType>
        <size>(1,2)</size>
        <designationCategory>Misc</designationCategory>
        <uiOrder>2050</uiOrder>
        <hasInteractionCell>true</hasInteractionCell>
        <interactionCellOffset>(1,0,0)</interactionCellOffset>
        <defaultPlacingRot>South</defaultPlacingRot>
        <building>
            <ai_chillDestination>false</ai_chillDestination>
            <destroySound>BuildingDestroyed_Metal_Small</destroySound>
            <fixedStorageSettings>
                <filter>
                    <categories>
                        <li>Foods</li>
                    </categories>
                    <specialFiltersToDisallow>
                        <li>AllowPlantFood</li>
                    </specialFiltersToDisallow>
                </filter>
            </fixedStorageSettings>
            <defaultStorageSettings>
                <filter>
                    <categories>
                        <li>Foods</li>
                    </categories>
                    <disallowedCategories>
                        <li>EggsFertilized</li>
                    </disallowedCategories>
                    <disallowedThingDefs>
                        <li>MealLavish</li>
                        <li>MealLavish_Veg</li>
                        <li>MealLavish_Meat</li>
                        <li>HemogenPack</li>
                        <li>Chocolate</li>
                    </disallowedThingDefs>
                </filter>
            </defaultStorageSettings>
        </building>
        <costList>
            <Steel>180</Steel>
            <Uranium>5</Uranium>
            <ComponentIndustrial>4</ComponentIndustrial>
            <ComponentSpacer>1</ComponentSpacer>
        </costList>
        <comps>
            <li Class="CompProperties_Explosive">
                <explosiveRadius>2.66</explosiveRadius>
                <explosiveDamageType>Flame</explosiveDamageType>
            </li>
            <li Class="CompProperties_EmptyStateGraphic">
                <graphicData>
                <texPath>Things/Building/Ship/ShipCryptosleepCasketOpenDoor</texPath>
                <graphicClass>Graphic_Multi</graphicClass>
                <drawSize>(1, 2)</drawSize>
                </graphicData>
            </li>
            <li Class="EBSGFramework.CompProperties_SleepCasketPower">
                <basePowerConsumption>-1000</basePowerConsumption>
                <transmitsPower>true</transmitsPower>
                <statFactors>
                    <li>PsychicSensitivity</li>
                </statFactors>
            </li>
        </comps>
        <placeWorkers>
            <li>PlaceWorker_PreventInteractionSpotOverlap</li>
        </placeWorkers>
        <inspectorTabs>
            <li>ITab_BiosculpterNutritionStorage</li>
            <li>ITab_ContentsCasket</li>
        </inspectorTabs>
        <terrainAffordanceNeeded>Medium</terrainAffordanceNeeded>
        <constructionSkillPrerequisite>8</constructionSkillPrerequisite>
    </ThingDef>

    <WorkGiverDef>
        <defName>EBSG_HaulToSleepCasket</defName>
        <label>resupply sleep casket</label>
        <giverClass>EBSGFramework.WorkGiver_HaulNutritionToFoodCasket</giverClass>
        <workType>Hauling</workType>
        <verb>resupply</verb>
        <gerund>resupplying</gerund>
        <priorityInType>109</priorityInType>
        <requiredCapacities>
            <li>Manipulation</li>
        </requiredCapacities>
        <modExtensions>
            <li Class="EBSGFramework.EBSGExtension">
                <relatedThing>EBSG_SleepCasket</relatedThing>
            </li>
        </modExtensions>
    </WorkGiverDef>
⚠️ **GitHub.com Fallback** ⚠️