BlueprintClasses

From Space Engineers Wiki
Jump to navigation Jump to search

A quick tutorial to explain how production blocks (refinery, assembler, etc) are tied to blueprints (recipes).

Terminology

  • Blueprint (Blueprints.sbc) defines a list of items (prerequisites) that can be turned into a different list of items (results).

There can be multiple blueprints that make up the same item(s), however only the <IsPrimary>true</IsPrimary> blueprint will be used for reverse lookup when for example Assembler block wants to disassemble something.

  • BlueprintClass (BlueprintClasses.sbc at the top) defines a group of blueprints, these are directly referenced by production blocks' sbc (assembler, refinery, etc) and they also define the tabs you see in Production terminal in-game.
  • BlueprintClassEntry (BlueprintClasses.sbc at the bottom) is how a Blueprint is linked to a BlueprintClass without needing to override blocks or classes, this is the way for mods to add new items.

Add a new blueprint without overriding blocks

Step 1. Create a Blueprint definition

You first need a Blueprint definition to specify what item(s) make what (by copying a vanilla Blueprints.sbc, erasing all except one blueprint and then changing its subtype to be unique ane the items).

How it should look after you've done the above:

<?xml version="1.0"?>
<Definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <Blueprints>
        <Blueprint>
            <Id>
                <TypeId>BlueprintDefinition</TypeId>
                <SubtypeId>StoneOreToIngot</SubtypeId>
            </Id>
            <DisplayName>DisplayName_BlueprintClass_Ingots</DisplayName>
            <Icon>Textures\GUI\Icons\ingot\ingot_class.dds</Icon>
            <Prerequisites>
                <Item Amount="1000" TypeId="Ore" SubtypeId="Stone" />
            </Prerequisites>
            <Results>
                <Item Amount="14" TypeId="Ingot" SubtypeId="Stone" />
                <Item Amount="30" TypeId="Ingot" SubtypeId="Iron" />
                <Item Amount="2.4" TypeId="Ingot" SubtypeId="Nickel" />
                <Item Amount="4.0" TypeId="Ingot" SubtypeId="Silicon" />
            </Results>
            <BaseProductionTimeInSeconds>10</BaseProductionTimeInSeconds>
        </Blueprint>
    </Blueprints>
</Definitions>

Now change it to be yours! First <SubtypeId> has to be unique otherwise you're overriding that vanilla blueprint.

On the <Item ... />, the TypeId and SubtypeId must be the same ones you see in the <Id> element on the item definition. For hand tools/weapons, use the PhysicalItem definition's Id.
Step 2. Prepare BlueprintClassEntries

Copy BlueprintClasses.sbc to your mod, then remove all classes (the entire <code<BlueprintClasses> to </BlueprintClasses> section) and to only leave the <BlueprintClassEntries> section.

Then in the <BlueprintClassEntries> leave only one entry because this list is additive so all mods can declare it without breaking. Can also remove entries if desired.

How it should look afterwards:

<?xml version="1.0"?>
<Definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <BlueprintClassEntries>
        <Entry Class="Components" BlueprintSubtypeId="ConstructionComponent" />
    </BlueprintClassEntries>
</Definitions>
Replace the BlueprintSubtypeId's value with your blueprint SubtypeId, then onto step 3 to see what to use for Class.
Step 3. Find which BlueprintClass you need

Open the game's \Content\Data\CubeBlocks\CubeBlocks_Production.sbc and find the block(s) you wish your blueprint to be part of, in their <BlueprintClasses> element.

For example:

<BlueprintClasses>
    <Class>SimpleComponents</Class>
    <Class>SimpleEquipment</Class>
    <Class>Tools</Class>
    <Class>SimpleWeapons</Class>
    <Class>Consumables</Class>
</BlueprintClasses>

Note: don't copy this block SBC to your mod, you don't need to override blocks only to add blueprints!

Decide which class makes sense, and also check other production blocks as a class can be used by multiple blocks!

Once you've decided, copy the class name (which is its SubtypeId) onto the Class from your entry in step 2. If confused, refer to the full examples section below.

Full Examples

Adding a blueprint to all 3 vanilla assemblers
<?xml version="1.0"?>
<Definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <Blueprints>
    <Blueprint>
      <Id>
        <TypeId>BlueprintDefinition</TypeId>
        <SubtypeId>YourFancyBlueprint</SubtypeId>
      </Id>
      <DisplayName>Name seen in Production UI</DisplayName>
      <Icon>Textures\SomeIcon.dds</Icon>
      <Prerequisites>
        <Item Amount="4" TypeId="Ingot" SubtypeId="Iron" />
        <Item Amount="1" TypeId="Ingot" SubtypeId="Nickel" />
        <Item Amount="2" TypeId="Ingot" SubtypeId="Silicon" />
      </Prerequisites>
      <Results>
        <Item Amount="1" TypeId="PhysicalGunObject" SubtypeId="HandDrill3Item" />
      </Results>
      <BaseProductionTimeInSeconds>10</BaseProductionTimeInSeconds>
    </Blueprint>
  </Blueprints>
  <BlueprintClassEntries>
    <!-- survival kit -->
    <Entry Class="BasicTools" BlueprintSubtypeId="YourFancyBlueprint" />

    <!-- basic assembler -->
    <Entry Class="Tools" BlueprintSubtypeId="YourFancyBlueprint" />

    <!-- assembler (2x1x1) -->
    <Entry Class="EliteTools" BlueprintSubtypeId="YourFancyBlueprint" />
  </BlueprintClassEntries>
</Definitions>

Changing existing blueprints

Same way any other definition, you copy its sbc to your mod, remove other definitions you don't want to touch then the remaining one leave its SubtypeId alone as that is what will override it, then change the things you wish to change.

Adding new classes

For this you will need either a new block or override an existing block or a script-based solution (like ModAdjuster) to partially modify a block. As for the class itself, it's like any other sbc, you copy the .sbc to your mod, remove all but one class and give it a unique subtype and customize everything about it.