mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-01-25 15:35:22 +00:00
commit
1eb7ca4315
54
QSB/EyeOfTheUniverse/VesselSync/VesselManager.cs
Normal file
54
QSB/EyeOfTheUniverse/VesselSync/VesselManager.cs
Normal file
@ -0,0 +1,54 @@
|
||||
using QSB.EyeOfTheUniverse.VesselSync.WorldObjects;
|
||||
using QSB.Player;
|
||||
using QSB.Utility;
|
||||
using QSB.WorldSync;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
|
||||
namespace QSB.EyeOfTheUniverse.VesselSync
|
||||
{
|
||||
internal class VesselManager : WorldObjectManager
|
||||
{
|
||||
public static VesselManager Instance { get; private set; }
|
||||
|
||||
private List<PlayerInfo> _playersInCage = new();
|
||||
private QSBVesselWarpController _warpController;
|
||||
|
||||
public override WorldObjectType WorldObjectType => WorldObjectType.Both;
|
||||
|
||||
public override void Awake()
|
||||
{
|
||||
base.Awake();
|
||||
Instance = this;
|
||||
}
|
||||
|
||||
protected override void RebuildWorldObjects(OWScene scene)
|
||||
{
|
||||
QSBWorldSync.Init<QSBVesselWarpController, VesselWarpController>();
|
||||
_warpController = QSBWorldSync.GetWorldObjects<QSBVesselWarpController>().First();
|
||||
_warpController.AttachedObject._cageTrigger.OnExit -= _warpController.AttachedObject.OnExitCageTrigger;
|
||||
}
|
||||
|
||||
public void Enter(PlayerInfo player)
|
||||
{
|
||||
_playersInCage.Add(player);
|
||||
}
|
||||
|
||||
public void Exit(PlayerInfo player)
|
||||
{
|
||||
_playersInCage.Remove(player);
|
||||
|
||||
if (_playersInCage.Count == 0 && _warpController.AttachedObject._hasPower)
|
||||
{
|
||||
var obj = _warpController.AttachedObject;
|
||||
obj._cageClosed = true;
|
||||
obj._cageAnimator.TranslateToLocalPosition(new Vector3(0f, -8.1f, 0f), 5f);
|
||||
obj._cageAnimator.RotateToLocalEulerAngles(new Vector3(0f, 180f, 0f), 5f);
|
||||
obj._cageAnimator.OnTranslationComplete -= obj.OnCageAnimationComplete;
|
||||
obj._cageAnimator.OnTranslationComplete += obj.OnCageAnimationComplete;
|
||||
obj._cageLoopingAudio.FadeIn(1f, false, false, 1f);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
using QSB.Messaging;
|
||||
using QSB.Player.Messages;
|
||||
using QSB.Utility;
|
||||
using QSB.WorldSync;
|
||||
using UnityEngine;
|
||||
|
||||
namespace QSB.EyeOfTheUniverse.VesselSync.WorldObjects
|
||||
{
|
||||
internal class QSBVesselWarpController : WorldObject<VesselWarpController>
|
||||
{
|
||||
public override void Init()
|
||||
{
|
||||
AttachedObject._cageTrigger.OnEntry += OnEntry;
|
||||
AttachedObject._cageTrigger.OnExit += OnExit;
|
||||
}
|
||||
|
||||
private void OnEntry(GameObject hitObj)
|
||||
{
|
||||
if (hitObj.CompareTag("PlayerDetector"))
|
||||
{
|
||||
new EnterLeaveMessage(Player.EnterLeaveType.EnterVesselCage).Send();
|
||||
}
|
||||
}
|
||||
|
||||
private void OnExit(GameObject hitObj)
|
||||
{
|
||||
if (hitObj.CompareTag("PlayerDetector"))
|
||||
{
|
||||
new EnterLeaveMessage(Player.EnterLeaveType.ExitVesselCage).Send();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -13,6 +13,8 @@
|
||||
EnterShip = 8,
|
||||
ExitShip = 9,
|
||||
EnterNomaiHeadZone = 10,
|
||||
ExitNomaiHeadZone = 11
|
||||
ExitNomaiHeadZone = 11,
|
||||
EnterVesselCage = 12,
|
||||
ExitVesselCage = 13
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
using OWML.Common;
|
||||
using QSB.Animation.NPC.WorldObjects;
|
||||
using QSB.EyeOfTheUniverse.VesselSync;
|
||||
using QSB.Messaging;
|
||||
using QSB.Player.TransformSync;
|
||||
using QSB.PoolSync;
|
||||
@ -96,6 +97,12 @@ namespace QSB.Player.Messages
|
||||
case EnterLeaveType.ExitShip:
|
||||
ShipManager.Instance.RemovePlayerFromShip(player);
|
||||
break;
|
||||
case EnterLeaveType.EnterVesselCage:
|
||||
VesselManager.Instance.Enter(player);
|
||||
break;
|
||||
case EnterLeaveType.ExitVesselCage:
|
||||
VesselManager.Instance.Exit(player);
|
||||
break;
|
||||
default:
|
||||
DebugLog.ToConsole($"Warning - Unknown EnterLeaveType : {Value}", MessageType.Warning);
|
||||
break;
|
||||
|
@ -26,6 +26,15 @@ namespace QSB.Player
|
||||
public string Name { get; set; }
|
||||
public PlayerHUDMarker HudMarker { get; set; }
|
||||
public PlayerTransformSync TransformSync { get; set; }
|
||||
public ClientState State { get; set; }
|
||||
public EyeState EyeState { get; set; }
|
||||
public bool IsDead { get; set; }
|
||||
public bool Visible { get; set; } = true;
|
||||
public bool IsReady { get; set; }
|
||||
public bool IsInMoon { get; set; }
|
||||
public bool IsInShrine { get; set; }
|
||||
public IQSBQuantumObject EntangledObject { get; set; }
|
||||
public QSBPlayerAudioController AudioController { get; set; }
|
||||
|
||||
// Body Objects
|
||||
public OWCamera Camera
|
||||
@ -52,6 +61,7 @@ namespace QSB.Player
|
||||
private OWCamera _camera;
|
||||
|
||||
public GameObject CameraBody { get; set; }
|
||||
|
||||
public GameObject Body
|
||||
{
|
||||
get
|
||||
@ -76,23 +86,11 @@ namespace QSB.Player
|
||||
private GameObject _body;
|
||||
|
||||
public GameObject RoastingStick { get; set; }
|
||||
public bool Visible { get; set; } = true;
|
||||
|
||||
// Tools
|
||||
public GameObject ProbeBody { get; set; }
|
||||
public QSBProbe Probe { get; set; }
|
||||
public QSBFlashlight FlashLight
|
||||
{
|
||||
get
|
||||
{
|
||||
if (CameraBody == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return CameraBody.GetComponentInChildren<QSBFlashlight>();
|
||||
}
|
||||
}
|
||||
public QSBFlashlight FlashLight => CameraBody?.GetComponentInChildren<QSBFlashlight>();
|
||||
public QSBTool Signalscope => GetToolByType(ToolType.Signalscope);
|
||||
public QSBTool Translator => GetToolByType(ToolType.Translator);
|
||||
public QSBProbeLauncherTool ProbeLauncher => (QSBProbeLauncherTool)GetToolByType(ToolType.ProbeLauncher);
|
||||
@ -108,6 +106,12 @@ namespace QSB.Player
|
||||
public QSBMarshmallow Marshmallow { get; set; }
|
||||
public QSBCampfire Campfire { get; set; }
|
||||
public IQSBOWItem HeldItem { get; set; }
|
||||
public bool FlashlightActive { get; set; }
|
||||
public bool SuitedUp { get; set; }
|
||||
public bool ProbeLauncherEquipped { get; set; }
|
||||
public bool SignalscopeEquipped { get; set; }
|
||||
public bool TranslatorEquipped { get; set; }
|
||||
public bool ProbeActive { get; set; }
|
||||
|
||||
// Conversation
|
||||
public int CurrentCharacterDialogueTreeId { get; set; }
|
||||
@ -115,27 +119,11 @@ namespace QSB.Player
|
||||
|
||||
// Animation
|
||||
public AnimationSync AnimationSync => QSBPlayerManager.GetSyncObject<AnimationSync>(PlayerId);
|
||||
public bool PlayingInstrument => AnimationSync.CurrentType is not AnimationType.PlayerSuited
|
||||
public bool PlayingInstrument => AnimationSync.CurrentType
|
||||
is not AnimationType.PlayerSuited
|
||||
and not AnimationType.PlayerUnsuited;
|
||||
public JetpackAccelerationSync JetpackAcceleration { get; set; }
|
||||
|
||||
// Misc
|
||||
// CLEANUP : this file is very messy. especially this bit
|
||||
public bool IsReady { get; set; }
|
||||
public bool IsInMoon;
|
||||
public bool IsInShrine;
|
||||
public IQSBQuantumObject EntangledObject;
|
||||
public bool IsDead { get; set; }
|
||||
public ClientState State { get; set; }
|
||||
public bool FlashlightActive { get; set; }
|
||||
public bool SuitedUp { get; set; }
|
||||
public bool ProbeLauncherEquipped { get; set; }
|
||||
public bool SignalscopeEquipped { get; set; }
|
||||
public bool TranslatorEquipped { get; set; }
|
||||
public bool ProbeActive { get; set; }
|
||||
public QSBPlayerAudioController AudioController { get; set; }
|
||||
public EyeState EyeState { get; set; }
|
||||
|
||||
// Local only
|
||||
public PlayerProbeLauncher LocalProbeLauncher
|
||||
{
|
||||
|
@ -17,6 +17,9 @@ namespace QSB.Utility
|
||||
var playerBody = Locator.GetPlayerBody();
|
||||
playerBody.WarpToPositionRotation(spawnPoint.transform.position, spawnPoint.transform.rotation);
|
||||
playerBody.SetVelocity(spawnPoint.GetPointVelocity());
|
||||
var bridgeVolume = FindObjectOfType<VesselWarpController>()._bridgeVolume;
|
||||
bridgeVolume.AddObjectToVolume(Locator.GetPlayerDetector());
|
||||
bridgeVolume.AddObjectToVolume(Locator.GetPlayerCameraDetector());
|
||||
}
|
||||
|
||||
private void InsertWarpCore()
|
||||
@ -24,9 +27,6 @@ namespace QSB.Utility
|
||||
var warpCore = GameObject.Find("Prefab_NOM_WarpCoreVessel").GetComponent<WarpCoreItem>();
|
||||
var socket = GameObject.Find("Interactibles_VesselBridge").GetComponentInChildren<WarpCoreSocket>();
|
||||
socket.PlaceIntoSocket(warpCore);
|
||||
var bridgeVolume = FindObjectOfType<VesselWarpController>()._bridgeVolume;
|
||||
bridgeVolume.AddObjectToVolume(Locator.GetPlayerDetector());
|
||||
bridgeVolume.AddObjectToVolume(Locator.GetPlayerCameraDetector());
|
||||
}
|
||||
|
||||
private void DamageShipElectricalSystem() => ShipManager.Instance.ShipElectricalComponent.SetDamaged(true);
|
||||
|
@ -272,6 +272,16 @@ namespace QSB.Utility
|
||||
|
||||
foreach (var obj in QSBWorldSync.GetWorldObjects())
|
||||
{
|
||||
if (obj == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (obj.ReturnObject() == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (obj.ShouldDisplayLabel())
|
||||
{
|
||||
DrawLabel(obj.ReturnObject().transform, obj.ReturnLabel());
|
||||
|
Loading…
x
Reference in New Issue
Block a user