From 1fd0079018224c8a0e56c38dc101924c80356b68 Mon Sep 17 00:00:00 2001 From: Mister_Nebula <41904486+misternebula@users.noreply.github.com> Date: Sat, 19 Jun 2021 13:22:05 +0100 Subject: [PATCH] add ship to enter/leave --- QSB/Events/EventNames.cs | 2 ++ QSB/Player/EnterLeaveType.cs | 4 +++- QSB/Player/Events/EnterLeaveEvent.cs | 2 ++ QSB/ShipSync/ShipManager.cs | 14 ++++++++++++++ 4 files changed, 21 insertions(+), 1 deletion(-) diff --git a/QSB/Events/EventNames.cs b/QSB/Events/EventNames.cs index 1f077434..68a90728 100644 --- a/QSB/Events/EventNames.cs +++ b/QSB/Events/EventNames.cs @@ -24,6 +24,8 @@ public static string ExitRoastingMode = "ExitRoastingMode"; public static string EnterFlightConsole = "EnterFlightConsole"; public static string ExitFlightConsole = "ExitFlightConsole"; + public static string EnterShip = "EnterShip"; + public static string ExitShip = "ExitShip"; // Custom event names -- change if you want! These can be anything, as long as both // sides of the GlobalMessenger (fireevent and addlistener) reference the same thing. diff --git a/QSB/Player/EnterLeaveType.cs b/QSB/Player/EnterLeaveType.cs index 534e16b8..ef2bbf07 100644 --- a/QSB/Player/EnterLeaveType.cs +++ b/QSB/Player/EnterLeaveType.cs @@ -9,6 +9,8 @@ EnterPlatform = 4, ExitPlatform = 5, EnterHeadZone = 6, - ExitHeadZone = 7 + ExitHeadZone = 7, + EnterShip = 8, + ExitShip = 9 } } diff --git a/QSB/Player/Events/EnterLeaveEvent.cs b/QSB/Player/Events/EnterLeaveEvent.cs index 9343c746..2642dc21 100644 --- a/QSB/Player/Events/EnterLeaveEvent.cs +++ b/QSB/Player/Events/EnterLeaveEvent.cs @@ -21,6 +21,8 @@ namespace QSB.Player.Events GlobalMessenger.AddListener(EventNames.QSBExitPlatform, (int id) => Handler(EnterLeaveType.ExitPlatform, id)); GlobalMessenger.AddListener(EventNames.QSBEnterHeadZone, (int id) => Handler(EnterLeaveType.EnterHeadZone, id)); GlobalMessenger.AddListener(EventNames.QSBExitHeadZone, (int id) => Handler(EnterLeaveType.ExitHeadZone, id)); + GlobalMessenger.AddListener(EventNames.EnterShip, () => Handler(EnterLeaveType.EnterShip)); + GlobalMessenger.AddListener(EventNames.ExitShip, () => Handler(EnterLeaveType.ExitShip)); } public override void CloseListener() diff --git a/QSB/ShipSync/ShipManager.cs b/QSB/ShipSync/ShipManager.cs index 7c20594b..83f03f8a 100644 --- a/QSB/ShipSync/ShipManager.cs +++ b/QSB/ShipSync/ShipManager.cs @@ -1,9 +1,11 @@ using OWML.Common; +using QSB.Player; using QSB.ShipSync.TransformSync; using QSB.Utility; using QSB.WorldSync; using QuantumUNET; using System; +using System.Collections.Generic; using System.Linq; using UnityEngine; @@ -33,6 +35,8 @@ namespace QSB.ShipSync } } + private List _playersInShip = new List(); + private uint _currentFlyer = uint.MaxValue; public void Start() @@ -82,6 +86,16 @@ namespace QSB.ShipSync PrintAll(shipHulls); } + public void AddPlayerToShip(PlayerInfo player) + { + _playersInShip.Add(player); + } + + public void RemovePlayerFromShip(PlayerInfo player) + { + _playersInShip.Remove(player); + } + private void PrintAll(Array array) { foreach (var item in array)