Skip to content

Commit d37787b

Browse files
authored
Merge pull request #678 from qsb-dev/dev
Version 1.1.0
2 parents 5cfaf77 + 40c2c22 commit d37787b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+477
-135
lines changed

APITestMod/APITestMod.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
</PropertyGroup>
1010

1111
<ItemGroup>
12-
<PackageReference Include="OuterWildsGameLibs" Version="1.1.13.457" IncludeAssets="compile" />
13-
<PackageReference Include="OWML" Version="2.9.7" IncludeAssets="compile" />
12+
<PackageReference Include="OuterWildsGameLibs" Version="1.1.14.768" IncludeAssets="compile" />
13+
<PackageReference Include="OWML" Version="2.11.1" IncludeAssets="compile" />
1414
</ItemGroup>
1515

1616
<ItemGroup>

APITestMod/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@
44
"name": "QSB API Test Mod",
55
"uniqueName": "_nebula.QSBAPITest",
66
"version": "1.0.0",
7-
"owmlVersion": "2.9.7",
7+
"owmlVersion": "2.11.1",
88
"dependencies": [ "Raicuparta.QuantumSpaceBuddies", "_nebula.MenuFramework" ]
99
}

DEVELOPMENT.md

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
> :warning: Warning! :warning:
2-
Mod development needs a powerful PC!
3-
Unexpected errors and issues may occur when editing networking code.
4-
Running multiple instances of the game can be very taxing on your computer.
5-
We're not responsible if you push your PC too hard.
1+
> [!WARNING]
2+
> Mod development needs a powerful PC!\
3+
> Unexpected errors and issues may occur when editing networking code.\
4+
> Running multiple instances of the game can be very taxing on your computer.\
5+
> We're not responsible if you push your PC too hard.
66
77
## Prerequisites
88
- Visual Studio 2022.
@@ -48,6 +48,9 @@ Use the API by copying [the API definition](https://github.com/misternebula/quan
4848
## Debugging
4949
### Debug Actions :
5050

51+
> [!NOTE]
52+
> this list is slightly outdated. it will be updated when debug settings are updated
53+
5154
Press Q + Numpad Enter to toggle debug mode in game (corresponds with the debug setting "debugMode" in the section below).
5255

5356
Hold Q and press :
@@ -65,6 +68,9 @@ Hold Q and press :
6568

6669
### Debug Settings :
6770

71+
> [!NOTE]
72+
> this list is slightly outdated because it will be replaced by mod options at some point
73+
6874
Create a file called `debugsettings.json` in the QSB folder.
6975
The template for this file is this :
7076

FizzySteamworks/FizzySteamworks.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
</None>
1818
</ItemGroup>
1919
<ItemGroup>
20-
<PackageReference Include="OuterWildsGameLibs" Version="1.1.13.457" IncludeAssets="compile" />
20+
<PackageReference Include="OuterWildsGameLibs" Version="1.1.14.768" IncludeAssets="compile" />
2121
<Reference Include="..\Lib\*.dll" />
2222
</ItemGroup>
2323
</Project>

MirrorWeaver/MirrorWeaver.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
</None>
1818
</ItemGroup>
1919
<ItemGroup>
20-
<PackageReference Include="OuterWildsGameLibs" Version="1.1.13.457" />
21-
<PackageReference Include="OWML" Version="2.9.7" />
20+
<PackageReference Include="OuterWildsGameLibs" Version="1.1.14.768" />
21+
<PackageReference Include="OWML" Version="2.11.1" />
2222
<Reference Include="..\Lib\*.dll" />
2323
</ItemGroup>
2424
</Project>
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
using HarmonyLib;
7+
using Mirror;
8+
using NewHorizons;
9+
using QSB;
10+
using QSB.Patches;
11+
using QSB.Player;
12+
using QSB.SaveSync.Messages;
13+
using QSB.Utility;
14+
15+
namespace QSBNH.Patches;
16+
17+
18+
/// <summary>
19+
/// extremely jank way to inject system and NH addons when joining.
20+
/// this should probably be split into its own separate message, but it doesnt really matter :P
21+
///
22+
/// BUG: completely explodes if one person has NH and the other does not
23+
/// </summary>
24+
internal class GameStateMessagePatches : QSBPatch
25+
{
26+
public override QSBPatchTypes Type => QSBPatchTypes.OnModStart;
27+
28+
private static string _initialSystem;
29+
private static int[] _hostAddonHash;
30+
31+
[HarmonyPostfix]
32+
[HarmonyPatch(typeof(GameStateMessage), nameof(GameStateMessage.Serialize))]
33+
public static void GameStateMessage_Serialize(GameStateMessage __instance, NetworkWriter writer)
34+
{
35+
var currentSystem = QSBNH.Instance.NewHorizonsAPI.GetCurrentStarSystem();
36+
37+
writer.Write(currentSystem);
38+
writer.WriteArray(QSBNH.HashAddonsForSystem(currentSystem));
39+
}
40+
41+
[HarmonyPostfix]
42+
[HarmonyPatch(typeof(GameStateMessage), nameof(GameStateMessage.Deserialize))]
43+
public static void GameStateMessage_Deserialize(GameStateMessage __instance, NetworkReader reader)
44+
{
45+
_initialSystem = reader.Read<string>();
46+
_hostAddonHash = reader.ReadArray<int>();
47+
}
48+
49+
[HarmonyPostfix]
50+
[HarmonyPatch(typeof(GameStateMessage), nameof(GameStateMessage.OnReceiveRemote))]
51+
public static void GameStateMessage_OnReceiveRemote()
52+
{
53+
if (QSBCore.IsHost)
54+
{
55+
DebugLog.DebugWrite($"Why is the host being given the initial state info?");
56+
}
57+
else
58+
{
59+
DebugLog.DebugWrite($"Player#{QSBPlayerManager.LocalPlayerId} is being sent to {_initialSystem}");
60+
61+
WarpManager.RemoteChangeStarSystem(_initialSystem, false, false, _hostAddonHash);
62+
}
63+
}
64+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
using HarmonyLib;
2+
using NewHorizons.External;
3+
using QSB;
4+
using QSB.Patches;
5+
using QSB.SaveSync;
6+
using QSB.Utility;
7+
8+
namespace QSBNH.Patches;
9+
10+
/// <summary>
11+
/// pretends to be a new profile when in multiplayer so NH saves its data to a new place
12+
/// </summary>
13+
public class NewHorizonsDataPatches : QSBPatch
14+
{
15+
public override QSBPatchTypes Type => QSBPatchTypes.OnModStart;
16+
17+
[HarmonyPrefix]
18+
[HarmonyPatch(typeof(NewHorizonsData), nameof(NewHorizonsData.GetProfileName))]
19+
public static bool NewHorizonsData_GetProfileName(out string __result)
20+
{
21+
if (QSBCore.IsInMultiplayer)
22+
{
23+
__result = QSBStandaloneProfileManager.SharedInstance?.currentProfile?.profileName + "_mult";
24+
DebugLog.DebugWrite($"using fake multiplayer profile {__result} for NH");
25+
}
26+
else
27+
{
28+
__result = QSBStandaloneProfileManager.SharedInstance?.currentProfile?.profileName;
29+
}
30+
31+
return false;
32+
}
33+
}

QSB-NH/QSB-NH.csproj

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net48</TargetFramework>
5+
<RootNamespace>QSBNH</RootNamespace>
6+
<ImplicitUsings>enable</ImplicitUsings>
7+
<OutputPath Condition="Exists('$(OwmlDir)')">$(OwmlDir)\Mods\Raicuparta.QuantumSpaceBuddies</OutputPath>
8+
<NoWarn>CS1998;CS0649</NoWarn>
9+
</PropertyGroup>
10+
11+
<ItemGroup>
12+
<Folder Include="lib\" />
13+
</ItemGroup>
14+
15+
<ItemGroup>
16+
<ProjectReference Include="..\QSB\QSB.csproj" />
17+
</ItemGroup>
18+
19+
<ItemGroup>
20+
<Reference Include="Mirror">
21+
<HintPath>..\Lib\Mirror.dll</HintPath>
22+
</Reference>
23+
<Reference Include="NewHorizons">
24+
<HintPath>lib\NewHorizons.dll</HintPath>
25+
<Private>false</Private>
26+
</Reference>
27+
<Reference Include="UniTask">
28+
<HintPath>..\Lib\UniTask.dll</HintPath>
29+
</Reference>
30+
</ItemGroup>
31+
32+
</Project>

QSB-NH/QSBNH.cs

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
using Mirror;
2+
using NewHorizons;
3+
using OWML.Common;
4+
using OWML.ModHelper;
5+
using QSB;
6+
using QSB.Utility;
7+
using UnityEngine;
8+
9+
namespace QSBNH
10+
{
11+
public class QSBNH : MonoBehaviour
12+
{
13+
public static QSBNH Instance;
14+
15+
public INewHorizons NewHorizonsAPI;
16+
17+
private void Start()
18+
{
19+
Instance = this;
20+
DebugLog.DebugWrite($"Start of QSB-NH compatibility code.", MessageType.Success);
21+
NewHorizonsAPI = QSBCore.Helper.Interaction.TryGetModApi<INewHorizons>("xen.NewHorizons");
22+
}
23+
24+
public static string HashToMod(int hash)
25+
{
26+
foreach (var mod in NewHorizons.Main.MountedAddons)
27+
{
28+
var name = mod.ModHelper.Manifest.UniqueName;
29+
if (name.GetStableHashCode() == hash)
30+
{
31+
return name;
32+
}
33+
}
34+
35+
return null;
36+
}
37+
38+
public static int[] HashAddonsForSystem(string system)
39+
{
40+
if (NewHorizons.Main.BodyDict.TryGetValue(system, out var bodies))
41+
{
42+
var addonHashes = bodies
43+
.Where(x => x.Mod.ModHelper.Manifest.UniqueName != "xen.NewHorizons")
44+
.Select(x => x.Mod.ModHelper.Manifest.UniqueName.GetStableHashCode())
45+
.Distinct();
46+
47+
var nhPlanetHashes = bodies
48+
.Where(x => x.Mod.ModHelper.Manifest.UniqueName == "xen.NewHorizons")
49+
.Select(x => x.Config.name.GetStableHashCode());
50+
51+
return addonHashes.Concat(nhPlanetHashes).ToArray();
52+
}
53+
else
54+
{
55+
return null;
56+
}
57+
}
58+
}
59+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
using Cysharp.Threading.Tasks;
2+
using QSB.WorldSync;
3+
using QSBNH.QuantumPlanet.WorldObjects;
4+
5+
namespace QSBNH.QuantumPlanet;
6+
public class QuantumPlanetManager : WorldObjectManager
7+
{
8+
public override WorldObjectScene WorldObjectScene => WorldObjectScene.Both;
9+
public override bool DlcOnly => false;
10+
11+
public override async UniTask BuildWorldObjects(OWScene scene, CancellationToken ct) =>
12+
QSBWorldSync.Init<QSBQuantumPlanet, NewHorizons.Components.Quantum.QuantumPlanet>();
13+
}

0 commit comments

Comments
 (0)