Update Setup

Raphtalia 2024-07-27 06:03:30 +00:00
parent f62dfbdf00
commit 8a04b9817f
1 changed files with 40 additions and 18 deletions

@ -1,4 +1,9 @@
This guide is to setup DungeonGenerationPlus into your Unity project and interior mod. [See here](https://git.touhou.dev/Raphtalia/DungeonGenerationPlus_LethalCompany_Mod/wiki/Quick-Setup) to setting up multiple main paths.
This guide is to setup DungeonGenerationPlus inside your Unity project and interior mod. If you have already setup the plugin, [see here](https://git.touhou.dev/Raphtalia/DungeonGenerationPlus_LethalCompany_Mod/wiki/Quick-Setup) to setting up multiple main paths.
## Setting up your Unity project
See [nomnom's guide](https://github.com/nomnomab/unity-lc-project-patcher) to setup your Unity project for Lethal Company modding.
See [Major's guide](https://www.youtube.com/watch?v=lsQl7P0PYs0) for the tutorial in creating an interior.
## Setting up the plugin in your Unity project
@ -12,34 +17,51 @@ If you'd like to use this mod's API and callback features, reference the same `D
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.
![](https://i.imgur.com/a010wJr.png)
![](https://i.imgur.com/uo4mYgl.png)
If you are creating a `.lethalbundle` asset to be automatically handled by LethalLevelLoader, then that's it. The DungeonGenerationPlus mod will automatically extract and load the `DunGenExtender` asset from the `.lethalbundle` asset when the game runs.
#### 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.
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.
#### 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.
```cs
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.
![](https://i.imgur.com/yVUBkPj.png)
![](https://i.imgur.com/ii2g1qX.png)
## Setting up the API Callbacks
After your interior is selected but before it is generated, a shallow copy of the DunGenExtender's properties is passed to an event caller handler thing. You can register a function call to this event caller handler thing to modify the properties before they are used. This is useful if you have configs for your dungeon's generation. The following is a code example of how to register a function call and how you may want to use it.
After your interior is selected but before the dungeon generation, a copy of the DunGenExtender's properties is created and passed to an 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.
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 original properties. However if you modify any reference value such as the list `NormalNodeArchetypes` by adding or removing elements, then it will change the value in the original properties.
The following is a code example of how to register a function call and how you may want to use it.
```cs
dunGenExtender.Events.OnModifyDunGenExtenderProperties.AddListener(UpdateDunGenExtenderProperties);
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);
}
public void UpdateDunGenExtenderProperties(DunGenExtenderProperties props) {
void UpdateDunGenExtenderProperties(DunGenExtenderProperties props) {
props.MainPathCount = PluginConfig.Instance.mainPathCountValue;
if (PluginConfig.Instance.disableBasementValue) {
props.MainPathCount = Mathf.Min(props.MainPathCount, 2);
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);
}
}
props.DungeonSizeBase = new Vector3(PluginConfig.Instance.dunGenWidthBaseValue, props.DungeonSizeBase.y, PluginConfig.Instance.dunGenLengthBaseValue);
props.DungeonSizeFactor = new Vector3(PluginConfig.Instance.dunGenWidthMultiFactorValue, props.DungeonSizeBase.y, PluginConfig.Instance.dunGenLengthMultiFactorValue);
}
```