move to new RespawnSync namespace

This commit is contained in:
Mister_Nebula 2021-11-18 11:34:14 +00:00
parent be025d0673
commit 4ae50fcccd
9 changed files with 87 additions and 7 deletions

View File

@ -1,6 +1,7 @@
using QSB.ClientServerStateSync;
using QSB.Events;
using QSB.Player;
using QSB.RespawnSync;
using QSB.Utility;
namespace QSB.DeathSync.Events

View File

@ -7,6 +7,7 @@ using QSB.WorldSync;
using QSB.Utility;
using System.Linq;
using UnityEngine;
using QSB.RespawnSync;
namespace QSB.DeathSync
{

View File

@ -30,6 +30,7 @@ using QSB.Anglerfish.Events;
using QSB.Utility;
using QSB.Utility.Events;
using System.Collections.Generic;
using QSB.RespawnSync.Events;
namespace QSB.Events
{

View File

@ -88,13 +88,14 @@
<Compile Include="ConversationSync\ConversationManager.cs" />
<Compile Include="DeathSync\EndLoopReason.cs" />
<Compile Include="DeathSync\Events\EndLoopEvent.cs" />
<Compile Include="DeathSync\Events\PlayerRespawnEvent.cs" />
<Compile Include="RespawnSync\Events\PlayerRespawnEvent.cs" />
<Compile Include="DeathSync\Events\StartLoopEvent.cs" />
<Compile Include="DeathSync\Patches\MapPatches.cs" />
<Compile Include="DeathSync\Events\PlayerDeathMessage.cs" />
<Compile Include="DeathSync\Patches\DeathPatches.cs" />
<Compile Include="DeathSync\RespawnManager.cs" />
<Compile Include="DeathSync\ShipRecoveryPoint.cs" />
<Compile Include="RespawnSync\RespawnHUDMarker.cs" />
<Compile Include="RespawnSync\RespawnManager.cs" />
<Compile Include="RespawnSync\ShipRecoveryPoint.cs" />
<Compile Include="EchoesOfTheEye\AirlockSync\AirlockManager.cs" />
<Compile Include="EchoesOfTheEye\AirlockSync\WorldObjects\QSBGhostAirlock.cs" />
<Compile Include="ElevatorSync\WorldObjects\QSBElevator.cs" />

View File

@ -4,7 +4,6 @@ using OWML.ModHelper.Input;
using QSB.Animation.NPC;
using QSB.CampfireSync;
using QSB.ConversationSync;
using QSB.DeathSync;
using QSB.EchoesOfTheEye.AirlockSync;
using QSB.EchoesOfTheEye.LightSensorSync;
using QSB.ElevatorSync;
@ -32,6 +31,7 @@ using QuantumUNET;
using QuantumUNET.Components;
using System.Linq;
using UnityEngine;
using QSB.RespawnSync;
/*
Copyright (C) 2020 - 2021

View File

@ -3,7 +3,7 @@ using QSB.Events;
using QSB.Messaging;
using QSB.Player;
namespace QSB.DeathSync.Events
namespace QSB.RespawnSync.Events
{
internal class PlayerRespawnEvent : QSBEvent<PlayerMessage>
{

View File

@ -0,0 +1,73 @@
using QSB.Player;
using QSB.Utility;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;
namespace QSB.RespawnSync
{
public class RespawnHUDMarker : HUDDistanceMarker
{
private bool _isReady;
public override void InitCanvasMarker()
{
DebugLog.DebugWrite($"InitCanvasMarker");
_markerRadius = 2f;
_markerTarget = new GameObject().transform;
_markerTarget.parent = transform;
_markerTarget.localPosition = Vector3.up * 0.25f;
}
private void Update()
{
if (!_isReady)
{
return;
}
if (_canvasMarker != null)
{
var isVisible = _canvasMarker.IsVisible();
if (RespawnManager.Instance.RespawnNeeded != isVisible)
{
DebugLog.DebugWrite($"set visibility to {isVisible}");
_canvasMarker.SetVisibility(RespawnManager.Instance.RespawnNeeded);
}
}
}
public void Initialize()
{
DebugLog.DebugWrite($"initialize");
_markerLabel = "RESPAWN PLAYER";
_isReady = true;
base.InitCanvasMarker();
}
public void Remove()
{
_isReady = false;
// do N O T destroy the parent - it completely breaks the ENTIRE GAME
if (_canvasMarker != null)
{
_canvasMarker.DestroyMarker();
}
if (_markerTarget != null)
{
Destroy(_markerTarget.gameObject);
}
Destroy(this);
}
}
}

View File

@ -8,7 +8,7 @@ using System.Linq;
using UnityEngine;
using UnityEngine.Networking;
namespace QSB.DeathSync
namespace QSB.RespawnSync
{
internal class RespawnManager : MonoBehaviour
{
@ -90,6 +90,9 @@ namespace QSB.DeathSync
multiInteract._interactRange = 1.5f;
_qsbRecoveryPoint.AddComponent<ShipRecoveryPoint>();
var marker = _qsbRecoveryPoint.AddComponent<RespawnHUDMarker>();
marker.Initialize();
}
_qsbRecoveryPoint.SetActive(true);

View File

@ -1,7 +1,7 @@
using QSB.Utility;
using UnityEngine;
namespace QSB.DeathSync
namespace QSB.RespawnSync
{
internal class ShipRecoveryPoint : MonoBehaviour
{