Skip to content

Reading Game Code


Chances are, early on in your modding journey you will be met by quite a conundrum - You want to know how something in the game works, but there is an issue! You cannot just open the game's files to find it (you silly goose).

You see, the way Unity games work, is that their code gets compiled into a .dll file, which you cannot normally open.


Fortunately, there is something called a "decompiler". What it does, is it grabs the game's code and reverses the process, resulting in readable code. While it is not perfect, it gets it's job done.

Currently there are 3 decompilers that are widely used:

dnSpyEx, ILSpy and dotPeek.


Picking which decompiler to use is up to personal preference, but for this article ILSpy will be used due to it's balance between simplicity and power.


Please keep in mind that while decompiling and reading the code is not illegal, distributing said decompiled code is illegal. Same applies for sharing the game's files.

What this means is that you CANNOT bundle any of the game's files with your mods.

Opening the game DLL

Upon starting ILSpy you will be met with a window similar to this. Screenshot of empty ILSpy window

From then you want to open the Assembly-CSharp.dll file present in the game's files.

To get it you need to do the following:

1. Open game files. On Steam it's done as simple as right clicking the game and pressing 'Browse local files'.

How to open local files on Steam

The game files folder will open Lethal Company local files

2. Go to Lethal Company_Data/Managed

Once you do that you will see many .dll files. Lethal Company DLLs

Copy the path and go back to ILSpy.

3. Open the file in ILSpy

In ILSpy click on File -> Open. How to open file in ILSpy

In an opened file browser paste the path you copied earlier for easy access, select Assembly-CSharp.dll, and press 'Open'. File browser window

After you have opened the file you should see that it has been added to the sidebar. Opened Assembly-CSharp.dll

Reading the game code

Click on the little + left of the file name. You should see a bunch of things pop up in a list. Opened Assembly-CSharp.dll

Those are called namespaces and are basically just used to organize code into groups. Nearly all of the game's codeis stored under the {} (blank) namespace, so open that by clicking on the + again.


Unlike 99% of the game's code, the actual player controller script (PlayerMovementB) is located in the GameNetcodeStuff namespace, so keep that in mind in case you cannot find it.

You will see a list of files, all containing code used by the game. If you double click any of them you can see the code inside. Opened classes

Searching fields and methods

Obviously, with so many different files it may be difficult to find out a specific function you need. Luckily, ILSpy has a solution - Search tool.

To open the search tool you can either:

Open it by clicking on Window -> Search. Opening search through menu


By clicking on the little magnifying glass icon on the topbar. Opening search through icon

Either way the Search window will open. Opened search menu

Using it is quite simple. You can type something in the search bar, and it will be displayed: Search menu in action

If you want to limit the search to only variables(fields) you can select so in the dropdown next to the search bar: Search only fields

Of course you can also search for types(classes) and methods(functions) by just selecting them.

Finding usage

A lot of the times, once you find something you need, you may want to know where it's being used. There is a tool for that as well.

By right clicking on any field or method, in a context menu you can select "Analyze". Analyze context menu

After clicking on it a small window with several dropdowns will open. Analyze window

Here is what most used dropdowns stand for in fields and methods:


Read By - Methods which use this field inside of them. Read By in fields

Assigned By - Methods which assign value to this field. Assigned By in fields


Uses - List of fields and methods that this method is using. Uses in methods

Used By - Methods which use this method. Used By in methods


Congrats! Now you know how to read game's code and how to find something that you need. Remember that if you cannot find something - There is no shame in asking. So, in case you need any help, you can get some in the Unofficial Lethal Company Community Discord.