Skip to content

Commit

Permalink
Merge pull request #647 from qsb-dev/dev
Browse files Browse the repository at this point in the history
1.0.0
  • Loading branch information
misternebula authored Feb 15, 2024
2 parents e0e8e7e + 206b01d commit 052d8f8
Show file tree
Hide file tree
Showing 92 changed files with 1,721 additions and 562 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']
Binary file added Asset Source Files/player-simulation-model.blend
Binary file not shown.
4 changes: 0 additions & 4 deletions DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ The template for this file is this :

```json
{
"dumpWorldObjects": false,
"instanceIdInLogs": false,
"hookDebugLogs": false,
"avoidTimeSync": false,
Expand All @@ -81,13 +80,11 @@ The template for this file is this :
"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.
Expand All @@ -98,6 +95,5 @@ The template for this file is this :
- 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: 2 additions & 1 deletion QSB.sln
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
ProjectSection(SolutionItems) = preProject
.gitignore = .gitignore
DEVELOPMENT.md = DEVELOPMENT.md
.github\FUNDING.yml = .github\FUNDING.yml
LICENSE = LICENSE
README.md = README.md
TRANSLATING.md = TRANSLATING.md
Expand All @@ -31,7 +32,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Mirror", "Mirror", "{851AB4
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "APITestMod", "APITestMod\APITestMod.csproj", "{0A10143E-6C00-409B-B3A5-C54C1B01599D}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "QSBPatcher", "QSBPatcher\QSBPatcher.csproj", "{CA4CBA2B-54D5-4C4B-9B51-957BC6D77D6B}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "QSBPatcher", "QSBPatcher\QSBPatcher.csproj", "{CA4CBA2B-54D5-4C4B-9B51-957BC6D77D6B}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down
1 change: 1 addition & 0 deletions QSB.sln.DotSettings
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/CASE_BLOCK_BRACES/@EntryValue">NEXT_LINE_SHIFTED_2</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=API/@EntryIndexedValue">API</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=ID/@EntryIndexedValue">ID</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=OW/@EntryIndexedValue">OW</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=QSB/@EntryIndexedValue">QSB</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=UWP/@EntryIndexedValue">UWP</s:String>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpKeepExistingMigration/@EntryIndexedValue">True</s:Boolean>
Expand Down
24 changes: 24 additions & 0 deletions QSB/API/IQSBAPI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,30 @@ public interface IQSBAPI
/// <param name="playerID">The ID of the player you want the name of.</param>
string GetPlayerName(uint playerID);

/// <summary>
/// Returns the body object of a given player. The pivot of this object is at the player's feet.
/// </summary>
/// <param name="playerID">The ID of the player you want the body of.</param>
GameObject GetPlayerBody(uint playerID);

/// <summary>
/// Returns the camera object of a given player. The pivot of this object is at the player's point of view.
/// </summary>
/// <param name="playerID">The ID of the player you want the camera of.</param>
GameObject GetPlayerCamera(uint playerID);

/// <summary>
/// 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.
/// </summary>
/// <param name="playerID">The ID of the player.</param>
bool GetPlayerReady(uint playerID);

/// <summary>
/// Returns true if the given player is dead.
/// </summary>
/// <param name="playerID">The ID of the player.</param>
bool GetPlayerDead(uint playerID);

/// <summary>
/// Returns the list of IDs of all connected players.
///
Expand Down
15 changes: 15 additions & 0 deletions QSB/API/QSBAPI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,21 @@ public void RegisterRequiredForAllPlayers(IModBehaviour mod)

public uint GetLocalPlayerID() => QSBPlayerManager.LocalPlayerId;
public string GetPlayerName(uint playerId) => QSBPlayerManager.GetPlayer(playerId).Name;
public GameObject GetPlayerBody(uint playerId) => QSBPlayerManager.GetPlayer(playerId).Body;
public GameObject GetPlayerCamera(uint playerId) => QSBPlayerManager.GetPlayer(playerId).CameraBody;

public bool GetPlayerReady(uint playerId)
{
var player = QSBPlayerManager.GetPlayer(playerId);
return player.IsReady && player.Body != null;
}

public bool GetPlayerDead(uint playerId)
{
var player = QSBPlayerManager.GetPlayer(playerId);
return player.IsDead;
}

public uint[] GetPlayerIDs() => QSBPlayerManager.PlayerList.Select(x => x.PlayerId).ToArray();

public UnityEvent<uint> OnPlayerJoin() => QSBAPIEvents.OnPlayerJoinEvent;
Expand Down
16 changes: 14 additions & 2 deletions QSB/Animation/Player/AnimationSync.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
using QSB.Messaging;
using QSB.Player;
using QSB.Utility;
using QSB.WorldSync;
using QSB.WorldSync.Messages;
using System;
using UnityEngine;

Expand Down Expand Up @@ -34,7 +34,11 @@ protected void Awake()
RequestInitialStatesMessage.SendInitialState += SendInitialState;
}

protected void OnDestroy() => RequestInitialStatesMessage.SendInitialState -= SendInitialState;
protected void OnDestroy()
{
RequestInitialStatesMessage.SendInitialState -= SendInitialState;
GlobalMessenger.RemoveListener("EnableBigHeadMode", new Callback(OnEnableBigHeadMode));
}

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

Delay.RunWhen(() => Player.CameraBody != null,
() => body.GetComponent<PlayerHeadRotationSync>().Init(Player.CameraBody.transform));

GlobalMessenger.AddListener("EnableBigHeadMode", new Callback(OnEnableBigHeadMode));
}

private void InitAccelerationSync()
Expand All @@ -107,6 +113,12 @@ private void InitAccelerationSync()
Player.JetpackAcceleration.Init(thrusterModel);
}

private void OnEnableBigHeadMode()
{
var bone = VisibleAnimator.GetBoneTransform(HumanBodyBones.Head);
bone.localScale = new Vector3(2.5f, 2.5f, 2.5f);
}

public void SetSuitState(bool suitedUp)
{
if (!Player.IsReady)
Expand Down
95 changes: 95 additions & 0 deletions QSB/Animation/Player/HelmetAnimator.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
using OWML.Common;
using QSB.PlayerBodySetup.Remote;
using QSB.Utility;
using UnityEngine;

namespace QSB.Animation.Player;

[UsedInUnityProject]
public class HelmetAnimator : MonoBehaviour
{
public Transform FakeHelmet;
public Transform FakeHead;
public GameObject SuitGroup;

private QSBDitheringAnimator _fakeHelmetDitheringAnimator;

private const float ANIM_TIME = 0.5f;
private bool _isPuttingOnHelmet;
private bool _isTakingOffHelmet;

public void Start()
{
_fakeHelmetDitheringAnimator = FakeHelmet.GetComponent<QSBDitheringAnimator>();

FakeHead.gameObject.SetActive(false);
}

public void RemoveHelmet()
{
if (!SuitGroup.activeSelf)
{
DebugLog.DebugWrite($"Trying to remove helmet when player is not wearing suit!", MessageType.Error);
return;
}

_fakeHelmetDitheringAnimator.SetVisible(true);
FakeHelmet.gameObject.SetActive(true);
FakeHead.gameObject.SetActive(true);
_fakeHelmetDitheringAnimator.SetVisible(false, ANIM_TIME);
_isTakingOffHelmet = true;
}

public void PutOnHelmet()
{
if (!SuitGroup.activeSelf)
{
DebugLog.DebugWrite($"Trying to put on helmet when player is not wearing suit!", MessageType.Error);
return;
}

_fakeHelmetDitheringAnimator.SetVisible(false);
FakeHead.gameObject.SetActive(true);
FakeHelmet.gameObject.SetActive(true);
_fakeHelmetDitheringAnimator.SetVisible(true, ANIM_TIME);
_isPuttingOnHelmet = true;
}

public void SetHelmetInstant(bool helmetOn)
{
if (helmetOn)
{
FakeHelmet.gameObject.SetActive(true);
_fakeHelmetDitheringAnimator.SetVisible(true);
FakeHead.gameObject.SetActive(false);
}
else
{
_fakeHelmetDitheringAnimator.SetVisible(false);
FakeHelmet.gameObject.SetActive(false);
if (!SuitGroup.activeSelf)
{
FakeHead.gameObject.SetActive(false);
}
}
}

private void Update()
{
if (_isPuttingOnHelmet && _fakeHelmetDitheringAnimator.FullyVisible)
{
_isPuttingOnHelmet = false;
FakeHead.gameObject.SetActive(false);
}

if (_isTakingOffHelmet && _fakeHelmetDitheringAnimator.FullyInvisible)
{
FakeHelmet.gameObject.SetActive(false);

if (!SuitGroup.activeSelf)
{
FakeHead.gameObject.SetActive(false);
}
}
}
}
43 changes: 43 additions & 0 deletions QSB/Animation/Player/Messages/PlayerHelmetMessage.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
using QSB.Messaging;
using QSB.Player.TransformSync;
using QSB.WorldSync;
using QSB.Player;

namespace QSB.Animation.Player.Messages;

public class PlayerHelmetMessage : QSBMessage<bool>
{
static PlayerHelmetMessage()
{
GlobalMessenger.AddListener(OWEvents.PutOnHelmet, () => Handle(true));
GlobalMessenger.AddListener(OWEvents.RemoveHelmet, () => Handle(false));
}

private static void Handle(bool on)
{
if (PlayerTransformSync.LocalInstance)
{
new PlayerHelmetMessage(on).Send();
}
}

public PlayerHelmetMessage(bool on) : base(on) { }

public override bool ShouldReceive => QSBWorldSync.AllObjectsReady;

public override void OnReceiveRemote()
{
var player = QSBPlayerManager.GetPlayer(From);
var animator = player.HelmetAnimator;
if (Data)
{
animator.PutOnHelmet();
player.AudioController.PlayWearHelmet();
}
else
{
animator.RemoveHelmet();
player.AudioController.PlayRemoveHelmet();
}
}
}
Binary file removed QSB/AssetBundles/qsb_debug
Binary file not shown.
Binary file modified QSB/AssetBundles/qsb_hud
Binary file not shown.
Binary file modified QSB/AssetBundles/qsb_network
Binary file not shown.
Binary file modified QSB/AssetBundles/qsb_network_big
Binary file not shown.
Binary file added QSB/AssetBundles/qsb_skins
Binary file not shown.
32 changes: 21 additions & 11 deletions QSB/Audio/QSBPlayerAudioController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,20 @@ public class QSBPlayerAudioController : MonoBehaviour
public OWAudioSource _damageAudioSource;

private AudioManager _audioManager;
private float _playWearHelmetTime;

public void Start()
{
_audioManager = Locator.GetAudioManager();
}

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

public void PlayEquipTool()
Expand All @@ -48,6 +46,18 @@ public void PlayWearSuit()
public void PlayRemoveSuit()
=> PlayOneShot(AudioType.PlayerSuitRemoveSuit);

public void PlayRemoveHelmet()
{
enabled = false;
PlayOneShot(AudioType.PlayerSuitRemoveHelmet);
}

public void PlayWearHelmet()
{
enabled = true;
_playWearHelmetTime = Time.time + 0.4f;
}

public void PlayOneShot(AudioType audioType, float pitch = 1f, float volume = 1f)
{
if (_oneShotExternalSource)
Expand Down
Loading

0 comments on commit 052d8f8

Please sign in to comment.