mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-01-29 09:32:38 +00:00
commit
8e36843179
@ -6,38 +6,38 @@ namespace QSB.Animation.Player.Thrusters
|
||||
{
|
||||
internal class RemoteThrusterFlameController : MonoBehaviour
|
||||
{
|
||||
[SerializeField]
|
||||
private Thruster _thruster;
|
||||
|
||||
[SerializeField]
|
||||
private Light _light;
|
||||
|
||||
[SerializeField]
|
||||
private AnimationCurve _scaleByThrust = AnimationCurve.Linear(0f, 0f, 1f, 1f);
|
||||
|
||||
[SerializeField]
|
||||
private DampedSpring _scaleSpring = new();
|
||||
|
||||
[SerializeField]
|
||||
private float _belowMaxThrustScalar = 1f;
|
||||
|
||||
private MeshRenderer _thrusterRenderer;
|
||||
private Vector3 _thrusterFilter;
|
||||
private float _baseLightRadius;
|
||||
private float _currentScale;
|
||||
|
||||
private bool _isReady;
|
||||
private bool _initialized;
|
||||
private PlayerInfo _attachedPlayer;
|
||||
|
||||
// TODO : Make flames not appear underwater (Check original code!)
|
||||
|
||||
public void InitFromOld(Thruster thruster, Light light, AnimationCurve scaleByThrust, DampedSpring scaleSpring, float belowMaxThrustScalar, float baseLightRadius, PlayerInfo player)
|
||||
public void Init(PlayerInfo player)
|
||||
{
|
||||
_thruster = thruster;
|
||||
_light = light;
|
||||
_scaleByThrust = scaleByThrust;
|
||||
_scaleSpring = scaleSpring;
|
||||
_belowMaxThrustScalar = belowMaxThrustScalar;
|
||||
_attachedPlayer = player;
|
||||
_baseLightRadius = baseLightRadius;
|
||||
_isReady = true;
|
||||
}
|
||||
|
||||
private void Init()
|
||||
{
|
||||
_thrusterRenderer = GetComponent<MeshRenderer>();
|
||||
_thrusterFilter = OWUtilities.GetShipThrusterFilter(_thruster);
|
||||
_baseLightRadius = _light.range;
|
||||
_currentScale = 0f;
|
||||
_thrusterRenderer.enabled = false;
|
||||
_light.enabled = false;
|
||||
@ -47,11 +47,6 @@ namespace QSB.Animation.Player.Thrusters
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (_isReady && !_initialized)
|
||||
{
|
||||
Init();
|
||||
}
|
||||
|
||||
if (!_initialized)
|
||||
{
|
||||
return;
|
||||
|
@ -6,9 +6,16 @@ namespace QSB.Animation.Player.Thrusters
|
||||
{
|
||||
internal class RemoteThrusterWashController : MonoBehaviour
|
||||
{
|
||||
private readonly float _raycastDistance = 10f;
|
||||
[SerializeField]
|
||||
private float _raycastDistance = 10f;
|
||||
|
||||
[SerializeField]
|
||||
private AnimationCurve _emissionDistanceScale;
|
||||
|
||||
[SerializeField]
|
||||
private AnimationCurve _emissionThrusterScale;
|
||||
|
||||
[SerializeField]
|
||||
private ParticleSystem _defaultParticleSystem;
|
||||
|
||||
private ParticleSystem.MainModule _defaultMainModule;
|
||||
@ -17,20 +24,12 @@ namespace QSB.Animation.Player.Thrusters
|
||||
|
||||
private PlayerInfo _attachedPlayer;
|
||||
|
||||
private bool _isReady;
|
||||
private bool _initialised;
|
||||
|
||||
public void InitFromOld(AnimationCurve distanceScale, AnimationCurve thrusterScale, ParticleSystem defaultParticleSystem, PlayerInfo player)
|
||||
public void Init(PlayerInfo player)
|
||||
{
|
||||
_emissionDistanceScale = distanceScale;
|
||||
_emissionThrusterScale = thrusterScale;
|
||||
_defaultParticleSystem = defaultParticleSystem;
|
||||
_attachedPlayer = player;
|
||||
_isReady = true;
|
||||
}
|
||||
|
||||
private void Init()
|
||||
{
|
||||
if (_defaultParticleSystem == null)
|
||||
{
|
||||
DebugLog.ToConsole($"Error - DefaultParticleSystem is null!", OWML.Common.MessageType.Error);
|
||||
@ -46,11 +45,6 @@ namespace QSB.Animation.Player.Thrusters
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (_isReady && !_initialised)
|
||||
{
|
||||
Init();
|
||||
}
|
||||
|
||||
if (!_initialised)
|
||||
{
|
||||
return;
|
||||
|
@ -1,5 +1,4 @@
|
||||
using QSB.Player;
|
||||
using QSB.Utility;
|
||||
using UnityEngine;
|
||||
|
||||
namespace QSB.Animation.Player.Thrusters
|
||||
@ -8,87 +7,27 @@ namespace QSB.Animation.Player.Thrusters
|
||||
{
|
||||
public static void CreateRemotePlayerVFX(PlayerInfo player)
|
||||
{
|
||||
var localPlayerVfx = GameObject.Find("PlayerVFX");
|
||||
var newVfx = localPlayerVfx.InstantiateInactive();
|
||||
var newVfx = player.Body.transform.Find("REMOTE_PlayerVFX").gameObject;
|
||||
|
||||
ReplaceParticleSystems(newVfx, player);
|
||||
CreatePlayerParticlesController(newVfx);
|
||||
CreateThrusterParticlesBehaviour(newVfx, player);
|
||||
CreateThrusterWashController(newVfx.transform.Find("ThrusterWash").gameObject, player);
|
||||
CreateThrusterFlameController(newVfx, player);
|
||||
|
||||
newVfx.transform.parent = player.Body.transform;
|
||||
newVfx.transform.localPosition = Vector3.zero;
|
||||
newVfx.transform.rotation = Quaternion.Euler(0, 0, 0);
|
||||
newVfx.transform.localScale = new Vector3(1, 1, 1);
|
||||
|
||||
// Deleted objects take 1 update to actually be deleted
|
||||
Delay.RunNextFrame(() => newVfx.SetActive(true));
|
||||
}
|
||||
|
||||
private static void ReplaceParticleSystems(GameObject root, PlayerInfo player)
|
||||
{
|
||||
var existingSystems = root.GetComponentsInChildren<RelativisticParticleSystem>(true);
|
||||
foreach (var system in existingSystems)
|
||||
{
|
||||
var gameObject = system.gameObject;
|
||||
Object.Destroy(system);
|
||||
var newSys = gameObject.AddComponent<CustomRelativisticParticleSystem>();
|
||||
newSys.Init(player);
|
||||
}
|
||||
newVfx.SetActive(true);
|
||||
}
|
||||
|
||||
private static void CreateThrusterFlameController(GameObject root, PlayerInfo player)
|
||||
{
|
||||
var existingControllers = root.GetComponentsInChildren<ThrusterFlameController>(true);
|
||||
var existingControllers = root.GetComponentsInChildren<RemoteThrusterFlameController>(true);
|
||||
foreach (var controller in existingControllers)
|
||||
{
|
||||
var gameObject = controller.gameObject;
|
||||
var oldThruster = controller._thruster;
|
||||
var oldLight = controller._light;
|
||||
var localPos = oldThruster switch
|
||||
{
|
||||
Thruster.Up_RightThruster or Thruster.Up_LeftThruster => new Vector3(0, 0, 3),
|
||||
Thruster.Down_RightThruster or Thruster.Down_LeftThruster => new Vector3(0, 0, 7),
|
||||
_ => new Vector3(0, 0, 5),
|
||||
};
|
||||
oldLight.transform.localPosition = localPos;
|
||||
|
||||
var oldAnimCurve = controller._scaleByThrust;
|
||||
var oldScaleSpring = controller._scaleSpring;
|
||||
var oldScalar = controller._belowMaxThrustScalar;
|
||||
var oldBase = oldLight.range;
|
||||
Object.Destroy(controller);
|
||||
var newObj = gameObject.AddComponent<RemoteThrusterFlameController>();
|
||||
newObj.InitFromOld(oldThruster, oldLight, oldAnimCurve, oldScaleSpring, oldScalar, oldBase, player);
|
||||
}
|
||||
}
|
||||
|
||||
private static void CreatePlayerParticlesController(GameObject root) =>
|
||||
// TODO : Implement this. (Footsteps / Landing)
|
||||
Object.Destroy(root.GetComponent<PlayerParticlesController>());
|
||||
|
||||
private static void CreateThrusterParticlesBehaviour(GameObject root, PlayerInfo player)
|
||||
{
|
||||
var existingBehaviours = root.GetComponentsInChildren<ThrusterParticlesBehavior>(true);
|
||||
foreach (var behaviour in existingBehaviours)
|
||||
{
|
||||
// TODO : Implement this. (Bubbles for underwater thrusters)
|
||||
Object.Destroy(behaviour);
|
||||
controller.Init(player);
|
||||
}
|
||||
}
|
||||
|
||||
private static void CreateThrusterWashController(GameObject root, PlayerInfo player)
|
||||
{
|
||||
var old = root.GetComponent<ThrusterWashController>();
|
||||
var oldDistanceScale = old._emissionDistanceScale;
|
||||
var oldThrusterScale = old._emissionThrusterScale;
|
||||
var defaultParticleSystem = old._defaultParticleSystem;
|
||||
|
||||
Object.Destroy(old);
|
||||
|
||||
var newObj = root.AddComponent<RemoteThrusterWashController>();
|
||||
newObj.InitFromOld(oldDistanceScale, oldThrusterScale, defaultParticleSystem, player);
|
||||
var newObj = root.GetComponent<RemoteThrusterWashController>();
|
||||
newObj.Init(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Binary file not shown.
@ -27,7 +27,9 @@ namespace QSB.PlayerBodySetup.Remote
|
||||
"Props_HEA_Lightbulb_OFF_mat",
|
||||
"Props_HEA_PlayerProbe_mat",
|
||||
"Props_HEA_PlayerProbeLightbulb_mat",
|
||||
"Effects_RecallBlackHole_mat"
|
||||
"Effects_RecallBlackHole_mat",
|
||||
"Effects_HEA_Vapor_Player_mat",
|
||||
"Effects_HEA_ThrusterFlames_mat"
|
||||
};
|
||||
|
||||
private static void ReplaceMaterial(Renderer renderer, int index, Material mat)
|
||||
|
Loading…
x
Reference in New Issue
Block a user