Skip to content

Commit 052d8f8

Browse files
authored
Merge pull request #647 from qsb-dev/dev
1.0.0
2 parents e0e8e7e + 206b01d commit 052d8f8

File tree

92 files changed

+1721
-562
lines changed

Some content is hidden

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

92 files changed

+1721
-562
lines changed

.github/FUNDING.yml

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
# These are supported funding model platforms
22

3-
patreon: qsb
43
custom: ['paypal.me/nebula2056/5', 'paypal.me/johncorby/5']
1.15 MB
Binary file not shown.

DEVELOPMENT.md

-4
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ The template for this file is this :
7070

7171
```json
7272
{
73-
"dumpWorldObjects": false,
7473
"instanceIdInLogs": false,
7574
"hookDebugLogs": false,
7675
"avoidTimeSync": false,
@@ -81,13 +80,11 @@ The template for this file is this :
8180
"drawGui": false,
8281
"drawLines": false,
8382
"drawLabels": false,
84-
"drawQuantumVisibilityObjects": false,
8583
"drawGhostAI": false,
8684
"greySkybox": false
8785
}
8886
```
8987

90-
- dumpWorldObjects - Creates a file with information about the WorldObjects that were created.
9188
- instanceIdInLogs - Appends the game instance id to every log message sent.
9289
- hookDebugLogs - Print Unity logs and warnings.
9390
- avoidTimeSync - Disables the syncing of time.
@@ -98,6 +95,5 @@ The template for this file is this :
9895
- drawGui - Draws a GUI at the top of the screen that gives information on many things.
9996
- drawLines - Draws gizmo-esque lines around things. Indicates reference sectors/transforms, triggers, etc. LAGGY.
10097
- drawLabels - Draws GUI labels attached to some objects. LAGGY.
101-
- drawQuantumVisibilityObjects - Indicates visibility objects with an orange shape.
10298
- drawGhostAI - Draws debug lines and labels just for the ghosts.
10399
- greySkybox - Turns the skybox grey. Useful in the Eye, where it's pretty dark.

