Skip to content
Owlchemist edited this page Dec 23, 2021 · 11 revisions

Custom modded behavior vs default behavior

By default, this mod will apply the offsetting component to ThingDefs and give it standard offsets (0, 0, ±0.2). Specifically, these conditions must be met to be given a component:

  1. If the ignore = false flag is set, the subsequent rules will be waived.
  2. Must be a building
  3. Must not have linked graphics (like walls)
  4. Must have hitpoints
  5. Cannot produce power

It may also allow mirroring if either are true:

  • The building is not rotatable and the mirror does not equal false
  • The building is rotatable and mirror is set to true

Guide to custom behavior

This wiki explains how other modders can add offsets to their own assets. I recommend using MayRequire directly within the definition itself, as this in-line patching is easiest to do, and more lightweight to load.

<modExtensions>
	<li MayRequire="owlchemist.perspectivebuildings" Class="Perspective.Offsetter">
		<offsets>
			<li>(0, 0, 0.5)</li>
			<li>(0, 0, -0.5)</li>
		</offsets>
	</li>
</modExtensions>

This is a minimal example of how to add some custom offsets. The following nodes are available for additional behavior:

  • offsetType: Controls the offsets list behavior, as defined:

    • Normal: (default) The list of offsets is treated literally, and the Adjust gizmo just cycles through them.
    • Four: Only one offset should be defined. This offset is applied in the four cardinal directions.
    • Eight: Only one offset should be defined. This offset is applied in all 8 directions (cardinal and corners).
  • offsets: The instructions for offsetType to use. By default, if no custom behavior is defined, the two standard offsets given are (0, 0, 0.2) and (0, 0, -0.2).

  • mirror: Controls mirroring behavior:

    • Normal: (default) Allow the mod to automatically determine if this building should have a mirroring gizmo.
    • True: Force-enable mirroring gizmo, even if the building would not normally have this.
    • False: Force-disable mirroring gizmo, even if the building would normally have this.
  • ignore: Used for general override:

    • Normal: (default) Standard offsets will be applied if all conditions are met.
    • False: Completely exclude this building from this mod. However, this value will automatically be defaulted to if the extension is entirely empty, for example.

Examples

This is a shortcut to just completely exempt this def from the mod.

<modExtensions>
	<li MayRequire="owlchemist.perspectivebuildings" Class="Perspective.Offsetter" />
</modExtensions>

This could be used to remove the mirror gizmo in case it's showing up when you don't want it to, like example on perfectly symmetrical graphics.

<modExtensions>
	<li MayRequire="owlchemist.perspectivebuildings" Class="Perspective.Offsetter">
		<mirror>False</mirror>
	</li>
</modExtensions>

This is similar to the standard offset, except it allows all 4 directions. It also has a unique offset of -0.05 on the y axis. This was used for chairs, in order to allow the chair to tuck underneath tables.

<modExtensions>
	<li MayRequire="owlchemist.perspectivebuildings" Class="Perspective.Offsetter">
		<offsetType>Four</offsetType>
		<offsets>
			<li>(0.2, -0.05, 0.2)</li>
		</offsets>
	</li>
</modExtensions>

Full example

This shows a full XML definition and how MayRequire can be used for in-line patching.

<ThingDef ParentName="CeilingLightBase">
	<defName>Owl_CeilingLight</defName>
	<label>ceiling light</label>
	<description>An electrical standing lamp that lights an area. People need light to move and work at full speed.</description>
	<graphicData>
		<texPath>Things/Building/Furniture/CeilingLight</texPath>
		<color>(1,1,1,0.35)</color>
		<shaderType>Transparent</shaderType>
	</graphicData>
	<comps>
		<li MayRequire="oskarpotocki.vanillafactionsexpanded.core" Class="VanillaFurnitureExpanded.CompProperties_RandomBuildingGraphic">
			<randomGraphics>
				<li>Things/Building/Furniture/CeilingLight</li>
				<li>Things/Building/Furniture/Techist_CeilingLight</li>
				<li>Things/Building/Furniture/Square_CeilingLight</li>
			</randomGraphics>
		</li>
		<li Class="CompProperties_Glower">
			<glowRadius>12</glowRadius>
			<glowColor>(217,217,208,0)</glowColor>
		</li>
	</comps>
	<modExtensions Inherit="False">
		<li Class="CeilingUtilities.CeilingFixture" />
		<li MayRequire="owlchemist.perspectivebuildings" Class="Perspective.Offsetter">
			<mirror>False</mirror>
			<offsetType>Eight</offsetType>
			<offsets>
				<li>(0.5, 0, 0.5)</li>
			</offsets>
		</li>
	</modExtensions>
</ThingDef>
Clone this wiki locally