You are viewing a potentially older version of this package. View all versions.
Crispy_Depression-LocalDeposit-1.1.5 icon

LocalDeposit

Host-side /deposit, /deposit -b, /undeposit terminal commands with a blue deposited total. Deposited scrap is put back around every autosave and when you leave, so saves stay vanilla. Host only; clients need nothing.

Date uploaded 5 days ago
Version 1.1.5
Download link Crispy_Depression-LocalDeposit-1.1.5.zip
Downloads 22
Dependency string Crispy_Depression-LocalDeposit-1.1.5

This mod requires the following mods to function

BepInEx-BepInExPack-5.4.2304 icon
BepInEx-BepInExPack

BepInEx pack for Mono Unity games. Preconfigured and ready to use.

Preferred version: 5.4.2304

README

LocalDeposit

Move ship scrap "off the ship" with a terminal command, keep a blue running total on the terminal, and get it all back automatically when you leave the save. Inspired by HQoL's deposit feature, rebuilt so that nothing is written to the save under a custom key and no other player needs the mod.

Read this first: host-only. Scrap are networked objects that only the host (server) may spawn or despawn. A mod running on a non-host client cannot remove scrap from the shared ship. Any local "hide it" trick would leave the item in the world for everyone else, would still count when sold, and could be picked up by others. So LocalDeposit works only when you are the lobby host. Other players need nothing installed and just see the items disappear/reappear through normal game networking. If you are not the host, the commands print an error and change nothing.

Commands (type in the ship terminal)

Command What it does
/deposit Deposits eligible scrap, skipping blacklisted items (PlainDepositUsesBlacklist = true, default). Gift Boxes are always skipped (deleting one destroys its hidden contents).
/deposit -b or /deposit --blacklist Same, but also skips every blacklisted item, and lists what was skipped and why.
/deposit --list (-l) Shows what is currently deposited.
/deposit --help Usage.
/undeposit Respawns everything you deposited, with its original value and item state (battery charge, shotgun ammo, ...).

"Eligible" means: scrap (Item.isScrap), value > 0, inside the ship's inner room, not held/pocketed, not attached to ship furniture, spawned by the game's own item list (so it can be rebuilt). Tools and equipment are never touched. Items lying outside the ship are ignored (and counted in the feedback).

The total appears as a blue $ line under your credits (top-right of the terminal), same colour HQoL uses.

What deposited scrap really is

  • Actual scrap in the shared world: removed (despawned) when deposited, so it no longer counts toward ship scrap, sale totals or anything else. It is recreated by /undeposit.
  • Ledger: a list in the host's memory with item type, value, position and saved state for every deposited item.
  • Blue number: a local display of the ledger total on the host's terminal. Other players (modded or not) do not see it; there is no networking in this mod.
  • Deposited scrap cannot be sold. Run /undeposit before selling at the Company.

Saves, leaving, and crashes

The mod never reads, writes or patches the save file and never creates custom keys. Instead it makes sure the ship itself holds every deposited item at the moment the game saves.