QSB.sln

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
99
ProjectSection(SolutionItems) = preProject
1010
.gitignore = .gitignore
1111
DEVELOPMENT.md = DEVELOPMENT.md
12+
.github\FUNDING.yml = .github\FUNDING.yml
1213
LICENSE = LICENSE
1314
README.md = README.md
1415
TRANSLATING.md = TRANSLATING.md
@@ -31,7 +32,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Mirror", "Mirror", "{851AB4
3132
EndProject
3233
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "APITestMod", "APITestMod\APITestMod.csproj", "{0A10143E-6C00-409B-B3A5-C54C1B01599D}"
3334
EndProject
34-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "QSBPatcher", "QSBPatcher\QSBPatcher.csproj", "{CA4CBA2B-54D5-4C4B-9B51-957BC6D77D6B}"
35+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "QSBPatcher", "QSBPatcher\QSBPatcher.csproj", "{CA4CBA2B-54D5-4C4B-9B51-957BC6D77D6B}"
3536
EndProject
3637
Global
3738
GlobalSection(SolutionConfigurationPlatforms) = preSolution

QSB.sln.DotSettings

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/CASE_BLOCK_BRACES/@EntryValue">NEXT_LINE_SHIFTED_2</s:String>
1111
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=API/@EntryIndexedValue">API</s:String>
1212
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=ID/@EntryIndexedValue">ID</s:String>
13+
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=OW/@EntryIndexedValue">OW</s:String>
1314
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=QSB/@EntryIndexedValue">QSB</s:String>
1415
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=UWP/@EntryIndexedValue">UWP</s:String>
1516
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpKeepExistingMigration/@EntryIndexedValue">True</s:Boolean>

QSB/API/IQSBAPI.cs

+24
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,30 @@ public interface IQSBAPI
3737
/// <param name="playerID">The ID of the player you want the name of.</param>
3838
string GetPlayerName(uint playerID);
3939

40+
/// <summary>
41+
/// Returns the body object of a given player. The pivot of this object is at the player's feet.
42+
/// </summary>
43+
/// <param name="playerID">The ID of the player you want the body of.</param>
44+
GameObject GetPlayerBody(uint playerID);
45+
46+
/// <summary>
47+
/// Returns the camera object of a given player. The pivot of this object is at the player's point of view.
48+
/// </summary>
49+
/// <param name="playerID">The ID of the player you want the camera of.</param>
50+
GameObject GetPlayerCamera(uint playerID);
51+
52+
/// <summary>
53+
/// Returns true if a given player has fully loaded into the game. If the local player is still loading into the game, this will return false.
54+
/// </summary>
55+
/// <param name="playerID">The ID of the player.</param>
56+
bool GetPlayerReady(uint playerID);
57+
58+
/// <summary>
59+
/// Returns true if the given player is dead.
60+
/// </summary>
61+
/// <param name="playerID">The ID of the player.</param>
62+
bool GetPlayerDead(uint playerID);
63+
4064
/// <summary>
4165
/// Returns the list of IDs of all connected players.
4266
///

QSB/API/QSBAPI.cs

+15
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,21 @@ public void RegisterRequiredForAllPlayers(IModBehaviour mod)
2525

2626
public uint GetLocalPlayerID() => QSBPlayerManager.LocalPlayerId;
2727
public string GetPlayerName(uint playerId) => QSBPlayerManager.GetPlayer(playerId).Name;
28+
public GameObject GetPlayerBody(uint playerId) => QSBPlayerManager.GetPlayer(playerId).Body;
29+
public GameObject GetPlayerCamera(uint playerId) => QSBPlayerManager.GetPlayer(playerId).CameraBody;
30+
31+
public bool GetPlayerReady(uint playerId)
32+
{
33+
var player = QSBPlayerManager.GetPlayer(playerId);
34+
return player.IsReady && player.Body != null;
35+
}
36+
37+
public bool GetPlayerDead(uint playerId)
38+
{
39+
var player = QSBPlayerManager.GetPlayer(playerId);
40+
return player.IsDead;
41+
}
42+
2843
public uint[] GetPlayerIDs() => QSBPlayerManager.PlayerList.Select(x => x.PlayerId).ToArray();
2944

3045
public UnityEvent<uint> OnPlayerJoin() => QSBAPIEvents.OnPlayerJoinEvent;

QSB/Animation/Player/AnimationSync.cs

+14-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
using QSB.Messaging;
77
using QSB.Player;
88
using QSB.Utility;
9-
using QSB.WorldSync;
9+
using QSB.WorldSync.Messages;
1010
using System;
1111
using UnityEngine;
1212

@@ -34,7 +34,11 @@ protected void Awake()
3434
RequestInitialStatesMessage.SendInitialState += SendInitialState;
3535
}
3636

37-
protected void OnDestroy() => RequestInitialStatesMessage.SendInitialState -= SendInitialState;
37+
protected void OnDestroy()
38+
{
39+
RequestInitialStatesMessage.SendInitialState -= SendInitialState;
40+
GlobalMessenger.RemoveListener("EnableBigHeadMode", new Callback(OnEnableBigHeadMode));
41+
}
3842

3943
/// <summary>
4044
/// This wipes the NetworkAnimator's fields, so it assumes the parameters have changed.
@@ -98,6 +102,8 @@ public void InitRemote(Transform body)
98102

99103
Delay.RunWhen(() => Player.CameraBody != null,
100104
() => body.GetComponent<PlayerHeadRotationSync>().Init(Player.CameraBody.transform));
105+
106+
GlobalMessenger.AddListener("EnableBigHeadMode", new Callback(OnEnableBigHeadMode));
101107
}
102108

103109
private void InitAccelerationSync()
@@ -107,6 +113,12 @@ private void InitAccelerationSync()
107113
Player.JetpackAcceleration.Init(thrusterModel);
108114
}
109115

