Fixed suit not appearing in ship after dying.

This commit is contained in:
Mister_Nebula 2021-05-18 15:10:38 +01:00
parent 6c9e39a6bb
commit 26ad61afd1
4 changed files with 51 additions and 6 deletions

View File

@ -30,6 +30,7 @@ namespace QSB.DeathSync
private ShipCockpitController _cockpitController;
private PlayerSpacesuit _spaceSuit;
private ShipTractorBeamSwitch _shipTractorBeam;
private SuitPickupVolume[] _suitPickupVolumes;
public void Awake() => Instance = this;
@ -40,6 +41,8 @@ namespace QSB.DeathSync
_spaceSuit = Locator.GetPlayerSuit();
_playerSpawner = FindObjectOfType<PlayerSpawner>();
_shipTractorBeam = FindObjectOfType<ShipTractorBeamSwitch>();
_suitPickupVolumes = FindObjectsOfType<SuitPickupVolume>();
_fluidDetector = Locator.GetPlayerCamera().GetComponentInChildren<FluidDetector>();
_playerSpawnPoint = GetSpawnPoint();
@ -88,6 +91,33 @@ namespace QSB.DeathSync
_playerResources.SetValue("_isSuffocating", false);
_playerResources.DebugRefillResources();
_spaceSuit.RemoveSuit(true);
foreach (var pickupVolume in _suitPickupVolumes)
{
var containsSuit = pickupVolume.GetValue<bool>("_containsSuit");
var allowReturn = pickupVolume.GetValue<bool>("_allowSuitReturn");
if (!containsSuit && allowReturn)
{
var interactVolume = pickupVolume.GetValue<MultipleInteractionVolume>("_interactVolume");
var pickupSuitIndex = pickupVolume.GetValue<int>("_pickupSuitCommandIndex");
pickupVolume.SetValue("_containsSuit", true);
interactVolume.ChangePrompt(UITextType.SuitUpPrompt, pickupSuitIndex);
var suitGeometry = pickupVolume.GetValue<GameObject>("_suitGeometry");
var suitCollider = pickupVolume.GetValue<OWCollider>("_suitOWCollider");
var toolGeometries = pickupVolume.GetValue<GameObject[]>("_toolGeometry");
suitGeometry.SetActive(true);
suitCollider.SetActivation(true);
foreach (var geo in toolGeometries)
{
geo.SetActive(true);
}
}
}
}
public void ResetShip()

View File

@ -21,11 +21,12 @@ namespace QSB.SectorSync
private void OnEnable() => RepeatingManager.Repeatings.Add(this);
private void OnDisable() => RepeatingManager.Repeatings.Remove(this);
public List<ISectoredSync<Component>> SectoredSyncs = new List<ISectoredSync<Component>>();
public List<ISectoredSync<Transform>> SectoredTransformSyncs = new List<ISectoredSync<Transform>>();
public List<ISectoredSync<OWRigidbody>> SectoredRigidbodySyncs = new List<ISectoredSync<OWRigidbody>>();
public void Invoke()
{
foreach (var sync in SectoredSyncs)
foreach (var sync in SectoredTransformSyncs)
{
if (sync.AttachedObject == null)
{
@ -38,6 +39,20 @@ namespace QSB.SectorSync
CheckTransformSyncSector(sync);
}
}
foreach (var sync in SectoredRigidbodySyncs)
{
if (sync.AttachedObject == null)
{
continue;
}
if ((sync as QNetworkBehaviour).HasAuthority
&& sync.AttachedObject.gameObject.activeInHierarchy
&& sync.IsReady)
{
CheckTransformSyncSector(sync);
}
}
}
public override void Awake()

View File

@ -15,14 +15,14 @@ namespace QSB.Syncs.RigidbodySync
public override void Start()
{
SectorSync = gameObject.AddComponent<SectorSync.SectorSync>();
QSBSectorManager.Instance.SectoredSyncs.Add((ISectoredSync<UnityEngine.Component>)this);
QSBSectorManager.Instance.SectoredRigidbodySyncs.Add(this);
base.Start();
}
protected override void OnDestroy()
{
base.OnDestroy();
QSBSectorManager.Instance.SectoredSyncs.Remove((ISectoredSync<UnityEngine.Component>)this);
QSBSectorManager.Instance.SectoredRigidbodySyncs.Remove(this);
if (SectorSync != null)
{
Destroy(SectorSync);

View File

@ -16,14 +16,14 @@ namespace QSB.Syncs.TransformSync
public override void Start()
{
SectorSync = gameObject.AddComponent<SectorSync.SectorSync>();
QSBSectorManager.Instance.SectoredSyncs.Add((ISectoredSync<UnityEngine.Component>)this);
QSBSectorManager.Instance.SectoredTransformSyncs.Add(this);
base.Start();
}
protected override void OnDestroy()
{
base.OnDestroy();
QSBSectorManager.Instance.SectoredSyncs.Remove((ISectoredSync<UnityEngine.Component>)this);
QSBSectorManager.Instance.SectoredTransformSyncs.Remove(this);
if (SectorSync != null)
{
Destroy(SectorSync);