From 20154d6483a1d741c5a5d53320f0b3cc7007925f Mon Sep 17 00:00:00 2001 From: _nebula <41904486+misternebula@users.noreply.github.com> Date: Sun, 28 Jan 2024 14:30:08 +0000 Subject: [PATCH] add skin randomizer debugsetting --- QSB/QSBCore.cs | 31 +++++++++++++++++++++++++++++-- QSB/Utility/DebugSettings.cs | 3 +++ 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/QSB/QSBCore.cs b/QSB/QSBCore.cs index e37e7367b..fb6bdb592 100644 --- a/QSB/QSBCore.cs +++ b/QSB/QSBCore.cs @@ -18,11 +18,13 @@ using System.IO; using System.Linq; using System.Reflection; +using Newtonsoft.Json.Linq; using QSB.API; using QSB.BodyCustomization; using QSB.Player.Messages; using UnityEngine; using UnityEngine.InputSystem; +using Random = System.Random; /* Copyright (C) 2020 - 2023 @@ -78,6 +80,9 @@ public class QSBCore : ModBehaviour public static IMenuAPI MenuApi { get; private set; } public static DebugSettings DebugSettings { get; private set; } = new(); + private static string randomSkinType; + private static string randomJetpackType; + public static readonly string[] IncompatibleMods = { @@ -281,6 +286,19 @@ public void Start() QSBWorldSync.Managers = components.OfType().ToArray(); QSBPatchManager.OnPatchType += OnPatchType; QSBPatchManager.OnUnpatchType += OnUnpatchType; + + if (DebugSettings.RandomizeSkins) + { + var skinSetting = (JObject)ModHelper.Config.Settings["skinType"]; + var skinOptions = skinSetting["options"].ToObject(); + randomSkinType = skinOptions[UnityEngine.Random.Range(0, skinOptions.Length - 1)]; + + var jetpackSetting = (JObject)ModHelper.Config.Settings["jetpackType"]; + var jetpackOptions = jetpackSetting["options"].ToObject(); + randomJetpackType = jetpackOptions[UnityEngine.Random.Range(0, jetpackOptions.Length - 1)]; + + Configure(ModHelper.Config); + } } private AssetBundle LoadBundle(string bundleName) @@ -401,8 +419,17 @@ public override void Configure(IModConfig config) ShipDamage = config.GetSettingsValue("shipDamage"); ShowExtraHUDElements = config.GetSettingsValue("showExtraHud"); TextChatInput = config.GetSettingsValue("textChatInput"); - SkinVariation = config.GetSettingsValue("skinType"); - JetpackVariation = config.GetSettingsValue("jetpackType"); + + if (DebugSettings.RandomizeSkins) + { + SkinVariation = randomSkinType; + JetpackVariation = randomJetpackType; + } + else + { + SkinVariation = config.GetSettingsValue("skinType"); + JetpackVariation = config.GetSettingsValue("jetpackType"); + } if (IsHost) { diff --git a/QSB/Utility/DebugSettings.cs b/QSB/Utility/DebugSettings.cs index 3e22a4ab2..0d0fdb802 100644 --- a/QSB/Utility/DebugSettings.cs +++ b/QSB/Utility/DebugSettings.cs @@ -32,6 +32,9 @@ public class DebugSettings [JsonProperty("latencySimulation")] public int LatencySimulation; + [JsonProperty("randomizeSkins")] + public bool RandomizeSkins; + [JsonProperty("debugMode")] public bool DebugMode;