
DawnLib
A modern API for Lethal Company content and all sizes of mods
Last updated | 19 hours ago |
Total downloads | 3859 |
Total rating | 3 |
Categories | Mods Tools Libraries Client-side Server-side |
Dependency string | TeamXiaolan-DawnLib-0.1.2 |
Dependants | 3 other packages depend on this package |
This mod requires the following mods to function

BepInEx-BepInExPack
BepInEx pack for Mono Unity games. Preconfigured and ready to use.
Preferred version: 5.4.2100
Evaisa-FixPluginTypesSerialization
Fix custom Serializable structs and such not properly getting deserialized by Unity.
Preferred version: 1.1.2
Hamunii-AutoHookGenPatcher
Automatically generates MonoMod.RuntimeDetour.HookGen's MMHOOK files during the BepInEx preloader phase.
Preferred version: 1.0.6
Zaggy1024-PathfindingLib
Provides functionality for mod authors to run pathfinding off of the main thread.
Preferred version: 2.3.1README
DawnLib
(was CodeRebirthLib)
DawnLib is a modern API for Lethal Company content and all sizes of mods. It contains:
- DawnLib API
- DuskMod API
- Some extra utilities
DawnLib also categorises (almost) everything in the game with keys, allowing for easy references to existing vanilla content.
NOTE: Enemies/Items/etc managed through DawnLib are likely unsupported by mods like CentralConfig or LethalQuantities. This is because of the way DawnLib supports dynamically updating weights and therefore cannot be fixed from DawnLib.
DawnLib (All C#)
<PackageReference Include="TeamXiaolan.DawnLib" Version="0.1.0" />
<!-- Optional Source Generation, mostly for when using the DuskMod API -->
<PackageReference Include="TeamXiaolan.DawnLib.SourceGen" Version="0.1.0" />
DawnLib is a hands-off way to register your content. The code to switch from LethalLib to DawnLib is very similar and will require minimal refactoring.
Most registration methods are under the DawnLib
static class. When calling DefineXXX
you are provided with a builder method that
explains most settings that you can configure.
Supported content:
- Enemies
- Items
- Map Objects
- Unlockables
- Additional Tile Sets
Example:
public static class MeltdownKeys {
public static readonly NamespacedKey<DawnItemInfo> GeigerCounter = NamespacedKey<DawnItemInfo>.From("facility_meltdown", "geiger_counter");
}
// In your plugin
DawnLib.DefineItem(MeltdownKeys.GeigerCounter, assets.geigerCounterItemDef, builder => builder
.DefineShop(shopBuilder => shopBuilder
.OverrideCost(90)
.OverrideInfoNode(assets.geigerCounterNode)
)
);
LethalContent
is an easy way to reference vanilla/modded content:
EnemyType blobEnemyType = LethalContent.Enemies[EnemyKeys.Blob].EnemyType;
It should be noted that the vanilla references will not be in the registry until a while after the lobby is created.
In order to make sure everything is ready, you can listen to a registry's "freeze" event.
OnFreeze
will only run once ever (even between lobby reloads)
LethalContent.Enemies.OnFreeze += () => {
// All vanilla content is in and no more modded content can be added.
};
if(LethalContent.Enemies.IsFrozen) { // or check that the registry has already been frozen
// ...
}
PersistentDataContainer
PersistentDataContainer
is an alternative to ES3
. You can easily access save data with the .GetPersistentDataContainer()
extension method, .GetCurrentContract()
or .GetCurrentSave()
void Awake() { // Plugin awake
PersistentDataContainer myContainer = this.GetPersistentDataContainer(); // use this however you want, note that 'this' is required to use the extension method in the Awake function.
// these only return null when not in-game. these also automatically handle resetting the save
PersistentDataContainer? contract = DawnLib.GetCurrentContract(); // resets on: getting fired and save deletion.
PersistentDataContainer? save = DawnLib.GetCurrentSave(); // resets on: ONLY save deletion.
}
Note: If you are going to make a large edit (calling .Set
, .GetOrSet
, etc multiple times) you should wrap it with using(container.LargeEdit())
. This delays saving data to the disk until all your edits have been completed.
DuskMod (C# & Editor)
<PackageReference Include="TeamXiaolan.DawnLib" Version="0.1.0" />
<PackageReference Include="TeamXiaolan.DawnLib.DuskMod" Version="0.1.0" />
<!-- Optional Source Generation -->
<PackageReference Include="TeamXiaolan.DawnLib.SourceGen" Version="0.1.0" />
The DuskMod API is more opinionated, but automatically handles:
- Asset Bundle Loading
- Config Generation
- Skipping bundles when config is disabled
- Progressive Unlockables
- Automatically generate NamespacedKeys (C# Source Generators)
- Registering content with no code!
It also supports:
- Achievements
- Weathers (through
WeatherRegistry
) - Vehicles (highly experimental)
And finally, for any troubles in setting anything up, contact @xuxiaolan
on discord for help.
Credits
- Bongo Loaforc (Code)
- XuXiaolan (Code)
- Slayer (Achievement UI)