This guide is to setup DungeonGenerationPlus inside your Unity project and interior mod. If you have already setup the plugin, see here to setting up multiple main paths.
Setting up your Unity project
See nomnom's guide to setup your Unity project for Lethal Company modding.
See Major's guide for the tutorial in creating an interior.
Setting up the plugin in your Unity project
Download the DunGenPlus.dll
through Thunderstore or through this Github repository. Drag and drop the .dll
file into your interior Unity project, anywhere under PathToUnityProject/Assets/
. This mod also requires the LethalLevelLoader plugin to be installed in your Unity project. With just those simple steps, the mod is installed. You can now setup and use this mod's features.
By using DungeonGenerationPlus, your mod becomes depended on this mod. DungeonGenerationPlus MUST be a mod installed into your Lethal Company mod pack.
If you'd like to use this mod's API and callback features, reference the same DunGenPlus.dll
file in your project solution thing.
<Reference Include="DunGenPlus">
<HintPath>..\..\..\Libraries\DunGenPlus.dll</HintPath>
</Reference>
Setting up the DunGenExtender asset
Inside the Project tab, right click to open the Assets tab. Select Create/DunGenExtender
to create the DunGenExtender
asset. Inside that asset, reference the DungeonFlow
that will be linked to this Extender asset. Finally, set it's AssetBundle name to the same one as your interior's asset, DungeonFlow
or ExtendedDungeonFlow
whichever it may be.
Automatic registration
If you are creating a .lethalbundle
asset to be automatically handled by LethalLevelLoader, then that's it. The DungeonGenerationPlus mod will automatically extract and register the DunGenExtender
asset from the .lethalbundle
asset when the game loads.
Manual registration
If you are loading the asset manually, you must register the DunGenExtender
asset manually through the API. The following is a code example of how you may want to do it.
public class Plugin : BaseUnityPlugin {
void Awake() {
// your plugin setup code stuff
var dungeon = YOUR_ASSET_BUNDLE.LoadAsset<DungeonFlow>("YOUR_DUNGEONFLOW_ASSET_NAME");
var extender = YOUR_ASSET_BUNDLE.LoadAsset<DunGenExtender>("YOUR_EXTENDER_ASSET_NAME");
DunGenPlus.API.AddDunGenExtender(dungeon, extender);
}
}
Verifying that it even registered
After any of the two previous steps, verify that the Extender was registered by finding this message in the logs.
Setting up the API Callbacks
After your interior is selected but before the dungeon generation, a copy of the DunGenExtender's
properties is created and passed to this event caller handler thing. If you want to modify these properties before they are used in the dungeon generation, you can register a function call to this event caller handler thing.
public class Plugin : BaseUnityPlugin {
void Awake() {
// your plugin setup code stuff
var extender = YOUR_ASSET_BUNDLE.LoadAsset<DunGenExtender>("YOUR_EXTENDER_ASSET_NAME");
extender.Events.OnModifyDunGenExtenderProperties.AddListener(UpdateDunGenExtenderProperties);
}
void UpdateDunGenExtenderProperties(DunGenExtenderProperties props, EventCallbackScenario callback) {
// code that modifies the properties stuff
}
}
You may want to use these callbacks if you want to have configs for your dungeon generation. For example, my interior has a config to allow the player to specify how many multiple main paths they want spawned. Small party groups may want only two main paths, large party groups may want three, or maybe they just want a vanilla experience with just one main path. As such, I use this callback to easily modify the MainPathCount
.
NOTE: The copy of the
DunGenExtender's
properties is only a shallow copy. You can replace any value in the copy and it won't affect the corresponding value in the original properties. You CANNOT modify any value if it's a reference value. The listNormalNodeArchetypes
is a reference value; it is the same object for the original and copied properties. You can replace this value in the copy as it will still exist in the original properties. If you modify the value by adding or removing elements, then the changes would be reflected in the original properties as well since they are both the same object.
The following is a code example of how you may want to use it. Here is also an example of how my interior uses it.
public class Plugin : BaseUnityPlugin {
void UpdateDunGenExtenderProperties(DunGenExtenderProperties props, EventCallbackScenario callback) {
if (callback.IsDevDebug) return;
props.MainPathCount = PluginConfig.Instance.mainPathCountValue;
props.DungeonSizeBase = new Vector3(PluginConfig.Instance.dunGenWidthBaseValue, props.DungeonSizeBase.y, PluginConfig.Instance.dunGenLengthBaseValue);
props.DungeonSizeFactor = new Vector3(PluginConfig.Instance.dunGenWidthMultiFactorValue, props.DungeonSizeFactor.y, PluginConfig.Instance.dunGenLengthMultiFactorValue);
}
}
NOTE: The purpose of
EventCallbackScenario
is purely for DevDebug mode. That mode replicates how Lethal Company generates dungeons for perfect accuracy, which also includes invoking the eventDunGenExtender.Events.OnModifyDunGenExtenderProperties
. If you don't want that callback to called and affect the dungeon generation during DevDebug mode, then you can return early by checking forEventCallbackScenario.IsDevDebug
.