Last updated: May 30, 2023 21:40:52
ToolGroups
Table of contents
ToolGroups are used to group multiple Tools together.
ToolGroupSpecification Scheme
Property | Default | Required | Description |
---|---|---|---|
Id | - | Yes | Unique identifier |
GroupId | - | No | Group unique identifier |
Type | - | Yes | Defines what tool will be created, check out TimberApi ToolGroups to find the identifiers or check out the mod creator |
Section | BottomBar | No | Location indicator |
Layout | Green | No | Defines what button layout will be created |
Order | - | Yes | Position of ToolButton |
Icon | - | Yes | Asset path to sprite |
NameLocKey | - | Yes | Localization key |
FallbackGroup | false | Yes | Determines whether this group is the fallback group. This is provided by the game so should always be false |
DevMode | false | No | Required dev mode when true |
Hidden | false | No | Hides existing tool when true |
GroupInformation | - | Sometimes | Implementation defined data, check out the mod creator for this information |
Example
{
"Id": "Other",
"GroupId": "Paths",
"Type": "PlaceableObjectTool",
"Section": "BottomBar",
"Order": "180",
"NameLocKey": "ToolGroups.Other",
"Icon": "Sprites/BottomBar/BuildingGroups/Other",
"FallbackGroup": false,
"DevMode": true,
"Hidden": true,
"GroupInformation": {
"BottomBarSection": 1
}
}
How To Register a New ToolGroup
When creating a Tool the original method of Timberborn does not work! Follow the step to register your tool to TimberApi ToolSystem.
- Create a new ToolGroup class that extends
ApiToolGroup
- Create a new ToolGroupFactory class that implements IToolGroupFactory
- Set a unique
Id
, this will be theType
identifier in theToolGroupSpecification
- Return a new instance of your ToolGroup class
- MultiBind the ToolGroupFactory to
IToolGroupFactory
in a configurator
Example
public class PlantingModeToolGroup : ApiToolGroup, IPlantingToolGroup
{
public PlantingModeToolGroup(string id, string? groupId, int order, string section, string displayNameLocKey, bool devMode, Sprite icon)
: base(id, groupId, order, section, displayNameLocKey, devMode, icon)
{
}
}
public class PlantingModeToolGroupFactory : IToolGroupFactory
{
public string Id => "PlantingModeToolGroup";
public IToolGroup Create(ToolGroupSpecification toolGroupSpecification)
{
return new PlantingModeToolGroup(
toolGroupSpecification.Id,
toolGroupSpecification.GroupId,
toolGroupSpecification.Order,
toolGroupSpecification.Section,
toolGroupSpecification.NameLocKey,
toolGroupSpecification.DevMode,
toolGroupSpecification.Icon
);
}
}
[Configurator(SceneEntrypoint.InGame)]
public class PlantingModeToolGroupConfigurator : IConfigurator
{
public void Configure(IContainerDefinition containerDefinition)
{
containerDefinition.MultiBind<IToolGroupFactory>().To<PlantingModeToolGroupFactory>().AsSingleton();
}
}