Skip to content

Commit

Permalink
Merge pull request #529 from misternebula/dev
Browse files Browse the repository at this point in the history
0.20.0
  • Loading branch information
misternebula authored Jul 11, 2022
2 parents 023a0b9 + c7b221a commit ac4f2ac
Show file tree
Hide file tree
Showing 107 changed files with 2,840 additions and 450 deletions.
1 change: 1 addition & 0 deletions QSB.sln
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
.gitignore = .gitignore
LICENSE = LICENSE
README.md = README.md
TRANSLATING.md = TRANSLATING.md
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MirrorWeaver", "MirrorWeaver\MirrorWeaver.csproj", "{DA8A467E-15BA-456C-9034-6EB80BAF1FF9}"
Expand Down
2 changes: 1 addition & 1 deletion QSB/Animation/Player/AnimationSync.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ private void InitAccelerationSync()

private void InitCrouchSync()
{
_crouchSync = GetComponent<CrouchSync>();
_crouchSync = this.GetRequiredComponent<CrouchSync>();
_crouchSync.Init(_playerController, VisibleAnimator);
}

Expand Down
2 changes: 0 additions & 2 deletions QSB/Animation/Player/Thrusters/JetpackAccelerationSync.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ namespace QSB.Animation.Player.Thrusters;
public class JetpackAccelerationSync : NetworkBehaviour
{
public Vector3VariableSyncer AccelerationVariableSyncer;
public BoolVariableSyncer ThrustingVariableSyncer;

private ThrusterModel _thrusterModel;

Expand All @@ -25,7 +24,6 @@ private void SyncLocalAccel()
if (_thrusterModel != null)
{
AccelerationVariableSyncer.Value = _thrusterModel.GetLocalAcceleration();
ThrustingVariableSyncer.Value = _thrusterModel.IsTranslationalThrusterFiring();
}
}
}
30 changes: 26 additions & 4 deletions QSB/Animation/Player/Thrusters/RemoteThrusterFlameController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ internal class RemoteThrusterFlameController : MonoBehaviour
private Vector3 _thrusterFilter;
private float _baseLightRadius;
private float _currentScale;

private RemotePlayerFluidDetector _fluidDetector;
private bool _underwater;
private bool _initialized;
private PlayerInfo _attachedPlayer;

Expand All @@ -43,6 +44,19 @@ public void Init(PlayerInfo player)
_light.enabled = false;
_light.shadows = LightShadows.Soft;
_initialized = true;
_underwater = false;
_fluidDetector = player.FluidDetector;
_fluidDetector.OnEnterFluidType += OnEnterExitFluidType;
_fluidDetector.OnExitFluidType += OnEnterExitFluidType;
}

private void OnDestroy()
{
if (_fluidDetector != null)
{
_fluidDetector.OnEnterFluidType -= OnEnterExitFluidType;
_fluidDetector.OnExitFluidType -= OnEnterExitFluidType;
}
}

private void Update()
Expand All @@ -52,7 +66,10 @@ private void Update()
return;
}

var num = _scaleByThrust.Evaluate(GetThrustFraction());
var num = _underwater
? 0f
: _scaleByThrust.Evaluate(GetThrustFraction());

if (_belowMaxThrustScalar < 1f)
{
num *= _belowMaxThrustScalar;
Expand All @@ -65,18 +82,23 @@ private void Update()
_scaleSpring.ResetVelocity();
}

if (_currentScale <= 0.001f)
if (_underwater && _currentScale <= 0.001f)
{
_currentScale = 0f;
_scaleSpring.ResetVelocity();
}

transform.localScale = Vector3.one * _currentScale;
_light.range = _baseLightRadius * _currentScale;
_thrusterRenderer.enabled = _currentScale > 0f;
_thrusterRenderer.enabled = _currentScale > 0f && _attachedPlayer.Visible;
_light.enabled = _currentScale > 0f;
}

private void OnEnterExitFluidType(FluidVolume.Type type)
{
this._underwater = this._fluidDetector.InFluidType(FluidVolume.Type.WATER);
}

private float GetThrustFraction() => Vector3.Dot(_attachedPlayer.JetpackAcceleration.AccelerationVariableSyncer.Value, _thrusterFilter);

