mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-03-10 16:14:45 +00:00
add HUD player boxes
This commit is contained in:
parent
8b4bd22ddb
commit
b5968feb4c
19
QSB/HUD/HUDIcon.cs
Normal file
19
QSB/HUD/HUDIcon.cs
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
namespace QSB.HUD;
|
||||||
|
|
||||||
|
public enum HUDIcon
|
||||||
|
{
|
||||||
|
UNKNOWN,
|
||||||
|
SPACE,
|
||||||
|
DEAD,
|
||||||
|
SHIP,
|
||||||
|
CAVE_TWIN,
|
||||||
|
TOWER_TWIN,
|
||||||
|
TIMBER_HEARTH,
|
||||||
|
ATTLEROCK,
|
||||||
|
BRITTLE_HOLLOW,
|
||||||
|
HOLLOWS_LANTERN,
|
||||||
|
GIANTS_DEEP,
|
||||||
|
DARK_BRAMBLE,
|
||||||
|
INTERLOPER,
|
||||||
|
WHITE_HOLE
|
||||||
|
}
|
26
QSB/HUD/Messages/PlanetMessage.cs
Normal file
26
QSB/HUD/Messages/PlanetMessage.cs
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
using QSB.Messaging;
|
||||||
|
using QSB.Player;
|
||||||
|
using QSB.Utility;
|
||||||
|
|
||||||
|
namespace QSB.HUD.Messages;
|
||||||
|
|
||||||
|
internal class PlanetMessage : QSBMessage<HUDIcon>
|
||||||
|
{
|
||||||
|
public PlanetMessage(HUDIcon icon) : base(icon) { }
|
||||||
|
|
||||||
|
public override void OnReceiveLocal() => OnReceiveRemote();
|
||||||
|
|
||||||
|
public override void OnReceiveRemote()
|
||||||
|
{
|
||||||
|
var from = QSBPlayerManager.GetPlayer(From);
|
||||||
|
|
||||||
|
if (from == default)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
DebugLog.DebugWrite($"{From} now on {Data}");
|
||||||
|
|
||||||
|
from.HUDBox?.UpdateIcon(Data);
|
||||||
|
}
|
||||||
|
}
|
170
QSB/HUD/MultiplayerHUDManager.cs
Normal file
170
QSB/HUD/MultiplayerHUDManager.cs
Normal file
@ -0,0 +1,170 @@
|
|||||||
|
using QSB.HUD.Messages;
|
||||||
|
using QSB.Messaging;
|
||||||
|
using QSB.Player;
|
||||||
|
using QSB.Utility;
|
||||||
|
using QSB.WorldSync;
|
||||||
|
using System.Linq;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.SceneManagement;
|
||||||
|
|
||||||
|
namespace QSB.HUD;
|
||||||
|
|
||||||
|
internal class MultiplayerHUDManager : MonoBehaviour, IAddComponentOnStart
|
||||||
|
{
|
||||||
|
private Transform _playerList;
|
||||||
|
|
||||||
|
public static Sprite UnknownSprite;
|
||||||
|
public static Sprite DeadSprite;
|
||||||
|
public static Sprite SpaceSprite;
|
||||||
|
public static Sprite ShipSprite;
|
||||||
|
public static Sprite TimberHearth;
|
||||||
|
public static Sprite Attlerock;
|
||||||
|
public static Sprite CaveTwin;
|
||||||
|
public static Sprite TowerTwin;
|
||||||
|
public static Sprite BrittleHollow;
|
||||||
|
public static Sprite HollowsLantern;
|
||||||
|
public static Sprite GiantsDeep;
|
||||||
|
public static Sprite DarkBramble;
|
||||||
|
public static Sprite Interloper;
|
||||||
|
public static Sprite WhiteHole;
|
||||||
|
|
||||||
|
public static ListStack<HUDIcon> HUDIconStack = new();
|
||||||
|
|
||||||
|
private void Start()
|
||||||
|
{
|
||||||
|
GlobalMessenger.AddListener(OWEvents.WakeUp, OnWakeUp);
|
||||||
|
|
||||||
|
QSBPlayerManager.OnAddPlayer += OnAddPlayer;
|
||||||
|
QSBPlayerManager.OnRemovePlayer += OnRemovePlayer;
|
||||||
|
|
||||||
|
UnknownSprite = QSBCore.HUDAssetBundle.LoadAsset<Sprite>("Assets/MULTIPLAYER_UI/playerbox_unknown.png");
|
||||||
|
DeadSprite = QSBCore.HUDAssetBundle.LoadAsset<Sprite>("Assets/MULTIPLAYER_UI/playerbox_dead.png");
|
||||||
|
ShipSprite = QSBCore.HUDAssetBundle.LoadAsset<Sprite>("Assets/MULTIPLAYER_UI/playerbox_ship.png");
|
||||||
|
CaveTwin = QSBCore.HUDAssetBundle.LoadAsset<Sprite>("Assets/MULTIPLAYER_UI/playerbox_cavetwin.png");
|
||||||
|
TowerTwin = QSBCore.HUDAssetBundle.LoadAsset<Sprite>("Assets/MULTIPLAYER_UI/playerbox_towertwin.png");
|
||||||
|
TimberHearth = QSBCore.HUDAssetBundle.LoadAsset<Sprite>("Assets/MULTIPLAYER_UI/playerbox_timberhearth.png");
|
||||||
|
Attlerock = QSBCore.HUDAssetBundle.LoadAsset<Sprite>("Assets/MULTIPLAYER_UI/playerbox_attlerock.png");
|
||||||
|
BrittleHollow = QSBCore.HUDAssetBundle.LoadAsset<Sprite>("Assets/MULTIPLAYER_UI/playerbox_brittlehollow.png");
|
||||||
|
HollowsLantern = QSBCore.HUDAssetBundle.LoadAsset<Sprite>("Assets/MULTIPLAYER_UI/playerbox_hollowslantern.png");
|
||||||
|
GiantsDeep = QSBCore.HUDAssetBundle.LoadAsset<Sprite>("Assets/MULTIPLAYER_UI/playerbox_giantsdeep.png");
|
||||||
|
DarkBramble = QSBCore.HUDAssetBundle.LoadAsset<Sprite>("Assets/MULTIPLAYER_UI/playerbox_darkbramble.png");
|
||||||
|
Interloper = QSBCore.HUDAssetBundle.LoadAsset<Sprite>("Assets/MULTIPLAYER_UI/playerbox_interloper.png");
|
||||||
|
WhiteHole = QSBCore.HUDAssetBundle.LoadAsset<Sprite>("Assets/MULTIPLAYER_UI/playerbox_whitehole.png");
|
||||||
|
SpaceSprite = QSBCore.HUDAssetBundle.LoadAsset<Sprite>("Assets/MULTIPLAYER_UI/playerbox_space.png");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnWakeUp()
|
||||||
|
{
|
||||||
|
var hudController = Locator.GetPlayerCamera().transform.Find("Helmet").Find("HUDController").GetComponent<HUDCanvas>();
|
||||||
|
var hudCamera = hudController._hudCamera;
|
||||||
|
var hudCanvas = hudCamera.transform.parent.Find("UICanvas");
|
||||||
|
|
||||||
|
var multiplayerGroup = Instantiate(QSBCore.HUDAssetBundle.LoadAsset<GameObject>("assets/Prefabs/multiplayergroup.prefab"));
|
||||||
|
multiplayerGroup.transform.parent = hudCanvas;
|
||||||
|
multiplayerGroup.transform.localPosition = new Vector3(457.4747f, -34.9757f, 41.7683f);
|
||||||
|
multiplayerGroup.transform.localRotation = Quaternion.Euler(355.0921f, 17.1967f, 359.7854f);
|
||||||
|
multiplayerGroup.transform.localScale = Vector3.one;
|
||||||
|
|
||||||
|
_playerList = multiplayerGroup.transform.Find("PlayerList");
|
||||||
|
|
||||||
|
foreach (var player in QSBPlayerManager.PlayerList)
|
||||||
|
{
|
||||||
|
AddBox(player);
|
||||||
|
}
|
||||||
|
|
||||||
|
CreateTrigger("TowerTwin_Body/Sector_TowerTwin", HUDIcon.TOWER_TWIN);
|
||||||
|
CreateTrigger("CaveTwin_Body/Sector_CaveTwin", HUDIcon.CAVE_TWIN);
|
||||||
|
CreateTrigger("TimberHearth_Body/Sector_TH", HUDIcon.TIMBER_HEARTH);
|
||||||
|
CreateTrigger("Moon_Body/Sector_THM", HUDIcon.ATTLEROCK);
|
||||||
|
CreateTrigger("BrittleHollow_Body/Sector_BH", HUDIcon.BRITTLE_HOLLOW);
|
||||||
|
CreateTrigger("VolcanicMoon_Body/Sector_VM", HUDIcon.HOLLOWS_LANTERN);
|
||||||
|
CreateTrigger("GiantsDeep_Body/Sector_GD", HUDIcon.GIANTS_DEEP);
|
||||||
|
CreateTrigger("DarkBramble_Body/Sector_DB", HUDIcon.DARK_BRAMBLE);
|
||||||
|
CreateTrigger("Comet_Body/Sector_CO", HUDIcon.INTERLOPER);
|
||||||
|
CreateTrigger("WhiteHole_Body/Sector_WhiteHole", HUDIcon.WHITE_HOLE);
|
||||||
|
|
||||||
|
HUDIconStack.Clear();
|
||||||
|
HUDIconStack.Push(HUDIcon.SPACE);
|
||||||
|
HUDIconStack.Push(HUDIcon.TIMBER_HEARTH);
|
||||||
|
|
||||||
|
new PlanetMessage(HUDIcon.TIMBER_HEARTH).Send();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void AddBox(PlayerInfo player)
|
||||||
|
{
|
||||||
|
var box = Instantiate(QSBCore.HUDAssetBundle.LoadAsset<GameObject>("assets/Prefabs/playerbox.prefab"));
|
||||||
|
box.transform.parent = _playerList;
|
||||||
|
box.transform.localScale = new Vector3(1, 1, 1);
|
||||||
|
box.transform.localPosition = Vector3.zero;
|
||||||
|
box.transform.localRotation = Quaternion.identity;
|
||||||
|
|
||||||
|
var boxScript = box.GetComponent<PlayerBox>();
|
||||||
|
boxScript.AssignPlayer(player);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnAddPlayer(PlayerInfo player)
|
||||||
|
{
|
||||||
|
if (!QSBWorldSync.AllObjectsReady)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
AddBox(player);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnRemovePlayer(PlayerInfo player)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private PlanetTrigger CreateTrigger(string parentPath, HUDIcon icon)
|
||||||
|
=> CreateTrigger(Find(parentPath), icon);
|
||||||
|
|
||||||
|
private PlanetTrigger CreateTrigger(GameObject parent, HUDIcon icon)
|
||||||
|
{
|
||||||
|
if (parent == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
var triggerGO = parent.FindChild("HUD_PLANET_TRIGGER");
|
||||||
|
if (triggerGO != null)
|
||||||
|
{
|
||||||
|
var trigger = triggerGO.GetAddComponent<PlanetTrigger>();
|
||||||
|
trigger.Icon = icon;
|
||||||
|
return trigger;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
triggerGO = new GameObject("HUD_PLANET_TRIGGER");
|
||||||
|
triggerGO.transform.SetParent(parent.transform, false);
|
||||||
|
triggerGO.SetActive(false);
|
||||||
|
var trigger = triggerGO.AddComponent<PlanetTrigger>();
|
||||||
|
trigger.Icon = icon;
|
||||||
|
triggerGO.SetActive(true);
|
||||||
|
return trigger;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static GameObject Find(string path)
|
||||||
|
{
|
||||||
|
var go = GameObject.Find(path);
|
||||||
|
|
||||||
|
if (go == null)
|
||||||
|
{
|
||||||
|
// find inactive use root + transform.find
|
||||||
|
var names = path.Split('/');
|
||||||
|
var rootName = names[0];
|
||||||
|
var root = SceneManager.GetActiveScene().GetRootGameObjects().FirstOrDefault(x => x.name == rootName);
|
||||||
|
if (root == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
var childPath = string.Join("/", names.Skip(1));
|
||||||
|
go = root.FindChild(childPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
return go;
|
||||||
|
}
|
||||||
|
}
|
36
QSB/HUD/PlanetTrigger.cs
Normal file
36
QSB/HUD/PlanetTrigger.cs
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
using QSB.HUD.Messages;
|
||||||
|
using QSB.Messaging;
|
||||||
|
using QSB.Utility;
|
||||||
|
|
||||||
|
namespace QSB.HUD;
|
||||||
|
|
||||||
|
public class PlanetTrigger : SectoredMonoBehaviour
|
||||||
|
{
|
||||||
|
public HUDIcon Icon;
|
||||||
|
|
||||||
|
public override void OnSectorOccupantAdded(SectorDetector detector)
|
||||||
|
{
|
||||||
|
if (detector.GetOccupantType() != DynamicOccupant.Player)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
MultiplayerHUDManager.HUDIconStack.Push(Icon);
|
||||||
|
var top = MultiplayerHUDManager.HUDIconStack.Peek();
|
||||||
|
DebugLog.DebugWrite($"Pushed {Icon}. Top is now {top}");
|
||||||
|
new PlanetMessage(top).Send();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void OnSectorOccupantRemoved(SectorDetector detector)
|
||||||
|
{
|
||||||
|
if (detector.GetOccupantType() != DynamicOccupant.Player)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
MultiplayerHUDManager.HUDIconStack.Remove(Icon);
|
||||||
|
var top = MultiplayerHUDManager.HUDIconStack.Peek();
|
||||||
|
DebugLog.DebugWrite($"Removed {Icon}. Top is now {top}");
|
||||||
|
new PlanetMessage(top).Send();
|
||||||
|
}
|
||||||
|
}
|
84
QSB/HUD/PlayerBox.cs
Normal file
84
QSB/HUD/PlayerBox.cs
Normal file
@ -0,0 +1,84 @@
|
|||||||
|
using QSB.Player;
|
||||||
|
using QSB.Utility;
|
||||||
|
using System;
|
||||||
|
using System.Linq;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.SceneManagement;
|
||||||
|
using UnityEngine.UI;
|
||||||
|
|
||||||
|
namespace QSB.HUD;
|
||||||
|
|
||||||
|
public class PlayerBox : MonoBehaviour
|
||||||
|
{
|
||||||
|
public Text PlayerName;
|
||||||
|
public Image InfoImage;
|
||||||
|
|
||||||
|
private PlayerInfo _player;
|
||||||
|
private bool _planetIconOverride;
|
||||||
|
private HUDIcon _planetIcon;
|
||||||
|
|
||||||
|
public void AssignPlayer(PlayerInfo player)
|
||||||
|
{
|
||||||
|
_player = player;
|
||||||
|
_player.HUDBox = this;
|
||||||
|
|
||||||
|
if (player.Name != null)
|
||||||
|
{
|
||||||
|
PlayerName.text = player.Name.ToUpper();
|
||||||
|
}
|
||||||
|
|
||||||
|
InfoImage.sprite = MultiplayerHUDManager.UnknownSprite;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void OnDeath()
|
||||||
|
{
|
||||||
|
InfoImage.sprite = MultiplayerHUDManager.DeadSprite;
|
||||||
|
_planetIconOverride = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void OnRespawn()
|
||||||
|
{
|
||||||
|
InfoImage.sprite = MultiplayerHUDManager.ShipSprite;
|
||||||
|
_planetIconOverride = true; // still in ship
|
||||||
|
}
|
||||||
|
|
||||||
|
public void OnEnterShip()
|
||||||
|
{
|
||||||
|
InfoImage.sprite = MultiplayerHUDManager.ShipSprite;
|
||||||
|
_planetIconOverride = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void OnExitShip()
|
||||||
|
{
|
||||||
|
_planetIconOverride = false;
|
||||||
|
InfoImage.sprite = SpriteFromEnum(_planetIcon);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void UpdateIcon(HUDIcon icon)
|
||||||
|
{
|
||||||
|
_planetIcon = icon;
|
||||||
|
|
||||||
|
if (!_planetIconOverride)
|
||||||
|
{
|
||||||
|
InfoImage.sprite = SpriteFromEnum(_planetIcon);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Sprite SpriteFromEnum(HUDIcon icon) => icon switch
|
||||||
|
{
|
||||||
|
HUDIcon.SHIP => MultiplayerHUDManager.ShipSprite,
|
||||||
|
HUDIcon.DEAD => MultiplayerHUDManager.DeadSprite,
|
||||||
|
HUDIcon.SPACE => MultiplayerHUDManager.SpaceSprite,
|
||||||
|
HUDIcon.CAVE_TWIN => MultiplayerHUDManager.CaveTwin,
|
||||||
|
HUDIcon.TOWER_TWIN => MultiplayerHUDManager.TowerTwin,
|
||||||
|
HUDIcon.TIMBER_HEARTH => MultiplayerHUDManager.TimberHearth,
|
||||||
|
HUDIcon.ATTLEROCK => MultiplayerHUDManager.Attlerock,
|
||||||
|
HUDIcon.BRITTLE_HOLLOW => MultiplayerHUDManager.BrittleHollow,
|
||||||
|
HUDIcon.HOLLOWS_LANTERN => MultiplayerHUDManager.HollowsLantern,
|
||||||
|
HUDIcon.GIANTS_DEEP => MultiplayerHUDManager.GiantsDeep,
|
||||||
|
HUDIcon.DARK_BRAMBLE => MultiplayerHUDManager.DarkBramble,
|
||||||
|
HUDIcon.INTERLOPER => MultiplayerHUDManager.Interloper,
|
||||||
|
HUDIcon.WHITE_HOLE => MultiplayerHUDManager.WhiteHole,
|
||||||
|
_ => MultiplayerHUDManager.UnknownSprite,
|
||||||
|
};
|
||||||
|
}
|
@ -93,6 +93,11 @@ public class PlayerInformationMessage : QSBMessage
|
|||||||
() => player.Camera.fieldOfView = FieldOfView);
|
() => player.Camera.fieldOfView = FieldOfView);
|
||||||
|
|
||||||
player.State = ClientState;
|
player.State = ClientState;
|
||||||
|
|
||||||
|
if (player.HUDBox != null)
|
||||||
|
{
|
||||||
|
player.HUDBox.PlayerName.text = PlayerName.ToUpper();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
using QSB.Animation.Player;
|
using QSB.Animation.Player;
|
||||||
using QSB.Audio;
|
using QSB.Audio;
|
||||||
using QSB.ClientServerStateSync;
|
using QSB.ClientServerStateSync;
|
||||||
|
using QSB.HUD;
|
||||||
using QSB.Messaging;
|
using QSB.Messaging;
|
||||||
using QSB.ModelShip;
|
using QSB.ModelShip;
|
||||||
using QSB.Player.Messages;
|
using QSB.Player.Messages;
|
||||||
@ -23,6 +24,7 @@ public partial class PlayerInfo
|
|||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
public PlayerHUDMarker HudMarker { get; set; }
|
public PlayerHUDMarker HudMarker { get; set; }
|
||||||
public PlayerMapMarker MapMarker { get; set; }
|
public PlayerMapMarker MapMarker { get; set; }
|
||||||
|
public PlayerBox HUDBox { get; set; }
|
||||||
public PlayerTransformSync TransformSync { get; }
|
public PlayerTransformSync TransformSync { get; }
|
||||||
public ClientState State { get; set; }
|
public ClientState State { get; set; }
|
||||||
public EyeState EyeState { get; set; }
|
public EyeState EyeState { get; set; }
|
||||||
@ -159,5 +161,19 @@ public partial class PlayerInfo
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void Die()
|
||||||
|
{
|
||||||
|
IsDead = true;
|
||||||
|
SetVisible(false, 1);
|
||||||
|
HUDBox.OnDeath();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Revive()
|
||||||
|
{
|
||||||
|
IsDead = false;
|
||||||
|
SetVisible(true, 1);
|
||||||
|
HUDBox.OnRespawn();
|
||||||
|
}
|
||||||
|
|
||||||
public override string ToString() => $"{PlayerId}:{GetType().Name} ({Name})";
|
public override string ToString() => $"{PlayerId}:{GetType().Name} ({Name})";
|
||||||
}
|
}
|
||||||
|
@ -142,7 +142,7 @@ internal class RespawnManager : MonoBehaviour, IAddComponentOnStart
|
|||||||
|
|
||||||
public void OnPlayerDeath(PlayerInfo player)
|
public void OnPlayerDeath(PlayerInfo player)
|
||||||
{
|
{
|
||||||
player.IsDead = true;
|
player.Die();
|
||||||
|
|
||||||
if (_playersPendingRespawn.Contains(player))
|
if (_playersPendingRespawn.Contains(player))
|
||||||
{
|
{
|
||||||
@ -160,13 +160,11 @@ internal class RespawnManager : MonoBehaviour, IAddComponentOnStart
|
|||||||
new EndLoopMessage().Send();
|
new EndLoopMessage().Send();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
player.SetVisible(false, 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnPlayerRespawn(PlayerInfo player)
|
public void OnPlayerRespawn(PlayerInfo player)
|
||||||
{
|
{
|
||||||
player.IsDead = false;
|
player.Revive();
|
||||||
|
|
||||||
if (!_playersPendingRespawn.Contains(player))
|
if (!_playersPendingRespawn.Contains(player))
|
||||||
{
|
{
|
||||||
@ -176,8 +174,6 @@ internal class RespawnManager : MonoBehaviour, IAddComponentOnStart
|
|||||||
{
|
{
|
||||||
_playersPendingRespawn.Remove(player);
|
_playersPendingRespawn.Remove(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
player.SetVisible(true, 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RespawnSomePlayer()
|
public void RespawnSomePlayer()
|
||||||
|
@ -166,6 +166,7 @@ internal class ShipManager : WorldObjectManager
|
|||||||
public void AddPlayerToShip(PlayerInfo player)
|
public void AddPlayerToShip(PlayerInfo player)
|
||||||
{
|
{
|
||||||
player.IsInShip = true;
|
player.IsInShip = true;
|
||||||
|
player.HUDBox.OnEnterShip();
|
||||||
_playersInShip.Add(player);
|
_playersInShip.Add(player);
|
||||||
UpdateElectricalComponent();
|
UpdateElectricalComponent();
|
||||||
}
|
}
|
||||||
@ -173,6 +174,7 @@ internal class ShipManager : WorldObjectManager
|
|||||||
public void RemovePlayerFromShip(PlayerInfo player)
|
public void RemovePlayerFromShip(PlayerInfo player)
|
||||||
{
|
{
|
||||||
player.IsInShip = false;
|
player.IsInShip = false;
|
||||||
|
player.HUDBox.OnExitShip();
|
||||||
_playersInShip.Remove(player);
|
_playersInShip.Remove(player);
|
||||||
UpdateElectricalComponent();
|
UpdateElectricalComponent();
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
using QSB.ClientServerStateSync;
|
using QSB.ClientServerStateSync;
|
||||||
using QSB.EchoesOfTheEye.Ghosts.WorldObjects;
|
using QSB.EchoesOfTheEye.Ghosts.WorldObjects;
|
||||||
|
using QSB.HUD;
|
||||||
using QSB.Player;
|
using QSB.Player;
|
||||||
using QSB.Player.TransformSync;
|
using QSB.Player.TransformSync;
|
||||||
using QSB.ShipSync;
|
using QSB.ShipSync;
|
||||||
@ -152,6 +153,12 @@ internal class DebugGUI : MonoBehaviour, IAddComponentOnStart
|
|||||||
{
|
{
|
||||||
WriteLine(1, $" - {item}");
|
WriteLine(1, $" - {item}");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WriteLine(1, $"HUD Icon Stack :");
|
||||||
|
foreach (var item in MultiplayerHUDManager.HUDIconStack)
|
||||||
|
{
|
||||||
|
WriteLine(1, $" - {item}");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
51
QSB/Utility/ListStack.cs
Normal file
51
QSB/Utility/ListStack.cs
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace QSB.Utility;
|
||||||
|
|
||||||
|
public class ListStack<T> : IEnumerable<T>
|
||||||
|
{
|
||||||
|
private readonly List<T> _items = new();
|
||||||
|
|
||||||
|
public void Clear()
|
||||||
|
=> _items.Clear();
|
||||||
|
|
||||||
|
public void Push(T item)
|
||||||
|
{
|
||||||
|
if (_items.Contains(item))
|
||||||
|
{
|
||||||
|
RemoveAll(x => EqualityComparer<T>.Default.Equals(x, item));
|
||||||
|
}
|
||||||
|
|
||||||
|
_items.Add(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
public T Pop()
|
||||||
|
{
|
||||||
|
if (_items.Count > 0)
|
||||||
|
{
|
||||||
|
var temp = _items[_items.Count - 1];
|
||||||
|
_items.RemoveAt(_items.Count - 1);
|
||||||
|
return temp;
|
||||||
|
}
|
||||||
|
|
||||||
|
return default;
|
||||||
|
}
|
||||||
|
|
||||||
|
public T Peek() => _items.Count > 0
|
||||||
|
? _items[_items.Count - 1]
|
||||||
|
: default;
|
||||||
|
|
||||||
|
public void RemoveAt(int index)
|
||||||
|
=> _items.RemoveAt(index);
|
||||||
|
|
||||||
|
public bool Remove(T item)
|
||||||
|
=> _items.Remove(item);
|
||||||
|
|
||||||
|
public int RemoveAll(Predicate<T> match)
|
||||||
|
=> _items.RemoveAll(match);
|
||||||
|
|
||||||
|
IEnumerator<T> IEnumerable<T>.GetEnumerator() => ((IEnumerable<T>)_items).GetEnumerator();
|
||||||
|
public IEnumerator GetEnumerator() => ((IEnumerable<T>)_items).GetEnumerator();
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user