├── .gitattributes
├── .github
├── FUNDING.yml
├── ISSUE_TEMPLATE
│ ├── bug_report.md
│ └── feature_request.md
└── workflows
│ ├── Build.yml
│ └── PR_Build.yml
├── .gitignore
├── LICENSE
├── MultiplayerExtensions.sln
├── MultiplayerExtensions.v3.ncrunchsolution
├── MultiplayerExtensions
├── Assets
│ ├── IconMeta64.png
│ ├── IconOculus64.png
│ ├── IconSteam64.png
│ └── IconToaster64.png
├── Config.cs
├── Directory.Build.props
├── Directory.Build.targets
├── Environment
│ ├── MpexAvatarNameTag.cs
│ ├── MpexAvatarPlaceLighting.cs
│ ├── MpexConnectedObjectManager.cs
│ ├── MpexLevelEndActions.cs
│ ├── MpexPlayerFacadeLighting.cs
│ └── MpexPlayerTableCell.cs
├── Installers
│ ├── MpexAppInstaller.cs
│ ├── MpexGameInstaller.cs
│ ├── MpexLobbyInstaller.cs
│ ├── MpexLocalActivePlayerInstaller.cs
│ └── MpexMenuInstaller.cs
├── MultiplayerExtensions.csproj
├── Patchers
│ ├── AvatarPlacePatcher.cs
│ ├── ColorSchemePatcher.cs
│ ├── EnvironmentPatcher.cs
│ ├── MenuEnvironmentPatcher.cs
│ └── PlayerPositionPatcher.cs
├── Patches
│ ├── AvatarPoseRestrictionPatch.cs
│ ├── PlatformMovementPatch.cs
│ └── ResumeSpawningPatch.cs
├── Players
│ ├── MpexPlayerData.cs
│ └── MpexPlayerManager.cs
├── Plugin.cs
├── UI
│ ├── MpexEnvironmentViewController.bsml
│ ├── MpexEnvironmentViewController.cs
│ ├── MpexGameplaySetup.bsml
│ ├── MpexGameplaySetup.cs
│ ├── MpexMiscViewController.bsml
│ ├── MpexMiscViewController.cs
│ ├── MpexSettingsViewController.bsml
│ ├── MpexSettingsViewController.cs
│ └── MpexSetupFlowCoordinator.cs
├── Utilities
│ ├── ColorConverter.cs
│ └── SpriteManager.cs
└── manifest.json
└── README.md
/.gitattributes:
--------------------------------------------------------------------------------
1 | ###############################################################################
2 | # Set default behavior to automatically normalize line endings.
3 | ###############################################################################
4 | * text=auto
5 |
6 | ###############################################################################
7 | # Set default behavior for command prompt diff.
8 | #
9 | # This is need for earlier builds of msysgit that does not have it on by
10 | # default for csharp files.
11 | # Note: This is only used by command line
12 | ###############################################################################
13 | #*.cs diff=csharp
14 |
15 | ###############################################################################
16 | # Set the merge driver for project and solution files
17 | #
18 | # Merging from the command prompt will add diff markers to the files if there
19 | # are conflicts (Merging from VS is not affected by the settings below, in VS
20 | # the diff markers are never inserted). Diff markers may cause the following
21 | # file extensions to fail to load in VS. An alternative would be to treat
22 | # these files as binary and thus will always conflict and require user
23 | # intervention with every merge. To do so, just uncomment the entries below
24 | ###############################################################################
25 | #*.sln merge=binary
26 | #*.csproj merge=binary
27 | #*.vbproj merge=binary
28 | #*.vcxproj merge=binary
29 | #*.vcproj merge=binary
30 | #*.dbproj merge=binary
31 | #*.fsproj merge=binary
32 | #*.lsproj merge=binary
33 | #*.wixproj merge=binary
34 | #*.modelproj merge=binary
35 | #*.sqlproj merge=binary
36 | #*.wwaproj merge=binary
37 |
38 | ###############################################################################
39 | # behavior for image files
40 | #
41 | # image files are treated as binary by default.
42 | ###############################################################################
43 | #*.jpg binary
44 | #*.png binary
45 | #*.gif binary
46 |
47 | ###############################################################################
48 | # diff behavior for common document formats
49 | #
50 | # Convert binary document formats to text before diffing them. This feature
51 | # is only available from the command line. Turn it on by uncommenting the
52 | # entries below.
53 | ###############################################################################
54 | #*.doc diff=astextplain
55 | #*.DOC diff=astextplain
56 | #*.docx diff=astextplain
57 | #*.DOCX diff=astextplain
58 | #*.dot diff=astextplain
59 | #*.DOT diff=astextplain
60 | #*.pdf diff=astextplain
61 | #*.PDF diff=astextplain
62 | #*.rtf diff=astextplain
63 | #*.RTF diff=astextplain
64 |
--------------------------------------------------------------------------------
/.github/FUNDING.yml:
--------------------------------------------------------------------------------
1 | patreon: goobwabber
2 | custom: ['https://ko-fi.com/goobwabber', 'https://ko-fi.com/zingabopp']
3 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/bug_report.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Bug report
3 | about: Create a bug report
4 | title: "[BUG] "
5 | labels: ''
6 | assignees: ''
7 |
8 | ---
9 | **Multiplayer Extensions Version and Download Source**
10 |
11 |
12 | **Your Platform**
13 |
14 |
15 | **Describe the bug**
16 |
17 |
18 | **To Reproduce**
19 |
20 | 1. Go to '...'
21 | 2. Click on '....'
22 | 3. Scroll down to '....'
23 | 4. See error
24 |
25 | **Expected behavior**
26 |
27 |
28 | **Log**
29 |
31 |
32 | **Screenshots/Video**
33 |
34 |
35 | **Additional context**
36 |
37 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/feature_request.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Feature request
3 | about: Suggest an idea for this project
4 | title: "[FEATURE] "
5 | labels: ''
6 | assignees: ''
7 |
8 | ---
9 |
10 | **Is your feature request related to a problem? Please describe.**
11 |
12 |
13 | **Describe the solution you'd like**
14 |
15 |
16 | **Additional context**
17 |
18 |
--------------------------------------------------------------------------------
/.github/workflows/Build.yml:
--------------------------------------------------------------------------------
1 | name: Build
2 |
3 | on:
4 | push:
5 | branches: [ master ]
6 | paths:
7 | - 'MultiplayerExtensions.sln'
8 | - 'MultiplayerExtensions/**'
9 | - '.github/workflows/Build.yml'
10 |
11 | jobs:
12 | Build:
13 | runs-on: ubuntu-latest
14 | steps:
15 | - uses: actions/checkout@v2
16 | - name: Setup dotnet
17 | uses: actions/setup-dotnet@v1
18 | with:
19 | dotnet-version: 5.0.x
20 | - name: Fetch SIRA References
21 | uses: ProjectSIRA/download-sira-stripped@1.0.0
22 | with:
23 | manifest: ./MultiplayerExtensions/manifest.json
24 | sira-server-code: ${{ secrets.SIRA_SERVER_CODE }}
25 | - name: Fetch Mod References
26 | uses: Goobwabber/download-beatmods-deps@1.1
27 | with:
28 | manifest: ./MultiplayerExtensions/manifest.json
29 | - name: Build
30 | id: Build
31 | env:
32 | FrameworkPathOverride: /usr/lib/mono/4.8-api
33 | run: dotnet build --configuration Release
34 | - name: GitStatus
35 | run: git status
36 | - name: Echo Filename
37 | run: echo $BUILDTEXT \($ASSEMBLYNAME\)
38 | env:
39 | BUILDTEXT: Filename=${{ steps.Build.outputs.filename }}
40 | ASSEMBLYNAME: AssemblyName=${{ steps.Build.outputs.assemblyname }}
41 | - name: Upload Artifact
42 | uses: actions/upload-artifact@v1
43 | with:
44 | name: ${{ steps.Build.outputs.filename }}
45 | path: ${{ steps.Build.outputs.artifactpath }}
46 |
--------------------------------------------------------------------------------
/.github/workflows/PR_Build.yml:
--------------------------------------------------------------------------------
1 | name: Pull Request Build
2 |
3 | on:
4 | pull_request:
5 | branches: [ main ]
6 | paths:
7 | - 'MultiplayerExtensions.sln'
8 | - 'MultiplayerExtensions/**'
9 | - '.github/workflows/PR_Build.yml'
10 |
11 | jobs:
12 | Build:
13 | runs-on: ubuntu-latest
14 | steps:
15 | - uses: actions/checkout@v2
16 | - name: Setup dotnet
17 | uses: actions/setup-dotnet@v1
18 | with:
19 | dotnet-version: 5.0.x
20 | - name: Fetch SIRA References
21 | uses: ProjectSIRA/download-sira-stripped@1.0.0
22 | with:
23 | manifest: ./MultiplayerExtensions/manifest.json
24 | sira-server-code: ${{ secrets.SIRA_SERVER_CODE }}
25 | - name: Fetch Mod References
26 | uses: Goobwabber/download-beatmods-deps@1.1
27 | with:
28 | manifest: ./MultiplayerExtensions/manifest.json
29 | - name: Build
30 | id: Build
31 | env:
32 | FrameworkPathOverride: /usr/lib/mono/4.8-api
33 | run: dotnet build --configuration Release
34 | - name: GitStatus
35 | run: git status
36 | - name: Echo Filename
37 | run: echo $BUILDTEXT \($ASSEMBLYNAME\)
38 | env:
39 | BUILDTEXT: Filename=${{ steps.Build.outputs.filename }}
40 | ASSEMBLYNAME: AssemblyName=${{ steps.Build.outputs.assemblyname }}
41 | - name: Upload Artifact
42 | uses: actions/upload-artifact@v1
43 | with:
44 | name: ${{ steps.Build.outputs.filename }}
45 | path: ${{ steps.Build.outputs.artifactpath }}
46 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 | ## files generated by popular Visual Studio add-ons.
3 | ##
4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
5 |
6 | # User-specific files
7 | *.rsuser
8 | *.suo
9 | *.user
10 | *.userosscache
11 | *.sln.docstates
12 |
13 | # User-specific files (MonoDevelop/Xamarin Studio)
14 | *.userprefs
15 |
16 | # Build results
17 | [Dd]ebug/
18 | [Dd]ebugPublic/
19 | [Rr]elease/
20 | [Rr]eleases/
21 | x64/
22 | x86/
23 | [Aa][Rr][Mm]/
24 | [Aa][Rr][Mm]64/
25 | bld/
26 | [Bb]in/
27 | [Oo]bj/
28 | [Ll]og/
29 |
30 | # Visual Studio 2015/2017 cache/options directory
31 | .vs/
32 | # Uncomment if you have tasks that create the project's static files in wwwroot
33 | #wwwroot/
34 |
35 | # Visual Studio 2017 auto generated files
36 | Generated\ Files/
37 |
38 | # MSTest test Results
39 | [Tt]est[Rr]esult*/
40 | [Bb]uild[Ll]og.*
41 |
42 | # NUNIT
43 | *.VisualState.xml
44 | TestResult.xml
45 |
46 | # Build Results of an ATL Project
47 | [Dd]ebugPS/
48 | [Rr]eleasePS/
49 | dlldata.c
50 |
51 | # Benchmark Results
52 | BenchmarkDotNet.Artifacts/
53 |
54 | # .NET Core
55 | project.lock.json
56 | project.fragment.lock.json
57 | artifacts/
58 |
59 | # StyleCop
60 | StyleCopReport.xml
61 |
62 | # Files built by Visual Studio
63 | *_i.c
64 | *_p.c
65 | *_h.h
66 | *.ilk
67 | *.meta
68 | *.obj
69 | *.iobj
70 | *.pch
71 | *.pdb
72 | *.ipdb
73 | *.pgc
74 | *.pgd
75 | *.rsp
76 | *.sbr
77 | *.tlb
78 | *.tli
79 | *.tlh
80 | *.tmp
81 | *.tmp_proj
82 | *_wpftmp.csproj
83 | *.log
84 | *.vspscc
85 | *.vssscc
86 | .builds
87 | *.pidb
88 | *.svclog
89 | *.scc
90 |
91 | # Chutzpah Test files
92 | _Chutzpah*
93 |
94 | # Visual C++ cache files
95 | ipch/
96 | *.aps
97 | *.ncb
98 | *.opendb
99 | *.opensdf
100 | *.sdf
101 | *.cachefile
102 | *.VC.db
103 | *.VC.VC.opendb
104 |
105 | # Visual Studio profiler
106 | *.psess
107 | *.vsp
108 | *.vspx
109 | *.sap
110 |
111 | # Visual Studio Trace Files
112 | *.e2e
113 |
114 | # TFS 2012 Local Workspace
115 | $tf/
116 |
117 | # Guidance Automation Toolkit
118 | *.gpState
119 |
120 | # ReSharper is a .NET coding add-in
121 | _ReSharper*/
122 | *.[Rr]e[Ss]harper
123 | *.DotSettings.user
124 |
125 | # JustCode is a .NET coding add-in
126 | .JustCode
127 |
128 | # TeamCity is a build add-in
129 | _TeamCity*
130 |
131 | # DotCover is a Code Coverage Tool
132 | *.dotCover
133 |
134 | # AxoCover is a Code Coverage Tool
135 | .axoCover/*
136 | !.axoCover/settings.json
137 |
138 | # Visual Studio code coverage results
139 | *.coverage
140 | *.coveragexml
141 |
142 | # NCrunch
143 | _NCrunch_*
144 | .*crunch*.local.xml
145 | nCrunchTemp_*
146 |
147 | # MightyMoose
148 | *.mm.*
149 | AutoTest.Net/
150 |
151 | # Web workbench (sass)
152 | .sass-cache/
153 |
154 | # Installshield output folder
155 | [Ee]xpress/
156 |
157 | # DocProject is a documentation generator add-in
158 | DocProject/buildhelp/
159 | DocProject/Help/*.HxT
160 | DocProject/Help/*.HxC
161 | DocProject/Help/*.hhc
162 | DocProject/Help/*.hhk
163 | DocProject/Help/*.hhp
164 | DocProject/Help/Html2
165 | DocProject/Help/html
166 |
167 | # Click-Once directory
168 | publish/
169 |
170 | # Publish Web Output
171 | *.[Pp]ublish.xml
172 | *.azurePubxml
173 | # Note: Comment the next line if you want to checkin your web deploy settings,
174 | # but database connection strings (with potential passwords) will be unencrypted
175 | *.pubxml
176 | *.publishproj
177 |
178 | # Microsoft Azure Web App publish settings. Comment the next line if you want to
179 | # checkin your Azure Web App publish settings, but sensitive information contained
180 | # in these scripts will be unencrypted
181 | PublishScripts/
182 |
183 | # NuGet Packages
184 | *.nupkg
185 | # The packages folder can be ignored because of Package Restore
186 | **/[Pp]ackages/*
187 | # except build/, which is used as an MSBuild target.
188 | !**/[Pp]ackages/build/
189 | # Uncomment if necessary however generally it will be regenerated when needed
190 | #!**/[Pp]ackages/repositories.config
191 | # NuGet v3's project.json files produces more ignorable files
192 | *.nuget.props
193 | *.nuget.targets
194 |
195 | # Microsoft Azure Build Output
196 | csx/
197 | *.build.csdef
198 |
199 | # Microsoft Azure Emulator
200 | ecf/
201 | rcf/
202 |
203 | # Windows Store app package directories and files
204 | AppPackages/
205 | BundleArtifacts/
206 | Package.StoreAssociation.xml
207 | _pkginfo.txt
208 | *.appx
209 |
210 | # Visual Studio cache files
211 | # files ending in .cache can be ignored
212 | *.[Cc]ache
213 | # but keep track of directories ending in .cache
214 | !?*.[Cc]ache/
215 |
216 | # Others
217 | ClientBin/
218 | ~$*
219 | *~
220 | *.dbmdl
221 | *.dbproj.schemaview
222 | *.jfm
223 | *.pfx
224 | *.publishsettings
225 | orleans.codegen.cs
226 |
227 | # Including strong name files can present a security risk
228 | # (https://github.com/github/gitignore/pull/2483#issue-259490424)
229 | #*.snk
230 |
231 | # Since there are multiple workflows, uncomment next line to ignore bower_components
232 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
233 | #bower_components/
234 |
235 | # RIA/Silverlight projects
236 | Generated_Code/
237 |
238 | # Backup & report files from converting an old project file
239 | # to a newer Visual Studio version. Backup files are not needed,
240 | # because we have git ;-)
241 | _UpgradeReport_Files/
242 | Backup*/
243 | UpgradeLog*.XML
244 | UpgradeLog*.htm
245 | ServiceFabricBackup/
246 | *.rptproj.bak
247 |
248 | # SQL Server files
249 | *.mdf
250 | *.ldf
251 | *.ndf
252 |
253 | # Business Intelligence projects
254 | *.rdl.data
255 | *.bim.layout
256 | *.bim_*.settings
257 | *.rptproj.rsuser
258 | *- Backup*.rdl
259 |
260 | # Microsoft Fakes
261 | FakesAssemblies/
262 |
263 | # GhostDoc plugin setting file
264 | *.GhostDoc.xml
265 |
266 | # Node.js Tools for Visual Studio
267 | .ntvs_analysis.dat
268 | node_modules/
269 |
270 | # Visual Studio 6 build log
271 | *.plg
272 |
273 | # Visual Studio 6 workspace options file
274 | *.opt
275 |
276 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
277 | *.vbw
278 |
279 | # Visual Studio LightSwitch build output
280 | **/*.HTMLClient/GeneratedArtifacts
281 | **/*.DesktopClient/GeneratedArtifacts
282 | **/*.DesktopClient/ModelManifest.xml
283 | **/*.Server/GeneratedArtifacts
284 | **/*.Server/ModelManifest.xml
285 | _Pvt_Extensions
286 |
287 | # Paket dependency manager
288 | .paket/paket.exe
289 | paket-files/
290 |
291 | # FAKE - F# Make
292 | .fake/
293 |
294 | # JetBrains Rider
295 | .idea/
296 | *.sln.iml
297 |
298 | # CodeRush personal settings
299 | .cr/personal
300 |
301 | # Python Tools for Visual Studio (PTVS)
302 | __pycache__/
303 | *.pyc
304 |
305 | # Cake - Uncomment if you are using it
306 | # tools/**
307 | # !tools/packages.config
308 |
309 | # Tabs Studio
310 | *.tss
311 |
312 | # Telerik's JustMock configuration file
313 | *.jmconfig
314 |
315 | # BizTalk build output
316 | *.btp.cs
317 | *.btm.cs
318 | *.odx.cs
319 | *.xsd.cs
320 |
321 | # OpenCover UI analysis results
322 | OpenCover/
323 |
324 | # Azure Stream Analytics local run output
325 | ASALocalRun/
326 |
327 | # MSBuild Binary and Structured Log
328 | *.binlog
329 |
330 | # NVidia Nsight GPU debugger configuration file
331 | *.nvuser
332 |
333 | # MFractors (Xamarin productivity tool) working folder
334 | .mfractor/
335 |
336 | # Local History for Visual Studio
337 | .localhistory/
338 |
339 | # BeatPulse healthcheck temp database
340 | healthchecksdb
341 |
342 | Refs/Beat Saber_Data/Managed/*
343 | Refs/Plugins/*
344 | Refs/Libs/Mono*
345 | !Refs/Beat Saber_Data/Managed/IPA.Loader.dll
346 | /bsinstalldir.txt
347 |
348 | MultiplayerExtensions/Properties/launchSettings.json
349 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2020 Zingabopp
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
23 | As an exception, all contents of the "Refs" directory, or any subdirectory named
24 | "Refs", are not part of the Software and are therefore not subject to the License,
25 | and remain the exclusive property of their copyright holders.
--------------------------------------------------------------------------------
/MultiplayerExtensions.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 16
4 | VisualStudioVersion = 16.0.30517.126
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MultiplayerExtensions", "MultiplayerExtensions\MultiplayerExtensions.csproj", "{4641BE95-C3F7-4636-BA24-67188A38D94C}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|Any CPU = Debug|Any CPU
11 | Release|Any CPU = Release|Any CPU
12 | EndGlobalSection
13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
14 | {4641BE95-C3F7-4636-BA24-67188A38D94C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15 | {4641BE95-C3F7-4636-BA24-67188A38D94C}.Debug|Any CPU.Build.0 = Debug|Any CPU
16 | {4641BE95-C3F7-4636-BA24-67188A38D94C}.Release|Any CPU.ActiveCfg = Release|Any CPU
17 | {4641BE95-C3F7-4636-BA24-67188A38D94C}.Release|Any CPU.Build.0 = Release|Any CPU
18 | EndGlobalSection
19 | GlobalSection(SolutionProperties) = preSolution
20 | HideSolutionNode = FALSE
21 | EndGlobalSection
22 | GlobalSection(ExtensibilityGlobals) = postSolution
23 | SolutionGuid = {E8F0586B-E2CD-47E7-B61F-73A798A37ADA}
24 | EndGlobalSection
25 | EndGlobal
26 |
--------------------------------------------------------------------------------
/MultiplayerExtensions.v3.ncrunchsolution:
--------------------------------------------------------------------------------
1 |
2 |
3 | True
4 | True
5 |
6 |
--------------------------------------------------------------------------------
/MultiplayerExtensions/Assets/IconMeta64.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Goobwabber/MultiplayerExtensions/38e9a0a28bceac054a60a31da07a2cd7462edb30/MultiplayerExtensions/Assets/IconMeta64.png
--------------------------------------------------------------------------------
/MultiplayerExtensions/Assets/IconOculus64.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Goobwabber/MultiplayerExtensions/38e9a0a28bceac054a60a31da07a2cd7462edb30/MultiplayerExtensions/Assets/IconOculus64.png
--------------------------------------------------------------------------------
/MultiplayerExtensions/Assets/IconSteam64.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Goobwabber/MultiplayerExtensions/38e9a0a28bceac054a60a31da07a2cd7462edb30/MultiplayerExtensions/Assets/IconSteam64.png
--------------------------------------------------------------------------------
/MultiplayerExtensions/Assets/IconToaster64.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Goobwabber/MultiplayerExtensions/38e9a0a28bceac054a60a31da07a2cd7462edb30/MultiplayerExtensions/Assets/IconToaster64.png
--------------------------------------------------------------------------------
/MultiplayerExtensions/Config.cs:
--------------------------------------------------------------------------------
1 | using IPA.Config.Stores.Attributes;
2 | using MultiplayerExtensions.Utilities;
3 | using UnityEngine;
4 |
5 | namespace MultiplayerExtensions
6 | {
7 | public class Config
8 | {
9 | public static readonly Color DefaultPlayerColor = new Color(0.031f, 0.752f, 1f);
10 |
11 | public virtual bool SoloEnvironment { get; set; } = false;
12 | public virtual bool SideBySide { get; set; } = false;
13 | public virtual float SideBySideDistance { get; set; } = 4f;
14 | public virtual bool DisableAvatarConstraints { get; set; } = false;
15 | public virtual bool DisableMultiplayerPlatforms { get; set; } = false;
16 | public virtual bool DisableMultiplayerLights { get; set; } = false;
17 | public virtual bool DisableMultiplayerObjects { get; set; } = false;
18 | public virtual bool DisableMultiplayerColors { get; set; } = false;
19 | public virtual bool DisablePlatformMovement { get; set; } = false;
20 | public virtual bool MissLighting { get; set; } = false;
21 | public virtual bool PersonalMissLightingOnly { get; set; } = false;
22 | [UseConverter(typeof(ColorConverter))]
23 | public virtual Color PlayerColor { get; set; } = DefaultPlayerColor;
24 | [UseConverter(typeof(ColorConverter))]
25 | public virtual Color MissColor { get; set; } = new Color(1, 0, 0);
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/MultiplayerExtensions/Directory.Build.props:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | true
6 | true
7 | true
8 |
9 |
10 |
11 |
12 |
13 | false
14 | true
15 | true
16 |
17 |
--------------------------------------------------------------------------------
/MultiplayerExtensions/Directory.Build.targets:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 | 2.0
7 |
8 | false
9 |
10 | $(OutputPath)$(AssemblyName)
11 |
12 | $(OutputPath)Final
13 | True
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 | $(PluginVersion)
28 |
29 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 | $(PluginVersion)
40 | $(PluginVersion)
41 |
42 | $(AssemblyName)
43 | $(ArtifactName)-$(PluginVersion)
44 | $(ArtifactName)-bs$(GameVersion)
45 | $(ArtifactName)-$(CommitHash)
46 |
47 |
48 |
49 |
50 |
51 |
52 | $(AssemblyName)
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 | $(AssemblyName)
68 | $(OutDir)zip\
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 | $(BeatSaberDir)\Plugins
82 | True
83 | Unable to copy assembly to game folder, did you set 'BeatSaberDir' correctly in your 'csproj.user' file? Plugins folder doesn't exist: '$(PluginDir)'.
84 |
85 | Unable to copy to Plugins folder, '$(BeatSaberDir)' does not appear to be a Beat Saber game install.
86 |
87 | Unable to copy to Plugins folder, 'BeatSaberDir' has not been set in your 'csproj.user' file.
88 | False
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 | $(BeatSaberDir)\IPA\Pending\Plugins
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
--------------------------------------------------------------------------------
/MultiplayerExtensions/Environment/MpexAvatarNameTag.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using HMUI;
4 | using MultiplayerCore.Players;
5 | using MultiplayerExtensions.Players;
6 | using MultiplayerExtensions.Utilities;
7 | using UnityEngine;
8 | using UnityEngine.UI;
9 | using Zenject;
10 |
11 | namespace MultiplayerExtensions.Environments.Lobby
12 | {
13 | public class MpexAvatarNameTag : MonoBehaviour
14 | {
15 | enum PlayerIconSlot
16 | {
17 | Platform = 0
18 | }
19 |
20 | private readonly Dictionary _playerIcons = new();
21 |
22 | private IConnectedPlayer _player = null!;
23 | private MpPlayerManager _playerManager = null!;
24 | private MpexPlayerManager _mpexPlayerManager = null!;
25 | private SpriteManager _spriteManager = null!;
26 | private ImageView _bg = null!;
27 | private CurvedTextMeshPro _nameText = null!;
28 |
29 | [Inject]
30 | internal void Construct(
31 | IConnectedPlayer player,
32 | MpPlayerManager playerManager,
33 | MpexPlayerManager mpexPlayerManager,
34 | SpriteManager spriteManager)
35 | {
36 | _player = player;
37 | _playerManager = playerManager;
38 | _mpexPlayerManager = mpexPlayerManager;
39 | _spriteManager = spriteManager;
40 | }
41 |
42 | private void Awake()
43 | {
44 | // Get references
45 | _bg = transform.Find("BG").GetComponent();
46 | _nameText = transform.Find("Name").GetComponent();
47 |
48 | // Enable horizontal layout on bg
49 | if (!_bg.TryGetComponent(out _))
50 | {
51 | var hLayout = _bg.gameObject.AddComponent();
52 | hLayout.childAlignment = TextAnchor.MiddleCenter;
53 | hLayout.childForceExpandWidth = false;
54 | hLayout.childForceExpandHeight = false;
55 | hLayout.childScaleWidth = false;
56 | hLayout.childScaleHeight = false;
57 | hLayout.spacing = 4f;
58 | }
59 |
60 | // Re-nest name onto bg
61 | _nameText.transform.SetParent(_bg.transform, false);
62 |
63 | // Take control of name tag
64 | if (_nameText.TryGetComponent(out var nativeNameScript))
65 | Destroy(nativeNameScript);
66 | _nameText.text = "Player";
67 |
68 | // Set player data
69 | _nameText.text = _player.userName;
70 | _nameText.color = Color.white;
71 | if (_mpexPlayerManager.TryGetPlayer(_player.userId, out var mpexData))
72 | _nameText.color = mpexData.Color;
73 | if (_playerManager.TryGetPlayer(_player.userId, out var data))
74 | SetPlatformData(data);
75 | }
76 |
77 | private void OnEnable()
78 | {
79 | _playerManager.PlayerConnectedEvent += HandlePlatformData;
80 | _mpexPlayerManager.PlayerConnectedEvent += HandleMpexData;
81 | }
82 |
83 | private void OnDisable()
84 | {
85 | _playerManager.PlayerConnectedEvent -= HandlePlatformData;
86 | _mpexPlayerManager.PlayerConnectedEvent -= HandleMpexData;
87 | }
88 |
89 | private void HandlePlatformData(IConnectedPlayer player, MpPlayerData data)
90 | {
91 | if (player == _player)
92 | SetPlatformData(data);
93 | }
94 |
95 | private void HandleMpexData(IConnectedPlayer player, MpexPlayerData data)
96 | {
97 | if (player == _player)
98 | _nameText.color = data.Color;
99 | }
100 |
101 | private void SetPlatformData(MpPlayerData data)
102 | {
103 | Sprite icon = null;
104 | switch (data.Platform)
105 | {
106 | case Platform.Steam:
107 | icon = _spriteManager.IconSteam64;
108 | break;
109 | case Platform.OculusQuest:
110 | icon = _spriteManager.IconMeta64;
111 | break;
112 | case Platform.OculusPC:
113 | icon = _spriteManager.IconOculus64;
114 | break;
115 | default:
116 | icon = _spriteManager.IconToaster64;
117 | break;
118 | }
119 | SetIcon(PlayerIconSlot.Platform, icon);
120 | }
121 |
122 | private void SetIcon(PlayerIconSlot slot, Sprite sprite)
123 | {
124 | if (!_playerIcons.TryGetValue(slot, out ImageView imageView))
125 | {
126 | var iconObj = new GameObject($"MpexPlayerIcon({slot})");
127 | iconObj.transform.SetParent(_bg.transform, false);
128 | iconObj.transform.SetSiblingIndex((int)slot);
129 | iconObj.layer = 5;
130 |
131 | iconObj.AddComponent();
132 |
133 | imageView = iconObj.AddComponent();
134 | imageView.maskable = true;
135 | imageView.fillCenter = true;
136 | imageView.preserveAspect = true;
137 | imageView.material = _bg.material; // No Glow Billboard material
138 | _playerIcons[slot] = imageView;
139 |
140 | var rectTransform = iconObj.GetComponent();
141 | rectTransform.localScale = new Vector3(3.2f, 3.2f);
142 | }
143 |
144 | imageView.sprite = sprite;
145 |
146 | _nameText.transform.SetSiblingIndex(999);
147 | }
148 | }
149 | }
--------------------------------------------------------------------------------
/MultiplayerExtensions/Environment/MpexAvatarPlaceLighting.cs:
--------------------------------------------------------------------------------
1 | using IPA.Utilities;
2 | using MultiplayerExtensions.Players;
3 | using System;
4 | using System.Collections.Generic;
5 | using System.Linq;
6 | using UnityEngine;
7 | using Zenject;
8 |
9 | namespace MultiplayerExtensions.Environments
10 | {
11 | public class MpexAvatarPlaceLighting : MonoBehaviour
12 | {
13 | public const float SmoothTime = 2f;
14 | public Color TargetColor { get; private set; } = Color.black;
15 | public int SortIndex { get; internal set; }
16 |
17 | private List _lights = new List();
18 |
19 | private IMultiplayerSessionManager _sessionManager = null!;
20 | private MenuLightsManager _lightsManager = null!;
21 | private MpexPlayerManager _mpexPlayerManager = null!;
22 | private Config _config = null!;
23 |
24 | [Inject]
25 | internal void Construct(
26 | IMultiplayerSessionManager sessionManager,
27 | MenuLightsManager lightsManager,
28 | MpexPlayerManager mpexPlayerManager,
29 | Config config)
30 | {
31 | _sessionManager = sessionManager;
32 | _lightsManager = lightsManager;
33 | _mpexPlayerManager = mpexPlayerManager;
34 | _config = config;
35 | }
36 |
37 | private void Start()
38 | {
39 | _lights = GetComponentsInChildren().ToList();
40 |
41 | if (_sessionManager == null || _lightsManager == null || _mpexPlayerManager == null || _sessionManager.localPlayer == null)
42 | return;
43 |
44 | if (_sessionManager.localPlayer.sortIndex == SortIndex)
45 | {
46 | SetColor(_config.PlayerColor, true);
47 | return;
48 | }
49 |
50 | foreach (var player in _sessionManager.connectedPlayers)
51 | if (player.sortIndex == SortIndex)
52 | {
53 | SetColor(_mpexPlayerManager.GetPlayer(player.userId)?.Color ?? Config.DefaultPlayerColor, true);
54 | return;
55 | }
56 |
57 | SetColor(Color.black);
58 | }
59 |
60 | private void OnEnable()
61 | {
62 | _mpexPlayerManager.PlayerConnectedEvent += HandlePlayerData;
63 | _sessionManager.playerConnectedEvent += HandlePlayerConnected;
64 | _sessionManager.playerDisconnectedEvent += HandlePlayerDisconnected;
65 | }
66 |
67 | private void OnDisable()
68 | {
69 | _mpexPlayerManager.PlayerConnectedEvent -= HandlePlayerData;
70 | _sessionManager.playerConnectedEvent -= HandlePlayerConnected;
71 | _sessionManager.playerDisconnectedEvent -= HandlePlayerDisconnected;
72 | }
73 |
74 | private void HandlePlayerData(IConnectedPlayer player, MpexPlayerData data)
75 | {
76 | if (player.sortIndex == SortIndex)
77 | SetColor(data.Color, false);
78 | }
79 |
80 | private void HandlePlayerConnected(IConnectedPlayer player)
81 | {
82 | if (player.sortIndex != SortIndex)
83 | return;
84 | if (_mpexPlayerManager.TryGetPlayer(player.userId, out MpexPlayerData data))
85 | SetColor(data.Color, false);
86 | else
87 | SetColor(Config.DefaultPlayerColor, false);
88 | }
89 |
90 | private void HandlePlayerDisconnected(IConnectedPlayer player)
91 | {
92 | if (player.sortIndex == SortIndex)
93 | SetColor(Color.black, false);
94 | }
95 |
96 | private void Update()
97 | {
98 | Color current = GetColor();
99 | if (current == TargetColor)
100 | return;
101 | if (_lightsManager.IsColorVeryCloseToColor(current, TargetColor))
102 | SetColor(TargetColor);
103 | else
104 | SetColor(Color.Lerp(current, TargetColor, Time.deltaTime * SmoothTime));
105 | }
106 |
107 | public void SetColor(Color color, bool immediate)
108 | {
109 | TargetColor = color;
110 | if (immediate)
111 | SetColor(color);
112 | }
113 |
114 | public Color GetColor()
115 | {
116 | if (_lights.Count > 0)
117 | return _lights[0].color;
118 | return Color.black;
119 | }
120 |
121 | private void SetColor(Color color)
122 | {
123 | foreach(TubeBloomPrePassLight light in _lights)
124 | {
125 | light.color = color;
126 | light.Refresh();
127 | }
128 | }
129 | }
130 | }
131 |
--------------------------------------------------------------------------------
/MultiplayerExtensions/Environment/MpexConnectedObjectManager.cs:
--------------------------------------------------------------------------------
1 | using UnityEngine;
2 | using Zenject;
3 |
4 | namespace MultiplayerExtensions.Environment
5 | {
6 | public class MpexConnectedObjectManager : MonoBehaviour
7 | {
8 | private MultiplayerConnectedPlayerSpectatingSpot _playerSpectatingSpot = null!;
9 | private IConnectedPlayerBeatmapObjectEventManager _beatmapObjectEventManager = null!;
10 | private BeatmapObjectManager _beatmapObjectManager = null!;
11 | private Config _config = null!;
12 |
13 | [Inject]
14 | internal void Construct(
15 | MultiplayerConnectedPlayerSpectatingSpot playerSpectatingSpot,
16 | IConnectedPlayerBeatmapObjectEventManager beatmapObjectEventManager,
17 | BeatmapObjectManager beatmapObjectManager,
18 | Config config)
19 | {
20 | _playerSpectatingSpot = playerSpectatingSpot;
21 | _beatmapObjectEventManager = beatmapObjectEventManager;
22 | _beatmapObjectManager = beatmapObjectManager;
23 | _config = config;
24 | }
25 |
26 | private void Start()
27 | {
28 | _playerSpectatingSpot.isObservedChangedEvent += HandleIsObservedChangedEvent;
29 | if (_config.DisableMultiplayerObjects)
30 | _beatmapObjectEventManager.Pause();
31 | }
32 |
33 | private void OnDestroy()
34 | {
35 | if (_playerSpectatingSpot != null)
36 | _playerSpectatingSpot.isObservedChangedEvent -= HandleIsObservedChangedEvent;
37 | }
38 |
39 | private void HandleIsObservedChangedEvent(bool isObserved)
40 | {
41 | if (_config.DisableMultiplayerPlatforms)
42 | transform.Find("Construction").gameObject.SetActive(isObserved);
43 | if (_config.DisableMultiplayerLights)
44 | transform.Find("Lasers").gameObject.SetActive(isObserved);
45 | if (!_config.DisableMultiplayerObjects)
46 | return;
47 | if (isObserved)
48 | {
49 | _beatmapObjectEventManager.Resume();
50 | return;
51 | }
52 | _beatmapObjectEventManager.Pause();
53 | _beatmapObjectManager.DissolveAllObjects();
54 | }
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/MultiplayerExtensions/Environment/MpexLevelEndActions.cs:
--------------------------------------------------------------------------------
1 | using SiraUtil.Affinity;
2 | using System;
3 |
4 | namespace MultiplayerExtensions.Environment
5 | {
6 | public class MpexLevelEndActions : IAffinity, ILevelEndActions
7 | {
8 | public event Action levelFailedEvent = null!;
9 | public event Action levelFinishedEvent = null!;
10 |
11 | [AffinityPrefix]
12 | [AffinityPatch(typeof(MultiplayerLocalActivePlayerFacade), "ReportPlayerDidFinish")]
13 | private void PlayerDidFinish() =>
14 | levelFinishedEvent?.Invoke();
15 |
16 | [AffinityPrefix]
17 | [AffinityPatch(typeof(MultiplayerLocalActivePlayerFacade), "ReportPlayerNetworkDidFailed")]
18 | private void PlayerDidFail() =>
19 | levelFailedEvent?.Invoke();
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/MultiplayerExtensions/Environment/MpexPlayerFacadeLighting.cs:
--------------------------------------------------------------------------------
1 | using IPA.Utilities;
2 | using System;
3 | using UnityEngine;
4 | using Zenject;
5 |
6 | namespace MultiplayerExtensions.Environment
7 | {
8 | class MpexPlayerFacadeLighting : MonoBehaviour
9 | {
10 | private readonly FieldAccessor.Accessor _allLightsAnimators
11 | = FieldAccessor
12 | .GetAccessor(nameof(_allLightsAnimators));
13 | private readonly FieldAccessor.Accessor _gameplayLightsAnimators
14 | = FieldAccessor
15 | .GetAccessor(nameof(_gameplayLightsAnimators));
16 |
17 | private readonly FieldAccessor.Accessor _activeLightsColor
18 | = FieldAccessor
19 | .GetAccessor(nameof(_activeLightsColor));
20 | private readonly FieldAccessor.Accessor _leadingLightsColor
21 | = FieldAccessor
22 | .GetAccessor(nameof(_leadingLightsColor));
23 | private readonly FieldAccessor.Accessor _failedLightsColor
24 | = FieldAccessor
25 | .GetAccessor(nameof(_failedLightsColor));
26 |
27 | private LightsAnimator[] _allLights => _allLightsAnimators(ref _gameplayAnimator);
28 | private LightsAnimator[] _gameplayLights => _gameplayLightsAnimators(ref _gameplayAnimator);
29 |
30 | private ColorSO _activeColor => _activeLightsColor(ref _gameplayAnimator);
31 | private ColorSO _leadingColor => _leadingLightsColor(ref _gameplayAnimator);
32 | private ColorSO _failedColor => _failedLightsColor(ref _gameplayAnimator);
33 |
34 | private bool _isLeading = false;
35 | private int _highestCombo = 0;
36 |
37 | private IConnectedPlayer _connectedPlayer = null!;
38 | private MultiplayerController _multiplayerController = null!;
39 | private IScoreSyncStateManager _scoreProvider = null!;
40 | private MultiplayerLeadPlayerProvider _leadPlayerProvider = null!;
41 | private MultiplayerGameplayAnimator _gameplayAnimator = null!;
42 | private MultiplayerSyncState _syncState = null!;
43 | private Config _config = null!;
44 |
45 | [Inject]
46 | internal void Construct(
47 | IConnectedPlayer connectedPlayer,
48 | MultiplayerController multiplayerController,
49 | IScoreSyncStateManager scoreProvider,
50 | MultiplayerLeadPlayerProvider leadPlayerProvider,
51 | Config config)
52 | {
53 | _connectedPlayer = connectedPlayer;
54 | _multiplayerController = multiplayerController;
55 | _scoreProvider = scoreProvider;
56 | _leadPlayerProvider = leadPlayerProvider;
57 | _config = config;
58 | }
59 |
60 | public void OnEnable()
61 | {
62 | _gameplayAnimator = GetComponentInChildren();
63 | _syncState = _scoreProvider.GetSyncStateForPlayer(_connectedPlayer);
64 | _leadPlayerProvider.newLeaderWasSelectedEvent += HandleNewLeaderWasSelected;
65 | }
66 |
67 | public void OnDisable()
68 | {
69 | _leadPlayerProvider.newLeaderWasSelectedEvent -= HandleNewLeaderWasSelected;
70 | }
71 |
72 | private void HandleNewLeaderWasSelected(string userId)
73 | {
74 | _isLeading = userId == _connectedPlayer.userId;
75 | }
76 |
77 | private void Update()
78 | {
79 | if (_multiplayerController.state == MultiplayerController.State.Gameplay
80 | && !_connectedPlayer.IsFailed())
81 | {
82 | int combo = _syncState.GetState(StandardScoreSyncState.Score.Combo, _syncState.player.offsetSyncTime);
83 | if (combo > _highestCombo)
84 | _highestCombo = combo;
85 |
86 | Color baseColor = _isLeading ? _leadingColor : _activeColor;
87 | float failPercentage = (Mathf.Min(_highestCombo, 20f) - combo) / 20f;
88 | Color color = _config.MissColor;
89 | color.a = baseColor.a;
90 | SetLights(Color.Lerp(baseColor, color, failPercentage));
91 | }
92 | }
93 |
94 | public void SetLights(Color color)
95 | {
96 | foreach (LightsAnimator light in _gameplayLightsAnimators(ref _gameplayAnimator))
97 | light.SetColor(color);
98 | }
99 | }
100 | }
101 |
--------------------------------------------------------------------------------
/MultiplayerExtensions/Environment/MpexPlayerTableCell.cs:
--------------------------------------------------------------------------------
1 | using MultiplayerCore.Objects;
2 | using SiraUtil.Affinity;
3 | using System;
4 | using System.Threading.Tasks;
5 | using UnityEngine;
6 | using UnityEngine.UI;
7 | using Zenject;
8 |
9 | namespace MultiplayerExtensions.Objects
10 | {
11 | public class MpexPlayerTableCell : IInitializable, IDisposable, IAffinity
12 | {
13 | private readonly ServerPlayerListViewController _playerListView;
14 | private readonly MpEntitlementChecker _entitlementChecker;
15 | private readonly ILobbyPlayersDataModel _playersDataModel;
16 | private readonly IMenuRpcManager _menuRpcManager;
17 |
18 | private static float alphaIsMe = 0.4f;
19 | private static float alphaIsNotMe = 0.2f;
20 |
21 | private static Color green = new Color(0f, 1f, 0f, 1f);
22 | private static Color yellow = new Color(0.125f, 0.75f, 1f, 1f);
23 | private static Color red = new Color(1f, 0f, 0f, 1f);
24 | private static Color normal = new Color(0.125f, 0.75f, 1f, 0.1f);
25 |
26 | internal MpexPlayerTableCell(
27 | ServerPlayerListViewController playerListView,
28 | NetworkPlayerEntitlementChecker entitlementChecker,
29 | ILobbyPlayersDataModel playersDataModel,
30 | IMenuRpcManager menuRpcManager)
31 | {
32 | _playerListView = playerListView;
33 | _entitlementChecker = (entitlementChecker as MpEntitlementChecker)!;
34 | _playersDataModel = playersDataModel;
35 | _menuRpcManager = menuRpcManager;
36 | }
37 |
38 | public void Initialize()
39 | {
40 | _menuRpcManager.setIsEntitledToLevelEvent += HandleSetIsEntitledToLevel;
41 | }
42 |
43 | public void Dispose()
44 | {
45 | _menuRpcManager.setIsEntitledToLevelEvent -= HandleSetIsEntitledToLevel;
46 | }
47 |
48 | [AffinityPrefix]
49 | [AffinityPatch(typeof(GameServerPlayerTableCell), nameof(GameServerPlayerTableCell.SetData))]
50 | public void SetDataPrefix(IConnectedPlayer connectedPlayer, ILobbyPlayerData playerData, bool hasKickPermissions, bool allowSelection, Task getLevelEntitlementTask, Image ____localPlayerBackgroundImage)
51 | {
52 | if (getLevelEntitlementTask != null)
53 | getLevelEntitlementTask = Task.FromResult(AdditionalContentModel.EntitlementStatus.Owned);
54 | }
55 |
56 | [AffinityPostfix]
57 | [AffinityPatch(typeof(GameServerPlayerTableCell), nameof(GameServerPlayerTableCell.SetData))]
58 | public void SetDataPostfix(IConnectedPlayer connectedPlayer, ILobbyPlayerData playerData, bool hasKickPermissions, bool allowSelection, Task getLevelEntitlementTask, Image ____localPlayerBackgroundImage)
59 | {
60 | ____localPlayerBackgroundImage.enabled = true;
61 | string? hostSelectedLevel = _playersDataModel[_playersDataModel.partyOwnerId].beatmapLevel?.beatmapLevel?.levelID;
62 | if (hostSelectedLevel == null)
63 | {
64 | SetLevelEntitlement(____localPlayerBackgroundImage, EntitlementsStatus.Unknown);
65 | return;
66 | }
67 |
68 | EntitlementsStatus entitlement = EntitlementsStatus.Unknown;
69 | if (!connectedPlayer.isMe)
70 | entitlement = _entitlementChecker.GetUserEntitlementStatusWithoutRequest(connectedPlayer.userId, hostSelectedLevel);
71 | // TODO: change color for local player
72 | if (entitlement != EntitlementsStatus.Unknown)
73 | SetLevelEntitlement(____localPlayerBackgroundImage, entitlement);
74 | else if (!connectedPlayer.isMe)
75 | {
76 | // This might be a bad idea, race condition can cause packets that scale with the amount of players
77 | _entitlementChecker.GetUserEntitlementStatus(connectedPlayer.userId, hostSelectedLevel);
78 | }
79 | }
80 |
81 | private void SetLevelEntitlement(Image backgroundImage, EntitlementsStatus status)
82 | {
83 | Color backgroundColor = status switch
84 | {
85 | EntitlementsStatus.Ok => green,
86 | EntitlementsStatus.NotOwned => red,
87 | _ => normal,
88 | };
89 |
90 | backgroundColor.a = alphaIsNotMe;
91 | backgroundImage.color = backgroundColor;
92 | }
93 |
94 | private void HandleSetIsEntitledToLevel(string userId, string levelId, EntitlementsStatus status)
95 | => _playerListView.SetDataToTable();
96 | }
97 | }
98 |
--------------------------------------------------------------------------------
/MultiplayerExtensions/Installers/MpexAppInstaller.cs:
--------------------------------------------------------------------------------
1 | using IPA.Loader;
2 | using MultiplayerExtensions.Patchers;
3 | using MultiplayerExtensions.Players;
4 | using MultiplayerExtensions.Utilities;
5 | using SiraUtil.Zenject;
6 | using Zenject;
7 |
8 | namespace MultiplayerExtensions.Installers
9 | {
10 | class MpexAppInstaller : Installer
11 | {
12 | private readonly Config _config;
13 |
14 | public MpexAppInstaller(
15 | Config config)
16 | {
17 | _config = config;
18 | }
19 |
20 | public override void InstallBindings()
21 | {
22 | Container.BindInstance(_config).AsSingle();
23 | Container.BindInterfacesAndSelfTo().AsSingle();
24 | Container.BindInterfacesAndSelfTo().AsSingle();
25 | Container.BindInterfacesAndSelfTo().AsSingle();
26 | }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/MultiplayerExtensions/Installers/MpexGameInstaller.cs:
--------------------------------------------------------------------------------
1 | using IPA.Utilities;
2 | using MultiplayerExtensions.Environment;
3 | using MultiplayerExtensions.Patchers;
4 | using MultiplayerExtensions.Players;
5 | using SiraUtil.Extras;
6 | using SiraUtil.Objects.Multiplayer;
7 | using UnityEngine;
8 | using Zenject;
9 |
10 | namespace MultiplayerExtensions.Installers
11 | {
12 | class MpexGameInstaller : Installer
13 | {
14 | public override void InstallBindings()
15 | {
16 | Container.BindInterfacesAndSelfTo().AsSingle();
17 | Container.BindInterfacesAndSelfTo().AsSingle();
18 | Container.RegisterRedecorator(new LocalActivePlayerRegistration(DecorateLocalActivePlayerFacade));
19 | Container.RegisterRedecorator(new LocalActivePlayerDuelRegistration(DecorateLocalActivePlayerFacade));
20 | Container.RegisterRedecorator(new ConnectedPlayerRegistration(DecorateConnectedPlayerFacade));
21 | Container.RegisterRedecorator(new ConnectedPlayerDuelRegistration(DecorateConnectedPlayerFacade));
22 | }
23 |
24 | private MultiplayerLocalActivePlayerFacade DecorateLocalActivePlayerFacade(MultiplayerLocalActivePlayerFacade original)
25 | {
26 | if (Plugin.Config.MissLighting)
27 | original.gameObject.AddComponent();
28 | return original;
29 | }
30 |
31 | private MultiplayerConnectedPlayerFacade DecorateConnectedPlayerFacade(MultiplayerConnectedPlayerFacade original)
32 | {
33 | if (Plugin.Config.MissLighting && !Plugin.Config.PersonalMissLightingOnly)
34 | original.gameObject.AddComponent();
35 | original.gameObject.AddComponent();
36 | return original;
37 | }
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/MultiplayerExtensions/Installers/MpexLobbyInstaller.cs:
--------------------------------------------------------------------------------
1 | using MultiplayerExtensions.Environments;
2 | using MultiplayerExtensions.Environments.Lobby;
3 | using SiraUtil.Extras;
4 | using SiraUtil.Objects.Multiplayer;
5 | using Zenject;
6 |
7 | namespace MultiplayerExtensions.Installers
8 | {
9 | class MpexLobbyInstaller : Installer
10 | {
11 | public override void InstallBindings()
12 | {
13 | Container.RegisterRedecorator(new LobbyAvatarPlaceRegistration(DecorateAvatarPlace));
14 | Container.RegisterRedecorator(new LobbyAvatarRegistration(DecorateAvatar));
15 | }
16 |
17 | private MultiplayerLobbyAvatarPlace DecorateAvatarPlace(MultiplayerLobbyAvatarPlace original)
18 | {
19 | original.gameObject.AddComponent();
20 | return original;
21 | }
22 |
23 | private MultiplayerLobbyAvatarController DecorateAvatar(MultiplayerLobbyAvatarController original)
24 | {
25 | var avatarCaption = original.transform.Find("AvatarCaption").gameObject;
26 | avatarCaption.AddComponent();
27 |
28 | return original;
29 | }
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/MultiplayerExtensions/Installers/MpexLocalActivePlayerInstaller.cs:
--------------------------------------------------------------------------------
1 | using MultiplayerExtensions.Environment;
2 | using MultiplayerExtensions.Patchers;
3 | using Zenject;
4 |
5 | namespace MultiplayerExtensions.Installers
6 | {
7 | public class MpexLocalActivePlayerInstaller : MonoInstaller
8 | {
9 | public override void InstallBindings()
10 | {
11 | // stuff needed for solo environments to work
12 | Container.BindInterfacesAndSelfTo().AsSingle();
13 | Container.Bind().FromInstance(EnvironmentContext.Gameplay).AsSingle();
14 | }
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/MultiplayerExtensions/Installers/MpexMenuInstaller.cs:
--------------------------------------------------------------------------------
1 | using MultiplayerExtensions.Environments;
2 | using MultiplayerExtensions.Objects;
3 | using MultiplayerExtensions.Patchers;
4 | using MultiplayerExtensions.UI;
5 | using UnityEngine;
6 | using Zenject;
7 |
8 | namespace MultiplayerExtensions.Installers
9 | {
10 | class MpexMenuInstaller : Installer
11 | {
12 | public override void InstallBindings()
13 | {
14 | //Container.BindInterfacesAndSelfTo().AsSingle();
15 | Container.BindInterfacesAndSelfTo().AsSingle();
16 | Container.BindInterfacesAndSelfTo().AsSingle();
17 |
18 | Container.BindInterfacesAndSelfTo().FromNewComponentOnNewGameObject().AsSingle();
19 | Container.BindInterfacesAndSelfTo().FromNewComponentAsViewController().AsSingle();
20 | Container.BindInterfacesAndSelfTo().FromNewComponentAsViewController().AsSingle();
21 | Container.BindInterfacesAndSelfTo().FromNewComponentAsViewController().AsSingle();
22 | Container.BindInterfacesAndSelfTo().AsSingle();
23 |
24 | // needed for local player's player place
25 | var avatarPlace = Container.Resolve().transform.Find("MultiplayerLobbyEnvironment").Find("LobbyAvatarPlace").gameObject;
26 | GameObject.Destroy(avatarPlace.GetComponent());
27 | Container.Inject(avatarPlace.AddComponent());
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/MultiplayerExtensions/MultiplayerExtensions.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Library
5 | Properties
6 | MultiplayerExtensions
7 | 1.0.3
8 | net472
9 | true
10 | portable
11 | ..\Refs
12 | $(LocalRefsDir)
13 |
14 | prompt
15 | 4
16 | 9.0
17 | enable
18 | Unofficial
19 | local
20 |
21 |
22 |
23 |
24 | false
25 | DEBUG;TRACE
26 |
27 |
28 | true
29 |
30 |
31 | True
32 |
33 |
34 | True
35 | True
36 |
37 |
38 |
39 | $(BeatSaberDir)\Beat Saber_Data\Managed\BeatmapCore.dll
40 | False
41 | False
42 |
43 |
44 | $(BeatSaberDir)\Beat Saber_Data\Managed\BGNet.dll
45 | False
46 | False
47 |
48 |
49 | $(BeatSaberDir)\Beat Saber_Data\Managed\Colors.dll
50 | False
51 |
52 |
53 | $(BeatSaberDir)\Beat Saber_Data\Managed\GameplayCore.dll
54 | False
55 | False
56 |
57 |
58 | $(BeatSaberDir)\Libs\Hive.Versioning.dll
59 | False
60 |
61 |
62 | $(BeatSaberDir)\Beat Saber_Data\Managed\HMRendering.dll
63 | False
64 |
65 |
66 | $(BeatSaberDir)\Beat Saber_Data\Managed\LiteNetLib.dll
67 | False
68 |
69 |
70 | $(BeatSaberDir)\Beat Saber_Data\Managed\netstandard.dll
71 | False
72 | False
73 |
74 |
75 | $(BeatSaberDir)\Beat Saber_Data\Managed\Polyglot.dll
76 | False
77 |
78 |
79 | $(BeatSaberDir)\Libs\SemVer.dll
80 | False
81 |
82 |
83 | $(BeatSaberDir)\Beat Saber_Data\Managed\System.IO.Compression.dll
84 | False
85 | False
86 |
87 |
88 | $(BeatSaberDir)\Beat Saber_Data\Managed\Main.dll
89 | False
90 |
91 |
92 | $(BeatSaberDir)\Beat Saber_Data\Managed\HMLib.dll
93 | False
94 |
95 |
96 | $(BeatSaberDir)\Beat Saber_Data\Managed\HMUI.dll
97 | False
98 |
99 |
100 | $(BeatSaberDir)\Beat Saber_Data\Managed\IPA.Loader.dll
101 | False
102 |
103 |
104 | $(BeatSaberDir)\Beat Saber_Data\Managed\Unity.TextMeshPro.dll
105 | False
106 |
107 |
108 | $(BeatSaberDir)\Beat Saber_Data\Managed\Unity.Timeline.dll
109 | False
110 |
111 |
112 | $(BeatSaberDir)\Beat Saber_Data\Managed\UnityEngine.dll
113 | False
114 |
115 |
116 | $(BeatSaberDir)\Beat Saber_Data\Managed\UnityEngine.AudioModule.dll
117 | False
118 | False
119 |
120 |
121 | $(BeatSaberDir)\Beat Saber_Data\Managed\UnityEngine.CoreModule.dll
122 | False
123 |
124 |
125 | $(BeatSaberDir)\Beat Saber_Data\Managed\UnityEngine.DirectorModule.dll
126 | False
127 |
128 |
129 | $(BeatSaberDir)\Beat Saber_Data\Managed\UnityEngine.ImageConversionModule.dll
130 | False
131 | False
132 |
133 |
134 | $(BeatSaberDir)\Beat Saber_Data\Managed\UnityEngine.TextRenderingModule.dll
135 |
136 |
137 | $(BeatSaberDir)\Beat Saber_Data\Managed\UnityEngine.UI.dll
138 | False
139 |
140 |
141 | $(BeatSaberDir)\Beat Saber_Data\Managed\UnityEngine.UIElementsModule.dll
142 | False
143 |
144 |
145 | $(BeatSaberDir)\Beat Saber_Data\Managed\UnityEngine.UIModule.dll
146 |
147 |
148 | $(BeatSaberDir)\Beat Saber_Data\Managed\UnityEngine.VRModule.dll
149 | False
150 |
151 |
152 | $(BeatSaberDir)\Beat Saber_Data\Managed\Zenject.dll
153 | False
154 |
155 |
156 | $(BeatSaberDir)\Beat Saber_Data\Managed\Zenject-usage.dll
157 | False
158 |
159 |
160 | $(BeatSaberDir)\Libs\0Harmony.dll
161 | False
162 | False
163 |
164 |
165 | $(BeatSaberDir)\Plugins\BSML.dll
166 | False
167 | False
168 |
169 |
170 | $(BeatSaberDir)\Plugins\SiraUtil.dll
171 | False
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 | 1.3.2
207 | runtime; build; native; contentfiles; analyzers; buildtransitive
208 | all
209 |
210 |
211 |
212 |
213 |
214 |
215 |
216 |
217 |
218 |
219 |
220 |
221 |
222 |
223 |
224 |
225 |
226 |
227 |
228 |
229 |
230 | Official
231 |
232 |
233 | $(VersionType)-$(GitBranch)-$(CommitHash)
234 |
235 |
236 | $(VersionType)-$(GitBranch)-$(CommitHash)-$(GitModified)
237 |
238 |
239 |
240 |
241 |
--------------------------------------------------------------------------------
/MultiplayerExtensions/Patchers/AvatarPlacePatcher.cs:
--------------------------------------------------------------------------------
1 | using HarmonyLib;
2 | using MultiplayerExtensions.Environments;
3 | using SiraUtil.Affinity;
4 | using System.Collections.Generic;
5 | using System.Reflection;
6 | using System.Reflection.Emit;
7 |
8 | namespace MultiplayerExtensions.Patchers
9 | {
10 | [HarmonyPatch]
11 | public class AvatarPlacePatcher : IAffinity
12 | {
13 | private readonly MenuEnvironmentManager _environmentManager;
14 |
15 | internal AvatarPlacePatcher(
16 | MenuEnvironmentManager environmentManager)
17 | {
18 | _environmentManager = environmentManager;
19 | }
20 |
21 | private static readonly MethodInfo _addMethod = typeof(List).GetMethod(nameof(List.Add));
22 | private static readonly MethodInfo _setupAvatarPlaceMethod = SymbolExtensions.GetMethodInfo(() => SetupAvatarPlace(null!, 0));
23 |
24 | [HarmonyTranspiler]
25 | [HarmonyPatch(typeof(MultiplayerLobbyAvatarPlaceManager), nameof(MultiplayerLobbyAvatarPlaceManager.SpawnAllPlaces))]
26 | private static IEnumerable SpawnAllPlaces(IEnumerable instructions) =>
27 | new CodeMatcher(instructions)
28 | .MatchForward(false, new CodeMatch(OpCodes.Callvirt, _addMethod))
29 | .Insert(new CodeInstruction(OpCodes.Ldloc_3), new CodeInstruction(OpCodes.Callvirt, _setupAvatarPlaceMethod))
30 | .InstructionEnumeration();
31 |
32 | private static MultiplayerLobbyAvatarPlace SetupAvatarPlace(MultiplayerLobbyAvatarPlace avatarPlace, int sortIndex)
33 | {
34 | avatarPlace.gameObject.GetComponent().SortIndex = sortIndex;
35 | return avatarPlace;
36 | }
37 |
38 | [AffinityPrefix]
39 | [AffinityPatch(typeof(MultiplayerLobbyAvatarPlaceManager), nameof(MultiplayerLobbyAvatarPlaceManager.SpawnAllPlaces))]
40 | private void SpawnAllPlacesPrefix(ILobbyStateDataModel ____lobbyStateDataModel)
41 | => _environmentManager.transform.Find("MultiplayerLobbyEnvironment").Find("LobbyAvatarPlace").gameObject.GetComponent().SortIndex = ____lobbyStateDataModel.localPlayer.sortIndex;
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/MultiplayerExtensions/Patchers/ColorSchemePatcher.cs:
--------------------------------------------------------------------------------
1 | using SiraUtil.Affinity;
2 |
3 | namespace MultiplayerExtensions.Patchers
4 | {
5 | public class ColorSchemePatcher : IAffinity
6 | {
7 | private readonly GameplayCoreSceneSetupData _sceneSetupData;
8 | private readonly Config _config;
9 |
10 | internal ColorSchemePatcher(
11 | GameplayCoreSceneSetupData sceneSetupData,
12 | Config config)
13 | {
14 | _sceneSetupData = sceneSetupData;
15 | _config = config;
16 | }
17 |
18 | [AffinityPostfix]
19 | [AffinityPatch(typeof(PlayersSpecificSettingsAtGameStartModel), nameof(PlayersSpecificSettingsAtGameStartModel.GetPlayerSpecificSettingsForUserId))]
20 | private void SetConnectedPlayerColorScheme(ref PlayerSpecificSettingsNetSerializable __result)
21 | {
22 | var colorscheme = _sceneSetupData.colorScheme;
23 | if (_config.DisableMultiplayerColors)
24 | __result.colorScheme = new ColorSchemeNetSerializable(colorscheme.saberAColor, colorscheme.saberBColor, colorscheme.obstaclesColor, colorscheme.environmentColor0, colorscheme.environmentColor1, colorscheme.environmentColor0Boost, colorscheme.environmentColor1Boost);
25 | }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/MultiplayerExtensions/Patchers/EnvironmentPatcher.cs:
--------------------------------------------------------------------------------
1 | using HarmonyLib;
2 | using IPA.Utilities;
3 | using SiraUtil.Affinity;
4 | using SiraUtil.Logging;
5 | using System;
6 | using System.Collections.Generic;
7 | using System.ComponentModel;
8 | using System.Linq;
9 | using UnityEngine;
10 | using UnityEngine.SceneManagement;
11 | using Zenject;
12 |
13 | namespace MultiplayerExtensions.Patchers
14 | {
15 | [HarmonyPatch]
16 | public class EnvironmentPatcher : IAffinity
17 | {
18 | private readonly GameScenesManager _scenesManager;
19 | private readonly Config _config;
20 | private readonly SiraLog _logger;
21 |
22 | internal EnvironmentPatcher(
23 | GameScenesManager scenesManager,
24 | Config config,
25 | SiraLog logger)
26 | {
27 | _scenesManager = scenesManager;
28 | _config = config;
29 | _logger = logger;
30 | }
31 |
32 | private List _behavioursToInject = new();
33 |
34 | [AffinityPostfix]
35 | [AffinityPatch(typeof(SceneDecoratorContext), "GetInjectableMonoBehaviours")]
36 | private void PreventEnvironmentInjection(SceneDecoratorContext __instance, List monoBehaviours, DiContainer ____container)
37 | {
38 | var scene = __instance.gameObject.scene;
39 | if (_scenesManager.IsSceneInStack("MultiplayerEnvironment") && _config.SoloEnvironment)
40 | {
41 | _logger.Info($"Fixing bind conflicts on scene '{scene.name}'.");
42 | List removedBehaviours = new();
43 |
44 | //if (scene.name == "MultiplayerEnvironment")
45 | // removedBehaviours = monoBehaviours.FindAll(behaviour => behaviour is ZenjectBinding binding && binding.Components.Any(c => c is LightWithIdManager));
46 | if (scene.name.Contains("Environment") && !scene.name.Contains("Multiplayer"))
47 | removedBehaviours = monoBehaviours.FindAll(behaviour => (behaviour is ZenjectBinding binding && binding.Components.Any(c => c is LightWithIdManager)));
48 |
49 | if (removedBehaviours.Any())
50 | {
51 | _logger.Info($"Removing behaviours '{string.Join(", ", removedBehaviours.Select(behaviour => behaviour.GetType()))}' from scene '{scene.name}'.");
52 | monoBehaviours.RemoveAll(monoBehaviour => removedBehaviours.Contains(monoBehaviour));
53 | }
54 |
55 | if (scene.name.Contains("Environment") && !scene.name.Contains("Multiplayer"))
56 | {
57 | _logger.Info($"Preventing environment injection.");
58 | _behavioursToInject = new(monoBehaviours);
59 | monoBehaviours.Clear();
60 | }
61 | }
62 | else
63 | {
64 | _behavioursToInject.Clear();
65 | }
66 | }
67 |
68 | private List _normalInstallers = new();
69 | private List _normalInstallerTypes = new();
70 | private List _scriptableObjectInstallers = new();
71 | private List _monoInstallers = new();
72 | private List _installerPrefabs = new();
73 |
74 | [AffinityPrefix]
75 | [AffinityPatch(typeof(SceneDecoratorContext), "InstallDecoratorInstallers")]
76 | private void PreventEnvironmentInstall(SceneDecoratorContext __instance, List ____normalInstallers, List ____normalInstallerTypes, List ____scriptableObjectInstallers, List ____monoInstallers, List ____installerPrefabs)
77 | {
78 | var scene = __instance.gameObject.scene;
79 | if (_scenesManager.IsSceneInStack("MultiplayerEnvironment") && _config.SoloEnvironment && scene.name.Contains("Environment") && !scene.name.Contains("Multiplayer"))
80 | {
81 | _logger.Info($"Preventing environment installation.");
82 |
83 | _normalInstallers = new(____normalInstallers);
84 | _normalInstallerTypes = new(____normalInstallerTypes);
85 | _scriptableObjectInstallers = new(____scriptableObjectInstallers);
86 | _monoInstallers = new(____monoInstallers);
87 | _installerPrefabs = new(____installerPrefabs);
88 |
89 | ____normalInstallers.Clear();
90 | ____normalInstallerTypes.Clear();
91 | ____scriptableObjectInstallers.Clear();
92 | ____monoInstallers.Clear();
93 | ____installerPrefabs.Clear();
94 | }
95 | else if (!_scenesManager.IsSceneInStack("MultiplayerEnvironment"))
96 | {
97 | _normalInstallers.Clear();
98 | _normalInstallerTypes.Clear();
99 | _scriptableObjectInstallers.Clear();
100 | _monoInstallers.Clear();
101 | _installerPrefabs.Clear();
102 | }
103 | }
104 |
105 | private List _objectsToEnable = new();
106 |
107 | [AffinityPrefix]
108 | [AffinityPatch(typeof(GameScenesManager), "ActivatePresentedSceneRootObjects")]
109 | private void PreventEnvironmentActivation(List scenesToPresent)
110 | {
111 | string defaultScene = scenesToPresent.FirstOrDefault(scene => scene.Contains("Environment") && !scene.Contains("Multiplayer"));
112 | if (defaultScene != null)
113 | {
114 | if (scenesToPresent.Contains("MultiplayerEnvironment"))
115 | {
116 | _logger.Info($"Preventing environment activation. ({defaultScene})");
117 | _objectsToEnable = SceneManager.GetSceneByName(defaultScene).GetRootGameObjects().ToList();
118 | scenesToPresent.Remove(defaultScene);
119 |
120 | // fix ring lighting dogshit
121 | var trackLaneRingManagers = _objectsToEnable[0].transform.GetComponentsInChildren();
122 | }
123 | else
124 | {
125 | // Make sure hud is enabled in solo
126 | var sceneObjects = SceneManager.GetSceneByName(defaultScene).GetRootGameObjects().ToList();
127 | foreach (GameObject gameObject in sceneObjects)
128 | {
129 | var hud = gameObject.transform.GetComponentInChildren();
130 | if (hud != null)
131 | hud.gameObject.SetActive(true);
132 | }
133 | }
134 | }
135 | }
136 |
137 | [AffinityPostfix]
138 | [AffinityPatch(typeof(GameObjectContext), "GetInjectableMonoBehaviours")]
139 | private void InjectEnvironment(GameObjectContext __instance, List monoBehaviours)
140 | {
141 | if (__instance.transform.name.Contains("LocalActivePlayer") && _config.SoloEnvironment)
142 | {
143 | _logger.Info($"Injecting environment.");
144 | monoBehaviours.AddRange(_behavioursToInject);
145 | }
146 | }
147 |
148 | [AffinityPrefix]
149 | [AffinityPatch(typeof(Context), "InstallInstallers", AffinityMethodType.Normal, null, typeof(List), typeof(List), typeof(List), typeof(List), typeof(List))]
150 | private void InstallEnvironment(Context __instance, List normalInstallers, List normalInstallerTypes, List scriptableObjectInstallers, List installers, List installerPrefabs)
151 | {
152 | if (__instance is GameObjectContext instance && __instance.transform.name.Contains("LocalActivePlayer") && _config.SoloEnvironment)
153 | {
154 | _logger.Info($"Installing environment.");
155 | normalInstallers.AddRange(_normalInstallers);
156 | normalInstallerTypes.AddRange(_normalInstallerTypes);
157 | scriptableObjectInstallers.AddRange(_scriptableObjectInstallers);
158 | installers.AddRange(_monoInstallers);
159 | installerPrefabs.AddRange(_installerPrefabs);
160 | }
161 | }
162 |
163 |
164 | [AffinityPrefix]
165 | [AffinityPatch(typeof(GameObjectContext), "InstallInstallers")]
166 | private void LoveYouCountersPlus(GameObjectContext __instance)
167 | {
168 | if (__instance.transform.name.Contains("LocalActivePlayer") && _config.SoloEnvironment)
169 | {
170 | DiContainer container = __instance.GetProperty("Container");
171 | var hud = (CoreGameHUDController)_behavioursToInject.Find(x => x is CoreGameHUDController);
172 | container.Unbind();
173 | container.Bind().FromInstance(hud).AsSingle();
174 | var multihud = __instance.transform.GetComponentInChildren();
175 | multihud.gameObject.SetActive(false);
176 | var multiPositionHud = __instance.transform.GetComponentInChildren();
177 | multiPositionHud.transform.position += new Vector3(0, 0.01f, 0);
178 | }
179 | }
180 |
181 | [AffinityPostfix]
182 | [AffinityPatch(typeof(GameObjectContext), "InstallSceneBindings")]
183 | private void ActivateEnvironment(GameObjectContext __instance)
184 | {
185 | if (__instance.transform.name.Contains("LocalActivePlayer") && _config.SoloEnvironment)
186 | {
187 | _logger.Info($"Activating environment.");
188 | foreach (GameObject gameObject in _objectsToEnable)
189 | gameObject.SetActive(true);
190 |
191 | var activeObjects = __instance.transform.Find("IsActiveObjects");
192 | activeObjects.Find("Lasers").gameObject.SetActive(false);
193 | activeObjects.Find("Construction").gameObject.SetActive(false);
194 | activeObjects.Find("BigSmokePS").gameObject.SetActive(false);
195 | activeObjects.Find("DustPS").gameObject.SetActive(false);
196 | activeObjects.Find("DirectionalLights").gameObject.SetActive(false);
197 |
198 | var localActivePlayer = __instance.transform.GetComponent();
199 | var activeOnlyGameObjects = localActivePlayer.GetField("_activeOnlyGameObjects");
200 | var newActiveOnlyGameObjects = activeOnlyGameObjects.Concat(_objectsToEnable);
201 | localActivePlayer.SetField("_activeOnlyGameObjects", newActiveOnlyGameObjects.ToArray());
202 | }
203 | }
204 |
205 | [HarmonyPostfix]
206 | [HarmonyPatch(typeof(Context), "InstallSceneBindings")]
207 | private static void HideOtherPlayerPlatforms(Context __instance)
208 | {
209 | if (__instance.transform.name.Contains("ConnectedPlayer"))
210 | {
211 | if (Plugin.Config.DisableMultiplayerPlatforms)
212 | __instance.transform.Find("Construction").gameObject.SetActive(false);
213 | if (Plugin.Config.DisableMultiplayerLights)
214 | __instance.transform.Find("Lasers").gameObject.SetActive(false);
215 | }
216 | }
217 |
218 | [HarmonyPrefix]
219 | [HarmonyPatch(typeof(EnvironmentSceneSetup), nameof(EnvironmentSceneSetup.InstallBindings))]
220 | private static bool RemoveDuplicateInstalls(EnvironmentSceneSetup __instance)
221 | {
222 | DiContainer container = __instance.GetProperty("Container");
223 | return !container.HasBinding();
224 | }
225 |
226 | [AffinityPostfix]
227 | [AffinityPatch(typeof(GameplayCoreInstaller), nameof(GameplayCoreInstaller.InstallBindings))]
228 | private void SetEnvironmentColors(GameplayCoreInstaller __instance)
229 | {
230 | if (!_config.SoloEnvironment || !_scenesManager.IsSceneInStack("MultiplayerEnvironment"))
231 | return;
232 |
233 | DiContainer container = __instance.GetProperty("Container");
234 | var colorManager = container.Resolve();
235 | container.Inject(colorManager);
236 | colorManager.Awake();
237 | colorManager.Start();
238 |
239 | foreach (var gameObject in _objectsToEnable)
240 | {
241 | var lightSwitchEventEffects = gameObject.transform.GetComponentsInChildren();
242 | foreach (var component in lightSwitchEventEffects)
243 | component.Awake();
244 | }
245 | }
246 | }
247 | }
248 |
--------------------------------------------------------------------------------
/MultiplayerExtensions/Patchers/MenuEnvironmentPatcher.cs:
--------------------------------------------------------------------------------
1 | using HarmonyLib;
2 | using SiraUtil.Affinity;
3 | using SiraUtil.Logging;
4 | using System.Linq;
5 |
6 | namespace MultiplayerExtensions.Patchers
7 | {
8 | [HarmonyPatch]
9 | public class MenuEnvironmentPatcher : IAffinity
10 | {
11 | private readonly GameplaySetupViewController _gameplaySetup;
12 | private readonly Config _config;
13 | private readonly SiraLog _logger;
14 |
15 | internal MenuEnvironmentPatcher(
16 | GameplaySetupViewController gameplaySetup,
17 | Config config,
18 | SiraLog logger)
19 | {
20 | _gameplaySetup = gameplaySetup;
21 | _config = config;
22 | _logger = logger;
23 | }
24 |
25 | [HarmonyPrefix]
26 | [HarmonyPatch(typeof(GameplaySetupViewController), nameof(GameplaySetupViewController.Setup))]
27 | private static void EnableEnvironmentTab(bool showModifiers, ref bool showEnvironmentOverrideSettings, bool showColorSchemesSettings, bool showMultiplayer, PlayerSettingsPanelController.PlayerSettingsPanelLayout playerSettingsPanelLayout)
28 | {
29 | if (showMultiplayer)
30 | showEnvironmentOverrideSettings = Plugin.Config.SoloEnvironment;
31 | }
32 |
33 | private EnvironmentInfoSO _originalEnvironmentInfo = null!;
34 |
35 | [AffinityPrefix]
36 | [AffinityPatch(typeof(MultiplayerLevelScenesTransitionSetupDataSO), "Init")]
37 | private void SetEnvironmentScene(IDifficultyBeatmap difficultyBeatmap, ref EnvironmentInfoSO ____multiplayerEnvironmentInfo)
38 | {
39 | if (!_config.SoloEnvironment)
40 | return;
41 |
42 | _originalEnvironmentInfo = ____multiplayerEnvironmentInfo;
43 | ____multiplayerEnvironmentInfo = difficultyBeatmap.GetEnvironmentInfo();
44 | if (_gameplaySetup.environmentOverrideSettings.overrideEnvironments)
45 | ____multiplayerEnvironmentInfo = _gameplaySetup.environmentOverrideSettings.GetOverrideEnvironmentInfoForType(____multiplayerEnvironmentInfo.environmentType);
46 | }
47 |
48 | [AffinityPostfix]
49 | [AffinityPatch(typeof(MultiplayerLevelScenesTransitionSetupDataSO), "Init")]
50 | private void ResetEnvironmentScene(IDifficultyBeatmap difficultyBeatmap, ref EnvironmentInfoSO ____multiplayerEnvironmentInfo)
51 | {
52 | if (_config.SoloEnvironment)
53 | ____multiplayerEnvironmentInfo = _originalEnvironmentInfo;
54 | }
55 |
56 | [AffinityPrefix]
57 | [AffinityPatch(typeof(ScenesTransitionSetupDataSO), "Init")]
58 | private void AddEnvironmentOverrides(ref SceneInfo[] scenes)
59 | {
60 | if (_config.SoloEnvironment && scenes.Any(scene => scene.name.Contains("Multiplayer")))
61 | {
62 | scenes = scenes.AddItem(_originalEnvironmentInfo.sceneInfo).ToArray();
63 | }
64 | }
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/MultiplayerExtensions/Patchers/PlayerPositionPatcher.cs:
--------------------------------------------------------------------------------
1 | using HarmonyLib;
2 | using SiraUtil.Affinity;
3 | using System.Collections.Generic;
4 | using UnityEngine;
5 |
6 | namespace MultiplayerExtensions.Patchers
7 | {
8 | [HarmonyPatch]
9 | public class PlayerPositionPatcher : IAffinity
10 | {
11 | private readonly Config _config;
12 |
13 | internal PlayerPositionPatcher(
14 | Config config)
15 | {
16 | _config = config;
17 | }
18 |
19 | // these are affinity patches because they only apply to one container
20 | [AffinityPrefix]
21 | [AffinityPatch(typeof(MultiplayerLayoutProvider), nameof(MultiplayerLayoutProvider.CalculateLayout))]
22 | private bool SideBySideLayout(ref MultiplayerPlayerLayout __result)
23 | {;
24 | __result = MultiplayerPlayerLayout.Duel;
25 | return !_config.SideBySide;
26 | }
27 |
28 | [HarmonyPrefix]
29 | [HarmonyPatch(typeof(MultiplayerConditionalActiveByLayout), nameof(MultiplayerConditionalActiveByLayout.Start))]
30 | private static void SideBySideLayoutConfirm(MultiplayerConditionalActiveByLayout __instance, MultiplayerLayoutProvider ____layoutProvider)
31 | {
32 | if (!Plugin.Config.SideBySide)
33 | return;
34 | if (____layoutProvider.layout == MultiplayerPlayerLayout.NotDetermined)
35 | __instance.HandlePlayersLayoutWasCalculated(MultiplayerPlayerLayout.Duel, 2);
36 | }
37 |
38 | [HarmonyPrefix]
39 | [HarmonyPatch(typeof(MultiplayerConditionalActiveByLayout), nameof(MultiplayerConditionalActiveByLayout.HandlePlayersLayoutWasCalculated))]
40 | private static void SideBySideObjectDisable(ref MultiplayerPlayerLayout layout)
41 | {
42 | if (Plugin.Config.SideBySide)
43 | layout = MultiplayerPlayerLayout.Duel;
44 | }
45 |
46 | [AffinityPrefix]
47 | [AffinityPatch(typeof(MultiplayerPlayerPlacement), nameof(MultiplayerPlayerPlacement.GetOuterCirclePositionAngleForPlayer))]
48 | private bool SideBySideAngle(int playerIndex, int localPlayerIndex, ref float __result)
49 | {
50 | __result = (playerIndex - localPlayerIndex) * 0.01f;
51 | return !_config.SideBySide;
52 | }
53 |
54 | [AffinityPrefix]
55 | [AffinityPatch(typeof(MultiplayerPlayerPlacement), nameof(MultiplayerPlayerPlacement.GetPlayerWorldPosition))]
56 | private bool SoloEnvironmentPosition(float outerCirclePositionAngle, ref Vector3 __result)
57 | {
58 | var sortIndex = outerCirclePositionAngle ;
59 | __result = new Vector3(sortIndex * 100f * _config.SideBySideDistance, 0, 0);
60 | return !_config.SideBySide;
61 | }
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/MultiplayerExtensions/Patches/AvatarPoseRestrictionPatch.cs:
--------------------------------------------------------------------------------
1 | using HarmonyLib;
2 | using UnityEngine;
3 |
4 | namespace MultiplayerExtensions.Patches
5 | {
6 | [HarmonyPatch]
7 | public class AvatarPoseRestrictionPatch
8 | {
9 | [HarmonyPrefix]
10 | [HarmonyPatch(typeof(AvatarPoseRestrictions), nameof(AvatarPoseRestrictions.HandleAvatarPoseControllerPositionsWillBeSet))]
11 | private static bool DisableAvatarRestrictions(AvatarPoseRestrictions __instance, Vector3 headPosition, Vector3 leftHandPosition, Vector3 rightHandPosition, out Vector3 newHeadPosition, out Vector3 newLeftHandPosition, out Vector3 newRightHandPosition)
12 | {
13 | newHeadPosition = headPosition;
14 | newLeftHandPosition = leftHandPosition;
15 | newRightHandPosition = rightHandPosition;
16 | if (!Plugin.Config.DisableAvatarConstraints)
17 | return true;
18 | newLeftHandPosition = __instance.LimitHandPositionRelativeToHead(leftHandPosition, headPosition);
19 | newRightHandPosition = __instance.LimitHandPositionRelativeToHead(rightHandPosition, headPosition);
20 | return false;
21 | }
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/MultiplayerExtensions/Patches/PlatformMovementPatch.cs:
--------------------------------------------------------------------------------
1 | using HarmonyLib;
2 |
3 | namespace MultiplayerExtensions.Patches
4 | {
5 | [HarmonyPatch]
6 | public class PlatformMovementPatch
7 | {
8 | [HarmonyPrefix]
9 | [HarmonyPatch(typeof(MultiplayerVerticalPlayerMovementManager), nameof(MultiplayerVerticalPlayerMovementManager.Update))]
10 | private static bool DisableVerticalPlayerMovement()
11 | {
12 | return !Plugin.Config.DisablePlatformMovement;
13 | }
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/MultiplayerExtensions/Patches/ResumeSpawningPatch.cs:
--------------------------------------------------------------------------------
1 | using HarmonyLib;
2 |
3 | namespace MultiplayerExtensions.Patches
4 | {
5 | [HarmonyPatch]
6 | public class ResumeSpawningPatch
7 | {
8 | [HarmonyPrefix]
9 | [HarmonyPatch(typeof(MultiplayerConnectedPlayerFacade), nameof(MultiplayerConnectedPlayerFacade.ResumeSpawning))]
10 | private static bool DisableAvatarRestrictions()
11 | {
12 | if (Plugin.Config.DisableMultiplayerObjects)
13 | return false;
14 | return true;
15 | }
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/MultiplayerExtensions/Players/MpexPlayerData.cs:
--------------------------------------------------------------------------------
1 | using LiteNetLib.Utils;
2 | using UnityEngine;
3 |
4 | namespace MultiplayerExtensions.Players
5 | {
6 | public class MpexPlayerData : INetSerializable
7 | {
8 | ///
9 | /// Player's color set in the plugin config.
10 | ///
11 | public Color Color { get; set; }
12 |
13 | public void Serialize(NetDataWriter writer)
14 | {
15 | writer.Put("#" + ColorUtility.ToHtmlStringRGB(Color));
16 | }
17 |
18 | public void Deserialize(NetDataReader reader)
19 | {
20 | Color color;
21 | if (!ColorUtility.TryParseHtmlString(reader.GetString(), out color))
22 | color = Config.DefaultPlayerColor;
23 | Color = color;
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/MultiplayerExtensions/Players/MpexPlayerManager.cs:
--------------------------------------------------------------------------------
1 | using MultiplayerCore.Networking;
2 | using System;
3 | using System.Collections.Concurrent;
4 | using System.Collections.Generic;
5 | using UnityEngine;
6 | using Zenject;
7 |
8 | namespace MultiplayerExtensions.Players
9 | {
10 | public class MpexPlayerManager : IInitializable
11 | {
12 | public event Action PlayerConnectedEvent = null!;
13 |
14 | public IReadOnlyDictionary Players => _playerData;
15 |
16 | private ConcurrentDictionary _playerData = new();
17 |
18 | private readonly MpPacketSerializer _packetSerializer;
19 | private readonly IMultiplayerSessionManager _sessionManager;
20 | private readonly Config _config;
21 |
22 | internal MpexPlayerManager(
23 | MpPacketSerializer packetSerializer,
24 | IMultiplayerSessionManager sessionManager,
25 | Config config)
26 | {
27 | _packetSerializer = packetSerializer;
28 | _sessionManager = sessionManager;
29 | _config = config;
30 | }
31 |
32 | public void Initialize()
33 | {
34 | _sessionManager.SetLocalPlayerState("modded", true);
35 | _packetSerializer.RegisterCallback(HandlePlayerData);
36 | _sessionManager.playerConnectedEvent += HandlePlayerConnected;
37 | }
38 |
39 | public void Dispose()
40 | {
41 | _packetSerializer.UnregisterCallback();
42 | }
43 |
44 | private void HandlePlayerConnected(IConnectedPlayer player)
45 | {
46 | _sessionManager.Send(new MpexPlayerData
47 | {
48 | Color = _config.PlayerColor
49 | });
50 | }
51 |
52 | private void HandlePlayerData(MpexPlayerData packet, IConnectedPlayer player)
53 | {
54 | _playerData[player.userId] = packet;
55 | PlayerConnectedEvent(player, packet);
56 | }
57 |
58 | public bool TryGetPlayer(string userId, out MpexPlayerData player)
59 | => _playerData.TryGetValue(userId, out player);
60 |
61 | public MpexPlayerData? GetPlayer(string userId)
62 | => _playerData.ContainsKey(userId) ? _playerData[userId] : null;
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/MultiplayerExtensions/Plugin.cs:
--------------------------------------------------------------------------------
1 | using HarmonyLib;
2 | using IPA;
3 | using IPA.Config.Stores;
4 | using IPA.Loader;
5 | using MultiplayerExtensions.Installers;
6 | using SiraUtil.Zenject;
7 | using IPALogger = IPA.Logging.Logger;
8 | using Conf = IPA.Config.Config;
9 |
10 | namespace MultiplayerExtensions
11 | {
12 | [Plugin(RuntimeOptions.DynamicInit)]
13 | public class Plugin
14 | {
15 | public const string ID = "com.goobwabber.multiplayerextensions";
16 |
17 | internal static IPALogger Logger = null!;
18 | internal static Config Config = null!;
19 |
20 | private readonly Harmony _harmony;
21 | private readonly PluginMetadata _metadata;
22 |
23 | [Init]
24 | public Plugin(IPALogger logger, Conf conf, Zenjector zenjector, PluginMetadata pluginMetadata)
25 | {
26 | Config config = conf.Generated();
27 | _harmony = new Harmony(ID);
28 | _metadata = pluginMetadata;
29 | Logger = logger;
30 | Config = config;
31 |
32 | zenjector.UseMetadataBinder();
33 | zenjector.UseLogger(logger);
34 | zenjector.UseSiraSync(SiraUtil.Web.SiraSync.SiraSyncServiceType.GitHub, "Goobwabber", "MultiplayerExtensions");
35 | zenjector.Install(Location.App, config);
36 | zenjector.Install(Location.Menu);
37 | zenjector.Install();
38 | zenjector.Install(Location.MultiplayerCore);
39 | zenjector.Install(Location.MultiPlayer);
40 | }
41 |
42 | [OnEnable]
43 | public void OnEnable()
44 | {
45 | _harmony.PatchAll(_metadata.Assembly);
46 | }
47 |
48 | [OnDisable]
49 | public void OnDisable()
50 | {
51 | _harmony.UnpatchSelf();
52 | }
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/MultiplayerExtensions/UI/MpexEnvironmentViewController.bsml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/MultiplayerExtensions/UI/MpexEnvironmentViewController.cs:
--------------------------------------------------------------------------------
1 | using BeatSaberMarkupLanguage.Attributes;
2 | using BeatSaberMarkupLanguage.Components.Settings;
3 | using BeatSaberMarkupLanguage.ViewControllers;
4 | using IPA.Utilities;
5 | using Zenject;
6 |
7 | namespace MultiplayerExtensions.UI
8 | {
9 | [ViewDefinition("MultiplayerExtensions.UI.MpexEnvironmentViewController.bsml")]
10 | public class MpexEnvironmentViewController : BSMLAutomaticViewController
11 | {
12 | private FieldAccessor.Accessor _showModifiers
13 | = FieldAccessor.GetAccessor(nameof(_showModifiers));
14 | private FieldAccessor.Accessor _showEnvironmentOverrideSettings
15 | = FieldAccessor.GetAccessor(nameof(_showEnvironmentOverrideSettings));
16 | private FieldAccessor.Accessor _showColorSchemesSettings
17 | = FieldAccessor.GetAccessor(nameof(_showColorSchemesSettings));
18 | private FieldAccessor.Accessor _showMultiplayer
19 | = FieldAccessor.GetAccessor(nameof(_showMultiplayer));
20 |
21 | private GameplaySetupViewController _gameplaySetup = null!;
22 | private Config _config = null!;
23 |
24 | [Inject]
25 | private void Construct(
26 | GameplaySetupViewController gameplaySetup,
27 | Config config)
28 | {
29 | _gameplaySetup = gameplaySetup;
30 | _config = config;
31 | }
32 |
33 | [UIAction("#post-parse")]
34 | private void PostParse()
35 | {
36 | _sideBySideDistanceIncrement.interactable = _sideBySide;
37 | }
38 |
39 | [UIComponent("side-by-side-distance-increment")]
40 | private GenericInteractableSetting _sideBySideDistanceIncrement = null!;
41 |
42 | [UIValue("solo-environment")]
43 | private bool _soloEnvironment
44 | {
45 | get => _config.SoloEnvironment;
46 | set
47 | {
48 | _config.SoloEnvironment = value;
49 | _gameplaySetup.Setup(
50 | _showModifiers(ref _gameplaySetup),
51 | _showEnvironmentOverrideSettings(ref _gameplaySetup),
52 | _showColorSchemesSettings(ref _gameplaySetup),
53 | _showMultiplayer(ref _gameplaySetup),
54 | PlayerSettingsPanelController.PlayerSettingsPanelLayout.Multiplayer
55 | );
56 | NotifyPropertyChanged();
57 | }
58 | }
59 |
60 | [UIValue("side-by-side")]
61 | private bool _sideBySide
62 | {
63 | get => _config.SideBySide;
64 | set
65 | {
66 | _config.SideBySide = value;
67 | if (_sideBySideDistanceIncrement != null)
68 | _sideBySideDistanceIncrement.interactable = value;
69 | NotifyPropertyChanged();
70 | }
71 | }
72 |
73 | [UIValue("side-by-side-distance")]
74 | private float _sideBySideDistance
75 | {
76 | get => _config.SideBySideDistance;
77 | set
78 | {
79 | _config.SideBySideDistance = value;
80 | NotifyPropertyChanged();
81 | }
82 | }
83 | }
84 | }
85 |
--------------------------------------------------------------------------------
/MultiplayerExtensions/UI/MpexGameplaySetup.bsml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/MultiplayerExtensions/UI/MpexGameplaySetup.cs:
--------------------------------------------------------------------------------
1 | using BeatSaberMarkupLanguage;
2 | using BeatSaberMarkupLanguage.Attributes;
3 | using BeatSaberMarkupLanguage.Components;
4 | using HMUI;
5 | using IPA.Utilities;
6 | using SiraUtil.Logging;
7 | using System;
8 | using System.Reflection;
9 | using UnityEngine;
10 | using Zenject;
11 |
12 | namespace MultiplayerExtensions.UI
13 | {
14 | public class MpexGameplaySetup : NotifiableBase, IInitializable, IDisposable
15 | {
16 | public const string ResourcePath = "MultiplayerExtensions.UI.MpexGameplaySetup.bsml";
17 |
18 | private FieldAccessor.Accessor _showModifiers
19 | = FieldAccessor.GetAccessor(nameof(_showModifiers));
20 | private FieldAccessor.Accessor _showEnvironmentOverrideSettings
21 | = FieldAccessor.GetAccessor(nameof(_showEnvironmentOverrideSettings));
22 | private FieldAccessor.Accessor _showColorSchemesSettings
23 | = FieldAccessor.GetAccessor(nameof(_showColorSchemesSettings));
24 | private FieldAccessor.Accessor _showMultiplayer
25 | = FieldAccessor.GetAccessor(nameof(_showMultiplayer));
26 |
27 | private GameplaySetupViewController _gameplaySetup;
28 | private MultiplayerSettingsPanelController _multiplayerSettingsPanel;
29 | private MainFlowCoordinator _mainFlowCoordinator;
30 | private MpexSetupFlowCoordinator _setupFlowCoordinator;
31 | private Config _config;
32 | private SiraLog _logger;
33 |
34 | internal MpexGameplaySetup(
35 | GameplaySetupViewController gameplaySetup,
36 | MainFlowCoordinator mainFlowCoordinator,
37 | MpexSetupFlowCoordinator setupFlowCoordinator,
38 | Config config,
39 | SiraLog logger)
40 | {
41 | _gameplaySetup = gameplaySetup;
42 | _multiplayerSettingsPanel = gameplaySetup.GetField("_multiplayerSettingsPanelController");
43 | _mainFlowCoordinator = mainFlowCoordinator;
44 | _setupFlowCoordinator = setupFlowCoordinator;
45 | _config = config;
46 | _logger = logger;
47 | }
48 |
49 | public void Initialize()
50 | {
51 | BSMLParser.instance.Parse(BeatSaberMarkupLanguage.Utilities.GetResourceContent(Assembly.GetExecutingAssembly(), ResourcePath), _multiplayerSettingsPanel.gameObject, this);
52 | while (0 < _vert.transform.childCount)
53 | _vert.transform.GetChild(0).SetParent(_multiplayerSettingsPanel.transform);
54 | }
55 |
56 | public void Dispose()
57 | {
58 |
59 | }
60 |
61 | [UIAction("preferences-click")]
62 | private void PresentPreferences()
63 | {
64 | FlowCoordinator deepestChildFlowCoordinator = DeepestChildFlowCoordinator(_mainFlowCoordinator);
65 | _setupFlowCoordinator.parentFlowCoordinator = deepestChildFlowCoordinator;
66 | deepestChildFlowCoordinator.PresentFlowCoordinator(_setupFlowCoordinator);
67 | }
68 |
69 | private FlowCoordinator DeepestChildFlowCoordinator(FlowCoordinator root)
70 | {
71 | var flow = root.childFlowCoordinator;
72 | if (flow == null) return root;
73 | if (flow.childFlowCoordinator == null || flow.childFlowCoordinator == flow)
74 | {
75 | return flow;
76 | }
77 | return DeepestChildFlowCoordinator(flow);
78 | }
79 |
80 | [UIObject("vert")]
81 | private GameObject _vert = null!;
82 |
83 | [UIValue("solo-environment")]
84 | private bool _soloEnvironment
85 | {
86 | get => _config.SoloEnvironment;
87 | set
88 | {
89 | _config.SoloEnvironment = value;
90 | _gameplaySetup.Setup(
91 | _showModifiers(ref _gameplaySetup),
92 | _showEnvironmentOverrideSettings(ref _gameplaySetup),
93 | _showColorSchemesSettings(ref _gameplaySetup),
94 | _showMultiplayer(ref _gameplaySetup),
95 | PlayerSettingsPanelController.PlayerSettingsPanelLayout.Multiplayer
96 | );
97 | NotifyPropertyChanged();
98 | }
99 | }
100 | }
101 | }
102 |
--------------------------------------------------------------------------------
/MultiplayerExtensions/UI/MpexMiscViewController.bsml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/MultiplayerExtensions/UI/MpexMiscViewController.cs:
--------------------------------------------------------------------------------
1 | using BeatSaberMarkupLanguage.Attributes;
2 | using BeatSaberMarkupLanguage.ViewControllers;
3 | using Zenject;
4 |
5 | namespace MultiplayerExtensions.UI
6 | {
7 | [ViewDefinition("MultiplayerExtensions.UI.MpexMiscViewController.bsml")]
8 | public class MpexMiscViewController : BSMLAutomaticViewController
9 | {
10 | private Config _config = null!;
11 |
12 | [Inject]
13 | private void Construct(
14 | Config config)
15 | {
16 | _config = config;
17 | }
18 |
19 | [UIValue("disable-avatar-constraints")]
20 | private bool _disableAvatarConstraints
21 | {
22 | get => _config.DisableAvatarConstraints;
23 | set
24 | {
25 | _config.DisableAvatarConstraints = value;
26 | NotifyPropertyChanged();
27 | }
28 | }
29 |
30 | [UIValue("disable-player-colors")]
31 | private bool _disablePlayerColors
32 | {
33 | get => _config.DisableMultiplayerColors;
34 | set
35 | {
36 | _config.DisableMultiplayerColors = value;
37 | NotifyPropertyChanged();
38 | }
39 | }
40 |
41 | [UIValue("disable-platform-movement")]
42 | private bool _disablePlatformMovement
43 | {
44 | get => _config.DisablePlatformMovement;
45 | set
46 | {
47 | _config.DisablePlatformMovement = value;
48 | NotifyPropertyChanged();
49 | }
50 | }
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/MultiplayerExtensions/UI/MpexSettingsViewController.bsml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/MultiplayerExtensions/UI/MpexSettingsViewController.cs:
--------------------------------------------------------------------------------
1 | using BeatSaberMarkupLanguage.Attributes;
2 | using BeatSaberMarkupLanguage.Components.Settings;
3 | using BeatSaberMarkupLanguage.ViewControllers;
4 | using Zenject;
5 |
6 | namespace MultiplayerExtensions.UI
7 | {
8 | [ViewDefinition("MultiplayerExtensions.UI.MpexSettingsViewController.bsml")]
9 | public class MpexSettingsViewController : BSMLAutomaticViewController
10 | {
11 | private Config _config = null!;
12 |
13 | [Inject]
14 | private void Construct(
15 | Config config)
16 | {
17 | _config = config;
18 | }
19 |
20 | [UIAction("#post-parse")]
21 | private void PostParse()
22 | {
23 | _personalMissLightingToggle.interactable = _missLighting;
24 | }
25 |
26 | [UIComponent("personal-miss-lighting-toggle")]
27 | private GenericInteractableSetting _personalMissLightingToggle = null!;
28 |
29 | [UIValue("hide-player-platforms")]
30 | private bool _hidePlayerPlatforms
31 | {
32 | get => _config.DisableMultiplayerPlatforms;
33 | set
34 | {
35 | _config.DisableMultiplayerPlatforms = value;
36 | NotifyPropertyChanged();
37 | }
38 | }
39 |
40 | [UIValue("hide-player-lights")]
41 | private bool _hidePlayerLights
42 | {
43 | get => _config.DisableMultiplayerLights;
44 | set
45 | {
46 | _config.DisableMultiplayerLights = value;
47 | NotifyPropertyChanged();
48 | }
49 | }
50 |
51 | [UIValue("hide-player-objects")]
52 | private bool _hidePlayerObjects
53 | {
54 | get => _config.DisableMultiplayerObjects;
55 | set
56 | {
57 | _config.DisableMultiplayerObjects = value;
58 | NotifyPropertyChanged();
59 | }
60 | }
61 |
62 | [UIValue("miss-lighting")]
63 | private bool _missLighting
64 | {
65 | get => _config.MissLighting;
66 | set
67 | {
68 | _config.MissLighting = value;
69 | if (_personalMissLightingToggle != null)
70 | _personalMissLightingToggle.interactable = value;
71 | NotifyPropertyChanged();
72 | }
73 | }
74 |
75 | [UIValue("personal-miss-lighting-only")]
76 | private bool _personalMissLightingOnly
77 | {
78 | get => _config.PersonalMissLightingOnly;
79 | set
80 | {
81 | _config.PersonalMissLightingOnly = value;
82 | NotifyPropertyChanged();
83 | }
84 | }
85 | }
86 | }
87 |
--------------------------------------------------------------------------------
/MultiplayerExtensions/UI/MpexSetupFlowCoordinator.cs:
--------------------------------------------------------------------------------
1 | using HMUI;
2 | using Zenject;
3 | using BeatSaberMarkupLanguage;
4 | using SiraUtil.Affinity;
5 | using System;
6 |
7 | namespace MultiplayerExtensions.UI
8 | {
9 | public class MpexSetupFlowCoordinator : FlowCoordinator
10 | {
11 | internal FlowCoordinator parentFlowCoordinator = null!;
12 | private MpexSettingsViewController _settingsViewController = null!;
13 | private MpexEnvironmentViewController _environmentViewController = null!;
14 | private MpexMiscViewController _miscViewController = null!;
15 | private ILobbyGameStateController _gameStateController = null!;
16 |
17 | [Inject]
18 | public void Construct(
19 | MainFlowCoordinator mainFlowCoordinator,
20 | MpexSettingsViewController settingsViewController,
21 | MpexEnvironmentViewController environmentViewController,
22 | MpexMiscViewController miscViewController,
23 | ILobbyGameStateController gameStateController)
24 | {
25 | parentFlowCoordinator = mainFlowCoordinator;
26 | _settingsViewController = settingsViewController;
27 | _environmentViewController = environmentViewController;
28 | _miscViewController = miscViewController;
29 | _gameStateController = gameStateController;
30 | }
31 |
32 | protected override void DidActivate(bool firstActivation, bool addedToHierarchy, bool screenSystemEnabling)
33 | {
34 | if (firstActivation)
35 | {
36 | SetTitle("Multiplayer Preferences");
37 | showBackButton = true;
38 | }
39 | if (addedToHierarchy)
40 | {
41 | ProvideInitialViewControllers(_settingsViewController, _environmentViewController, _miscViewController);
42 | _gameStateController.gameStartedEvent += DismissGameStartedEvent;
43 | }
44 | }
45 |
46 | protected override void DidDeactivate(bool removedFromHierarchy, bool screenSystemDisabling)
47 | {
48 | if (removedFromHierarchy)
49 | _gameStateController.gameStartedEvent -= DismissGameStartedEvent;
50 | }
51 |
52 | private void DismissGameStartedEvent(ILevelGameplaySetupData obj)
53 | {
54 | parentFlowCoordinator.DismissFlowCoordinator(this, null, ViewController.AnimationDirection.Horizontal, true);
55 | }
56 |
57 | protected override void BackButtonWasPressed(ViewController topViewController)
58 | {
59 | parentFlowCoordinator.DismissFlowCoordinator(this);
60 | }
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/MultiplayerExtensions/Utilities/ColorConverter.cs:
--------------------------------------------------------------------------------
1 | using IPA.Config.Data;
2 | using IPA.Config.Stores;
3 | using System;
4 | using UnityEngine;
5 |
6 | namespace MultiplayerExtensions.Utilities
7 | {
8 | public class ColorConverter : ValueConverter
9 | {
10 | public override Color FromValue(Value? value, object parent)
11 | {
12 | if (value is not Text text)
13 | throw new ArgumentException("Argument not Text", nameof(value));
14 | if (!ColorUtility.TryParseHtmlString(text.Value, out var color))
15 | throw new ArgumentException("Could not parse HtmlString", nameof(value));
16 | return color;
17 | }
18 |
19 | public override Value? ToValue(Color obj, object parent)
20 | => Value.Text($"#{ColorUtility.ToHtmlStringRGB(obj)}");
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/MultiplayerExtensions/Utilities/SpriteManager.cs:
--------------------------------------------------------------------------------
1 | using SiraUtil.Logging;
2 | using System;
3 | using System.Reflection;
4 | using System.Security.Policy;
5 | using UnityEngine;
6 | using Zenject;
7 |
8 | namespace MultiplayerExtensions.Utilities
9 | {
10 | public class SpriteManager : IInitializable, IDisposable
11 | {
12 | public Sprite IconOculus64 { get; private set; } = null!;
13 | public Sprite IconSteam64 { get; private set; } = null!;
14 | public Sprite IconMeta64 { get; private set; } = null!;
15 | public Sprite IconToaster64 { get; private set; } = null!;
16 |
17 | private readonly SiraLog _logger;
18 |
19 | internal SpriteManager(
20 | SiraLog logger)
21 | {
22 | _logger = logger;
23 | }
24 |
25 | public void Initialize()
26 | {
27 | IconOculus64 = GetSpriteFromResources("MultiplayerExtensions.Assets.IconOculus64.png");
28 | IconSteam64 = GetSpriteFromResources("MultiplayerExtensions.Assets.IconSteam64.png");
29 | IconMeta64 = GetSpriteFromResources("MultiplayerExtensions.Assets.IconMeta64.png");
30 | IconToaster64 = GetSpriteFromResources("MultiplayerExtensions.Assets.IconToaster64.png");
31 | }
32 |
33 | public void Dispose()
34 | {
35 | if (IconOculus64 != null) Sprite.Destroy(IconOculus64);
36 | IconOculus64 = null;
37 | if (IconSteam64 != null) Sprite.Destroy(IconSteam64);
38 | IconSteam64 = null;
39 | if (IconMeta64 != null) Sprite.Destroy(IconMeta64);
40 | IconMeta64 = null;
41 | if (IconToaster64 != null) Sprite.Destroy(IconToaster64);
42 | IconToaster64 = null;
43 | }
44 |
45 | private Sprite GetSpriteFromResources(string resourcePath, float pixelsPerUnit = 10.0f)
46 | {
47 | Sprite? sprite = GetSprite(GetResource(Assembly.GetCallingAssembly(), resourcePath), pixelsPerUnit);
48 | if (sprite == null)
49 | return null!;
50 | sprite.name = resourcePath;
51 | return sprite;
52 | }
53 |
54 | private byte[] GetResource(Assembly asm, string resourceName)
55 | {
56 | System.IO.Stream stream = asm.GetManifestResourceStream(resourceName);
57 | byte[] data = new byte[stream.Length];
58 | stream.Read(data, 0, (int)stream.Length);
59 | return data;
60 | }
61 |
62 | public Sprite? GetSprite(byte[]? data, float pixelsPerUnit = 100.0f, bool returnDefaultOnFail = true)
63 | {
64 | Sprite? ReturnDefault(bool useDefault)
65 | {
66 | return null;
67 | }
68 | try
69 | {
70 | Texture2D texture = new Texture2D(2, 2);
71 | if (data == null || data.Length == 0)
72 | {
73 | //Logger?.Invoke($"data seems to be null or empty.", null);
74 | return ReturnDefault(returnDefaultOnFail);
75 | }
76 | texture.LoadImage(data);
77 | return Sprite.Create(texture, new Rect(0, 0, texture.width, texture.height), new Vector2(0, 0), pixelsPerUnit);
78 | }
79 | catch (Exception ex)
80 | {
81 | _logger.Warn($"Caught unhandled exception {ex.Message}");
82 | return ReturnDefault(returnDefaultOnFail);
83 | }
84 | }
85 | }
86 | }
87 |
--------------------------------------------------------------------------------
/MultiplayerExtensions/manifest.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "https://raw.githubusercontent.com/bsmg/BSIPA-MetadataFileSchema/master/Schema.json",
3 | "id": "MultiplayerExtensions",
4 | "name": "MultiplayerExtensions",
5 | "author": "Goobwabber",
6 | "version": "1.0.3",
7 | "description": "Expands the functionality of Beat Saber Multiplayer.",
8 | "gameVersion": "1.24.0",
9 | "dependsOn": {
10 | "BSIPA": "^4.1.4",
11 | "BeatSaberMarkupLanguage": "^1.5.1",
12 | "SiraUtil": "^3.1.0",
13 | "MultiplayerCore": "^1.0.0"
14 | },
15 | "links": {
16 | "project-home": "https://github.com/Goobwabber/MultiplayerExtensions",
17 | "donate": "https://github.com/Goobwabber/MultiplayerExtensions#donate"
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # MultiplayerExtensions (Steam/PC-Only) [](https://github.com/Goobwabber/MultiplayerExtensions/actions?query=workflow%3ABuild+branch%3Amaster)
2 | A Beat Saber mod which aims to improve the multiplayer experience.
3 |
4 | **THIS MOD DOES NOT ENABLE CUSTOM SONGS.**
5 |
6 | ## Features
7 | * Fancy platform lighting
8 | * Fancy in-game lighting
9 | **Looking for more features, feel free to contribute your own.**
10 |
11 | ## Installation
12 | 1. Ensure you have the [required mods](https://github.com/Goobwabber/MultiplayerExtensions#requirements).
13 | 2. Download the `MultiplayerExtensions` file listed under `Assets` **[Here](https://github.com/Goobwabber/MultiplayerExtensions/releases)**.
14 | * Optionally, you can get a development build by downloading the file listed under `Artifacts` **[Here](https://github.com/Goobwabber/MultiplayerExtensions/actions?query=workflow%3ABuild+branch%3Amaster)** (pick the topmost successful build).
15 | * You must be logged into GitHub to download a development build.
16 | 3. Extract the zip file to your Beat Saber game directory (the one `Beat Saber.exe` is in).
17 | * The `MultiplayerExtensions.dll` (and `MultiplayerExtensions.pdb` if it exists) should end up in your `Plugins` folder (**NOT** the one in `Beat Saber_Data`).
18 | 4. **Optional**: Edit `Beat Saber IPA.json` (in your `UserData` folder) and change `Debug` -> `ShowCallSource` to `true`. This will enable BSIPA to get file and line numbers from the `PDB` file where errors occur, which is very useful when reading the log files. This may have a *slight* impact on performance.
19 |
20 | Lastly, check out [other mods](https://github.com/Goobwabber/MultiplayerExtensions#related-mods) that work well with MultiplayerExtensions!
21 |
22 | ## Requirements
23 | These can be downloaded from [BeatMods](https://beatmods.com/#/mods) or using Mod Assistant. **Do NOT use any of the DLLs in the `Refs` folder, they have been stripped of code and will not work.**
24 | * MultiplayerCore v1.0.0+
25 | * BeatSaberMarkupLanguage v1.5.1+
26 | * SiraUtil 3.0.0+
27 |
28 | ## Reporting Issues
29 | * The best way to report issues is to click on the `Issues` tab at the top of the GitHub page. This allows any contributor to see the problem and attempt to fix it, and others with the same issue can contribute more information. **Please try the troubleshooting steps before reporting the issues listed there. Please only report issues after using the latest build, your problem may have already been fixed.**
30 | * Include in your issue:
31 | * A detailed explanation of your problem (you can also attach videos/screenshots)
32 | * **Important**: The log file from the game session the issue occurred (restarting the game creates a new log file).
33 | * The log file can be found at `Beat Saber\Logs\_latest.log` (`Beat Saber` being the folder `Beat Saber.exe` is in).
34 | * If you ask for help on Discord, at least include your `_latest.log` file in your help request.
35 |
36 | ## Contributing
37 | Anyone can feel free to contribute bug fixes or enhancements to MultiplayerExtensions. GitHub Actions for Pull Requests made from GitHub accounts that don't have direct access to the repository will fail. This is normal because the Action requires a `Secret` to download dependencies.
38 | ### Building
39 | Visual Studio 2019 with the [BeatSaberModdingTools](https://github.com/Zingabopp/BeatSaberModdingTools) extension is the recommended development environment.
40 | 1. Check out the repository
41 | 2. Open `MultiplayerExtensions.sln`
42 | 3. Right-click the `MultiplayerExtensions` project, go to `Beat Saber Modding Tools` -> `Set Beat Saber Directory`
43 | * This assumes you have already set the directory for your Beat Saber game folder in `Extensions` -> `Beat Saber Modding Tools` -> `Settings...`
44 | * If you do not have the BeatSaberModdingTools extension, you will need to manually create a `MultiplayerExtensions.csproj.user` file to set the location of your game install. An example is showing below.
45 | 4. The project should now build.
46 | ### Testing
47 | MultiplayerExtensions and other multiplayer mods may not work without a compatible private server to play on. The only one at this point in time is [BeatTogether](https://github.com/pythonology/BeatTogether), which comes in the form of it's [Master](https://github.com/pythonology/BeatTogether.MasterServer) and [Dedicated](https://github.com/pythonology/BeatTogether.DedicatedServer) servers. If you are looking to update this mod to a newer version, these servers will also need to be up to date and working for that version. You can gain access to their private beta by donating on their [patreon](https://www.patreon.com/BeatTogether). Alternatively, you can set up your own cluster.
48 |
49 | **Example csproj.user File:**
50 | ```xml
51 |
52 |
53 |
54 | Full\Path\To\Beat Saber
55 |
56 |
57 | ```
58 | ## Donate
59 | You can support development of MultiplayerExtensions by donating at the following links:
60 | * https://www.patreon.com/goobwabber
61 | * https://ko-fi.com/goobwabber
62 | * https://ko-fi.com/zingabopp
63 |
64 | ## Related Mods
65 | * [MultiplayerCore](https://github.com/Goobwabber/MultiplayerCore)
66 | * BeatTogether for [PC](https://github.com/pythonology/BeatTogether) or [Quest](https://github.com/pythonology/BeatTogether.Quest)
67 | * [BeatSaberServerBrowser](https://github.com/roydejong/BeatSaberServerBrowser)
68 |
--------------------------------------------------------------------------------