private void OnRenderObject()
Expand Down
75 changes: 75 additions & 0 deletions QSB/Animation/Player/Thrusters/RemoteThrusterParticlesBehaviour.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
using QSB.Player;
using QSB.Utility;
using UnityEngine;

namespace QSB.Animation.Player.Thrusters;

internal class RemoteThrusterParticlesBehaviour : MonoBehaviour
{
[SerializeField]
private Thruster _thruster;

[SerializeField]
private bool _underwaterParticles;

private bool _initialized;
private PlayerInfo _attachedPlayer;
private RemotePlayerFluidDetector _fluidDetector;
private ParticleSystem _thrustingParticles;
private Vector3 _thrusterFilter;
private bool _underwater;

public void Init(PlayerInfo player)
{
_attachedPlayer = player;
_fluidDetector = player.FluidDetector;
_thrustingParticles = gameObject.GetComponent<ParticleSystem>();
_thrustingParticles.GetComponent<CustomRelativisticParticleSystem>().Init(player);
_thrusterFilter = OWUtilities.GetShipThrusterFilter(_thruster);
_underwater = false;
_thrustingParticles.Stop(true, ParticleSystemStopBehavior.StopEmittingAndClear);

_fluidDetector.OnEnterFluidType += OnEnterExitFluidType;
_fluidDetector.OnExitFluidType += OnEnterExitFluidType;

_initialized = true;
}

private void OnDestroy()
{
_initialized = false;
if (_fluidDetector != null)
{
_fluidDetector.OnEnterFluidType -= OnEnterExitFluidType;
_fluidDetector.OnExitFluidType -= OnEnterExitFluidType;
}
}

private void Update()
{
if (!_initialized)
{
return;
}

if (((_underwater != _underwaterParticles)
? 0f
: Vector3.Dot(_attachedPlayer.JetpackAcceleration.AccelerationVariableSyncer.Value, _thrusterFilter)) > 1f)
{
if (!_thrustingParticles.isPlaying)
{
_thrustingParticles.Play();
return;
}
}
else if (_thrustingParticles.isPlaying)
{
_thrustingParticles.Stop();
}
}

private void OnEnterExitFluidType(FluidVolume.Type type)
{
_underwater = _fluidDetector.InFluidType(FluidVolume.Type.WATER);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ private void Update()

emissionThrusterScale = (!aboveSurface) ? 0f : (emissionThrusterScale * _emissionDistanceScale.Evaluate(hitInfo.distance));

if (emissionThrusterScale > 0f)
if (emissionThrusterScale > 0f && _attachedPlayer.Visible)
{
var position = hitInfo.point + (hitInfo.normal * 0.25f);
var rotation = Quaternion.LookRotation(hitInfo.normal);
Expand Down
18 changes: 14 additions & 4 deletions QSB/Animation/Player/Thrusters/ThrusterManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@ public static void CreateRemotePlayerVFX(PlayerInfo player)
{
var newVfx = player.Body.transform.Find("REMOTE_PlayerVFX").gameObject;

CreateThrusterWashController(newVfx.transform.Find("ThrusterWash").gameObject, player);
CreateThrusterFlameController(newVfx, player);
InitWashController(newVfx.transform.Find("ThrusterWash").gameObject, player);
InitFlameControllers(newVfx, player);
InitParticleControllers(newVfx, player);
}

private static void CreateThrusterFlameController(GameObject root, PlayerInfo player)
private static void InitFlameControllers(GameObject root, PlayerInfo player)
{
var existingControllers = root.GetComponentsInChildren<RemoteThrusterFlameController>(true);
foreach (var controller in existingControllers)
Expand All @@ -22,7 +23,16 @@ private static void CreateThrusterFlameController(GameObject root, PlayerInfo pl
}
}

private static void CreateThrusterWashController(GameObject root, PlayerInfo player)
private static void InitParticleControllers(GameObject root, PlayerInfo player)
{
var existingBehaviours = root.GetComponentsInChildren<RemoteThrusterParticlesBehaviour>(true);
foreach (var item in existingBehaviours)
{
item.Init(player);
}
}

private static void InitWashController(GameObject root, PlayerInfo player)
{
var newObj = root.GetComponent<RemoteThrusterWashController>();
newObj.Init(player);
Expand Down
Binary file removed QSB/AssetBundles/conversation
Binary file not shown.
Binary file removed QSB/AssetBundles/debug
Binary file not shown.
Binary file removed QSB/AssetBundles/empty
Binary file not shown.
Binary file removed QSB/AssetBundles/network
Binary file not shown.
Binary file added QSB/AssetBundles/qsb_conversation
Binary file not shown.
Binary file added QSB/AssetBundles/qsb_debug
Binary file not shown.
Binary file added QSB/AssetBundles/qsb_empty
Binary file not shown.
Binary file added QSB/AssetBundles/qsb_network
Binary file not shown.
Binary file not shown.
Binary file removed QSB/AssetBundles/textassets
Binary file not shown.
28 changes: 23 additions & 5 deletions QSB/ClientServerStateSync/ClientStateManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ private static void OnPostSceneLoad(OWScene oldScene, OWScene newScene)

if (QSBCore.IsHost)
{

switch (newScene)
{
case OWScene.TitleScreen:
Expand All @@ -73,7 +72,17 @@ private static void OnPostSceneLoad(OWScene oldScene, OWScene newScene)

break;
case OWScene.EyeOfTheUniverse:
newState = ClientState.AliveInEye;
if (oldScene == OWScene.SolarSystem)
{
// coming from solar system
newState = ClientState.WaitingForOthersToBeReady;
}
else
{
// loading in from title screen
newState = ClientState.AliveInEye;
}

break;
default:
newState = ClientState.NotLoaded;
Expand Down Expand Up @@ -121,13 +130,22 @@ private static void OnPostSceneLoad(OWScene oldScene, OWScene newScene)

break;
case OWScene.EyeOfTheUniverse:
if (serverState == ServerState.WaitingForAllPlayersToReady)
if (oldScene == OWScene.SolarSystem)
{
// coming from solar system
newState = ClientState.WaitingForOthersToBeReady;
}
else
{
newState = ClientState.AliveInEye;
// loading in from title screen
if (serverState == ServerState.WaitingForAllPlayersToReady)
{
newState = ClientState.WaitingForOthersToBeReady;
}
else
{
newState = ClientState.AliveInEye;
}
}

break;
Expand Down Expand Up @@ -182,4 +200,4 @@ private static ClientState ForceGetCurrentState()
OWScene.EyeOfTheUniverse => ClientState.AliveInEye,
_ => ClientState.NotLoaded
};
}
}
16 changes: 12 additions & 4 deletions QSB/ClientServerStateSync/ServerStateManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ private void Start()
return;
}

QSBSceneManager.OnPostSceneLoad += OnPostSceneLoaded;
QSBSceneManager.OnPostSceneLoad += OnPostSceneLoad;
GlobalMessenger.AddListener("TriggerSupernova", OnTriggerSupernova);

Delay.RunWhen(() => PlayerTransformSync.LocalInstance != null,
Expand All @@ -38,7 +38,7 @@ private void Start()

private void OnDestroy()
{
QSBSceneManager.OnPostSceneLoad -= OnPostSceneLoaded;
QSBSceneManager.OnPostSceneLoad -= OnPostSceneLoad;
GlobalMessenger.RemoveListener("TriggerSupernova", OnTriggerSupernova);
}

Expand All @@ -56,7 +56,7 @@ public void ChangeServerState(ServerState newState)
public ServerState GetServerState()
=> _currentState;

private static void OnPostSceneLoaded(OWScene oldScene, OWScene newScene)
private static void OnPostSceneLoad(OWScene oldScene, OWScene newScene)
{
switch (newScene)
{
Expand All @@ -83,7 +83,15 @@ private static void OnPostSceneLoaded(OWScene oldScene, OWScene newScene)
break;

case OWScene.EyeOfTheUniverse:
new ServerStateMessage(ServerState.WaitingForAllPlayersToReady).Send();
if (oldScene == OWScene.SolarSystem)
{
new ServerStateMessage(ServerState.WaitingForAllPlayersToReady).Send();
}
else
{
new ServerStateMessage(ServerState.InEye).Send();
}

break;

case OWScene.None:
Expand Down
Loading

0 comments on commit ac4f2ac

Please sign in to comment.