setting for player names

This commit is contained in:
Mister_Nebula 2022-11-07 20:14:03 +00:00
parent 165ae8fdaf
commit 9c4c80eb36
7 changed files with 64 additions and 3 deletions

View File

@ -1,4 +1,5 @@
using QSB.Utility;
using QSB.ServerSettings;
using QSB.Utility;
using UnityEngine;
namespace QSB.Player;
@ -34,6 +35,11 @@ public class PlayerHUDMarker : HUDDistanceMarker
return false;
}
if (!ServerSettingsManager.ShowPlayerNames)
{
return false;
}
return _player.IsReady &&
!_player.IsDead &&
_player.Visible &&

View File

@ -1,4 +1,5 @@
using QSB.Utility;
using QSB.ServerSettings;
using QSB.Utility;
using UnityEngine;
namespace QSB.Player;
@ -57,6 +58,11 @@ public class PlayerMapMarker : MonoBehaviour
return false;
}
if (!ServerSettingsManager.ShowPlayerNames)
{
return false;
}
var playerScreenPos = Locator.GetActiveCamera().WorldToScreenPoint(transform.position);
var isInfrontOfCamera = playerScreenPos.z > 0f;

View File

@ -4,9 +4,11 @@ using OWML.Common;
using OWML.ModHelper;
using QSB.Localization;
using QSB.Menus;
using QSB.Messaging;
using QSB.Patches;
using QSB.QuantumSync;
using QSB.SaveSync;
using QSB.ServerSettings;
using QSB.Utility;
using QSB.WorldSync;
using System;
@ -56,6 +58,7 @@ public class QSBCore : ModBehaviour
Application.version.Split('.').Take(3).Join(delimiter: ".");
public static bool DLCInstalled => EntitlementsManager.IsDlcOwned() == EntitlementsManager.AsyncOwnershipStatus.Owned;
public static bool IncompatibleModsAllowed { get; private set; }
public static bool ShowPlayerNames { get; private set; }
public static GameVendor GameVendor { get; private set; } = GameVendor.None;
public static bool IsStandalone => GameVendor is GameVendor.Epic or GameVendor.Steam;
public static IProfileManager ProfileManager => IsStandalone
@ -242,6 +245,14 @@ public class QSBCore : ModBehaviour
{
DefaultServerIP = config.GetSettingsValue<string>("defaultServerIP");
IncompatibleModsAllowed = config.GetSettingsValue<bool>("incompatibleModsAllowed");
var _showPlayerNames = config.GetSettingsValue<bool>("showPlayerNames");
if (_showPlayerNames != ShowPlayerNames)
{
new ServerSettingsMessage().Send();
}
ShowPlayerNames = _showPlayerNames;
}
private void Update()

View File

@ -1,6 +1,7 @@
using QSB.ConversationSync.Messages;
using QSB.Messaging;
using QSB.Player;
using QSB.ServerSettings;
using QSB.Utility;
namespace QSB.SaveSync.Messages;
@ -21,6 +22,7 @@ internal class RequestGameStateMessage : QSBMessage
}
new GameStateMessage(From).Send();
new ServerSettingsMessage().Send();
var gameSave = PlayerData._currentGameSave;

View File

@ -0,0 +1,9 @@
using QSB.Utility;
using UnityEngine;
namespace QSB.ServerSettings;
internal class ServerSettingsManager : MonoBehaviour, IAddComponentOnStart
{
public static bool ShowPlayerNames;
}

View File

@ -0,0 +1,26 @@
using Mirror;
using QSB.Messaging;
namespace QSB.ServerSettings;
internal class ServerSettingsMessage : QSBMessage
{
private bool _showPlayerNames;
public override void Serialize(NetworkWriter writer)
{
base.Serialize(writer);
writer.Write(QSBCore.ShowPlayerNames);
}
public override void Deserialize(NetworkReader reader)
{
base.Deserialize(reader);
_showPlayerNames = reader.ReadBool();
}
public override void OnReceiveRemote()
{
ServerSettingsManager.ShowPlayerNames = _showPlayerNames;
}
}

View File

@ -2,6 +2,7 @@
"enabled": true,
"settings": {
"defaultServerIP": "localhost",
"incompatibleModsAllowed": false
"incompatibleModsAllowed": false,
"showPlayerNames": true
}
}