forked from Indaclouds/LethalCompanyModder
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLethalCompanyModder.ps1
553 lines (484 loc) · 24.2 KB
/
LethalCompanyModder.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
#Requires -Version 5.1
<#
.SYNOPSIS
Install a selection of mods for Lethal Company.
.DESCRIPTION
This script installs a selection of mods for Lethal Company defined in a preset.
.EXAMPLE
PS> ./LethalCompanyModder.ps1
Install mods for Lethal Company.
.NOTES
This script assumes that your installation of Lethal Company is managed by Steam on Windows.
It also installs BepInEx plugin framework, as some mods are BepInEx plugins.
.LINK
- BepInEx GitHub repository: https://github.com/BepInEx/BepInEx
- BepInEx installation guide: https://docs.bepinex.dev/articles/user_guide/installation/index.html
- Thunderstore API documentation: https://thunderstore.io/api/docs/
- Lethal Company community page on Thunderstore: https://thunderstore.io/c/lethal-company/
#>
[CmdletBinding(DefaultParameterSetName = "Curated")]
param (
[Parameter(
HelpMessage = "Specify this parameter if you intend to host the game (server)"
)]
[Alias("Server")]
[switch] $ServerHost,
[Parameter(
HelpMessage = "Name of the preset of mods to install"
)]
[string] $Preset = "Default",
[Parameter(
ParameterSetName = "Curated",
HelpMessage = "Name of the Git branch where the curated preset of mods is located"
)]
[string] $GitBranch = "main",
[Parameter(
ParameterSetName = "Custom",
HelpMessage = "Path to a JSON file including the preset of mods to install"
)]
[ValidateScript({ if (Test-Path -Path $_ -PathType Leaf) { $true } else { throw "`"$_`" file not found." } })]
[string] $File,
[Parameter(
HelpMessage = "Upgrade everything but keep the existing configuration"
)]
[ValidateScript({ if ($Force.IsPresent) { throw "Cannot use Upgrade and Force parameters at the same time." } else { $true } })]
[Alias("Update")]
[switch] $Upgrade,
[Parameter(
HelpMessage = "Proceed to clean installation"
)]
[ValidateScript({ if ($Upgrade.IsPresent) { throw "Cannot use Upgrade and Force parameters at the same time." } else { $true } })]
[switch] $Force,
[Parameter(
HelpMessage = "Specify true to enable custom mod configuration, false otherwise"
)]
[switch] $CustomModConfig
)
#region ---- System and PowerShell configuration and pre-flight check
# Set PowerShell Cmdlet
$ErrorActionPreference = "Stop"
$ProgressPreference = "SilentlyContinue" # Fix slow execution for some cmdlets
if ($PSBoundParameters.Debug -and $PSEdition -eq "Desktop") {
# Fix repetitive action confirmation in PowerShell Desktop when Debug parameter is set
$DebugPreference = "Continue"
}
# Check if system is running on Windows
if ($env:OS -notmatch "Windows") { Write-Error -Message "Cannot run as it supports Windows only." }
#endregion ----
#region ---- Define helper functions
function New-TemporaryDirectory {
# Create a new temporary directory and return its path
[CmdletBinding()]
param ()
process {
$RandomString = -join ((97..122) | Get-Random -Count 8 | ForEach-Object -Process { [char]$_ })
New-Item -Path $env:TEMP -Name "LethalCompanyModder-$RandomString" -ItemType Directory | Select-Object -ExpandProperty FullName
}
}
function Invoke-PackageDownloader {
# Download and extract a package in a temporary directory and return its path
[CmdletBinding()]
param (
[string] $Url
)
process {
$TemporaryDirectory = New-TemporaryDirectory
try {
Write-Debug -Message "Download package archive from `"$Url`"."
Invoke-WebRequest -Uri $Url -OutFile "$TemporaryDirectory\package.zip"
Write-Debug -Message "Extract package archive to temporary directory `"$TemporaryDirectory`"."
Expand-Archive -Path "$TemporaryDirectory\package.zip" -DestinationPath $TemporaryDirectory
Remove-Item -Path "$TemporaryDirectory\package.zip"
}
catch {
Remove-Item -Path $TemporaryDirectory -Recurse
Write-Error -Message "An error occured with package downloader: {0}" -f $_.Exception.Message
}
$TemporaryDirectory
}
}
function Invoke-StartWaitStopProcess {
# Start, wait and stop process
[CmdletBinding()]
param (
[string] $Executable,
[string] $ProcessName,
[int] $Seconds = 10
)
Write-Debug -Message "Start `"$Executable`" and wait."
Start-Process -FilePath $Executable -WindowStyle Hidden
Start-Sleep -Seconds $Seconds
Write-Debug -Message "Stop `"$ProcessName`" process and wait."
Stop-Process -Name $ProcessName -Force
Start-Sleep -Seconds 1
}
#endregion ----
#region ---- Definition of mods for Lethal Company
$ModsData = $(switch ($PSCmdlet.ParameterSetName) {
"Curated" {
Invoke-WebRequest -Uri "https://raw.githubusercontent.com/fscorrupt/LethalCompanyModder/$GitBranch/mods.json" | Select-Object -ExpandProperty Content
}
"Custom" {
Get-Content -Path $File -Raw
}
}) | ConvertFrom-Json
$SelectedMods = $ModsData.Presets | Select-Object -ExpandProperty $Preset
if (-not $SelectedMods) {
Write-Error -Message "No mod to install. Preset `"$Preset`" is empty or does not exist."
}
$Mods = $ModsData.Mods | Where-Object -Property Name -In -Value $SelectedMods
# If ServerHost parameter is not present, exclude mods that are only required by server host
if (-not $ServerHost.IsPresent) {
$Mods = $Mods | Where-Object -Property "ServerHostOnly" -NE -Value $true
}
#endregion ----
#region ---- Installation of mods for Lethal Company
$Banner = @"
##################################################################################
## ##
### ### ####### ######### ### ### ### ### ##
### ### ### #### ### ### ##### ### ##
### ### #### #### ########## ####### ### ###
### ### ######## #### ########## #### #### ### ###
### ### ### #### ### ### ########### ### ###
### ########## ######## #### ### ### ##### ##### ######### ###
## ##
### ##### ###### ##### ##### ####### ##### #### ####### #### ###
### ######### ########## ###### ###### ######### ###### ##### ######## #### ###
## ##### #### ### ###### ###### ### #### ####### ####### #### ####### ###
## #### ### ### ############## ######### #### #### ############ ###### ###
## ##### #### ### ### ########## ####### ########## #### ####### #### ##
## ######### ########## ### ##### #### ### ################ ###### ### ##
## ###### ###### ### ### ### ### #### ######## #### ### ##
## ##
######################################################################################
Our auto-pilot is going to install a selection of high-end mods for you (and the Company).
In the meantime, just seat back and relax...
Mods to be installed:
{0}
"@ -f (($Mods | ForEach-Object -Process { " o {0}: {1}" -f $_.DisplayName, $_.Description }) -join "`r`n")
Write-Host $Banner -ForegroundColor Green
Write-Host "Installation of Lethal Company mods started." -ForegroundColor Cyan
if ($Upgrade.IsPresent) { Write-Host "This runs in upgrade mode." -ForegroundColor Cyan }
# Search for directory where Lethal Company is installed
Write-Host "Search for Lethal Company installation directory."
$DriveRootPaths = Get-PSDrive -PSProvider FileSystem | Where-Object -Property "Name" -NE -Value "Temp" | Select-Object -ExpandProperty Root
$PredictPaths = @(
"Program Files (x86)\Steam\steamapps\common" # Default Steam installation path for games
"Program Files\Steam\steamapps\common"
"SteamLibrary\steamapps\common"
"Steam\SteamLibrary\steamapps\common"
) | ForEach-Object -Process { foreach ($p in $DriveRootPaths) { Join-Path -Path $p -ChildPath $_ } }
$ChildItemParams = @{
Path = $PredictPaths + $DriveRootPaths # Respect order to check every path prediction first
Filter = "Lethal Company"
}
$GameDirectory = Get-ChildItem @ChildItemParams -Directory -Recurse -ErrorAction SilentlyContinue | Select-Object -ExpandProperty FullName -First 1
if (-not $GameDirectory) { Write-Error -Message "Lethal Company installation directory not found." }
Write-Debug -Message "Lethal Company directory found `"$GameDirectory`"."
try { $GameExecutable = Join-Path -Path $GameDirectory -ChildPath "Lethal Company.exe" -Resolve }
catch { Write-Error -Message "Lethal Company executable not found in directory `"$GameDirectory`"." }
Write-Debug -Message "Lethal Company executable found `"$GameExecutable`"."
# Define BepInEx structure
$BepInEx = @{
RootDirectory = "$GameDirectory\BepInEx"
CoreDirectory = "$GameDirectory\BepInEx\core"
ConfigDirectory = "$GameDirectory\BepInEx\config"
ConfigFile = "$GameDirectory\BepInEx\config\BepInEx.cfg"
PluginsDirectory = "$GameDirectory\BepInEx\plugins"
PatchersDirectory = "$GameDirectory\BepInEx\patchers"
LogFile = "$GameDirectory\BepInEx\LogOutput.log"
WinhttpDll = "$GameDirectory\winhttp.dll"
DoorstopConfigIni = "$GameDirectory\doorstop_config.ini"
}
if (Test-Path -Path $BepInEx.RootDirectory) {
if (-not $Upgrade.IsPresent) {
if (-not $Force.IsPresent) {
Write-Warning -Message "BepInEx directory already exist. Switching to upgrade mode."
$Upgrade = $true
}
}
# Backup BepInEx directory
Write-Host "Backup Current BepInEx directory."
$BackupParams = @{
Path = $BepInEx.RootDirectory
DestinationPath = "{0}_Backup.zip" -f $BepInEx.RootDirectory
}
Write-Debug -Message ("Backup existing BepInEx directory to `"{0}`"." -f $BackupParams.DestinationPath)
Compress-Archive @BackupParams -Force
# Remove existing BepInEx components from Lethal Company directory
Write-Host "Clean BepInEx files and directory up."
$ItemsToRemove = if ($Upgrade.IsPresent) {
@(
$BepInEx.CoreDirectory
$BepInEx.PluginsDirectory
$BepInEx.PatchersDirectory
$BepInEx.LogFile
$BepInEx.WinhttpDll
$BepInEx.DoorstopConfigIni
)
}
else {
@(
$BepInEx.RootDirectory
$BepInEx.WinhttpDll
$BepInEx.DoorstopConfigIni
)
}
$ItemsToRemove | ForEach-Object -Process {
if (Test-Path -Path $_) {
Write-Debug -Message "Remove existing BepInEx component `"$_`"."
Remove-Item -Path $_ -Recurse -Force
}
}
}
# Install BepInEx from GitHub
if ($Upgrade.IsPresent) {
Write-Host "Update BepInEx plugin framework."
}
Else {
Write-Host "Install BepInEx plugin framework."
}
$DownloadUrl = (Invoke-RestMethod -Uri "https://api.github.com/repos/BepInEx/BepInEx/releases/latest")."assets"."browser_download_url" | Select-String -Pattern ".*\/BepInEx_x64_.*.zip"
if (-not $DownloadUrl) { Write-Error -Message "BepInEx download URL not found." }
try {
$TempPackage = Invoke-PackageDownloader -Url $DownloadUrl
Write-Debug -Message "Copy BepInEx package to `"$GameDirectory`"."
Copy-Item -Path "$TempPackage\*" -Destination $GameDirectory -Exclude "changelog.txt" -Recurse -Force
}
finally { if ($TempPackage) { Remove-Item -Path $TempPackage -Recurse } }
# Run Lethal Company executable to generate BepInEx configuration files
if ($Upgrade.IsPresent) {
Write-Host "Launch Lethal Company to update BepInEx."
}
Else {
Write-Host "Launch Lethal Company to install BepInEx."
}
Invoke-StartWaitStopProcess -Executable $GameExecutable -ProcessName "Lethal Company"
# Check if BepInEx files have been successfully generated
Write-Host "Validate BepInEx installation."
$BepInEx.ConfigFile, $BepInEx.LogFile | ForEach-Object -Process {
if (Test-Path -Path $_) { Write-Debug -Message "BepInEx file `"$_`" found." }
else { Write-Error -Message "BepInEx installation failed because `"$_`" not found." }
}
# Install Mods from Thunderstore
$ThunderstoreMods = $Mods | Where-Object -Property "Provider" -EQ -Value "Thunderstore"
$mod = $Mods | Where-Object -Property "Name" -EQ -Value "More_Emotes"
foreach ($mod in $ThunderstoreMods) {
if ($Upgrade.IsPresent) {
Write-Host (" Update {0} mod by {1}." -f $mod.DisplayName, $mod.Namespace)
}
Else {
Write-Host (" Install {0} mod by {1}." -f $mod.DisplayName, $mod.Namespace)
}
$FullName = "{0}/{1}" -f $mod.Namespace, $mod.Name
$DownloadUrl = (Invoke-RestMethod -Uri "https://thunderstore.io/api/experimental/package/$FullName/")."latest"."download_url"
if (-not $DownloadUrl) { Write-Error -Message "$FullName mod download URL was not found." }
try {
$TempPackage = Invoke-PackageDownloader -Url $DownloadUrl
switch ($mod.Type) {
"BepInExPlugin" {
Write-Debug -Message ("{0} {1}: Copy DLL files to `"{2}`"." -f $mod.Type, $FullName, $BepInEx.PluginsDirectory)
Get-ChildItem -Path "$TempPackage\*" -Include "*.dll" -Recurse | Move-Item -Destination $BepInEx.PluginsDirectory
if ($mod.Name -EQ "More_Emotes") {
$MoreEmotesFolder = $BepInEx.PluginsDirectory + "\MoreEmotes"
New-Item -ItemType Directory -Path $BepInEx.PluginsDirectory -Name MoreEmotes -Force | Out-Null
Get-ChildItem -Path "$TempPackage\*" -Include "*animationsbundle*" -Recurse | Move-Item -Destination $MoreEmotesFolder
Get-ChildItem -Path "$TempPackage\*" -Include "*animatorbundle*" -Recurse | Move-Item -Destination $MoreEmotesFolder
}
foreach ($item in $mod.ExtraIncludes) {
$Path = Join-Path -Path $TempPackage -ChildPath $item
Write-Debug -Message ("{0} {1}: Copy `"{2}`" to `"{3}`"." -f $mod.Type, $FullName, $item, $BepInEx.PluginsDirectory)
Move-Item -Path $Path -Destination $BepInEx.PluginsDirectory
}
}
"BepInExPatcher" {
Write-Debug -Message ("{0} {1}: Copy DLL files to `"{2}`"." -f $mod.Type, $FullName, $BepInEx.PatchersDirectory)
Get-ChildItem -Path "$TempPackage\*" -Include "*.dll" -Recurse | Move-Item -Destination $BepInEx.PatchersDirectory
Write-Debug -Message ("{0} {1}: Copy CFG files to `"{2}`"." -f $mod.Type, $FullName, $BepInEx.ConfigDirectory)
Get-ChildItem -Path "$TempPackage\*" -Include "*.cfg" -Recurse | ForEach-Object -Process {
$Path = Join-Path -Path $BepInEx.ConfigDirectory -ChildPath $_.Name
if (-not (Test-Path -Path $Path)) {
Move-Item -Path $_.FullName -Destination $BepInEx.ConfigDirectory
}
}
}
Default { Write-Warning -Message ("Unknown `"{0}`" mod type for {1}. Skip." -f $mod.Type, $FullName) }
}
}
finally { if ($TempPackage) { Remove-Item -Path $TempPackage -Recurse } }
}
if ($Upgrade.IsPresent) {
Write-Host "Update of Lethal Company mods completed." -ForegroundColor Cyan
}
Else {
Write-Host "Installation of Lethal Company mods completed." -ForegroundColor Cyan
}
# Edit config file
$HelmetCameraConfig = "RickArg.lethalcompany.helmetcameras.cfg"
$MoreEmotesConfig = "MoreEmotes.cfg"
$TerminalKeyBindingsConfig = "net.navarrotech.TerminalKeyBindings.cfg"
$HelmetCameraConfigPath = $BepInEx.ConfigDirectory + "\" + $HelmetCameraConfig
$MoreEmotesConfigPath = $BepInEx.ConfigDirectory + "\" + $MoreEmotesConfig
$TerminalKeyBindingsConfigPath = $BepInEx.ConfigDirectory + "\" + $TerminalKeyBindingsConfig
# Modification of Config Files
if ($CustomModConfig) {
Write-Host "Config file modification started." -ForegroundColor Cyan
Write-Host "lets modify: " -NoNewline
Write-Host "$HelmetCameraConfig" -ForegroundColor green
# Read the content of the file
if (Test-Path $HelmetCameraConfigPath) {
$HelmetCameraContent = Get-Content $HelmetCameraConfigPath -Raw
}
Else {
$HelmetCameraContent = Invoke-WebRequest -Uri "https://raw.githubusercontent.com/fscorrupt/LethalCompanyModder/$GitBranch/ModsConfigs/$HelmetCameraConfig" | Select-Object -ExpandProperty Content
$HelmetCameraContent | Out-File $HelmetCameraConfigPath -Force
Start-Sleep 2
$HelmetCameraContent | Set-Content $HelmetCameraConfigPath
$HelmetCameraContent = Get-Content $HelmetCameraConfigPath -Raw
}
# Use regular expressions to find and replace the values
$HelmetCameraContent = $HelmetCameraContent -replace '(?<=monitorResolution = )\d+', '4'
$HelmetCameraContent = $HelmetCameraContent -replace '(?<=renderDistance = )\d+', '25'
# Write the modified content back to the file
$HelmetCameraContent | Set-Content $HelmetCameraConfigPath
# Check if the changes were successful
$updatedHelmetCameraContent = Get-Content $HelmetCameraConfigPath -Raw
$monitorResolution = [regex]::Match($updatedHelmetCameraContent, '(?<=monitorResolution = )\d+').Value
$renderDistance = [regex]::Match($updatedHelmetCameraContent, '(?<=renderDistance = )\d+').Value
if ($monitorResolution -eq '4' -and $renderDistance -eq '25') {
Write-Host " Changes were successful. monitorResolution is now $monitorResolution and renderDistance is now $renderDistance." -ForegroundColor Cyan
}
else {
Write-Host " Changes were not successful." -ForegroundColor Red
}
Write-Host "lets modify: " -NoNewline
Write-Host "$TerminalKeyBindingsConfig" -ForegroundColor green
# Read the content of the file
if (Test-Path $TerminalKeyBindingsConfigPath) {
$TerminalKeyBindingsContent = Get-Content $TerminalKeyBindingsConfigPath -Raw
}
Else {
$TerminalKeyBindingsContent = Invoke-WebRequest -Uri "https://raw.githubusercontent.com/fscorrupt/LethalCompanyModder/$GitBranch/ModsConfigs/$TerminalKeyBindingsConfig" | Select-Object -ExpandProperty Content
$TerminalKeyBindingsContent | Out-File $TerminalKeyBindingsConfigPath -Force
Start-Sleep 2
$TerminalKeyBindingsContent | Set-Content $TerminalKeyBindingsConfigPath
$TerminalKeyBindingsContent = Get-Content $TerminalKeyBindingsConfigPath -Raw
}
# Use regular expressions to find and replace the values
$TerminalKeyBindingsContent = $TerminalKeyBindingsContent -replace '(?<=^\s*KeyMap\s*=\s*).*', 'KeyMap = Numpad0:scan;Numpad9:view monitor;Numpad1:switch Monstro;Numpad2:switch Smetana;Numpad3:switch PyJamaTank;Numpad4:switch FS.Corrupt;Numpad5:switch Chrusolika;Numpad6:switch Sickedwick;Numpad7:tp;Numpad8:itp;'
# Write the modified content back to the file
$TerminalKeyBindingsContent | Set-Content $TerminalKeyBindingsConfigPath
# Check if the changes were successful
$updatedTerminalKeyBindingsContent = Get-Content $TerminalKeyBindingsConfigPath -Raw
$KeyMap = [regex]::Match($updatedTerminalKeyBindingsContent, '(?<=KeyMap = )\w+.*').Value
$bindings = $KeyMap.split(';')
if ($KeyMap -match 'Monstro') {
Write-Host " Changes were successful. TerminalKeyBindings added..." -ForegroundColor Cyan
Write-Host " Currently Enabled Bindings:"
Foreach ($bind in $bindings) {
if ($bind -match ':') {
$splitbind = $bind.split(':')
Write-Host " $($splitbind[0]) -> " -NoNewline -ForegroundColor Gray
Write-Host "$($splitbind[1])" -ForegroundColor Yellow
}
}
}
else {
Write-Host " Changes were not successful." -ForegroundColor Red
}
# More Emotes Config Part
Write-Host "lets modify: " -NoNewline
Write-Host "$MoreEmotesConfig" -ForegroundColor green
# Read the content of the file
if (Test-Path $MoreEmotesConfigPath) {
$MoreEmotesContent = Get-Content $MoreEmotesConfigPath -Raw
}
Else {
$MoreEmotesContent = Invoke-WebRequest -Uri "https://raw.githubusercontent.com/fscorrupt/LethalCompanyModder/$GitBranch/ModsConfigs/$MoreEmotesConfig" | Select-Object -ExpandProperty Content
$MoreEmotesContent | Out-File $MoreEmotesConfigPath -Force
Start-Sleep 2
$MoreEmotesContent | Set-Content $MoreEmotesConfigPath
$MoreEmotesContent = Get-Content $MoreEmotesConfigPath -Raw
}
# Use regular expressions to find and replace the values
$MoreEmotesContent = $MoreEmotesContent -replace '(?<=^\s*Key\s*=\s*)v', 'm'
# Write the modified content back to the file
$MoreEmotesContent | Set-Content $MoreEmotesConfigPath
# Check if the changes were successful
$updatedMoreEmotesContent = Get-Content $MoreEmotesConfigPath -Raw
$wheel = [regex]::Match($updatedMoreEmotesContent, '(?<=Key = )\w+').Value
if ($wheel -eq 'm') {
Write-Host " Changes were successful. key is now $wheel." -ForegroundColor Cyan
}
else {
Write-Host " Changes were not successful." -ForegroundColor Red
}
try {
$Path = Get-ChildItem H: -Filter "BeepInEx" -ErrorAction SilentlyContinue
if ($Path) {
# Backup BepInEx directory
Write-Host "Backup Updated Directory..."
$BackupUpdatedParams = @{
Path = $BepInEx.RootDirectory
DestinationPath = "{0}_Backup_Updated.zip" -f $BepInEx.RootDirectory
}
Write-Debug -Message ("Backup existing BepInEx directory to `"{0}`"." -f $BackupUpdatedParams.DestinationPath)
Compress-Archive @BackupUpdatedParams -Force
Copy-Item $BackupUpdatedParams.DestinationPath "H:\BeepInEx\BepInEx.zip" -Force -ErrorAction SilentlyContinue
Write-Host " Backup copied to Google Drive..." -ForegroundColor Cyan
}
}
catch {
#nothing
}
<#
# Doom Part
Write-Host "Starting setup of DOOM..." -ForegroundColor Cyan
# dot.Net Prerequisite
Write-Host "Checking dot.Net prerequisite..." -ForegroundColor Cyan
Invoke-WebRequest -Uri https://dotnet.microsoft.com/download/dotnet/scripts/v1/dotnet-install.ps1 -OutFile "$TemporaryDirectory\dotnet-install.ps1"
& "$TemporaryDirectory\dotnet-install.ps1"
$DoomDownloadUrl = "https://codeload.github.com/Cryptoc1/lc-doom/zip/refs/heads/develop"
Write-Host "Starting setup of DOOM..." -ForegroundColor Cyan
if (-not $DoomDownloadUrl) { Write-Error -Message "Doom download URL not found." }
try {
$TempPackage = Invoke-PackageDownloader -Url $DoomDownloadUrl
Write-Host " Copy Doom repo to `"$GameDirectory`"."
Copy-Item -Path "$TempPackage\*" -Destination $GameDirectory -Recurse -Force
}
finally { if ($TempPackage) { Remove-Item -Path $TempPackage -Recurse } }
Write-Host " Now we have to create the .user csproj..."
$doomcsprojFile = "LethalCompany.Doom.csproj.user"
$doomcsprojPath = "$GameDirectory\lc-doom-develop\src\src\$doomcsprojFile "
$ManagedPath = "$GameDirectory\Lethal Company_Data\Managed"
$LCDOOMPath = "$GameDirectory\BepInEx\plugins\LC-DOOM"
if (!(Test-Path $LCDOOMPath)) {
New-Item -ItemType Directory -Path $LCDOOMPath | Out-Null
}
# Read the content of the file
if (Test-Path $doomcsprojPath) {
$fileContent = Get-Content $doomcsprojPath -Raw
}
Else {
$Content = @"
<PropertyGroup>
<GameManagedDir>$ManagedPath</GameManagedDir>
<PluginPublishDir>$LCDOOMPath</PluginPublishDir>
</PropertyGroup>
"@
$content | Out-File $doomcsprojPath -Force
Start-Sleep 2
$content | Set-Content $doomcsprojPath
$fileContent = Get-Content $doomcsprojPath -Raw
Write-Host " Change .user csproj Game Data..."
}
# Switch to Project src
Set-Location "$GameDirectory\lc-doom-develop"
Write-Host "Starting to publish doom game..." -ForegroundColor Cyan
dotnet publish -p:PublishPlugin=true
Write-Host "Setup of DOOM completed..." -ForegroundColor Cyan
#>
}
Write-Host "`r`nGet back to work with your crewmates! No more excuses for not meeting the Company's profit quotas...`r`n" -ForegroundColor Green
#endregion ----