DRG Consumable - KonradHeinser/EBSGFramework GitHub Wiki
If you're looking to ingestible resource packs similar to the hemogen pack, you actually need Resource Packs instead.
This thing comp allows you to designate ThingDefs as items that can be consumed by people with the DRG and grants them a resource offset for each one consumed. Because this is just a thing comp instead of a full thing, I'll be showing all of it in my more normal thing comp explain mod rather than the full explainathon I use for most things added by DRG. The only thing to note is that if you want pawns to treat this like a standard resource pack and automatically consume/deliver it, you will need to add it to the main resource gene's resourcePacks tag.
For your basic comp, you'll need something like this:
<comps>
<li Class="EBSGFramework.CompProperties_DRGConsumable">
<resourceOffsets>
<li>
</li>
</resourceOffsets>
</li>
</comps>
Each resource gene that this item needs to offset will get its own list item. In most cases, I assume there will only ever be one item on this list, but I set it up this way to allow multiple people to point to the same resource. It is important to note that in a situation where multiple resource genes are increasing due to this item, the increases will NOT be divided at all, so all resource genes will increase by the full amount you specify.
Each li can contain the following tags, though only the mainResourceGene and amount are required:
- mainResourceGene : The resource gene to offset
- amount : The amount to offset by. A 0.1 means an offset of 10 in game
- ticks : Default (100) : The amount of ticks to take for consumption
- consumeEffect : The EffecterDef to use on consumption. Similar to ingestEffect
- consumeSound : The SoundDef to use on consumption. Similar to ingestSound
- consumptionReportString : Default ( Consuming {0}. ) : What the small pawn info-card reports the pawn is doing, with {0} representing the short label of the ThingDef
- floatMenuString : Default ( Consume {0}. ) : What the float menu displays when a pawn with the right gene is selected and the item is right clicked
- consumeHoldOffset : The HoldOffsetSet to use. Similar to ingestHoldOffsetStanding
IMPORTANT NOTE: If there are multiple resource genes attached to the item that the pawn has, other than the mainResourceGene and its amount, only the first match will be used. This means that the first viable resource gene will dictate the ticks used, and for the rest of the tags the code will sort through the list of items to find any instance where the pawn has the gene and the tag has something in it. For example, if the first gene has all them filled in all of those are used and any other li is ignored. If it has only has the strings filled in, then the code will see if it can find a consume effect, sound and hold offset in a different list.
If that doesn't make sense to you at the moment, just ignore that for now, and if someone reports unexpected sounds or visuals, know that that mess is why.
This example is intended to show what it will probably look like any time you want to add this comp to an existing item. Keep in mind that if it's an item in your mod, there is no need to make the patch, just add it directly to the comps, and you can remove a conditional or two if the item you're patching always has those the thing the conditional is checking for:
This patch makes it possible for Radiomancers from SHG - Just the Radiomancer to absorb uranium to recover their energy
<?xml version="1.0" encoding="utf-8" ?>
<Patch>
<Operation Class="PatchOperationConditional">
<xpath>Defs/ThingDef[defName="Uranium"]/comps</xpath>
<match Class="PatchOperationConditional">
<xpath>Defs/ThingDef[defName="Uranium"]/comps/li[@Class="EBSGFramework.CompProperties_DRGConsumable"]</xpath>
<match Class="PatchOperationAdd">
<xpath>Defs/ThingDef[defName="Uranium"]/comps/li[@Class="EBSGFramework.CompProperties_DRGConsumable"]/resourceOffsets</xpath>
<value>
<li>
<mainResourceGene>SHG_Archetypes_Radiomancer</mainResourceGene>
<amount>0.1</amount>
<consumptionReportString>Absorbing {0}.</consumptionReportString>
<floatMenuString>Absorb {0}.</floatMenuString>
</li>
</value>
</match>
<nomatch Class="PatchOperationAdd">
<xpath>Defs/ThingDef[defName="Uranium"]/comps</xpath>
<value>
<li Class="EBSGFramework.CompProperties_DRGConsumable">
<resourceOffsets>
<li>
<mainResourceGene>SHG_Archetypes_Radiomancer</mainResourceGene>
<amount>0.1</amount>
<consumptionReportString>Absorbing {0}.</consumptionReportString>
<floatMenuString>Absorb {0}.</floatMenuString>
</li>
</resourceOffsets>
</li>
</value>
</nomatch>
</match>
<nomatch Class="PatchOperationAdd">
<xpath>Defs/ThingDef[defName="Uranium"]</xpath>
<value>
<comps>
<li Class="EBSGFramework.CompProperties_DRGConsumable">
<resourceOffsets>
<li>
<mainResourceGene>SHG_Archetypes_Radiomancer</mainResourceGene>
<amount>0.1</amount>
<consumptionReportString>Absorbing {0}.</consumptionReportString>
<floatMenuString>Absorb {0}.</floatMenuString>
</li>
</resourceOffsets>
</li>
</comps>
</value>
</nomatch>
</Operation>
</Patch>