-
Notifications
You must be signed in to change notification settings - Fork 9
SHORTTUTORIAL: Facilities
roxxploxx edited this page May 7, 2017
·
2 revisions
Facilities are what link two items together for some purpose. For example, the "More Furniture" mod uses this to make file cabinets that connect to research benches for more productivity.
- A Facility empowers a Thing with additional functionality or efficiency.
- A Thing notifies what facilitates itself by a Component "CompProperties_AffectedByFacilities".
<comps>
<li Class="CompProperties_AffectedByFacilities">
<linkableFacilities>
<li>...FacilityDefName...</li>
</linkableFacilities>
</li>
</comps>
- A Facility says what it modifies.
<comps>
<li Class="CompProperties_Facility">
<statOffsets>
<ResearchSpeedFactor>0.05</ResearchSpeedFactor> <!-- for example. see RimWorld/StatDefOf.cs -->
</statOffsets>
<maxSimultaneous>1</maxSimultaneous>
<mustBePlacedAdjacent>...bool...</mustBePlacedAdjacent>
<canLinkToMedBedsOnly>...bool...</canLinkToMedBedsOnly>
</li>
</comps>
- Improve Stats: Just add a new ThingDef which has the CompProperties_Facility Component and add to the Thing, a CompProperties_AffectedByFacilities. Set the
<statOffsets>
tag appropriately. - Cool New Functionality via a Facility?: Same as above but create a new c# class for the Thing, which uses data from the facilitator(s). In your class, when handling the Tick callback, grab your CompFacilitator via
this.GetComp<CompFacilitator>
. - Add Facilitator to Existing Thing: Well, you're going to have to overwrite the ThingDef definition for that Thing in your XML file (i.e. copy and paste the XML ThingDef into your mod and use the same
<defName>
tag, but add in this facilitator; 'SimpleResearchBench' for example). This can lead to incompatibility problems with other mods so be careful!