Skip to content

Commit

Permalink
add skin randomizer debugsetting
Browse files Browse the repository at this point in the history
  • Loading branch information
misternebula committed Jan 28, 2024
1 parent 096f24c commit 20154d6
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
31 changes: 29 additions & 2 deletions QSB/QSBCore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 =
{
Expand Down Expand Up @@ -281,6 +286,19 @@ public void Start()
QSBWorldSync.Managers = components.OfType<WorldObjectManager>().ToArray();
QSBPatchManager.OnPatchType += OnPatchType;
QSBPatchManager.OnUnpatchType += OnUnpatchType;

if (DebugSettings.RandomizeSkins)
{
var skinSetting = (JObject)ModHelper.Config.Settings["skinType"];
var skinOptions = skinSetting["options"].ToObject<string[]>();
randomSkinType = skinOptions[UnityEngine.Random.Range(0, skinOptions.Length - 1)];

var jetpackSetting = (JObject)ModHelper.Config.Settings["jetpackType"];
var jetpackOptions = jetpackSetting["options"].ToObject<string[]>();
randomJetpackType = jetpackOptions[UnityEngine.Random.Range(0, jetpackOptions.Length - 1)];

Configure(ModHelper.Config);
}
}

private AssetBundle LoadBundle(string bundleName)
Expand Down Expand Up @@ -401,8 +419,17 @@ public override void Configure(IModConfig config)
ShipDamage = config.GetSettingsValue<bool>("shipDamage");
ShowExtraHUDElements = config.GetSettingsValue<bool>("showExtraHud");
TextChatInput = config.GetSettingsValue<bool>("textChatInput");
SkinVariation = config.GetSettingsValue<string>("skinType");
JetpackVariation = config.GetSettingsValue<string>("jetpackType");

if (DebugSettings.RandomizeSkins)
{
SkinVariation = randomSkinType;
JetpackVariation = randomJetpackType;
}
else
{
SkinVariation = config.GetSettingsValue<string>("skinType");
JetpackVariation = config.GetSettingsValue<string>("jetpackType");
}

if (IsHost)
{
Expand Down
3 changes: 3 additions & 0 deletions QSB/Utility/DebugSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ public class DebugSettings
[JsonProperty("latencySimulation")]
public int LatencySimulation;

[JsonProperty("randomizeSkins")]
public bool RandomizeSkins;

[JsonProperty("debugMode")]
public bool DebugMode;

Expand Down

0 comments on commit 20154d6

Please sign in to comment.