How the game saves (read from the v81 code): every save (round end, "ship ready to land", leaving the game) goes through GameNetworkManager.SaveGame(), which is two direct, synchronous calls with no coroutine in between. The mod brackets that single call:

  1. Before the save: every deposited item is respawned with the same code path the vanilla save loader uses.
  2. The game saves normally. It finds real items on the ship and writes them as usual.
  3. After the save (a Harmony finalizer, so it also runs if the save throws): the same objects are despawned again and deactivated immediately (so a leftover Start() can't re-parent them for the rest of the frame).

Guarantees the code enforces (and the test suite checks with fault injection):

  • An item is never both in the world and in the ledger once the bracket ends: if despawning fails and the item is still on the ship, it is left there, its ledger entry is dropped, and a warning is shown (HUD tip + log). If the item vanished some other way, its entry is kept so /undeposit can rebuild it. So nothing is lost or duplicated.
  • If an item cannot be respawned for the save, it is reported, stays deposited, and is not in that save.
  • The guard ignores duplicate/nested triggers and always resets, even when the save throws.
  • Scrap is counted once: during the save the world holds the items, the ledger entry is not shown twice, and nothing else reads the ship total in that synchronous span.

Leaving (Leave Game, disconnect, quit): everything is restored permanently before the game's own leave-save. Fired / new run: vanilla wipes the ship and the ledger is wiped with it.

Default: AutosaveMode = RestoreOnly

This is the default since 1.1.1. If you don't want the respawn/despawn churn, set this. Before each autosave the items are restored and stay on the ship until you /deposit again. Same save guarantees, no flicker risk, no hitch from re-despawning.

Alt+F4 / quitting

Alt+F4 is not a hard kill in this game: Unity calls the game's OnApplicationQuit, which calls Disconnect() and then SaveGame(). The mod restores your items first, but during application quit the network may already be shut down, in which case they cannot be respawned. Since 1.1.2 the mod then skips that save (SkipSaveIfItemsCannotBeRestored = true) so your last good save is not overwritten by a ship that is missing the deposited items. The cost: progress since the previous save is lost in that case. Prefer Leave Game from the ESC menu, which restores reliably.

Remaining risks (please read)

  • Not run in a real game. Also: vanilla saves at most maxShipItemCapacity (45) ship items; install a mod that raises it (e.g. TooManyItems) or most deposited/restored scrap is dropped from the save. The logic is tested with a fake world; spawn/despawn on the real engine is not.
  • Cost: every autosave respawns and despawns every deposited item on the host. With thousands of items this is a visible hitch and a burst of network messages. That is the price of keeping the file vanilla; use RestoreOnly if it hurts.
  • Flicker: spawn and despawn happen in the same frame, so the engine should batch them and clients should never render the items; but I could not verify client behaviour, and clients may still run spawn/despawn side effects.
  • Crash during the save: the bracket makes the items exist for the whole write. If the process dies mid-write, whether the file is intact depends on the game's save library (Easy Save); I could not inspect it. A crash outside the bracket leaves the last completed save, which contains every item deposited before it.
  • A crash after you deposited new items but before the next save simply restores the previous save's state.
  • Vanilla caps how many items it saves (maxShipItemCapacity); deposited items count toward it exactly as if on the ship.
  • Mods that hook item spawn/despawn will see the extra spawns.

Configuration

Generated on first launch at BepInEx/config/local.deposit.lethalcompany.cfg.

[Blacklist]
Items = ShotgunItem, KnifeItem, Shotgun, Knife, Kitchen knife, GiftBox, Gift Box
PartialMatch = true

[Behaviour]
PlainDepositUsesBlacklist = true
SkipItemsOnShipFurniture = true
AutosaveMode = RestoreOnly   # or RestoreSaveRedeposit
SkipSaveIfItemsCannotBeRestored = true

[Debug]
LogItemIdentifiers = false

Items is a comma-separated list. Each entry is compared (ignoring case, spaces, _ and -) to three identifiers of an item: its internal asset name (Item.name), its display name (Item.itemName) and its scan-node header text. Entries that match nothing (typos, uninstalled modded items) are silently ignored.

Finding identifiers: set LogItemIdentifiers = true, host a lobby, then open BepInEx/LogOutput.log and search for LocalDeposit item identifiers; every item is listed as asset name | display name | isScrap. Modded items appear there too.

Requirements

  • Lethal Company (built and checked against the v81 Assembly-CSharp.dll), BepInEx 5 (BepInEx-BepInExPack).
  • Host only. No other dependency (no LethalLib, no networking library).

Tests

tests/GuardTests exercises the save-bracket state machine against a fake world (normal cycle, failed restore, failed re-deposit, vanishing items, exceptions during the save, duplicate hooks, 5000 randomized fault-injection runs):

cd tests/GuardTests && dotnet run -c Release -p:UnityCoreModule="/path/to/Lethal Company_Data/Managed/UnityEngine.CoreModule.dll"

Build

./build.sh "/path/to/Lethal Company"      # needs the .NET SDK; game must have BepInEx installed
# -> dist/LocalDeposit-1.0.0.zip

Or dotnet build -c Release -p:LethalCompanyDir="D:/Games/Lethal Company". References are taken from Lethal Company_Data/Managed and BepInEx/core; nothing is bundled. Install by dropping LocalDeposit.dll into BepInEx/plugins/ (or import the zip in r2modman/Thunderstore).

Known limitations

  • Host only (see top).
  • Restored items return at their old position with default rotation, exactly like vanilla save loading.
  • Items inside a deposited-and-restored stack may briefly overlap physically, same as loading a vanilla save.
  • Not tested together with HQoL's own deposit/storage (both patch the terminal and the ship-save routine). Disable one of them.
  • Mods that add scrap with unusual per-item state not exposed through GetItemDataToSave() will lose that extra state.
  • Mods that replace the terminal parser wholesale may bypass the / commands.

CHANGELOG

Changelog

1.1.7

  • New icon, shorter Thunderstore summary, rewritten README.

1.1.6

  • HQoL takes precedence: if HQoL is loaded, /deposit and /undeposit do nothing and print a message saying so.
  • Thunderstore README rewritten; detailed notes moved to docs/DETAILS.md.

1.1.5

  • Host check is enforced inside the deposit/restore/save code too, not only in the command handler. Non-hosts cannot use the mod.

1.1.4

  • Default blacklist now lists the confirmed asset names ShotgunItem and KnifeItem.

1.1.3

  • Plain /deposit now applies the blacklist by default (PlainDepositUsesBlacklist = true).
  • Blacklist entries match partially by default (PartialMatch): knife matches Kitchen knife.
  • New SkipItemsOnShipFurniture option: items in the cabinet/on shelves were skipped by a furniture rule, unrelated to the blacklist.

1.1.2

  • Fix: Alt+F4 / quit could overwrite your save with a ship missing the deposited items (the game saves during quit while the network is already shutting down, so the restore could not run). The mod now SKIPS any save it cannot make complete (SkipSaveIfItemsCannotBeRestored, default true), so the previous save file stays intact.

1.1.1

  • Default AutosaveMode is now RestoreOnly (undeposit before every save, leave items on the ship).
  • Docs: vanilla only saves 45 ship items; a cap-raising mod is required.

1.1.0

  • Autosave bracket: deposited items are respawned for the duration of every vanilla save and removed again right after (AutosaveMode = RestoreSaveRedeposit, default), so every save contains them and a crash cannot lose them.
  • AutosaveMode = RestoreOnly: restore before each save and leave the items on the ship.
  • Re-deposit failure leaves the item on the ship and shows a warning; items are never dropped or duplicated.
  • Pure state machine with a fault-injection test suite in tests/GuardTests.

1.0.0

  • Initial release: /deposit, /deposit -b, /deposit --list, /undeposit, blue terminal total, blacklist config, automatic undeposit on leaving the game.