using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using CombinedWeathersToolkit.Toolkit;
using CombinedWeathersToolkit.Toolkit.Core;
using CombinedWeathersToolkit.Utils;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Newtonsoft.Json.Linq;
using Unity.Netcode;
using UnityEngine;
using WeatherRegistry;
using WeatherRegistry.Modules;
using WeatherRegistry.Patches;
using WeatherTweaks.Definitions;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: IgnoresAccessChecksTo("WeatherRegistry")]
[assembly: IgnoresAccessChecksTo("WeatherTweaks")]
[assembly: AssemblyCompany("CombinedWeathersToolkit")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+8ba9189238034c0a1dd355016728894ed69b941e")]
[assembly: AssemblyProduct("CombinedWeathersToolkit")]
[assembly: AssemblyTitle("CombinedWeathersToolkit")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
internal sealed class NullableAttribute : Attribute
{
public readonly byte[] NullableFlags;
public NullableAttribute(byte P_0)
{
NullableFlags = new byte[1] { P_0 };
}
public NullableAttribute(byte[] P_0)
{
NullableFlags = P_0;
}
}
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
internal sealed class NullableContextAttribute : Attribute
{
public readonly byte Flag;
public NullableContextAttribute(byte P_0)
{
Flag = P_0;
}
}
}
namespace CombinedWeathersToolkit
{
internal class Config
{
public readonly ConfigEntry<bool> AllowConfigRegistery;
public readonly ConfigEntry<bool> AllowJsonRegistery;
public readonly ConfigEntry<bool> RegisterPredefinedWeathers;
public readonly ConfigEntry<float> PredefinedWeathersWeightModifier;
public readonly ConfigEntry<string> WeatherConfigCreatorString;
public readonly ConfigEntry<string> WeatherConfigCreatorExample;
public readonly ConfigEntry<bool> DebugLogsEnabled;
public readonly ConfigEntry<bool> DebugCommandsEnabled;
public readonly List<string> WeatherConfigCreatorList = new List<string>();
public Config(ConfigFile cfg)
{
//IL_0099: Unknown result type (might be due to invalid IL or missing references)
//IL_00a3: Expected O, but got Unknown
cfg.SaveOnConfigSet = false;
AllowConfigRegistery = cfg.Bind<bool>("General", "Allow config registery", true, "Allow the mod to register any combined weather effects that are created in the config.");
AllowJsonRegistery = cfg.Bind<bool>("General", "Allow json registery", true, "Allow the mod to register any combined weather effects that are created with .json files.");
RegisterPredefinedWeathers = cfg.Bind<bool>("Predefined weathers", "Register predefined combined weathers", true, "If true, some predefined combined weather effects will be registered by this mod without the need of manually creating them.");
PredefinedWeathersWeightModifier = cfg.Bind<float>("Predefined weathers", "Global weight modifier", 0.2f, new ConfigDescription("If 'Register predefined combined weathers' is true, this config will dynamically update the weight of all predefined combined weathers based on this value which will act as a multiplier.\nIf you want all predefined weathers to spawn more often then enter a bigger value here.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 100f), Array.Empty<object>()));
DebugLogsEnabled = cfg.Bind<bool>("Debug", "Debug logs", false, "Enable more explicit logs in the console (for debug reasons).");
DebugCommandsEnabled = cfg.Bind<bool>("Debug", "Debug commands", false, "Enable debug commands in the game's chat (for debug reasons).");
WeatherConfigCreatorString = cfg.Bind<string>("Config weathers", "Weather Config creator", "", "Comma separated list of combined weather effects that will be used to register new weathers from the config.");
WeatherConfigCreatorExample = cfg.Bind<string>("Config weathers", "Example", "Eclipsed + Foggy : Eclipsed : Foggy,Solar Storm: color(#ff0000) : solarflare : stormy,Enemies infestation: color(red) : Eclipsed : forsaken : blood moon : type(progressing)", "This is an example config that explains how to register new combined weathers with the 'Weather Config creator' config.\nFollow the format in the example to write your own weather in 'Weather Config creator'.");
cfg.Save();
cfg.SaveOnConfigSet = true;
}
public void SetupCustomConfigs()
{
Compatibility.CheckInstalledPlugins();
if (!Compatibility.WeatherRegisteryInstalled)
{
Plugin.logger.LogError((object)"WeatherRegistery is not installed! Please install WeatherRegistery before using this mod.");
}
if (!Compatibility.WeatherTweaksInstalled)
{
Plugin.logger.LogError((object)"WeatherTweaks is not installed! Please install WeatherTweaks before using this mod.");
}
if (AllowConfigRegistery.Value)
{
PopulateWeatherConfigCreatorList();
}
}
private void PopulateWeatherConfigCreatorList()
{
if (string.IsNullOrWhiteSpace(WeatherConfigCreatorString.Value))
{
return;
}
foreach (string item in from s in WeatherConfigCreatorString.Value.Split(',')
select s.Trim())
{
WeatherConfigCreatorList.Add(item);
}
}
}
[BepInPlugin("zigzag.combinedweatherstoolkit", "Combined_Weathers_Toolkit", "1.0.2")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class Plugin : BaseUnityPlugin
{
private const string GUID = "zigzag.combinedweatherstoolkit";
private const string NAME = "Combined_Weathers_Toolkit";
private const string VERSION = "1.0.2";
public static Plugin instance;
public static ManualLogSource logger;
private readonly Harmony harmony = new Harmony("zigzag.combinedweatherstoolkit");
internal static List<string> installedWeathers = new List<string>();
internal static Config config { get; private set; } = null;
internal static void DebugLog(object message)
{
if (config.DebugLogsEnabled.Value)
{
logger.LogWarning(message);
}
}
private void Awake()
{
instance = this;
logger = ((BaseUnityPlugin)this).Logger;
config = new Config(((BaseUnityPlugin)this).Config);
config.SetupCustomConfigs();
harmony.PatchAll();
logger.LogInfo((object)"Combined_Weathers_Toolkit is loaded !");
}
}
}
namespace CombinedWeathersToolkit.Utils
{
internal class Compatibility
{
public static bool WeatherRegisteryInstalled;
public static bool WeatherTweaksInstalled;
public static void CheckInstalledPlugins()
{
WeatherRegisteryInstalled = IsPluginInstalled("mrov.WeatherRegistry");
WeatherTweaksInstalled = IsPluginInstalled("WeatherTweaks");
}
private static bool IsPluginInstalled(string pluginGUID, string? pluginVersion = null)
{
return Chainloader.PluginInfos.ContainsKey(pluginGUID) && (pluginVersion == null || new Version(pluginVersion).CompareTo(Chainloader.PluginInfos[pluginGUID].Metadata.Version) <= 0);
}
}
internal class Effects
{
public static void ChangeWeather(string weatherNameResolvable)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
ChangeWeather(((WeatherResolvable)new WeatherNameResolvable(weatherNameResolvable)).WeatherType);
}
public static void ChangeWeather(LevelWeatherType weather)
{
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
StartOfRound.Instance.currentLevel.currentWeather = weather;
if (((NetworkBehaviour)GameNetworkManager.Instance.localPlayerController).IsHost)
{
WeatherController.SetWeatherEffects(weather);
}
}
public static void AddCombinedWeather(string weatherNameResolvable)
{
//IL_005d: Unknown result type (might be due to invalid IL or missing references)
//IL_0061: Unknown result type (might be due to invalid IL or missing references)
//IL_0086: Unknown result type (might be due to invalid IL or missing references)
//IL_0087: Unknown result type (might be due to invalid IL or missing references)
//IL_0088: Unknown result type (might be due to invalid IL or missing references)
//IL_0065: Unknown result type (might be due to invalid IL or missing references)
//IL_0069: Unknown result type (might be due to invalid IL or missing references)
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
//IL_0071: Unknown result type (might be due to invalid IL or missing references)
//IL_0075: Unknown result type (might be due to invalid IL or missing references)
//IL_007a: Unknown result type (might be due to invalid IL or missing references)
//IL_007f: Unknown result type (might be due to invalid IL or missing references)
string text = weatherNameResolvable.ToLower();
if (1 == 0)
{
}
LevelWeatherType val = (LevelWeatherType)(text switch
{
"rainy" => 1,
"stormy" => 2,
"foggy" => 3,
"flooded" => 4,
"dustclouds" => 0,
"eclipsed" => 5,
_ => ((WeatherResolvable)new WeatherNameResolvable(weatherNameResolvable)).WeatherType,
});
if (1 == 0)
{
}
LevelWeatherType weather = val;
AddCombinedWeather(weather);
}
public static void AddCombinedWeather(LevelWeatherType weather)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
WeatherController.AddWeatherEffect(weather);
}
public static bool IsWeatherEffectPresent(string weatherNameResolvable)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
return IsWeatherEffectPresent(((WeatherResolvable)new WeatherNameResolvable(weatherNameResolvable)).WeatherType);
}
public static bool IsWeatherEffectPresent(LevelWeatherType weatherType)
{
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
for (int i = 0; i < WeatherManager.CurrentEffectTypes.Count; i++)
{
if (WeatherManager.CurrentEffectTypes[i] == weatherType)
{
return true;
}
}
return false;
}
public static void RemoveWeather(string weatherNameResolvable)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
RemoveWeather(((WeatherResolvable)new WeatherNameResolvable(weatherNameResolvable)).WeatherType);
}
public static void RemoveWeather(LevelWeatherType weatherType)
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
if (WeatherManager.CurrentEffectTypes.Contains(weatherType))
{
WeatherManager.GetWeather(weatherType).Effect.DisableEffect(true);
}
}
public static void RemoveLastWeather()
{
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
if (WeatherManager.CurrentEffectTypes.Count > 0)
{
List<LevelWeatherType> currentEffectTypes = WeatherManager.CurrentEffectTypes;
RemoveWeather(currentEffectTypes[currentEffectTypes.Count - 1]);
}
}
public static string GetListOfCurrentWeathers()
{
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
if (WeatherManager.CurrentEffectTypes.Count == 0)
{
return "None";
}
string text = "";
for (int i = 0; i < WeatherManager.CurrentEffectTypes.Count; i++)
{
string text2 = text;
LevelWeatherType val = WeatherManager.CurrentEffectTypes[i];
text = text2 + ((object)(LevelWeatherType)(ref val)).ToString();
if (i < WeatherManager.CurrentEffectTypes.Count - 1)
{
text += ", ";
}
}
return text;
}
public static ImprovedWeatherEffect? GetWeatherEffect(string weatherNameResolvable)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
return GetWeatherEffect(((WeatherResolvable)new WeatherNameResolvable(weatherNameResolvable)).WeatherType);
}
public static ImprovedWeatherEffect? GetWeatherEffect(LevelWeatherType weatherType)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
Weather weather = WeatherManager.GetWeather(weatherType);
if ((Object)(object)weather == (Object)null)
{
return null;
}
return WeatherManager.GetWeather(weatherType).Effect;
}
public static void Message(string title, string bottom, bool warning = false)
{
HUDManager.Instance.DisplayTip(title, bottom, warning, false, "LC_Tip1");
}
}
}
namespace CombinedWeathersToolkit.Toolkit
{
internal class ConfigRegistery
{
internal static void LoadAllConfigValues()
{
if (Plugin.config.WeatherConfigCreatorList.Count == 0)
{
return;
}
int num = 0;
Plugin.DebugLog("[ConfigRegistery] Found values in config file, now loading Weather Config creator");
foreach (string weatherConfigCreator in Plugin.config.WeatherConfigCreatorList)
{
ToolkitWeather toolkitWeather = new ToolkitWeather();
if (string.IsNullOrWhiteSpace(weatherConfigCreator))
{
return;
}
int num2 = 0;
foreach (string item in from s in weatherConfigCreator.Split(':')
select s.Trim())
{
if (string.IsNullOrWhiteSpace(item))
{
Plugin.logger.LogError((object)"[ConfigRegistery] One of the field in Weather Config creator is empty or null, this could result in an unwanted behavior");
continue;
}
string text = string.Concat(item.Where((char c) => !char.IsWhiteSpace(c))).ToLower();
if (num2 == 0)
{
toolkitWeather.Name = item;
}
else if (text.StartsWith("color(") && text.EndsWith(')'))
{
string text2 = text;
toolkitWeather.SetColorFromString(text2.Substring(6, text2.Length - 1 - 6));
}
else if (text.StartsWith("type(") && text.EndsWith(')'))
{
string text2 = text;
toolkitWeather.SetTypeFromString(text2.Substring(5, text2.Length - 1 - 5));
}
else
{
toolkitWeather.AddWeather(text, isNameAlreadyConcat: true);
}
num2++;
}
if (toolkitWeather.Register())
{
num++;
Plugin.DebugLog("[ConfigRegistery] Registered weather: " + toolkitWeather.Name);
}
else
{
Plugin.DebugLog("[ConfigRegistery] The '" + weatherConfigCreator + "' value is not valid and could not register a weather ; this can happen if the name of the weather was not set or if one of the added weathers is a modded weather and the mod it's from it not installed");
}
}
Plugin.logger.LogInfo((object)$"[ConfigRegistery] Loaded {num} custom weathers from Weather Config creator");
}
}
internal class JsonRegistery
{
internal static void LoadAllJsonFiles()
{
string[] files = Directory.GetFiles(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), ".."), "*.cwt.json", SearchOption.AllDirectories);
string[] array = files;
foreach (string text in array)
{
string fileName = Path.GetFileName(text);
Plugin.DebugLog("[JsonRegistery] Found json file, now loading: " + fileName);
int num = RegisterWeathersFromJson(text);
Plugin.logger.LogInfo((object)$"[JsonRegistery] Loaded {num} custom weathers from json file: {fileName}");
}
}
private static int RegisterWeathersFromJson(string filePath)
{
//IL_0078: Unknown result type (might be due to invalid IL or missing references)
//IL_007e: Invalid comparison between Unknown and I4
//IL_008d: Unknown result type (might be due to invalid IL or missing references)
string text = File.ReadAllText(filePath);
if (text == null || text.Length <= 0)
{
Plugin.logger.LogError((object)"[JsonRegistery] The file is empty or null");
return 0;
}
int num = 0;
JObject val = JObject.Parse(text);
foreach (JProperty item in val.Properties())
{
string name = item.Name;
JToken value = item.Value;
ToolkitWeather toolkitWeather = new ToolkitWeather();
if ((int)value.Type == 1)
{
foreach (JProperty item2 in ((JObject)value).Properties())
{
switch (item2.Name.ToLower())
{
case "type":
toolkitWeather.SetTypeFromString(ExtractJsonProperty<string>(item2));
break;
case "name":
toolkitWeather.Name = ExtractJsonProperty<string>(item2);
break;
case "color":
toolkitWeather.SetColorFromString(ExtractJsonProperty<string>(item2));
break;
case "weight":
toolkitWeather.Weight = ExtractJsonProperty<int>(item2);
break;
case "scrap_amount":
toolkitWeather.ScrapAmountMultiplier = ExtractJsonProperty<float>(item2);
break;
case "scrap_value":
toolkitWeather.ScrapValueMultiplier = ExtractJsonProperty<float>(item2);
break;
case "filtering":
toolkitWeather.Filtering = ExtractJsonProperty<bool>(item2);
break;
case "level_filter":
toolkitWeather.LevelFilter = ExtractJsonProperty<string>(item2);
break;
case "level_weights":
toolkitWeather.LevelWeights = ExtractJsonProperty<string>(item2);
break;
case "weather_to_weather_weights":
toolkitWeather.WeatherToWeatherWeights = ExtractJsonProperty<string>(item2);
break;
case "progressing_times":
toolkitWeather.AddProgressingValues(ExtractJsonProperty<float[]>(item2), areTimesValues: true);
break;
case "progressing_chances":
toolkitWeather.AddProgressingValues(ExtractJsonProperty<float[]>(item2), areTimesValues: false);
break;
case "weathers":
toolkitWeather.AddWeathers(ExtractJsonProperty<string[]>(item2));
break;
}
}
}
else
{
Plugin.logger.LogError((object)("[JsonRegistery] The '" + name + "' property is not an Object, skipping..."));
}
if (toolkitWeather.Register())
{
num++;
Plugin.DebugLog("[JsonRegistery] Registered weather: " + toolkitWeather.Name);
}
else
{
Plugin.DebugLog("[JsonRegistery] The '" + name + "' property is not valid and could not register a weather ; this can happen if the property has no 'name' field or if one of the added weathers is a modded weather and the mod it's from it not installed");
}
}
return num;
}
private static T ExtractJsonProperty<T>(JProperty property)
{
//IL_0056: Unknown result type (might be due to invalid IL or missing references)
//IL_005c: Invalid comparison between Unknown and I4
//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
//IL_00db: Invalid comparison between Unknown and I4
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_0065: Invalid comparison between Unknown and I4
//IL_0177: Unknown result type (might be due to invalid IL or missing references)
//IL_017e: Invalid comparison between Unknown and I4
//IL_00de: Unknown result type (might be due to invalid IL or missing references)
//IL_00e4: Invalid comparison between Unknown and I4
//IL_01f2: Unknown result type (might be due to invalid IL or missing references)
//IL_01f8: Invalid comparison between Unknown and I4
//IL_02e8: Unknown result type (might be due to invalid IL or missing references)
//IL_02ee: Invalid comparison between Unknown and I4
//IL_0206: Unknown result type (might be due to invalid IL or missing references)
//IL_02f7: Unknown result type (might be due to invalid IL or missing references)
//IL_0320: Expected O, but got Unknown
//IL_0223: Unknown result type (might be due to invalid IL or missing references)
//IL_0229: Invalid comparison between Unknown and I4
//IL_022d: Unknown result type (might be due to invalid IL or missing references)
//IL_0233: Invalid comparison between Unknown and I4
JToken value = property.Value;
if (typeof(T) == typeof(string))
{
return (T)(object)((object)value).ToString();
}
if (typeof(T) == typeof(int))
{
if ((int)value.Type == 6 || (int)value.Type == 7)
{
return (T)(object)Extensions.Value<int>((IEnumerable<JToken>)value);
}
if (int.TryParse(((object)value).ToString(), out var result))
{
return (T)(object)result;
}
}
else if (typeof(T) == typeof(float))
{
if ((int)value.Type == 7 || (int)value.Type == 6)
{
return (T)(object)Extensions.Value<float>((IEnumerable<JToken>)value);
}
string s = ((object)value).ToString();
if (float.TryParse(s, NumberStyles.Float | NumberStyles.AllowThousands, CultureInfo.InvariantCulture, out var result2) || float.TryParse(s, NumberStyles.Float | NumberStyles.AllowThousands, CultureInfo.CurrentCulture, out result2))
{
return (T)(object)result2;
}
}
else if (typeof(T) == typeof(bool))
{
if ((int)value.Type == 9)
{
return (T)(object)Extensions.Value<bool>((IEnumerable<JToken>)value);
}
if (bool.TryParse(((object)value).ToString(), out var result3))
{
return (T)(object)result3;
}
}
else if (typeof(T) == typeof(float[]))
{
List<float> list = new List<float>();
if ((int)value.Type == 2)
{
foreach (JToken item in (JArray)value)
{
if ((int)item.Type == 7 || (int)item.Type == 6)
{
list.Add(Extensions.Value<float>((IEnumerable<JToken>)item));
continue;
}
string s2 = ((object)item).ToString();
if (float.TryParse(s2, NumberStyles.Float | NumberStyles.AllowThousands, CultureInfo.InvariantCulture, out var result4) || float.TryParse(s2, NumberStyles.Float | NumberStyles.AllowThousands, CultureInfo.CurrentCulture, out result4))
{
list.Add(result4);
}
}
return (T)(object)list.ToArray();
}
}
else if (typeof(T) == typeof(string[]))
{
if ((int)value.Type == 2)
{
return (T)(object)((IEnumerable<JToken>)(JArray)value).Select((JToken x) => ((object)x).ToString()).ToArray();
}
return (T)(object)new string[1] { ((object)value).ToString() };
}
return default(T);
}
}
internal class PredefinedRegistery
{
internal static void LoadAllPredefinedWeathers()
{
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_005d: Unknown result type (might be due to invalid IL or missing references)
//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
//IL_0105: Unknown result type (might be due to invalid IL or missing references)
//IL_0151: Unknown result type (might be due to invalid IL or missing references)
//IL_0184: Unknown result type (might be due to invalid IL or missing references)
//IL_01af: Unknown result type (might be due to invalid IL or missing references)
//IL_01fb: Unknown result type (might be due to invalid IL or missing references)
//IL_0268: Unknown result type (might be due to invalid IL or missing references)
//IL_0293: Unknown result type (might be due to invalid IL or missing references)
//IL_02b9: Unknown result type (might be due to invalid IL or missing references)
//IL_030d: Unknown result type (might be due to invalid IL or missing references)
//IL_0338: Unknown result type (might be due to invalid IL or missing references)
//IL_0363: Unknown result type (might be due to invalid IL or missing references)
//IL_038e: Unknown result type (might be due to invalid IL or missing references)
//IL_03da: Unknown result type (might be due to invalid IL or missing references)
//IL_0405: Unknown result type (might be due to invalid IL or missing references)
//IL_0430: Unknown result type (might be due to invalid IL or missing references)
//IL_0473: Unknown result type (might be due to invalid IL or missing references)
//IL_04b1: Unknown result type (might be due to invalid IL or missing references)
//IL_04dc: Unknown result type (might be due to invalid IL or missing references)
//IL_050f: Unknown result type (might be due to invalid IL or missing references)
//IL_053d: Unknown result type (might be due to invalid IL or missing references)
//IL_0594: Unknown result type (might be due to invalid IL or missing references)
//IL_05bf: Unknown result type (might be due to invalid IL or missing references)
//IL_05ea: Unknown result type (might be due to invalid IL or missing references)
//IL_062d: Unknown result type (might be due to invalid IL or missing references)
//IL_0660: Unknown result type (might be due to invalid IL or missing references)
//IL_068b: Unknown result type (might be due to invalid IL or missing references)
//IL_06b6: Unknown result type (might be due to invalid IL or missing references)
//IL_06e9: Unknown result type (might be due to invalid IL or missing references)
//IL_0714: Unknown result type (might be due to invalid IL or missing references)
//IL_073f: Unknown result type (might be due to invalid IL or missing references)
//IL_076a: Unknown result type (might be due to invalid IL or missing references)
//IL_0795: Unknown result type (might be due to invalid IL or missing references)
//IL_0898: Unknown result type (might be due to invalid IL or missing references)
Plugin.DebugLog("[PredefinedRegistery] Predefined weathers are enabled, now loading everything");
RegisterWeather("Rainy + Majora Moon", "rainy", "majoramoon");
RegisterWeather("Majora Eclipsed", Color.magenta, "eclipsed", "majoramoon");
RegisterWeather("Majora Chaos", Hex("#750000"), "rainy", "stormy", "eclipsed", "majoramoon");
RegisterWeather("Snowfall + Majora Moon", "snowfall", "majoramoon");
RegisterWeather("Majora Aurora", Hex("#9eb5ff"), "solarflare", "majoramoon");
RegisterWeather("Tornado + Majora Moon", "tornado", "majoramoon");
RegisterWeather("Cosmic Crash", Hex("#82ffd7"), "meteorshower", "majoramoon");
RegisterWeather("Hallowed + Majora Moon", "hallowed", "majoramoon");
RegisterWeather("Majora Tempest", Hex("#736f00"), "stormy", "hurricane", "majoramoon");
RegisterWeather("Dark Majora Moon", Hex("#290033"), "blackfog", "majoramoon");
RegisterWeather("The Crimson Flood", Hex("#ff4580"), "flooded", "bloodmoon");
RegisterWeather("Snowfall + Blood Moon", "snowfall", "bloodmoon");
RegisterWeather("Toxic Smog + Blood Moon", Hex("#ff00b3"), "toxicsmog", "bloodmoon");
RegisterWeather("Meteor Shower + Blood Moon", "meteorshower", "bloodmoon");
RegisterWeather("Forsaken + Blood Moon", "forsaken", "bloodmoon");
RegisterWeather("Dark Blood Moon", Hex("#24000c"), "blackfog", "bloodmoon");
RegisterWeather("Majora Supermoon", Hex("#ff0095"), "majoramoon", "bloodmoon");
RegisterWeather("Climate Anomaly", Color.yellow, "snowfall", "heatwave", "solarflare");
RegisterWeather("Heatwave + Blizzard", "heatwave", "blizzard");
RegisterWeather("Nuclear Winter", Hex("#32a89d"), "toxicsmog", "blizzard");
RegisterWeather("Blizzard + Forsaken", Hex("#574885"), "blizzard", "forsaken");
RegisterWeather("Hallowed Smog", Hex("#1d3d1d"), "toxicsmog", "hallowed");
RegisterWeather("Toxic Winds", Hex("#008042"), "toxicsmog", "tornado");
RegisterWeather("Black Fog + Heatwave", "blackfog", "heatwave");
RegisterWeather("Black Fog + Snowfall", Hex("#99ffce"), "blackfog", "snowfall");
RegisterWeather("Black Winter", Hex("#5e0fb8"), "blackfog", "blizzard");
RegisterWeatherProgressing("Thermal Shift", Hex("#874a00"), "blizzard", "snowfall", "none", "solarflare", "heatwave");
RegisterWeatherProgressing("Gravitational Freeze", Hex("#006887"), "heatwave", "solarflare", "none", "snowfall", "blizzard");
RegisterWeather("Foggy + Meteor Shower", Color.red, "foggy", "meteorshower");
RegisterWeather("Meteor Tempest", Hex("#01060d"), "stormy", "tornado", "meteorshower");
RegisterWeather("Gravity Anomaly", Hex("#ff7a7a"), "meteorshower", "eclipsed", "solarflare");
RegisterWeather("Superstorm", Color.magenta, "stormy", "flooded", "tornado", "hurricane");
RegisterWeather("Flooded + Hallowed", "flooded", "hallowed");
RegisterWeather("Hallowed Eclipse", Color.red, "hallowed", "eclipsed");
RegisterWeather("Forsaken Storm", Hex("#94294b"), "stormy", "forsaken");
RegisterWeatherProgressing("Impending Storm", Hex("#c4c156"), "none", "rainy", "cloudy", "stormy", "hurricane");
RegisterWeather("Haunted", Hex("#4f2d6e"), "blackout", "hallowed", "blackfog");
RegisterWeather("Nocturne Frost", Hex("##2431a6"), "blackout", "blizzard");
RegisterWeather("Darkness", Hex("#030029"), "blackfog", "blackout");
RegisterWeather("Total Darkness", Hex("#030029"), "blackfog", "blackout", "foggy");
RegisterWeather("Bluefall", Hex("#36a3d6"), "blue", "snowfall");
RegisterWeather("Blue Fog", Hex("#060a4a"), "blue", "blackfog");
RegisterWeather("Blue Moon", Hex("#004175"), "blue", "bloodmoon");
RegisterWeather("Majoblue", Hex("#170075"), "blue", "majoramoon");
RegisterWeather("Eternal Darkness", Hex("#030029"), "blackfog", "blackout", "foggy", "heatwave", "evilblue");
string[] source = new string[6] { "blizzard", "cloudy", "blackout", "blue", "evilblue", "nightshift" };
List<string> list = new List<string> { "rainy", "stormy", "eclipsed" };
foreach (string weather in Plugin.installedWeathers)
{
if (!source.Any((string x) => x == weather))
{
list.Add(weather);
}
}
RegisterWeather("The End of the World", Color.magenta, list.ToArray());
Plugin.logger.LogInfo((object)"[PredefinedRegistery] All predefined weathers are loaded");
}
private static void RegisterWeather(string name, params string[] weathers)
{
ToolkitWeather toolkit = new ToolkitWeather
{
Name = name
};
RegisterWeather(toolkit, (CustomWeatherType)1, weathers);
}
private static void RegisterWeather(string name, Color color, params string[] weathers)
{
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
ToolkitWeather toolkit = new ToolkitWeather
{
Name = name,
NameColor = color
};
RegisterWeather(toolkit, (CustomWeatherType)1, weathers);
}
private static void RegisterWeatherProgressing(string name, params string[] weathers)
{
ToolkitWeather toolkit = new ToolkitWeather
{
Name = name
};
RegisterWeather(toolkit, (CustomWeatherType)2, weathers);
}
private static void RegisterWeatherProgressing(string name, Color color, params string[] weathers)
{
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
ToolkitWeather toolkit = new ToolkitWeather
{
Name = name,
NameColor = color
};
RegisterWeather(toolkit, (CustomWeatherType)2, weathers);
}
private static void RegisterWeather(ToolkitWeather toolkit, CustomWeatherType type, params string[] weathers)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
toolkit.Type = type;
toolkit.WeightModifier = Plugin.config.PredefinedWeathersWeightModifier.Value;
toolkit.AddWeathers(weathers);
if (toolkit.Register())
{
Plugin.DebugLog("[PredefinedRegistery] Registered weather: " + toolkit.Name);
}
}
private static Color Hex(string hexColor)
{
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
Color result = default(Color);
if (ColorUtility.TryParseHtmlString(hexColor, ref result))
{
return result;
}
return Color.cyan;
}
}
}
namespace CombinedWeathersToolkit.Toolkit.Core
{
internal class ToolkitCombinedWeatherType : CombinedWeatherType
{
internal ToolkitWeather ToolkitWeather;
public override string ConfigCategory => ToolkitHelper.GetConfigCategory(ToolkitWeather);
internal ToolkitCombinedWeatherType(ToolkitWeather toolkit)
: base(toolkit.Name, toolkit.Weathers, toolkit.WeightModifier.GetValueOrDefault(0.2f))
{
ToolkitWeather = toolkit;
ToolkitHelper.SetColor(toolkit, (Weather)(object)this);
}
public override void Init()
{
//IL_003a: Unknown result type (might be due to invalid IL or missing references)
//IL_0044: Expected O, but got Unknown
ToolkitHelper.SetConfig(ToolkitWeather, (WeatherTweaksWeather)(object)this);
if (ToolkitWeather.Weight.HasValue)
{
((RegistryWeatherConfig)((CombinedWeatherType)this).Config).DefaultWeight = new IntegerConfigHandler(ToolkitWeather.Weight.Value, true);
IntPtr functionPointer = typeof(WeatherTweaksWeather).GetMethod("Init").MethodHandle.GetFunctionPointer();
((Action)Activator.CreateInstance(typeof(Action), this, functionPointer))();
}
else
{
((CombinedWeatherType)this).Init();
}
}
public override (float valueMultiplier, float amountMultiplier) GetDefaultMultiplierData()
{
if (!ToolkitWeather.ScrapValueMultiplier.HasValue && !ToolkitWeather.ScrapAmountMultiplier.HasValue)
{
(float, float) defaultMultiplierData = ((CombinedWeatherType)this).GetDefaultMultiplierData();
if (ToolkitHelper.ShouldResetAmountData(ToolkitWeather))
{
defaultMultiplierData.Item2 = 1f;
}
return defaultMultiplierData;
}
return ToolkitHelper.GetMultipliers(ToolkitWeather);
}
}
internal class ToolkitHelper
{
internal static string GetConfigCategory(ToolkitWeather toolkit)
{
return "WeatherToolkit Weather: " + toolkit.Name;
}
internal static void SetColor(ToolkitWeather toolkit, Weather weather)
{
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
if (toolkit.NameColor.HasValue)
{
weather.Color = toolkit.NameColor.Value;
}
}
internal static void SetConfig(ToolkitWeather toolkit, WeatherTweaksWeather weather)
{
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_001d: Expected O, but got Unknown
//IL_003e: Unknown result type (might be due to invalid IL or missing references)
//IL_0048: Expected O, but got Unknown
//IL_0069: Unknown result type (might be due to invalid IL or missing references)
//IL_0073: Expected O, but got Unknown
//IL_0094: Unknown result type (might be due to invalid IL or missing references)
//IL_009e: Expected O, but got Unknown
((Weather)weather).Config.FilteringOption = new BooleanConfigHandler(toolkit.Filtering.GetValueOrDefault(), true);
((Weather)weather).Config.LevelFilters = new LevelListConfigHandler((!string.IsNullOrEmpty(toolkit.LevelFilter)) ? toolkit.LevelFilter : "Company", true);
((Weather)weather).Config.LevelWeights = new LevelWeightsConfigHandler((!string.IsNullOrEmpty(toolkit.LevelWeights)) ? toolkit.LevelWeights : "", true);
((Weather)weather).Config.WeatherToWeatherWeights = new WeatherWeightsConfigHandler((!string.IsNullOrEmpty(toolkit.WeatherToWeatherWeights)) ? toolkit.WeatherToWeatherWeights : "", true);
}
internal static (float valueMultiplier, float amountMultiplier) GetMultipliers(ToolkitWeather toolkit)
{
float item = 1f;
float item2 = 1f;
if (toolkit.ScrapValueMultiplier.HasValue)
{
item2 = toolkit.ScrapValueMultiplier.Value;
}
if (toolkit.ScrapAmountMultiplier.HasValue)
{
item = toolkit.ScrapAmountMultiplier.Value;
}
return (item2, item);
}
internal static bool ShouldResetAmountData(ToolkitWeather toolkit)
{
return toolkit.Name == "The End of the World";
}
public static ToolkitWeather? GetToolkitFromWeatherTweaksWeather(WeatherTweaksWeather? weather)
{
if ((Object)(object)weather == (Object)null || !((Weather)weather).ConfigCategory.StartsWith("WeatherToolkit"))
{
return null;
}
ToolkitWeather result = null;
ToolkitCombinedWeatherType toolkitCombinedWeatherType = weather as ToolkitCombinedWeatherType;
if ((Object)(object)toolkitCombinedWeatherType != (Object)null)
{
result = toolkitCombinedWeatherType.ToolkitWeather;
}
else
{
ToolkitProgressingWeatherType toolkitProgressingWeatherType = weather as ToolkitProgressingWeatherType;
if ((Object)(object)toolkitProgressingWeatherType != (Object)null)
{
result = toolkitProgressingWeatherType.ToolkitWeather;
}
}
return result;
}
}
internal class ToolkitProgressingWeatherType : ProgressingWeatherType
{
internal ToolkitWeather ToolkitWeather;
public override string ConfigCategory => ToolkitHelper.GetConfigCategory(ToolkitWeather);
internal ToolkitProgressingWeatherType(ToolkitWeather toolkit)
: base(toolkit.Name, toolkit.Weathers[0], toolkit.GetProgressingWeatherEntries(), toolkit.WeightModifier.GetValueOrDefault(0.2f) + 0.1f)
{
ToolkitWeather = toolkit;
ToolkitHelper.SetColor(toolkit, (Weather)(object)this);
}
public override void Init()
{
//IL_003a: Unknown result type (might be due to invalid IL or missing references)
//IL_0044: Expected O, but got Unknown
ToolkitHelper.SetConfig(ToolkitWeather, (WeatherTweaksWeather)(object)this);
if (ToolkitWeather.Weight.HasValue)
{
((RegistryWeatherConfig)((ProgressingWeatherType)this).Config).DefaultWeight = new IntegerConfigHandler(ToolkitWeather.Weight.Value, true);
IntPtr functionPointer = typeof(WeatherTweaksWeather).GetMethod("Init").MethodHandle.GetFunctionPointer();
((Action)Activator.CreateInstance(typeof(Action), this, functionPointer))();
}
else
{
((ProgressingWeatherType)this).Init();
}
}
public override (float valueMultiplier, float amountMultiplier) GetDefaultMultiplierData()
{
if (!ToolkitWeather.ScrapValueMultiplier.HasValue && !ToolkitWeather.ScrapAmountMultiplier.HasValue)
{
return ((ProgressingWeatherType)this).GetDefaultMultiplierData();
}
return ToolkitHelper.GetMultipliers(ToolkitWeather);
}
}
public class ToolkitWeather
{
public CustomWeatherType? Type;
public string? Name;
public Color? NameColor;
public int? Weight;
public float? ScrapAmountMultiplier;
public float? ScrapValueMultiplier;
public bool? Filtering;
public string? LevelFilter;
public string? LevelWeights;
public string? WeatherToWeatherWeights;
public float? WeightModifier;
public List<float> ProgressingTimes = new List<float>();
public List<float> ProgressingChances = new List<float>();
public List<WeatherResolvable> Weathers = new List<WeatherResolvable>();
public void SetTypeFromString(string typeString)
{
//IL_0043: Unknown result type (might be due to invalid IL or missing references)
//IL_0047: Unknown result type (might be due to invalid IL or missing references)
//IL_005b: Unknown result type (might be due to invalid IL or missing references)
//IL_004b: Unknown result type (might be due to invalid IL or missing references)
//IL_004f: Unknown result type (might be due to invalid IL or missing references)
//IL_0053: Unknown result type (might be due to invalid IL or missing references)
string text = typeString.ToLower();
if (1 == 0)
{
}
CustomWeatherType value = (CustomWeatherType)(text switch
{
"combined" => 1,
"combo" => 1,
"progressing" => 2,
"progressive" => 2,
_ => 0,
});
if (1 == 0)
{
}
Type = value;
}
public void SetColorFromString(string colorString)
{
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_027c: Unknown result type (might be due to invalid IL or missing references)
//IL_0289: Unknown result type (might be due to invalid IL or missing references)
//IL_0201: Unknown result type (might be due to invalid IL or missing references)
//IL_0211: Unknown result type (might be due to invalid IL or missing references)
//IL_026f: Unknown result type (might be due to invalid IL or missing references)
//IL_0248: Unknown result type (might be due to invalid IL or missing references)
//IL_023b: Unknown result type (might be due to invalid IL or missing references)
//IL_022e: Unknown result type (might be due to invalid IL or missing references)
//IL_0262: Unknown result type (might be due to invalid IL or missing references)
//IL_0221: Unknown result type (might be due to invalid IL or missing references)
//IL_0255: Unknown result type (might be due to invalid IL or missing references)
if (colorString[0] == '#')
{
Color value = default(Color);
if (ColorUtility.TryParseHtmlString(colorString, ref value))
{
NameColor = value;
}
else
{
NameColor = null;
}
return;
}
string text = colorString.ToLower();
if (1 == 0)
{
}
Color? nameColor = text switch
{
"red" => Color.red,
"green" => Color.green,
"blue" => Color.blue,
"yellow" => Color.yellow,
"cyan" => Color.cyan,
"magenta" => Color.magenta,
"black" => Color.black,
"white" => Color.white,
"gray" => Color.gray,
"grey" => Color.grey,
"clear" => Color.clear,
_ => null,
};
if (1 == 0)
{
}
NameColor = nameColor;
}
public void AddProgressingValues(float[] values, bool areTimesValues)
{
foreach (float num in values)
{
if (!(num < 0f))
{
if (areTimesValues)
{
ProgressingTimes.Add(num);
}
else
{
ProgressingChances.Add(num);
}
}
}
}
public void AddWeather(string weatherName, bool isNameAlreadyConcat = false)
{
//IL_014b: Unknown result type (might be due to invalid IL or missing references)
//IL_0151: Expected O, but got Unknown
//IL_0154: Unknown result type (might be due to invalid IL or missing references)
//IL_015a: Expected O, but got Unknown
//IL_0139: Unknown result type (might be due to invalid IL or missing references)
//IL_013f: Expected O, but got Unknown
//IL_016f: Unknown result type (might be due to invalid IL or missing references)
//IL_0175: Expected O, but got Unknown
//IL_0166: Unknown result type (might be due to invalid IL or missing references)
//IL_016c: Expected O, but got Unknown
//IL_015d: Unknown result type (might be due to invalid IL or missing references)
//IL_0163: Expected O, but got Unknown
//IL_0130: Unknown result type (might be due to invalid IL or missing references)
//IL_0136: Expected O, but got Unknown
//IL_0142: Unknown result type (might be due to invalid IL or missing references)
//IL_0148: Expected O, but got Unknown
if (!string.IsNullOrEmpty(weatherName))
{
string text = (isNameAlreadyConcat ? weatherName : string.Concat(weatherName.Where((char c) => !char.IsWhiteSpace(c))).ToLower());
if (1 == 0)
{
}
WeatherResolvable val = (WeatherResolvable)(text switch
{
"none" => (object)new WeatherTypeResolvable((LevelWeatherType)(-1)),
"dustclouds" => (object)new WeatherTypeResolvable((LevelWeatherType)0),
"rainy" => (object)new WeatherTypeResolvable((LevelWeatherType)1),
"stormy" => (object)new WeatherTypeResolvable((LevelWeatherType)2),
"foggy" => (object)new WeatherTypeResolvable((LevelWeatherType)3),
"flooded" => (object)new WeatherTypeResolvable((LevelWeatherType)4),
"eclipsed" => (object)new WeatherTypeResolvable((LevelWeatherType)5),
_ => (object)new WeatherNameResolvable(text),
});
if (1 == 0)
{
}
WeatherResolvable item = val;
Weathers.Add(item);
}
}
public void AddWeathers(string[] weatherNames)
{
foreach (string weatherName in weatherNames)
{
AddWeather(weatherName);
}
}
public List<ProgressingWeatherEntry> GetProgressingWeatherEntries()
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
//IL_003a: Unknown result type (might be due to invalid IL or missing references)
//IL_0051: Expected O, but got Unknown
List<ProgressingWeatherEntry> list = new List<ProgressingWeatherEntry>();
for (int i = 1; i < Weathers.Count; i++)
{
list.Add(new ProgressingWeatherEntry
{
DayTime = ProgressingTimes[i - 1],
Chance = ProgressingChances[i - 1],
Weather = Weathers[i]
});
}
return list;
}
public bool AreWeathersInstalled()
{
foreach (WeatherResolvable weather in Weathers)
{
if (weather.WeatherName != "" && !Plugin.installedWeathers.Any((string w) => w == weather.WeatherName))
{
return false;
}
}
return true;
}
public bool IsValid()
{
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0070: Unknown result type (might be due to invalid IL or missing references)
//IL_0076: Invalid comparison between Unknown and I4
//IL_009c: Unknown result type (might be due to invalid IL or missing references)
//IL_00a2: Invalid comparison between Unknown and I4
if (!Type.HasValue || Type == (CustomWeatherType?)0)
{
Type = (CustomWeatherType)1;
}
if (string.IsNullOrEmpty(Name))
{
return false;
}
if (!AreWeathersInstalled())
{
return false;
}
if ((int)Type.GetValueOrDefault() == 1)
{
return Weathers.Count >= 1;
}
if ((int)Type.GetValueOrDefault() == 2)
{
if (Weathers.Count <= 1)
{
return false;
}
if (Weathers.Count - 1 == ProgressingTimes.Count && Weathers.Count - 1 == ProgressingChances.Count)
{
return true;
}
if (ProgressingTimes.Count != 0 && ProgressingChances.Count != 0)
{
return false;
}
if ((ProgressingTimes.Count == 0 && ProgressingChances.Count == 0) || (ProgressingTimes.Count == 0 && ProgressingChances.Count == Weathers.Count - 1) || (ProgressingChances.Count == 0 && ProgressingTimes.Count == Weathers.Count - 1))
{
if (ProgressingTimes.Count == 0)
{
float num = 1f / (float)Weathers.Count;
for (int i = 0; i < Weathers.Count - 1; i++)
{
ProgressingTimes.Add(num * (float)(i + 1));
}
}
if (ProgressingChances.Count == 0)
{
ProgressingChances.AddRange(Weathers.Select((WeatherResolvable x) => 1f));
}
return true;
}
return false;
}
return false;
}
public bool Register()
{
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Invalid comparison between Unknown and I4
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Invalid comparison between Unknown and I4
if (!IsValid())
{
return false;
}
CustomWeatherType? type = Type;
CustomWeatherType? val = type;
if (val.HasValue)
{
CustomWeatherType valueOrDefault = val.GetValueOrDefault();
if ((int)valueOrDefault == 1)
{
new ToolkitCombinedWeatherType(this);
return true;
}
if ((int)valueOrDefault == 2)
{
new ToolkitProgressingWeatherType(this);
return true;
}
}
return false;
}
}
}
namespace CombinedWeathersToolkit.Patches
{
[HarmonyPatch(typeof(SetMapScreenInfoToCurrentLevelPatch))]
internal class CustomToolkitScreenColor
{
[HarmonyPostfix]
[HarmonyPatch("GetColoredString")]
public static void GetColoredStringToolkit(SelectableLevel level, ref string __result)
{
//IL_0077: Unknown result type (might be due to invalid IL or missing references)
//IL_007c: Unknown result type (might be due to invalid IL or missing references)
//IL_007f: Unknown result type (might be due to invalid IL or missing references)
//IL_0085: Unknown result type (might be due to invalid IL or missing references)
//IL_0091: Unknown result type (might be due to invalid IL or missing references)
//IL_0097: Unknown result type (might be due to invalid IL or missing references)
//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
if (Settings.ColoredWeathers)
{
Weather currentWeather = WeatherManager.GetCurrentWeather(level);
ToolkitWeather toolkitFromWeatherTweaksWeather = ToolkitHelper.GetToolkitFromWeatherTweaksWeather((WeatherTweaksWeather?)(object)((currentWeather is WeatherTweaksWeather) ? currentWeather : null));
if (toolkitFromWeatherTweaksWeather != null && toolkitFromWeatherTweaksWeather.NameColor.HasValue)
{
Plugin.DebugLog($"{toolkitFromWeatherTweaksWeather.Name} weather was spawned using CWT with a defined color of {toolkitFromWeatherTweaksWeather.NameColor}");
string displayWeatherString = SetMapScreenInfoToCurrentLevelPatch.GetDisplayWeatherString(level, currentWeather);
Color value = toolkitFromWeatherTweaksWeather.NameColor.Value;
((Color)(ref value))..ctor(value.r, value.g * 1.1f, value.b, value.a);
string text = ColorUtility.ToHtmlStringRGB(value);
__result = "<color=#" + text + ">" + displayWeatherString + "</color>";
}
}
}
}
[HarmonyPatch(typeof(HUDManager))]
internal class DebugCommandsManager
{
[HarmonyPostfix]
[HarmonyPatch("AddChatMessage")]
public static void AddChatMessageDebugCommand(string chatMessage)
{
if (Plugin.config.DebugCommandsEnabled.Value && !((Object)(object)StartOfRound.Instance == (Object)null) && !StartOfRound.Instance.inShipPhase && StartOfRound.Instance.shipHasLanded && !StartOfRound.Instance.shipIsLeaving && chatMessage.StartsWith("/cwt"))
{
string[] array = chatMessage.Split(' ');
if (array.Length > 1)
{
ExecuteCommand(array);
}
}
}
private static void ExecuteCommand(string[] command)
{
string text = command[1];
string text2 = text;
if (!(text2 == "clear"))
{
if (text2 == "list")
{
Effects.Message("Debug CWT", "Current weathers: " + Effects.GetListOfCurrentWeathers());
return;
}
Effects.AddCombinedWeather(command[1]);
Effects.Message("Debug CWT", "Spawned " + command[1] + " combined weather");
}
else
{
Effects.ChangeWeather((LevelWeatherType)(-1));
Effects.Message("Debug CWT", "Removed all weathers from current level");
}
}
}
[HarmonyPatch(typeof(Plugin))]
internal class InitToolkitWeatherRegistery
{
[HarmonyPrefix]
[HarmonyPatch("MainMenuInit")]
public static void InitToolkitWeathers()
{
Plugin.installedWeathers.AddRange(from w in WeatherManager.RegisteredWeathers
where (int)w.Type == 2 && (int)w.Origin != 4
select string.Concat(w.Name.Where((char c) => !char.IsWhiteSpace(c))).ToLower());
if (Plugin.config.RegisterPredefinedWeathers.Value)
{
PredefinedRegistery.LoadAllPredefinedWeathers();
}
if (Plugin.config.AllowConfigRegistery.Value)
{
ConfigRegistery.LoadAllConfigValues();
}
if (Plugin.config.AllowJsonRegistery.Value)
{
JsonRegistery.LoadAllJsonFiles();
}
}
}
[HarmonyPatch(typeof(WeatherTweaksWeather))]
internal class OverrideToolkitScrapMultipliers
{
[HarmonyPrefix]
[HarmonyPatch("Init")]
public static bool InitToolkit(WeatherTweaksWeather __instance)
{
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Invalid comparison between Unknown and I4
//IL_005d: Unknown result type (might be due to invalid IL or missing references)
//IL_0067: Expected O, but got Unknown
//IL_006f: Unknown result type (might be due to invalid IL or missing references)
//IL_0079: Expected O, but got Unknown
//IL_008a: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)__instance == (Object)null || (int)((Weather)__instance).Origin != 4)
{
return true;
}
ToolkitWeather toolkitFromWeatherTweaksWeather = ToolkitHelper.GetToolkitFromWeatherTweaksWeather(__instance);
if (toolkitFromWeatherTweaksWeather == null)
{
return true;
}
var (num, num2) = __instance.GetDefaultMultiplierData();
((Weather)__instance).Config.ScrapValueMultiplier = new FloatConfigHandler(num, true);
((Weather)__instance).Config.ScrapAmountMultiplier = new FloatConfigHandler(num2, true);
((Weather)__instance).Effect.SunAnimatorBool = WeatherManager.GetWeather(__instance.WeatherTypes.Last().WeatherType).Effect.SunAnimatorBool;
IntPtr functionPointer = typeof(Weather).GetMethod("Init", BindingFlags.Instance | BindingFlags.NonPublic).MethodHandle.GetFunctionPointer();
((Action)Activator.CreateInstance(typeof(Action), __instance, functionPointer))();
return false;
}
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
public IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}