116+
private void OnEnableBigHeadMode()
117+
{
118+
var bone = VisibleAnimator.GetBoneTransform(HumanBodyBones.Head);
119+
bone.localScale = new Vector3(2.5f, 2.5f, 2.5f);
120+
}
121+
110122
public void SetSuitState(bool suitedUp)
111123
{
112124
if (!Player.IsReady)
+95
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
using OWML.Common;
2+
using QSB.PlayerBodySetup.Remote;
3+
using QSB.Utility;
4+
using UnityEngine;
5+
6+
namespace QSB.Animation.Player;
7+
8+
[UsedInUnityProject]
9+
public class HelmetAnimator : MonoBehaviour
10+
{
11+
public Transform FakeHelmet;
12+
public Transform FakeHead;
13+
public GameObject SuitGroup;
14+
15+
private QSBDitheringAnimator _fakeHelmetDitheringAnimator;
16+
17+
private const float ANIM_TIME = 0.5f;
18+
private bool _isPuttingOnHelmet;
19+
private bool _isTakingOffHelmet;
20+
21+
public void Start()
22+
{
23+
_fakeHelmetDitheringAnimator = FakeHelmet.GetComponent<QSBDitheringAnimator>();
24+
25+
FakeHead.gameObject.SetActive(false);
26+
}
27+
28+
public void RemoveHelmet()
29+
{
30+
if (!SuitGroup.activeSelf)
31+
{
32+
DebugLog.DebugWrite($"Trying to remove helmet when player is not wearing suit!", MessageType.Error);
33+
return;
34+
}
35+
36+
_fakeHelmetDitheringAnimator.SetVisible(true);
37+
FakeHelmet.gameObject.SetActive(true);
38+
FakeHead.gameObject.SetActive(true);
39+
_fakeHelmetDitheringAnimator.SetVisible(false, ANIM_TIME);
40+
_isTakingOffHelmet = true;
41+
}
42+
43+
public void PutOnHelmet()
44+
{
45+
if (!SuitGroup.activeSelf)
46+
{
47+
DebugLog.DebugWrite($"Trying to put on helmet when player is not wearing suit!", MessageType.Error);
48+
return;
49+
}
50+
51+
_fakeHelmetDitheringAnimator.SetVisible(false);
52+
FakeHead.gameObject.SetActive(true);
53+
FakeHelmet.gameObject.SetActive(true);
54+
_fakeHelmetDitheringAnimator.SetVisible(true, ANIM_TIME);
55+
_isPuttingOnHelmet = true;
56+
}
57+
58+
public void SetHelmetInstant(bool helmetOn)
59+
{
60+
if (helmetOn)
61+
{
62+
FakeHelmet.gameObject.SetActive(true);
63+
_fakeHelmetDitheringAnimator.SetVisible(true);
64+
FakeHead.gameObject.SetActive(false);
65+
}
66+
else
67+
{
68+
_fakeHelmetDitheringAnimator.SetVisible(false);
69+
FakeHelmet.gameObject.SetActive(false);
70+
if (!SuitGroup.activeSelf)
71+
{
72+
FakeHead.gameObject.SetActive(false);
73+
}
74+
}
75+
}
76+
77+
private void Update()
78+
{
79+
if (_isPuttingOnHelmet && _fakeHelmetDitheringAnimator.FullyVisible)
80+
{
81+
_isPuttingOnHelmet = false;
82+
FakeHead.gameObject.SetActive(false);
83+
}
84+
85+
if (_isTakingOffHelmet && _fakeHelmetDitheringAnimator.FullyInvisible)
86+
{
87+
FakeHelmet.gameObject.SetActive(false);
88+
89+
if (!SuitGroup.activeSelf)
90+
{
91+
FakeHead.gameObject.SetActive(false);
92+
}
93+
}
94+
}
95+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
using QSB.Messaging;
2+
using QSB.Player.TransformSync;
3+
using QSB.WorldSync;
4+
using QSB.Player;
5+
6+
namespace QSB.Animation.Player.Messages;
7+
8+
public class PlayerHelmetMessage : QSBMessage<bool>
9+
{
10+
static PlayerHelmetMessage()
11+
{
12+
GlobalMessenger.AddListener(OWEvents.PutOnHelmet, () => Handle(true));
13+
GlobalMessenger.AddListener(OWEvents.RemoveHelmet, () => Handle(false));
14+
}
15+
16+
private static void Handle(bool on)
17+
{
18+
if (PlayerTransformSync.LocalInstance)
19+
{
20+
new PlayerHelmetMessage(on).Send();
21+
}
22+
}
23+
24+
public PlayerHelmetMessage(bool on) : base(on) { }
25+
26+
public override bool ShouldReceive => QSBWorldSync.AllObjectsReady;
27+
28+
public override void OnReceiveRemote()
29+
{
30+
var player = QSBPlayerManager.GetPlayer(From);
31+
var animator = player.HelmetAnimator;
32+
if (Data)
33+
{
34+
animator.PutOnHelmet();
35+
player.AudioController.PlayWearHelmet();
36+
}
37+
else
38+
{
39+
animator.RemoveHelmet();
40+
player.AudioController.PlayRemoveHelmet();
41+
}
42+
}
43+
}

QSB/AssetBundles/qsb_debug

-7.18 KB
Binary file not shown.

QSB/AssetBundles/qsb_hud

-411 Bytes
Binary file not shown.

QSB/AssetBundles/qsb_network

35.3 KB
Binary file not shown.

QSB/AssetBundles/qsb_network_big

172 KB
Binary file not shown.

QSB/AssetBundles/qsb_skins

30.7 MB
Binary file not shown.

QSB/Audio/QSBPlayerAudioController.cs

+21-11
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,20 @@ public class QSBPlayerAudioController : MonoBehaviour
1212
public OWAudioSource _damageAudioSource;
1313

1414
private AudioManager _audioManager;
15+
private float _playWearHelmetTime;
1516

1617
public void Start()
1718
{
1819
_audioManager = Locator.GetAudioManager();
20+
}
1921

20-
// TODO: This should be done in the Unity project
21-
var damageAudio = new GameObject("DamageAudioSource");
22-
damageAudio.SetActive(false);
23-
damageAudio.transform.SetParent(transform, false);
24-
damageAudio.transform.localPosition = Vector3.zero;
25-
_damageAudioSource = damageAudio.AddComponent<OWAudioSource>();
26-
_damageAudioSource._audioSource = damageAudio.GetAddComponent<AudioSource>();
27-
_damageAudioSource.SetTrack(_repairToolSource.GetTrack());
28-
_damageAudioSource.spatialBlend = 1f;
29-
_damageAudioSource.gameObject.GetAddComponent<QSBDopplerFixer>();
30-
damageAudio.SetActive(true);
22+
private void Update()
23+
{
24+
if (Time.time > this._playWearHelmetTime)
25+
{
26+
enabled = false;
27+
PlayOneShot(global::AudioType.PlayerSuitWearHelmet);
28+
}
3129
}
3230

3331
public void PlayEquipTool()
@@ -48,6 +46,18 @@ public void PlayWearSuit()
4846
public void PlayRemoveSuit()
4947
=> PlayOneShot(AudioType.PlayerSuitRemoveSuit);
5048

49+
public void PlayRemoveHelmet()
50+
{
51+
enabled = false;
52+
PlayOneShot(AudioType.PlayerSuitRemoveHelmet);
53+
}
54+
55+
public void PlayWearHelmet()
56+
{
57+
enabled = true;
58+
_playWearHelmetTime = Time.time + 0.4f;
59+
}
60+
5161
public void PlayOneShot(AudioType audioType, float pitch = 1f, float volume = 1f)
5262
{
5363
if (_oneShotExternalSource)

0 commit comments

Comments
 (0)