Skip to content

Commit

Permalink
Merge branch 'dev' into kill-initial-sync
Browse files Browse the repository at this point in the history
  • Loading branch information
misternebula committed May 5, 2024
2 parents 6f94c47 + 5b14377 commit 2e7e76a
Show file tree
Hide file tree
Showing 201 changed files with 4,838 additions and 3,085 deletions.
1 change: 0 additions & 1 deletion .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# These are supported funding model platforms

patreon: qsb
custom: ['paypal.me/nebula2056/5', 'paypal.me/johncorby/5']
7 changes: 6 additions & 1 deletion .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
name: Build

on: push
on:
push:
paths-ignore:
- "*.md"
- "LICENSE"
- ".gitignore"

jobs:
build:
Expand Down
11 changes: 8 additions & 3 deletions APITestMod/APITestMod.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ public void Start()
qsbAPI.OnPlayerJoin().AddListener((uint playerId) => ModHelper.Console.WriteLine($"{playerId} joined the game!", MessageType.Success));
qsbAPI.OnPlayerLeave().AddListener((uint playerId) => ModHelper.Console.WriteLine($"{playerId} left the game!", MessageType.Success));
qsbAPI.OnChatMessage().AddListener((string message, uint from) => ModHelper.Console.WriteLine($"Chat message \"{message}\" from {from} ({(from == uint.MaxValue ? "QSB" : qsbAPI.GetPlayerName(from))})"));
qsbAPI.RegisterHandler<string>("apitest-string", MessageHandler);
qsbAPI.RegisterHandler<int>("apitest-int", MessageHandler);
qsbAPI.RegisterHandler<float>("apitest-float", MessageHandler);
button.onClick.AddListener(() =>
{
Expand All @@ -42,16 +47,16 @@ public void Start()
ModHelper.Console.WriteLine($"Retreiving custom data : {qsbAPI.GetCustomData<string>(qsbAPI.GetLocalPlayerID(), "APITEST.TESTSTRING")}");
ModHelper.Console.WriteLine("Sending string message test...");
qsbAPI.RegisterHandler<string>("apitest-string", MessageHandler);
qsbAPI.SendMessage("apitest-string", "STRING MESSAGE", receiveLocally: true);
ModHelper.Console.WriteLine("Sending int message test...");
qsbAPI.RegisterHandler<int>("apitest-int", MessageHandler);
qsbAPI.SendMessage("apitest-int", 123, receiveLocally: true);
ModHelper.Console.WriteLine("Sending float message test...");
qsbAPI.RegisterHandler<float>("apitest-float", MessageHandler);
qsbAPI.SendMessage("apitest-float", 3.14f, receiveLocally: true);
qsbAPI.SendChatMessage("Non-system chat message", false, Color.white);
qsbAPI.SendChatMessage("System chat message", true, Color.cyan);
});
};
}
Expand Down
4 changes: 2 additions & 2 deletions APITestMod/APITestMod.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="OuterWildsGameLibs" Version="1.1.13.457" IncludeAssets="compile" />
<PackageReference Include="OWML" Version="2.9.5" IncludeAssets="compile" />
<PackageReference Include="OuterWildsGameLibs" Version="1.1.14.768" IncludeAssets="compile" />
<PackageReference Include="OWML" Version="2.11.1" IncludeAssets="compile" />
</ItemGroup>

<ItemGroup>
Expand Down
52 changes: 49 additions & 3 deletions APITestMod/IQSBAPI.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,31 @@
using System;
using OWML.Common;
using UnityEngine;
using UnityEngine.Events;

