mirror of
https://github.com/NotAKidoS/NAK_CVR_Mods.git
synced 2025-09-02 06:19:22 +00:00
Merge pull request #34 from SketchFoxsky/main
Stickers World Restrictions
This commit is contained in:
commit
50804b323d
10 changed files with 1118 additions and 1038 deletions
|
@ -18,13 +18,15 @@ public static partial class BTKUIAddon
|
||||||
private static readonly MultiSelection _tabDoubleClickSelection =
|
private static readonly MultiSelection _tabDoubleClickSelection =
|
||||||
MultiSelection.CreateMultiSelectionFromMelonPref(ModSettings.Entry_TabDoubleClick);
|
MultiSelection.CreateMultiSelectionFromMelonPref(ModSettings.Entry_TabDoubleClick);
|
||||||
|
|
||||||
|
public static Button placeStickersButton;
|
||||||
|
|
||||||
#region Category Setup
|
#region Category Setup
|
||||||
|
|
||||||
private static void Setup_StickersModCategory()
|
private static void Setup_StickersModCategory()
|
||||||
{
|
{
|
||||||
_ourCategory = _rootPage.AddMelonCategory(ModSettings.Hidden_Foldout_SettingsCategory);
|
_ourCategory = _rootPage.AddMelonCategory(ModSettings.Hidden_Foldout_SettingsCategory);
|
||||||
|
|
||||||
Button placeStickersButton = _ourCategory.AddButton("Place Stickers", "Stickers-magic-wand", "Place stickers via raycast.", ButtonStyle.TextWithIcon);
|
placeStickersButton = _ourCategory.AddButton("Place Stickers", "Stickers-magic-wand", "Place stickers via raycast.", ButtonStyle.TextWithIcon);
|
||||||
placeStickersButton.OnPress += OnPlaceStickersButtonClick;
|
placeStickersButton.OnPress += OnPlaceStickersButtonClick;
|
||||||
|
|
||||||
Button clearSelfStickersButton = _ourCategory.AddButton("Clear Self", "Stickers-eraser", "Clear own stickers.", ButtonStyle.TextWithIcon);
|
Button clearSelfStickersButton = _ourCategory.AddButton("Clear Self", "Stickers-eraser", "Clear own stickers.", ButtonStyle.TextWithIcon);
|
||||||
|
@ -59,10 +61,18 @@ public static partial class BTKUIAddon
|
||||||
private static void OnPlaceStickersButtonClick()
|
private static void OnPlaceStickersButtonClick()
|
||||||
{
|
{
|
||||||
if (!_isOurTabOpened) return;
|
if (!_isOurTabOpened) return;
|
||||||
|
|
||||||
|
if (StickerSystem.RestrictedInstance == false)
|
||||||
|
{
|
||||||
string mode = StickerSystem.Instance.IsInStickerMode ? "Exiting" : "Entering";
|
string mode = StickerSystem.Instance.IsInStickerMode ? "Exiting" : "Entering";
|
||||||
QuickMenuAPI.ShowAlertToast($"{mode} sticker placement mode...", 2);
|
QuickMenuAPI.ShowAlertToast($"{mode} sticker placement mode...", 2);
|
||||||
StickerSystem.Instance.IsInStickerMode = !StickerSystem.Instance.IsInStickerMode;
|
StickerSystem.Instance.IsInStickerMode = !StickerSystem.Instance.IsInStickerMode;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
QuickMenuAPI.ShowAlertToast("Stickers are not allowed in this world!", 2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static void OnClearSelfStickersButtonClick()
|
private static void OnClearSelfStickersButtonClick()
|
||||||
{
|
{
|
||||||
|
@ -85,5 +95,29 @@ public static partial class BTKUIAddon
|
||||||
StickerSystem.OpenStickersFolder();
|
StickerSystem.OpenStickersFolder();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void UpdateStickerMenu() //TODO: add Icon changing, Bono needs to expose the value first.
|
||||||
|
{
|
||||||
|
if (StickerSystem.RestrictedInstance == true)
|
||||||
|
{
|
||||||
|
_rootPage.MenuSubtitle = "Stickers... are sadly disabled in this world.";
|
||||||
|
|
||||||
|
placeStickersButton.Disabled = true;
|
||||||
|
placeStickersButton.ButtonText = "Stickers Disabled";
|
||||||
|
placeStickersButton.ButtonTooltip = "This world is not allowing Stickers.";
|
||||||
|
placeStickersButton.ButtonIcon = "Stickers-magic-wand-broken";
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_rootPage.MenuSubtitle = "Stickers! Double-click the tab to quickly toggle Sticker Mode.";
|
||||||
|
|
||||||
|
placeStickersButton.Disabled = false;
|
||||||
|
placeStickersButton.ButtonText = "Place Stickers";
|
||||||
|
placeStickersButton.ButtonTooltip = "Place stickers via raycast.";
|
||||||
|
placeStickersButton.ButtonIcon = "Stickers-magic-wand";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
#endregion Button Actions
|
#endregion Button Actions
|
||||||
}
|
}
|
|
@ -2,6 +2,8 @@
|
||||||
using BTKUILib.UIObjects;
|
using BTKUILib.UIObjects;
|
||||||
using NAK.Stickers.Networking;
|
using NAK.Stickers.Networking;
|
||||||
using NAK.Stickers.Utilities;
|
using NAK.Stickers.Utilities;
|
||||||
|
using System.Reflection;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
namespace NAK.Stickers.Integrations;
|
namespace NAK.Stickers.Integrations;
|
||||||
|
|
||||||
|
@ -24,24 +26,26 @@ public static partial class BTKUIAddon
|
||||||
private static void Setup_Icons()
|
private static void Setup_Icons()
|
||||||
{
|
{
|
||||||
// All icons used - https://www.flaticon.com/authors/gohsantosadrive
|
// All icons used - https://www.flaticon.com/authors/gohsantosadrive
|
||||||
QuickMenuAPI.PrepareIcon(ModSettings.ModName, "Stickers-alphabet", UIUtils.GetIconStream("Gohsantosadrive_Icons.Stickers-alphabet.png"));
|
QuickMenuAPI.PrepareIcon(ModSettings.ModName, "Stickers-alphabet", Assembly.GetExecutingAssembly().GetManifestResourceStream("Stickers.Resources.Gohsantosadrive_Icons.Stickers-alphabet.png"));
|
||||||
QuickMenuAPI.PrepareIcon(ModSettings.ModName, "Stickers-eraser", UIUtils.GetIconStream("Gohsantosadrive_Icons.Stickers-eraser.png"));
|
QuickMenuAPI.PrepareIcon(ModSettings.ModName, "Stickers-eraser", Assembly.GetExecutingAssembly().GetManifestResourceStream("Stickers.Resources.Gohsantosadrive_Icons.Stickers-eraser.png"));
|
||||||
QuickMenuAPI.PrepareIcon(ModSettings.ModName, "Stickers-folder", UIUtils.GetIconStream("Gohsantosadrive_Icons.Stickers-folder.png"));
|
QuickMenuAPI.PrepareIcon(ModSettings.ModName, "Stickers-folder", Assembly.GetExecutingAssembly().GetManifestResourceStream("Stickers.Resources.Gohsantosadrive_Icons.Stickers-folder.png"));
|
||||||
QuickMenuAPI.PrepareIcon(ModSettings.ModName, "Stickers-headset", UIUtils.GetIconStream("Gohsantosadrive_Icons.Stickers-headset.png"));
|
QuickMenuAPI.PrepareIcon(ModSettings.ModName, "Stickers-headset", Assembly.GetExecutingAssembly().GetManifestResourceStream("Stickers.Resources.Gohsantosadrive_Icons.Stickers-headset.png"));
|
||||||
QuickMenuAPI.PrepareIcon(ModSettings.ModName, "Stickers-magnifying-glass", UIUtils.GetIconStream("Gohsantosadrive_Icons.Stickers-magnifying-glass.png"));
|
QuickMenuAPI.PrepareIcon(ModSettings.ModName, "Stickers-magnifying-glass", Assembly.GetExecutingAssembly().GetManifestResourceStream("Stickers.Resources.Gohsantosadrive_Icons.Stickers-magnifying-glass.png"));
|
||||||
QuickMenuAPI.PrepareIcon(ModSettings.ModName, "Stickers-magic-wand", UIUtils.GetIconStream("Gohsantosadrive_Icons.Stickers-magic-wand.png"));
|
QuickMenuAPI.PrepareIcon(ModSettings.ModName, "Stickers-magic-wand", Assembly.GetExecutingAssembly().GetManifestResourceStream("Stickers.Resources.Gohsantosadrive_Icons.Stickers-magic-wand.png"));
|
||||||
QuickMenuAPI.PrepareIcon(ModSettings.ModName, "Stickers-mouse", UIUtils.GetIconStream("Gohsantosadrive_Icons.Stickers-mouse.png"));
|
QuickMenuAPI.PrepareIcon(ModSettings.ModName, "Stickers-magic-wand-broken", Assembly.GetExecutingAssembly().GetManifestResourceStream("Stickers.Resources.Gohsantosadrive_Icons.Stickers-magic-wand-broken.png"));
|
||||||
|
QuickMenuAPI.PrepareIcon(ModSettings.ModName, "Stickers-mouse", Assembly.GetExecutingAssembly().GetManifestResourceStream("Stickers.Resources.Gohsantosadrive_Icons.Stickers-mouse.png"));
|
||||||
//QuickMenuAPI.PrepareIcon(ModSettings.ModName, "Stickers-pencil", UIUtils.GetIconStream("Gohsantosadrive_Icons.Stickers-pencil.png"));
|
//QuickMenuAPI.PrepareIcon(ModSettings.ModName, "Stickers-pencil", UIUtils.GetIconStream("Gohsantosadrive_Icons.Stickers-pencil.png"));
|
||||||
QuickMenuAPI.PrepareIcon(ModSettings.ModName, "Stickers-puzzle", UIUtils.GetIconStream("Gohsantosadrive_Icons.Stickers-puzzle.png"));
|
QuickMenuAPI.PrepareIcon(ModSettings.ModName, "Stickers-puzzle", Assembly.GetExecutingAssembly().GetManifestResourceStream("Stickers.Resources.Gohsantosadrive_Icons.Stickers-puzzle.png"));
|
||||||
QuickMenuAPI.PrepareIcon(ModSettings.ModName, "Stickers-rubbish-bin", UIUtils.GetIconStream("Gohsantosadrive_Icons.Stickers-rubbish-bin.png"));
|
QuickMenuAPI.PrepareIcon(ModSettings.ModName, "Stickers-puzzle-disabled", Assembly.GetExecutingAssembly().GetManifestResourceStream("Stickers.Resources.Gohsantosadrive_Icons.Stickers-puzzle-disabled.png")); //Disabled Sticker Puzzle
|
||||||
|
QuickMenuAPI.PrepareIcon(ModSettings.ModName, "Stickers-rubbish-bin", Assembly.GetExecutingAssembly().GetManifestResourceStream("Stickers.Resources.Gohsantosadrive_Icons.Stickers-rubbish-bin.png"));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void Setup_StickerModTab()
|
private static void Setup_StickerModTab()
|
||||||
{
|
{
|
||||||
_rootPage = new Page(ModSettings.ModName, ModSettings.SM_SettingsCategory, true, "Stickers-puzzle")
|
_rootPage = new Page(ModSettings.ModName, ModSettings.SM_SettingsCategory, true, "Stickers-Puzzle") //Sticker Icon will be left blank as it is updated on world join, AFTER Icon value is exposed..
|
||||||
{
|
{
|
||||||
MenuTitle = ModSettings.SM_SettingsCategory,
|
MenuTitle = ModSettings.SM_SettingsCategory,
|
||||||
MenuSubtitle = "Stickers! Double-click the tab to quickly toggle Sticker Mode.",
|
MenuSubtitle = "", //Left this blank as it is defined when the world loads
|
||||||
};
|
};
|
||||||
|
|
||||||
_rootPageElementID = _rootPage.ElementID;
|
_rootPageElementID = _rootPage.ElementID;
|
||||||
|
@ -87,7 +91,10 @@ public static partial class BTKUIAddon
|
||||||
{
|
{
|
||||||
default:
|
default:
|
||||||
case TabDoubleClick.ToggleStickerMode:
|
case TabDoubleClick.ToggleStickerMode:
|
||||||
|
if (StickerSystem.RestrictedInstance == false)
|
||||||
|
{
|
||||||
OnPlaceStickersButtonClick();
|
OnPlaceStickersButtonClick();
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case TabDoubleClick.ClearAllStickers:
|
case TabDoubleClick.ClearAllStickers:
|
||||||
OnClearAllStickersButtonClick();
|
OnClearAllStickersButtonClick();
|
||||||
|
|
|
@ -27,6 +27,6 @@ using System.Reflection;
|
||||||
namespace NAK.Stickers.Properties;
|
namespace NAK.Stickers.Properties;
|
||||||
internal static class AssemblyInfoParams
|
internal static class AssemblyInfoParams
|
||||||
{
|
{
|
||||||
public const string Version = "1.0.7";
|
public const string Version = "1.0.8";
|
||||||
public const string Author = "NotAKidoS";
|
public const string Author = "NotAKidoS, SketchFoxsky";
|
||||||
}
|
}
|
|
@ -22,6 +22,12 @@ Any image placed in the `UserData/Stickers/` folder will be available to choose
|
||||||
- Requires the experimental Shader Safety Settings to be disabled as it will cause crashes when decals attempt to generate on GPU.
|
- Requires the experimental Shader Safety Settings to be disabled as it will cause crashes when decals attempt to generate on GPU.
|
||||||
- The mod will automatically disable this setting when it is enabled on startup.
|
- The mod will automatically disable this setting when it is enabled on startup.
|
||||||
|
|
||||||
|
### Restrictions
|
||||||
|
- Full Restriction.
|
||||||
|
- To disable Stickers for the whole world, name an empty GameObject "**[DisableStickers]**".
|
||||||
|
- Partial Restriction.
|
||||||
|
- To keep stickers enabled but not allowing it on certain objects, add the "**[NoSticker]**" tag to the GameObject name.
|
||||||
|
|
||||||
## Attributions
|
## Attributions
|
||||||
- All icons used are by [Gohsantosadrive](<https://www.flaticon.com/authors/gohsantosadrive>) on Flaticon.
|
- All icons used are by [Gohsantosadrive](<https://www.flaticon.com/authors/gohsantosadrive>) on Flaticon.
|
||||||
- Decal generation system by [Mr F](<https://assetstore.unity.com/publishers/37453>) on the Unity Asset Store.
|
- Decal generation system by [Mr F](<https://assetstore.unity.com/publishers/37453>) on the Unity Asset Store.
|
||||||
|
|
Binary file not shown.
After Width: | Height: | Size: 59 KiB |
Binary file not shown.
After Width: | Height: | Size: 37 KiB |
|
@ -43,6 +43,8 @@ public static partial class ModNetwork
|
||||||
|
|
||||||
if (ModSettings.Entry_FriendsOnly.Value && !Friends.FriendsWith(sender))
|
if (ModSettings.Entry_FriendsOnly.Value && !Friends.FriendsWith(sender))
|
||||||
return false; // ignore messages from non-friends if friends only is enabled
|
return false; // ignore messages from non-friends if friends only is enabled
|
||||||
|
if (StickerSystem.RestrictedInstance == true) // ignore messages from users when the world is restricted. This also includes older or modified version of Stickers mod.
|
||||||
|
return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,8 +2,14 @@
|
||||||
using ABI_RC.Core.Networking.IO.Instancing;
|
using ABI_RC.Core.Networking.IO.Instancing;
|
||||||
using ABI_RC.Core.UI;
|
using ABI_RC.Core.UI;
|
||||||
using ABI_RC.Systems.GameEventSystem;
|
using ABI_RC.Systems.GameEventSystem;
|
||||||
|
using JetBrains.Annotations;
|
||||||
using NAK.Stickers.Networking;
|
using NAK.Stickers.Networking;
|
||||||
using NAK.Stickers.Utilities;
|
using NAK.Stickers.Utilities;
|
||||||
|
using System.EnterpriseServices;
|
||||||
|
using UnityEngine;
|
||||||
|
using MelonLoader;
|
||||||
|
using UnityEngine.ProBuilder.MeshOperations;
|
||||||
|
using NAK.Stickers.Integrations;
|
||||||
|
|
||||||
namespace NAK.Stickers;
|
namespace NAK.Stickers;
|
||||||
|
|
||||||
|
@ -11,6 +17,8 @@ public partial class StickerSystem
|
||||||
{
|
{
|
||||||
#region Singleton
|
#region Singleton
|
||||||
|
|
||||||
|
public static bool RestrictedInstance = false;
|
||||||
|
|
||||||
public static StickerSystem Instance { get; private set; }
|
public static StickerSystem Instance { get; private set; }
|
||||||
|
|
||||||
public static void Initialize()
|
public static void Initialize()
|
||||||
|
@ -28,7 +36,8 @@ public partial class StickerSystem
|
||||||
|
|
||||||
// listen for game events
|
// listen for game events
|
||||||
CVRGameEventSystem.Initialization.OnPlayerSetupStart.AddListener(Instance.OnPlayerSetupStart);
|
CVRGameEventSystem.Initialization.OnPlayerSetupStart.AddListener(Instance.OnPlayerSetupStart);
|
||||||
}
|
|
||||||
|
}
|
||||||
|
|
||||||
#endregion Singleton
|
#endregion Singleton
|
||||||
|
|
||||||
|
@ -37,6 +46,7 @@ public partial class StickerSystem
|
||||||
private void OnPlayerSetupStart()
|
private void OnPlayerSetupStart()
|
||||||
{
|
{
|
||||||
CVRGameEventSystem.World.OnUnload.AddListener(_ => OnWorldUnload());
|
CVRGameEventSystem.World.OnUnload.AddListener(_ => OnWorldUnload());
|
||||||
|
CVRGameEventSystem.World.OnLoad.AddListener(_ => OnWorldLoad());
|
||||||
CVRGameEventSystem.Instance.OnConnected.AddListener((_) => { if (!Instances.IsReconnecting) OnInitialConnection(); });
|
CVRGameEventSystem.Instance.OnConnected.AddListener((_) => { if (!Instances.IsReconnecting) OnInitialConnection(); });
|
||||||
|
|
||||||
CVRGameEventSystem.Player.OnJoinEntity.AddListener(Instance.OnPlayerJoined);
|
CVRGameEventSystem.Player.OnJoinEntity.AddListener(Instance.OnPlayerJoined);
|
||||||
|
@ -51,12 +61,29 @@ public partial class StickerSystem
|
||||||
|
|
||||||
private void OnInitialConnection()
|
private void OnInitialConnection()
|
||||||
{
|
{
|
||||||
|
OnWorldLoad(); //Checks the world again in case the bundle updated.
|
||||||
ClearStickersSelf(); // clear stickers on remotes just in case we rejoined
|
ClearStickersSelf(); // clear stickers on remotes just in case we rejoined
|
||||||
ModNetwork.Reset(); // reset network buffers and metadata
|
ModNetwork.Reset(); // reset network buffers and metadata
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void OnWorldLoad()
|
||||||
|
{
|
||||||
|
GameObject StickerWorldRestriction = GameObject.Find("[DisableStickers]");
|
||||||
|
if (StickerWorldRestriction != null)
|
||||||
|
{
|
||||||
|
RestrictedInstance = true;
|
||||||
|
MelonLogger.Msg("This is a Restricted Instance");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MelonLogger.Msg("This is NOT a Restricted Instance");
|
||||||
|
}
|
||||||
|
BTKUIAddon.UpdateStickerMenu();
|
||||||
|
}
|
||||||
|
|
||||||
private void OnWorldUnload()
|
private void OnWorldUnload()
|
||||||
{
|
{
|
||||||
|
RestrictedInstance = false;
|
||||||
CleanupAllButSelf(); // release all stickers except for self
|
CleanupAllButSelf(); // release all stickers except for self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -51,7 +51,7 @@ public partial class StickerSystem
|
||||||
|
|
||||||
private bool PlaceStickerSelf(Vector3 position, Vector3 forward, Vector3 up, bool alignWithNormal = true)
|
private bool PlaceStickerSelf(Vector3 position, Vector3 forward, Vector3 up, bool alignWithNormal = true)
|
||||||
{
|
{
|
||||||
if (!AttemptPlaceSticker(PlayerLocalId, position, forward, up, alignWithNormal, SelectedStickerSlot))
|
if (!AttemptPlaceSticker(PlayerLocalId, position, forward, up, alignWithNormal, SelectedStickerSlot, RestrictedInstance))
|
||||||
return false; // failed
|
return false; // failed
|
||||||
|
|
||||||
// placed, now network
|
// placed, now network
|
||||||
|
@ -59,7 +59,7 @@ public partial class StickerSystem
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool AttemptPlaceSticker(string playerId, Vector3 position, Vector3 forward, Vector3 up, bool alignWithNormal = true, int stickerSlot = 0, bool isPreview = false)
|
private bool AttemptPlaceSticker(string playerId, Vector3 position, Vector3 forward, Vector3 up, bool alignWithNormal = true, int stickerSlot = 0, bool RestrictedInstance = false, bool isPreview = false)
|
||||||
{
|
{
|
||||||
StickerData stickerData = GetOrCreateStickerData(playerId);
|
StickerData stickerData = GetOrCreateStickerData(playerId);
|
||||||
if (Time.time - stickerData.LastPlacedTime < StickerCooldown)
|
if (Time.time - stickerData.LastPlacedTime < StickerCooldown)
|
||||||
|
@ -75,6 +75,10 @@ public partial class StickerSystem
|
||||||
if (hit.transform.gameObject.name.StartsWith("[NoSticker]"))
|
if (hit.transform.gameObject.name.StartsWith("[NoSticker]"))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
// if the world contained a gameobject with the [DisableStickers] name and restricted the instance disable stickers!
|
||||||
|
if (RestrictedInstance == true)
|
||||||
|
return false;
|
||||||
|
|
||||||
if (isPreview)
|
if (isPreview)
|
||||||
{
|
{
|
||||||
stickerData.PlacePreview(hit, alignWithNormal ? -hit.normal : forward, up, stickerSlot);
|
stickerData.PlacePreview(hit, alignWithNormal ? -hit.normal : forward, up, stickerSlot);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue