diff --git a/.gitignore b/.gitignore
index c4d56b42c..38339019d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -105,3 +105,4 @@ Assets/Content/Addressables/Windows/addressables_content_state.bin
Assets/Content/Addressables/Windows/addressables_content_state.bin.meta
Assets/Content/Addressables/link.xml
Assets/Content/Addressables/link.xml.meta
+graphify-out/
diff --git a/Assets/Scripts/SS3D/Permissions/PermissionSettings.cs b/Assets/Scripts/SS3D/Permissions/PermissionSettings.cs
index cb1ea3536..38af19699 100644
--- a/Assets/Scripts/SS3D/Permissions/PermissionSettings.cs
+++ b/Assets/Scripts/SS3D/Permissions/PermissionSettings.cs
@@ -12,9 +12,18 @@ public class PermissionSettings : ScriptableSettings
[SerializeField]
private bool _addServerOwnerPermissionToServerHost;
+ [SerializeField]
+ private bool _adminFunctionsForAll;
+
///
/// We can define if the host will get the owner permission when he joins the game.
///
public static bool AddServerOwnerPermissionToServerHost => GetOrFind()._addServerOwnerPermissionToServerHost;
+
+ ///
+ /// If true, admin-only functions are available to all users.
+ /// Defaults to false, meaning only admins (host by default) can use admin functions.
+ ///
+ public static bool AdminFunctionsForAll => GetOrFind()._adminFunctionsForAll;
}
}
\ No newline at end of file
diff --git a/Assets/Scripts/SS3D/Systems/Tile/TileMapCreator/TileMapMenuSubSystem.cs b/Assets/Scripts/SS3D/Systems/Tile/TileMapCreator/TileMapMenuSubSystem.cs
index f854abe2c..887a7f319 100644
--- a/Assets/Scripts/SS3D/Systems/Tile/TileMapCreator/TileMapMenuSubSystem.cs
+++ b/Assets/Scripts/SS3D/Systems/Tile/TileMapCreator/TileMapMenuSubSystem.cs
@@ -4,6 +4,8 @@
using SS3D.Core;
using SS3D.Core.Behaviours;
using SS3D.Data.Management;
+using SS3D.Logging;
+using SS3D.Permissions;
using SS3D.Systems.Inputs;
using TMPro;
using UnityEngine;
@@ -128,6 +130,12 @@ protected override void OnStart()
///
private void HandleToggleMenu(InputAction.CallbackContext context)
{
+ if (!_enabled && !CanAccessTilemapEditor())
+ {
+ Log.Information(this, "Player lacks permission to access the tilemap editor", Logs.ServerOnly);
+ return;
+ }
+
if (_enabled)
{
_inputSystem.ToggleActionMap(_controls, false, new[] { _controls.ToggleMenu });
@@ -145,6 +153,28 @@ private void HandleToggleMenu(InputAction.CallbackContext context)
ClearAllTab();
_tileMapBuildTab.Display();
}
+
+ ///
+ /// Checks whether the local player is allowed to use the tilemap editor.
+ ///
+ private bool CanAccessTilemapEditor()
+ {
+ if (PermissionSettings.AdminFunctionsForAll)
+ {
+ return true;
+ }
+
+ string ckey = Core.Settings.LocalPlayer.Ckey;
+ if (string.IsNullOrEmpty(ckey))
+ {
+ return false;
+ }
+
+ PermissionSubSystem permissionSystem = SubSystems.Get();
+ return permissionSystem != null
+ && permissionSystem.HasLoadedPermissions
+ && permissionSystem.IsAtLeast(ckey, ServerRoleTypes.Administrator);
+ }
///
/// Hide or show the tilemap menu.