public interface IQSBAPI
{
#region General

/// <summary>
/// If called, all players connected to YOUR hosted game must have this mod installed.
/// </summary>
void RegisterRequiredForAllPlayers(IModBehaviour mod);

/// <summary>
/// Returns if the current player is the host.
/// </summary>
bool GetIsHost();

/// <summary>
/// Returns if the current player is in multiplayer.
/// </summary>
bool GetIsInMultiplayer();

#endregion

#region Player

/// <summary>
/// Returns the player ID of the current player.
/// </summary>
Expand All @@ -22,23 +39,25 @@ public interface IQSBAPI

/// <summary>
/// Returns the list of IDs of all connected players.
///
/// The first player in the list is the host.
/// </summary>
uint[] GetPlayerIDs();

/// <summary>
/// Invoked when a player joins the game.
/// Invoked when any player (local or remote) joins the game.
/// </summary>
UnityEvent<uint> OnPlayerJoin();

/// <summary>
/// Invoked when a player leaves the game.
/// Invoked when any player (local or remote) leaves the game.
/// </summary>
UnityEvent<uint> OnPlayerLeave();

/// <summary>
/// Sets some arbitrary data for a given player.
/// </summary>
/// <typeparam name="T">The type of the data.</typeparam>
/// <typeparam name="T">The type of the data. If not serializable, data will not be synced.</typeparam>
/// <param name="playerId">The ID of the player.</param>
/// <param name="key">The unique key to access this data by.</param>
/// <param name="data">The data to set.</param>
Expand All @@ -53,8 +72,14 @@ public interface IQSBAPI
/// <returns>The data requested. If key is not valid, returns default.</returns>
T GetCustomData<T>(uint playerId, string key);

#endregion

#region Messaging

/// <summary>
/// Sends a message containing arbitrary data to every player.
///
/// Keep your messages under around 1100 bytes.
/// </summary>
/// <typeparam name="T">The type of the data being sent. This type must be serializable.</typeparam>
/// <param name="messageType">The unique key of the message.</param>
Expand All @@ -70,4 +95,25 @@ public interface IQSBAPI
/// <param name="messageType">The unique key of the message.</param>
/// <param name="handler">The action to be ran when the message is received. The uint is the player ID that sent the messsage.</param>
void RegisterHandler<T>(string messageType, Action<uint, T> handler);

#endregion

#region Chat

/// <summary>
/// Invoked when a chat message is received.
/// The string is the message body.
/// The uint is the player who sent the message. If it's a system message, this is uint.MaxValue.
/// </summary>
UnityEvent<string, uint> OnChatMessage();

/// <summary>
/// Sends a message in chat.
/// </summary>
/// <param name="message">The text of the message.</param>
/// <param name="systemMessage">If false, the message is sent as if the local player wrote it manually. If true, the message has no player attached to it, like the player join messages.</param>
/// <param name="color">The color of the message.</param>
void SendChatMessage(string message, bool systemMessage, Color color);

#endregion
}
2 changes: 1 addition & 1 deletion APITestMod/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
"name": "QSB API Test Mod",
"uniqueName": "_nebula.QSBAPITest",
"version": "1.0.0",
"owmlVersion": "2.9.5",
"owmlVersion": "2.11.1",
"dependencies": [ "Raicuparta.QuantumSpaceBuddies", "_nebula.MenuFramework" ]
}
Binary file added Asset Source Files/player-simulation-model.blend
Binary file not shown.
38 changes: 22 additions & 16 deletions DEVELOPMENT.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
> :warning: Warning! :warning:
Mod development needs a powerful PC!
Unexpected errors and issues may occur when editing networking code.
Running multiple instances of the game can be very taxing on your computer.
We're not responsible if you push your PC too hard.
> [!WARNING]
> Mod development needs a powerful PC!\
> Unexpected errors and issues may occur when editing networking code.\
> Running multiple instances of the game can be very taxing on your computer.\
> We're not responsible if you push your PC too hard.
## Prerequisites
- Visual Studio 2022.
Expand All @@ -19,12 +19,12 @@ We recommend using the Outer Wilds Mod Manager, but you can use OWML on its own
- New Manager : Press the "..." button at the top, and select "Show OWML Folder".
- `QSB.sln` should now be ready to open. ***This solution needs to be opened with Visual Studio 2022 or higher!***

## Steam
## Multiple instances on Steam
If using the Steam version of Outer Wilds, you will need to create a file to allow you to run multiple instances of the game.
- Navigate to your game install folder. You can find this by right-clicking on the game in Steam, and going `Manage > Browse local files`.
- Create a file named `steam_appid.txt`.
- In this file, write `753640` and save.
This file will override some Steam DRM features and allow the game to be ran multiple times at once.
- In this file, write `753640` and save. This file will override some Steam DRM features and allow the game to be ran multiple times at once.
- Either turn on "Force Exe" in the mod manager, or run OuterWilds.exe directly.

