
DawnLib
A modern API for Lethal Company content and all sizes of mods
Date uploaded | 3 days ago |
Version | 0.1.8 |
Download link | TeamXiaolan-DawnLib-0.1.8.zip |
Downloads | 10149 |
Dependency string | TeamXiaolan-DawnLib-0.1.8 |
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)
CHANGELOG
v0.1.9
- Fixed an issue with some enemies like from pikmin not registering.
v0.1.8
- Added
On First Scan
event toExtraScanEvents
. - Fixed issues with other mods adding duplicate items into the list of all items.
- Fixed more compatibilities with other mods.
- Made sure to fix issues with achievement popup not working properly.
v0.1.7
- Attempt at fixing some more file locking issues or whatever.
- Fixed a bunch of the definitions being broken in editor.
v0.1.6
- Improved error handling with corrupted save data and tagging.
- Fixed an issue with applying item spawn group tags.
- Added
ExtraScanEvents
with anOn Scan
event (requiresScan Node Properties
) - Refined VehicleBase + VehicleStation code to be compatible with dropship attaching etc.
v0.1.5
- Fixed issues with LLL shop items not being proper keyword names by LLL.
- Fixed achievement UI sound not playing and breaking the achievements.
- Fixed an issue where mods like MoreShipUpgrades allow LethalLib shop items to be disabled incorrectly.
v0.1.4
- Fixed issues with checking unlockables and unlockables not registering.
- Fixed issues with trying to use the Achievement Predicate.
- Fixed Editor.dll issues with accessing achievements for AchievementTriggers script.
- Fixed issues with DailyPricingStrategy accessing TimeOfDay too early.
- Fixed issues with achievements causing a share violation error on loading multiple achievements simultaneously sometimes.
v0.1.2
- Disabled achievements button if there are no achievements.
v0.1.1
- Fixed some editor dll stuff and separated compatiblity with soundapi into another dll.
v0.1.0
Hello World!
DawnLib
- Added registering content through
DawnLib
- Added
WeightTable
andCurveTable
so that weights can be updated dynamically in-game. - Added
ITerminalPurchasePredicate
to allow some items to not be bought based on conditions.TerminalPurchaseResult.Success()
: Acts like normalTerminalPurchaseResult.Failed()
: Player is unable to purchase the item and a different terminal node is displayed. Also allows overriding the name in this state with.SetOverrideName(string)
TerminalPurchaseResult.Hidden()
: Does not show up instore
, and player is also unable to purchase the item.
ITerminalPurchase
interface for (currently only some) possible terminal purchases:ITerminalPurchasePredicate Predicate
: see above, set withbuilder.SetPredicate(predicate)
IProvider<int> Cost
: allows cost to be easily updated, set withbuilder.SetCost(int)
orbuilder.SetCost(provider)
- Removed
VanillaEnemies
and addedLethalContent
- Added
tags
- Allow registering new tilesets to dungeons
- Added
PersistentDataContainer
DuskMod
MIGRATING FROM CODEREBIRTHLIB:
You will need to remake your Content Container
, Mod Information
and content definitions.
The general flow has not changed overall.
- Reworked
Content Container
:Entity Name
(from content definitions) andEntity Name Reference
have been removed. Instead, content can just be referenced.Asset Bundle Name
is now a dropdown.- Button to dump all
NamespacedKey
s to a.json
file to be used with theTeamXiaolan.DawnLib.SourceGen
package.
- Added 4 types of
Achievements
:Discovery
,Instant
,Stat
,Parent
- Content definitions can now apply
tags
- Added
DuskModContent
for theAchievement
registry. - Moved
.RegisterMod()
fromCRLib
toDuskMod
- Added
DuskAdditionalTilesDefinition
- Added 2
DuskTerminalPredicate
s:ProgressivePredicate
: Allows for a shop item to be unlocked through progressionAchievementPredicate
: Requires that the player purchasing the item has an achievement
- Added 1
DuskPricingStrategy
:- NOTE: Setting a pricing strategy in a content definition overrides the price set in the config.
DailyPricingStrategy
: Price of shop item changes as the quota progresses.
Utilities / Misc
- Added
NetworkAudioSource
,AssetBundleUtils
- Removed
ExtendedLogging
and split it intoDebugLogSources
(yes this uses SoundAPI code)