## Building
Simply build the solution normally. (`Build > Build Solution` or CTRL-SHIFT-B)
Expand All @@ -48,54 +48,60 @@ Use the API by copying [the API definition](https://github.com/misternebula/quan
## Debugging
### Debug Actions :

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

Hold Q and press :

- Numpad 1 - Teleport to nearest player.
- Numpad 2 - If holding LeftShift, warp to the dreamworld Vault fire. If not, warp to the Endless Canyon.
- Numpad 2 - If holding LeftShift, warp to the dreamworld Vault fire. If not, warp to the Endless Canyon. If already in dreamworld, pick up lantern.
- Numpad 3 - Unlock the Sealed Vault.
- Numpad 4 - Damage the ship's electrical system.
- Numpad 5 - Trigger the supernova.
- Numpad 6 - Set the flags for having met Solanum and the Prisoner.
- Numpad 7 - Warp to the Vessel.
- Numpad 8 - Insert the Advanced Warp Core into the Vessel.
- Numpad 7 - Warp to the Vessel and insert the warp core.
- Numpad 8 - Spawn a fake player. For Ghostbuster testing.
- Numpad 9 - If holding LeftShift, load the SolarSystem scene. If not, load the EyeOfTheUniverse scene.
- Numpad 0 - Revive a random dead player.

### Debug Settings :

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

```json
{
"dumpWorldObjects": false,
"instanceIdInLogs": false,
"hookDebugLogs": false,
"avoidTimeSync": false,
"autoStart": false,
"kickEveryone": false,
"disableLoopDeath": false,
"timeout": 25,
"debugMode": false,
"drawGui": false,
"drawLines": false,
"drawLabels": false,
"drawQuantumVisibilityObjects": false,
"drawGhostAI": false,
"greySkybox": false
}
```

- dumpWorldObjects - Creates a file with information about the WorldObjects that were created.
- instanceIdInLogs - Appends the game instance id to every log message sent.
- hookDebugLogs - Print Unity logs and warnings.
- avoidTimeSync - Disables the syncing of time.
- autoStart - Host/connect automatically for faster testing.
- kickEveryone - Kick anyone who joins a game.
- disableLoopDeath - Make it so the loop doesn't end when everyone is dead.
- timeout - How many seconds for your connection to timeout, in seconds.
- debugMode - Enables debug mode. If this is set to `false`, none of the following settings do anything.
- drawGui - Draws a GUI at the top of the screen that gives information on many things.
- drawLines - Draws gizmo-esque lines around things. Indicates reference sectors/transforms, triggers, etc. LAGGY.
- drawLabels - Draws GUI labels attached to some objects. LAGGY.
- drawQuantumVisibilityObjects - Indicates visibility objects with an orange shape.
- drawGhostAI - Draws debug lines and labels just for the ghosts.
- greySkybox - Turns the skybox grey. Useful in the Eye, where it's pretty dark.
3 changes: 1 addition & 2 deletions DevEnv.template.targets
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Project>
<PropertyGroup>
<OwmlDir>$(AppData)\OuterWildsModManager\OWML</OwmlDir>
<UnityAssetsDir>$(SolutionDir)\qsb-unityproject\Assets</UnityAssetsDir>
Expand Down
5 changes: 2 additions & 3 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,11 @@

<PropertyGroup Label="Common Properties">
<TargetFramework>net48</TargetFramework>
<LangVersion>default</LangVersion>
<LangVersion>latest</LangVersion>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath>
<Company>Henry Pointer, Aleksander Waage, Ricardo Lopes</Company>
<Copyright>Copyright © Henry Pointer, Aleksander Waage, Ricardo Lopes 2020-2021</Copyright>
<NoWarn>MSB3270</NoWarn>
</PropertyGroup>

<PropertyGroup Label="Default Locations" Condition="!Exists('$(DevEnvLoc)')">
Expand Down
Loading

0 comments on commit 2e7e76a

Please sign in to comment.