using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using Crest;
using HarmonyLib;
using UnityEngine;
using UnityEngine.SceneManagement;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("BitsAndBobsRadRedux")]
[assembly: AssemblyDescription("https://github.com/bryon82/SailwindBitsAndBobsRadRedux")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("raddude")]
[assembly: AssemblyProduct("BitsAndBobsRadRedux")]
[assembly: AssemblyCopyright("Copyright © 2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("74247c43-4bc4-43d4-b6dc-e9786a045779")]
[assembly: AssemblyFileVersion("1.3.2.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.3.2.0")]
[module: UnverifiableCode]
namespace BitsAndBobsRadRedux;
internal class InventorySlotLamp
{
[HarmonyPatch(typeof(GPButtonInventorySlot), "Awake")]
public class AddInventorySlotLampLighter
{
public static void Postfix(GPButtonInventorySlot __instance)
{
InventorySlotLampLighter inventorySlotLampLighter = ((Component)__instance).gameObject.AddComponent<InventorySlotLampLighter>();
inventorySlotLampLighter.InventorySlot = __instance;
}
}
}
internal class Comet : MonoBehaviour
{
public ParticleSystem tailParticles;
private MeshRenderer _coreRenderer;
private void Awake()
{
Transform obj = ((Component)this).transform.Find("Core");
_coreRenderer = ((obj != null) ? ((Component)obj).GetComponent<MeshRenderer>() : null);
Transform obj2 = ((Component)this).transform.Find("Tail");
tailParticles = ((obj2 != null) ? ((Component)obj2).GetComponent<ParticleSystem>() : null);
}
public void SetBrightness(float brightness)
{
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_004a: 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_006e: Unknown result type (might be due to invalid IL or missing references)
((Component)this).gameObject.SetActive(brightness > 0f);
if ((Object)(object)_coreRenderer != (Object)null)
{
Color color = ((Renderer)_coreRenderer).material.color;
color.a = brightness;
((Renderer)_coreRenderer).material.color = color;
}
if ((Object)(object)tailParticles != (Object)null)
{
EmissionModule emission = tailParticles.emission;
((EmissionModule)(ref emission)).rateOverTimeMultiplier = brightness * 8f;
}
}
public void SetPosition(Vector3 worldPosition, Camera mainCamera)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
((Component)this).transform.position = worldPosition;
((Component)this).transform.LookAt(((Component)mainCamera).transform.position);
}
public void SetTailDirection(Vector3 antiSolarDirection)
{
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)tailParticles == (Object)null))
{
((Component)tailParticles).transform.rotation = Quaternion.LookRotation(antiSolarDirection);
}
}
}
internal class Meteorite : MonoBehaviour
{
private Transform _meteorMesh;
private ParticleSystem _fireTrail;
private ParticleSystem _smoke;
private ParticleSystem _breakupParticles;
private ParticleSystem _flash;
private float _speed;
private float _lifetime;
private Vector3 _rotationSpeed;
private float _breakupPoint;
private Vector3 _direction;
private float _timer;
private bool _brokenUp;
private bool _initialized;
private void Awake()
{
//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
_meteorMesh = ((Component)this).transform.Find("MeteorMesh");
Transform obj = ((Component)this).transform.Find("FireTrail");
_fireTrail = ((obj != null) ? ((Component)obj).GetComponent<ParticleSystem>() : null);
Transform obj2 = ((Component)this).transform.Find("Smoke");
_smoke = ((obj2 != null) ? ((Component)obj2).GetComponent<ParticleSystem>() : null);
Transform obj3 = ((Component)this).transform.Find("BreakupParticles");
_breakupParticles = ((obj3 != null) ? ((Component)obj3).GetComponent<ParticleSystem>() : null);
Transform obj4 = ((Component)this).transform.Find("Flash");
_flash = ((obj4 != null) ? ((Component)obj4).GetComponent<ParticleSystem>() : null);
_breakupPoint = Random.Range(0.5f, 0.7f);
_rotationSpeed = new Vector3(250f, 180f, 300f);
}
public void Initialize(Vector3 startPosition, Vector3 endPosition, float lifetime, float speed)
{
//IL_006c: Unknown result type (might be due to invalid IL or missing references)
//IL_0074: 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_0076: Unknown result type (might be due to invalid IL or missing references)
//IL_007b: Unknown result type (might be due to invalid IL or missing references)
//IL_007e: Unknown result type (might be due to invalid IL or missing references)
//IL_0083: Unknown result type (might be due to invalid IL or missing references)
//IL_008f: Unknown result type (might be due to invalid IL or missing references)
//IL_0094: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)_meteorMesh == (Object)null || (Object)(object)_fireTrail == (Object)null || (Object)(object)_smoke == (Object)null || (Object)(object)_breakupParticles == (Object)null || (Object)(object)_flash == (Object)null)
{
BBRR_Plugin.LogError("One or more required components are missing from the Meteorite prefab.");
Object.Destroy((Object)(object)((Component)this).gameObject);
return;
}
((Component)this).transform.position = startPosition;
Vector3 val = endPosition - startPosition;
_direction = ((Vector3)(ref val)).normalized;
((Component)this).transform.rotation = Quaternion.LookRotation(_direction);
_timer = 0f;
_brokenUp = false;
_lifetime = lifetime;
_speed = speed;
_initialized = true;
}
private void Update()
{
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
//IL_003f: Unknown result type (might be due to invalid IL or missing references)
//IL_0045: Unknown result type (might be due to invalid IL or missing references)
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
//IL_005c: Unknown result type (might be due to invalid IL or missing references)
//IL_0062: Unknown result type (might be due to invalid IL or missing references)
if (_initialized)
{
float deltaTime = Time.deltaTime;
_timer += deltaTime;
Transform transform = ((Component)this).transform;
transform.position += _direction * _speed * deltaTime;
_meteorMesh.Rotate(_rotationSpeed * deltaTime, (Space)1);
float num = _timer / _lifetime;
if (!_brokenUp && num >= _breakupPoint)
{
Breakup();
}
if (_timer >= _lifetime)
{
Object.Destroy((Object)(object)((Component)this).gameObject);
}
}
}
private void Breakup()
{
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
//IL_0045: Unknown result type (might be due to invalid IL or missing references)
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
_brokenUp = true;
_breakupParticles.Emit(30);
_flash.Emit(1);
Transform meteorMesh = _meteorMesh;
meteorMesh.localScale *= 0.45f;
EmissionModule emission = _fireTrail.emission;
((EmissionModule)(ref emission)).rateOverTimeMultiplier = ((EmissionModule)(ref emission)).rateOverTimeMultiplier * 0.3f;
_smoke.Emit(40);
}
}
internal class Setup
{
private const string OCEAN_SCENE = "the ocean";
internal const string DRAGON_CLIFFS_SCENE = "island 9 E Dragon Cliffs";
internal static Light PlayerLight { get; private set; }
internal static List<GameObject> DCGateLampGOs { get; private set; }
internal static GameObject MeteorShowerGO { get; private set; }
internal static GameObject VolcanoSteamGO { get; private set; }
internal static void SceneLoaded(Scene scene, LoadSceneMode loadSceneMode)
{
if (((Scene)(ref scene)).name.Equals("the ocean"))
{
((MonoBehaviour)BBRR_Plugin.Instance).StartCoroutine(AddMeteorShowers());
((MonoBehaviour)BBRR_Plugin.Instance).StartCoroutine(AddMaleficSteam());
((MonoBehaviour)BBRR_Plugin.Instance).StartCoroutine(AddMeteorite());
}
if (((Scene)(ref scene)).name.Equals("island 9 E Dragon Cliffs"))
{
AddDCGateLights();
}
}
internal static IEnumerator SetPlayerLight()
{
yield return (object)new WaitUntil((Func<bool>)(() => (Object)(object)Camera.main != (Object)null && (Object)(object)((Component)Camera.main).GetComponent<Light>() != (Object)null));
Camera camera = Camera.main;
PlayerLight = ((camera != null) ? ((Component)camera).GetComponent<Light>() : null);
}
internal static void AddDCGateLights()
{
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_003e: Unknown result type (might be due to invalid IL or missing references)
//IL_0043: Unknown result type (might be due to invalid IL or missing references)
//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
//IL_010a: Unknown result type (might be due to invalid IL or missing references)
//IL_0128: Unknown result type (might be due to invalid IL or missing references)
DCGateLampGOs = new List<GameObject>();
Vector3[] array = (Vector3[])(object)new Vector3[2]
{
new Vector3(0f, 3.35f, 3.1f),
new Vector3(0f, -3.35f, 3.1f)
};
GameObject val = GameObject.Find("island 9 E (dragon cliffs) scenery");
Transform val2 = ((IEnumerable<Transform>)((Component)val.transform).GetComponentsInChildren<Transform>(true)).FirstOrDefault((Func<Transform, bool>)((Transform t) => ((Object)t).name.Equals("east_gate (4)")));
Transform child = ((IEnumerable<Transform>)((Component)val.transform).GetComponentsInChildren<Transform>(true)).FirstOrDefault((Func<Transform, bool>)((Transform t) => ((Object)t).name.Equals("east_street_rope (1)"))).GetChild(0);
Vector3[] array2 = array;
foreach (Vector3 localPosition in array2)
{
GameObject val3 = Object.Instantiate<GameObject>(((Component)child).gameObject, val2);
val3.transform.localScale = new Vector3(1.33f, 1.33f, 1.33f);
val3.transform.localPosition = localPosition;
val3.transform.rotation = Quaternion.Euler(270f, 0f, 0f);
val3.GetComponent<Light>().range = 50f;
val3.GetComponent<Light>().intensity = 1.5f;
DCGateLampGOs.Add(val3);
}
BBRR_Plugin.LogDebug("Dragon Cliffs gate lamps added");
}
internal static IEnumerator AddMeteorShowers()
{
yield return (object)new WaitUntil((Func<bool>)(() => AssetLoader.AssetsLoaded));
if ((Object)(object)AssetLoader.MeteorShower == (Object)null)
{
BBRR_Plugin.LogError("MeteorShower prefab not loaded");
yield break;
}
GameObject meteorShowers = Object.Instantiate<GameObject>(AssetLoader.MeteorShower, ((Component)Camera.main).transform.position, AssetLoader.MeteorShower.transform.rotation);
meteorShowers.AddComponent<MeteorShowerScheduler>();
MeteorShowerGO = meteorShowers;
BBRR_Plugin.LogDebug("Meteor showers added");
}
internal static IEnumerator AddMeteorite()
{
yield return (object)new WaitUntil((Func<bool>)(() => AssetLoader.AssetsLoaded));
if ((Object)(object)AssetLoader.Meteorite == (Object)null)
{
BBRR_Plugin.LogError("Meteorite prefab not loaded");
yield break;
}
AssetLoader.Meteorite.AddComponent<Meteorite>();
BBRR_Plugin.LogDebug("Meteorite added");
}
internal static IEnumerator AddMaleficSteam()
{
yield return (object)new WaitUntil((Func<bool>)(() => AssetLoader.AssetsLoaded));
if ((Object)(object)AssetLoader.VolcanoSteam == (Object)null)
{
BBRR_Plugin.LogError("VolcanoSteam prefab not loaded");
yield break;
}
Transform parent = ((IEnumerable<Transform>)((Component)((Component)Refs.islands[17]).transform).GetComponentsInChildren<Transform>(true)).FirstOrDefault((Func<Transform, bool>)((Transform t) => ((Object)t).name.Equals("Cube_001")));
GameObject volcanoSteam = Object.Instantiate<GameObject>(AssetLoader.VolcanoSteam, parent);
volcanoSteam.transform.localPosition = new Vector3(17.5f, 19f, 235f);
volcanoSteam.transform.rotation = Quaternion.Euler(0f, 0f, 0f);
volcanoSteam.AddComponent<VolcanoSteamAdjuster>();
VolcanoSteamGO = volcanoSteam;
BBRR_Plugin.LogDebug("Volcano steam added");
}
}
internal class InventorySlotLampLighter : MonoBehaviour
{
internal GPButtonInventorySlot InventorySlot { get; set; }
private void LateUpdate()
{
if (Configs.enableActivateInventoryLamp.Value && ((GoPointerButton)InventorySlot).IsLookedAt())
{
ShipItem currentItem = InventorySlot.currentItem;
if (currentItem is ShipItemLight && (GameInput.GetKeyDown((InputName)9) || Input.GetMouseButtonDown(1)))
{
((GoPointerButton)currentItem).OnAltActivate();
}
}
}
}
internal class AssetLoader
{
private static readonly List<string> assetPaths = new List<string>
{
Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)BBRR_Plugin.Instance).Info.Location), "Assets"),
Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)BBRR_Plugin.Instance).Info.Location))
};
internal static GameObject MeteorShower { get; private set; }
internal static GameObject VolcanoSteam { get; private set; }
internal static GameObject Meteorite { get; private set; }
internal static GameObject Comet { get; private set; }
internal static bool AssetsLoaded { get; private set; } = false;
public static string FindAssetPath(string fileName)
{
foreach (string assetPath in assetPaths)
{
string text = Path.Combine(assetPath, fileName);
if (File.Exists(text))
{
return text;
}
}
return null;
}
internal static IEnumerator LoadAssets()
{
BBRR_Plugin.LogDebug("Loading assets");
string bundlePath = FindAssetPath("bbrr_assets");
if (string.IsNullOrEmpty(bundlePath))
{
BBRR_Plugin.LogError("Asset bundle not found");
yield break;
}
AssetBundleCreateRequest assetBundleRequest = AssetBundle.LoadFromFileAsync(bundlePath);
yield return assetBundleRequest;
AssetBundle assetBundle = assetBundleRequest.assetBundle;
if ((Object)(object)assetBundle == (Object)null)
{
BBRR_Plugin.LogError("Failed to load " + bundlePath);
yield break;
}
AssetBundleRequest request = assetBundle.LoadAllAssetsAsync();
yield return request;
Object? obj = ((IEnumerable<Object>)request.allAssets).FirstOrDefault((Func<Object, bool>)((Object a) => a.name.Equals("MeteorShower")));
MeteorShower = (GameObject)(object)((obj is GameObject) ? obj : null);
Object? obj2 = ((IEnumerable<Object>)request.allAssets).FirstOrDefault((Func<Object, bool>)((Object a) => a.name.Equals("VolcanoSteam")));
VolcanoSteam = (GameObject)(object)((obj2 is GameObject) ? obj2 : null);
Object? obj3 = ((IEnumerable<Object>)request.allAssets).FirstOrDefault((Func<Object, bool>)((Object a) => a.name.Equals("Meteorite")));
Meteorite = (GameObject)(object)((obj3 is GameObject) ? obj3 : null);
Object? obj4 = ((IEnumerable<Object>)request.allAssets).FirstOrDefault((Func<Object, bool>)((Object a) => a.name.Equals("Comet")));
Comet = (GameObject)(object)((obj4 is GameObject) ? obj4 : null);
AssetsLoaded = true;
BBRR_Plugin.LogInfo("Assets loaded");
}
}
internal class BlueTobacco
{
[HarmonyPatch(typeof(SaveablePrefab), "Start")]
private class SetBlueTobaccoType
{
public static void Postfix(SaveablePrefab __instance)
{
if (((Object)((Component)__instance).gameObject).name.StartsWith("318 tobacco blue"))
{
((Component)__instance).gameObject.GetComponent<ShipItemTobacco>().tobaccoType = 5;
}
}
}
[HarmonyPatch(typeof(PlayerTobacco), "Smoke")]
private class SetBlueTobaccoPotency
{
public static void Postfix(PlayerTobacco __instance, int tobaccoType)
{
if (tobaccoType == 5)
{
if (!Configs.enableBlueTobacco.Value)
{
__instance.green += Time.deltaTime * 2f;
PlayerNeeds.sleep -= Time.deltaTime * 0.11f;
}
else
{
__instance.green += Time.deltaTime * 2f * (float)Configs.bluePotencyMult.Value * 0.33f;
PlayerNeeds.sleep -= Time.deltaTime * 0.11f * (float)Configs.bluePotencyMult.Value;
}
}
}
}
}
[BepInPlugin("com.raddude.bitsandbobsradredux", "BitsAndBobsRadRedux", "1.3.2")]
public class BBRR_Plugin : BaseUnityPlugin
{
public const string PLUGIN_GUID = "com.raddude.bitsandbobsradredux";
public const string PLUGIN_NAME = "BitsAndBobsRadRedux";
public const string PLUGIN_VERSION = "1.3.2";
private static ManualLogSource _logger;
internal static BBRR_Plugin Instance { get; private set; }
internal static void LogDebug(string message)
{
_logger.LogDebug((object)message);
}
internal static void LogInfo(string message)
{
_logger.LogInfo((object)message);
}
internal static void LogWarning(string message)
{
_logger.LogWarning((object)message);
}
internal static void LogError(string message)
{
_logger.LogError((object)message);
}
private void Awake()
{
if ((Object)(object)Instance != (Object)null && (Object)(object)Instance != (Object)(object)this)
{
Object.Destroy((Object)(object)((Component)this).gameObject);
return;
}
Instance = this;
_logger = ((BaseUnityPlugin)this).Logger;
((MonoBehaviour)this).StartCoroutine(AssetLoader.LoadAssets());
Configs.InitializeConfigs();
Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "com.raddude.bitsandbobsradredux");
((MonoBehaviour)this).StartCoroutine(Setup.SetPlayerLight());
SceneManager.sceneLoaded += Setup.SceneLoaded;
}
private void Update()
{
Configs.UpdateConfigs();
}
}
internal class MeteorShower
{
private readonly int _startDay;
private readonly int _peakDay;
private readonly int _endDay;
private readonly float _peakRate;
private const float SECONDS_IN_AN_HOUR = 3600f;
internal string Name { get; private set; }
internal float Declination { get; private set; }
internal float RightAscension { get; private set; }
internal static List<MeteorShower> MeteorShowers { get; private set; }
internal MeteorShower(string name, int startDay, int peakDay, int endDay, float peakHourlyRate, float declination, float rightAscension)
{
Name = name;
_startDay = startDay;
_peakDay = peakDay;
_endDay = endDay;
_peakRate = peakHourlyRate / 3600f;
Declination = declination;
RightAscension = rightAscension;
}
internal float GetRateForDay(int day)
{
if (day < _startDay || day > _endDay)
{
return 0f;
}
float num = ((day <= _peakDay) ? (_peakDay - _startDay) : (_endDay - _peakDay));
float num2 = 1f - (float)Mathf.Abs(day - _peakDay) / num;
return _peakRate * (1f - (1f - num2) * (1f - num2));
}
internal static void InitializeMeteorShowers()
{
MeteorShowers = new List<MeteorShower>
{
new MeteorShower("Quadrantids", 0, 3, 12, 120f, 50f, 232f),
new MeteorShower("Lyrids", 104, 112, 120, 18f, 33f, 272.5f),
new MeteorShower("Arietids", 142, 158, 175, 60f, 25f, 45.5f),
new MeteorShower("Perseids", 198, 224, 236, 100f, 58f, 48.25f),
new MeteorShower("Orionids", 275, 295, 316, 20f, 16f, 96f),
new MeteorShower("Leonids", 307, 321, 334, 15f, 21.6f, 154.25f),
new MeteorShower("Geminids", 335, 346, 351, 150f, 32f, 108.75f)
};
}
}
internal class MeteorShowerScheduler : MonoBehaviour
{
private EmissionModule _emission;
private ColorOverLifetimeModule _colorOverLifetime;
private Camera _mainCamera;
private bool _notified;
private Vector3 _radiant;
private float _meteoriteChance;
private float _meteoriteTimer;
private const float BACKGROUND_RATE = 0.0014f;
private const float BACKGROUND_DECLINATION = 60f;
private const float BACKGROUND_RA = 350f;
private const float RADIUS_FROM_CAMERA = 2500f;
private const float START_HOUR = 17f;
private const float END_HOUR = 6f;
private const float SAFETY_MARGIN = 200f;
private const float NO_GO_RADIUS = 200f;
internal static MeteorShowerScheduler Instance { get; private set; }
private void Start()
{
//IL_003f: Unknown result type (might be due to invalid IL or missing references)
//IL_0044: 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_0050: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)Instance != (Object)null && (Object)(object)Instance != (Object)(object)this)
{
Object.Destroy((Object)(object)((Component)this).gameObject);
return;
}
Instance = this;
ParticleSystem component = ((Component)this).GetComponent<ParticleSystem>();
_emission = component.emission;
_colorOverLifetime = component.colorOverLifetime;
_mainCamera = Camera.main;
_notified = false;
ConfigureParticleSystem();
MeteorShower.InitializeMeteorShowers();
}
private void LateUpdate()
{
//IL_0047: Unknown result type (might be due to invalid IL or missing references)
float localTime = Sun.sun.localTime;
if ((!(localTime > 17f) || !(localTime <= 24f)) && (!(localTime >= 0f) || !(localTime < 6f)))
{
((EmissionModule)(ref _emission)).rateOverTime = MinMaxCurve.op_Implicit(0f);
_notified = false;
return;
}
UpdateMeteorShower();
_meteoriteTimer += Time.deltaTime;
if (!(_meteoriteTimer >= 5f))
{
return;
}
_meteoriteTimer = 0f;
float value = Random.value;
if (value < _meteoriteChance * (float)Configs.meteoriteChanceMult.Value)
{
if ((Object)(object)AssetLoader.Meteorite == (Object)null)
{
BBRR_Plugin.LogError("Meteorite prefab not loaded. Cannot spawn meteorite.");
return;
}
SpawnMeteorite();
BBRR_Plugin.LogDebug("Meteorite spawned.");
}
}
private void ConfigureParticleSystem()
{
//IL_0014: 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_002a: Unknown result type (might be due to invalid IL or missing references)
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_0040: Unknown result type (might be due to invalid IL or missing references)
//IL_0045: 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)
//IL_005d: Unknown result type (might be due to invalid IL or missing references)
//IL_0062: Unknown result type (might be due to invalid IL or missing references)
//IL_0067: Unknown result type (might be due to invalid IL or missing references)
//IL_006d: Expected O, but got Unknown
//IL_007d: Unknown result type (might be due to invalid IL or missing references)
GradientAlphaKey[] array = (GradientAlphaKey[])(object)new GradientAlphaKey[3]
{
new GradientAlphaKey(0f, 0f),
new GradientAlphaKey(1f, 0.5f),
new GradientAlphaKey(0f, 1f)
};
GradientColorKey[] array2 = (GradientColorKey[])(object)new GradientColorKey[1]
{
new GradientColorKey(Color.white, 0f)
};
Gradient val = new Gradient();
val.SetKeys(array2, array);
((ColorOverLifetimeModule)(ref _colorOverLifetime)).color = MinMaxGradient.op_Implicit(val);
}
private void UpdateMeteorShower()
{
//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
//IL_00f7: 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_010a: Unknown result type (might be due to invalid IL or missing references)
//IL_0145: Unknown result type (might be due to invalid IL or missing references)
//IL_014a: Unknown result type (might be due to invalid IL or missing references)
//IL_014c: Unknown result type (might be due to invalid IL or missing references)
//IL_0168: Unknown result type (might be due to invalid IL or missing references)
int day = GameState.day % 365;
float num = 0.0014f;
float declination = 60f;
float rightAscensionDegrees = 350f;
foreach (MeteorShower meteorShower in MeteorShower.MeteorShowers)
{
float rateForDay = meteorShower.GetRateForDay(day);
if (rateForDay > num)
{
num = rateForDay;
declination = meteorShower.Declination;
rightAscensionDegrees = meteorShower.RightAscension;
}
if (!_notified && rateForDay > 0f)
{
BBRR_Plugin.LogInfo(meteorShower.Name + " meteor shower tonight with a rate of " + $"{rateForDay * (float)Configs.meteorShowerRateMult.Value:0.000} meteors per second");
_notified = true;
}
}
Vector3 relativePosition = GetRelativePosition(declination, rightAscensionDegrees);
((EmissionModule)(ref _emission)).rateOverTime = MinMaxCurve.op_Implicit(num * (float)Configs.meteorShowerRateMult.Value);
_radiant = ((Vector3)(ref relativePosition)).normalized;
_meteoriteChance = Mathf.Lerp(0.005f, 0.1f, Mathf.InverseLerp(0.0014f, 150f, num));
((Component)this).transform.position = ((Component)_mainCamera).transform.position + relativePosition;
((Component)this).transform.LookAt(((Component)_mainCamera).transform.position);
}
private Vector3 GetRelativePosition(float declination, float rightAscensionDegrees)
{
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_014f: Unknown result type (might be due to invalid IL or missing references)
//IL_0154: Unknown result type (might be due to invalid IL or missing references)
//IL_0158: Unknown result type (might be due to invalid IL or missing references)
float num = (float)Math.PI / 180f;
float num2 = ((Component)_mainCamera).transform.position.x / 9000f + 36f;
float num3 = Sun.sun.localTime / 24f * 360f - rightAscensionDegrees;
if (num3 < 0f)
{
num3 += 360f;
}
float num4 = Mathf.Sin(declination * num) * Mathf.Sin(num2 * num) + Mathf.Cos(declination * num) * Mathf.Cos(num2 * num) * Mathf.Cos(num3 * num);
float num5 = Mathf.Asin(num4) * 57.29578f;
float num6 = (Mathf.Sin(declination * num) - Mathf.Sin(num5 * num) * Mathf.Sin(num2 * num)) / (Mathf.Cos(num5 * num) * Mathf.Cos(num2 * num));
float num7 = Mathf.Acos(num6) * 57.29578f;
if (Mathf.Sin(num3 * num) >= 0f)
{
num7 = 360f - num7;
}
float num8 = 2500f * Mathf.Cos(num5 * num) * Mathf.Cos((0f - (num7 - 90f)) * num);
float num9 = 2500f * Mathf.Cos(num5 * num) * Mathf.Sin((0f - (num7 - 90f)) * num);
float num10 = 2500f * Mathf.Sin(num5 * num);
return new Vector3(num8, num10, num9);
}
private void SpawnMeteorite()
{
//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)
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_003e: Unknown result type (might be due to invalid IL or missing references)
//IL_0043: 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)
//IL_0058: 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_005e: Unknown result type (might be due to invalid IL or missing references)
//IL_0063: Unknown result type (might be due to invalid IL or missing references)
//IL_0073: Unknown result type (might be due to invalid IL or missing references)
//IL_0078: Unknown result type (might be due to invalid IL or missing references)
//IL_007d: Unknown result type (might be due to invalid IL or missing references)
//IL_007e: Unknown result type (might be due to invalid IL or missing references)
//IL_0083: Unknown result type (might be due to invalid IL or missing references)
//IL_0092: Unknown result type (might be due to invalid IL or missing references)
//IL_0094: Unknown result type (might be due to invalid IL or missing references)
//IL_009a: Unknown result type (might be due to invalid IL or missing references)
//IL_009f: Unknown result type (might be due to invalid IL or missing references)
//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
//IL_0119: Unknown result type (might be due to invalid IL or missing references)
//IL_011b: Unknown result type (might be due to invalid IL or missing references)
//IL_011f: Unknown result type (might be due to invalid IL or missing references)
//IL_0124: Unknown result type (might be due to invalid IL or missing references)
//IL_0129: Unknown result type (might be due to invalid IL or missing references)
//IL_0130: Unknown result type (might be due to invalid IL or missing references)
//IL_0135: Unknown result type (might be due to invalid IL or missing references)
//IL_013a: Unknown result type (might be due to invalid IL or missing references)
//IL_013c: Unknown result type (might be due to invalid IL or missing references)
//IL_013d: Unknown result type (might be due to invalid IL or missing references)
//IL_013f: Unknown result type (might be due to invalid IL or missing references)
//IL_0144: Unknown result type (might be due to invalid IL or missing references)
//IL_0146: Unknown result type (might be due to invalid IL or missing references)
//IL_0148: Unknown result type (might be due to invalid IL or missing references)
//IL_014e: Unknown result type (might be due to invalid IL or missing references)
//IL_014f: Unknown result type (might be due to invalid IL or missing references)
//IL_0154: Unknown result type (might be due to invalid IL or missing references)
//IL_0156: Unknown result type (might be due to invalid IL or missing references)
//IL_0158: Unknown result type (might be due to invalid IL or missing references)
//IL_015a: Unknown result type (might be due to invalid IL or missing references)
//IL_015f: Unknown result type (might be due to invalid IL or missing references)
//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
//IL_01b2: Unknown result type (might be due to invalid IL or missing references)
//IL_01b4: Unknown result type (might be due to invalid IL or missing references)
//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
//IL_01c4: Unknown result type (might be due to invalid IL or missing references)
//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
//IL_01ce: Unknown result type (might be due to invalid IL or missing references)
//IL_01d3: Unknown result type (might be due to invalid IL or missing references)
//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
//IL_01f5: Unknown result type (might be due to invalid IL or missing references)
//IL_0217: Unknown result type (might be due to invalid IL or missing references)
//IL_0224: Unknown result type (might be due to invalid IL or missing references)
//IL_0189: Unknown result type (might be due to invalid IL or missing references)
//IL_018e: Unknown result type (might be due to invalid IL or missing references)
//IL_0183: Unknown result type (might be due to invalid IL or missing references)
//IL_0193: Unknown result type (might be due to invalid IL or missing references)
//IL_019f: Unknown result type (might be due to invalid IL or missing references)
//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
//IL_01aa: 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_029a: Unknown result type (might be due to invalid IL or missing references)
//IL_029c: Unknown result type (might be due to invalid IL or missing references)
//IL_025a: Unknown result type (might be due to invalid IL or missing references)
//IL_025c: 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_0267: Unknown result type (might be due to invalid IL or missing references)
//IL_026c: Unknown result type (might be due to invalid IL or missing references)
//IL_026e: Unknown result type (might be due to invalid IL or missing references)
//IL_0270: Unknown result type (might be due to invalid IL or missing references)
//IL_0276: Unknown result type (might be due to invalid IL or missing references)
//IL_027b: Unknown result type (might be due to invalid IL or missing references)
//IL_0280: Unknown result type (might be due to invalid IL or missing references)
Vector3 position = ((Component)_mainCamera).transform.position;
float num = (((Object)(object)OceanRenderer.Instance != (Object)null) ? (position.y - OceanRenderer.Instance.ViewerHeightAboveWater) : 0f);
Vector3 val = -_radiant;
val = Quaternion.AngleAxis(Random.Range(-10f, 10f), Vector3.up) * val;
val = Quaternion.AngleAxis(Random.Range(-15f, 15f), Vector3.right) * val;
((Vector3)(ref val)).Normalize();
float num2 = 500f;
Vector3 val2 = position + _radiant * num2;
Vector3 val3 = Vector3.Cross(Vector3.up, val);
Vector3 val4 = ((Vector3)(ref val3)).normalized;
if (((Vector3)(ref val4)).sqrMagnitude < 0.01f)
{
val4 = Vector3.right;
}
float num3 = Random.Range(-1f, 1f) * Random.Range(200f, 500f);
float num4 = Random.Range(-1f, 1f) * Random.Range(100f, 300f);
Vector3 val5 = val2 + val4 * num3 + Vector3.up * num4;
Vector3 val6 = position - val5;
Vector3 val7 = Vector3.Dot(val6, val) * val;
Vector3 val8 = val6 - val7;
float magnitude = ((Vector3)(ref val8)).magnitude;
if (magnitude < 200f)
{
Vector3 val9 = ((magnitude > 0.01f) ? (-((Vector3)(ref val8)).normalized) : val4);
float num5 = 200f - magnitude;
val5 += val9 * num5;
}
Vector3 val10 = val5 - val * 300f;
Vector3 endPosition = val5 + val * 300f;
float num6 = Random.Range(9f, 12f);
float num7 = 100f * num6;
float num8 = val10.y - num - 200f;
float num9 = Mathf.Max(num8 / num7, 0f);
if (val.y < 0f && 0f - val.y > num9)
{
val.y = 0f - Mathf.Clamp(num9, 0f, 0.6f);
((Vector3)(ref val)).Normalize();
endPosition = val5 + val * 300f;
val10 = val5 - val * 300f;
}
GameObject val11 = Object.Instantiate<GameObject>(AssetLoader.Meteorite);
Meteorite component = val11.GetComponent<Meteorite>();
component.Initialize(val10, endPosition, num6, 100f);
}
}
internal class VolcanoSteamAdjuster : MonoBehaviour
{
private struct TimeColorTransition
{
public float startTime;
public float endTime;
public int startColorIndex;
public int endColorIndex;
}
private EmissionModule _emission;
private ForceOverLifetimeModule _forceLifetime;
private Material _material;
private Wind _wind;
private float _timer = 0f;
private readonly Color32[] _lightingColors = (Color32[])(object)new Color32[4]
{
new Color32((byte)29, (byte)28, (byte)27, (byte)238),
new Color32((byte)38, (byte)38, (byte)38, (byte)238),
new Color32((byte)214, (byte)186, (byte)132, (byte)238),
new Color32(byte.MaxValue, (byte)246, (byte)234, (byte)238)
};
private const float LOW_ACTIVITY_CHANCE = 0.33f;
private const float HIGH_ACTIVITY_CHANCE = 0.66f;
private const float PARTICLE_LIFETIME = 90f;
private const int MAX_PARTICLES = 1000;
private readonly TimeColorTransition[] _colorTransitions = new TimeColorTransition[6]
{
new TimeColorTransition
{
startTime = 4f,
endTime = 5f,
startColorIndex = 0,
endColorIndex = 1
},
new TimeColorTransition
{
startTime = 5f,
endTime = 6f,
startColorIndex = 1,
endColorIndex = 2
},
new TimeColorTransition
{
startTime = 6f,
endTime = 12f,
startColorIndex = 2,
endColorIndex = 3
},
new TimeColorTransition
{
startTime = 12f,
endTime = 18f,
startColorIndex = 3,
endColorIndex = 2
},
new TimeColorTransition
{
startTime = 18f,
endTime = 19f,
startColorIndex = 2,
endColorIndex = 1
},
new TimeColorTransition
{
startTime = 19f,
endTime = 20f,
startColorIndex = 1,
endColorIndex = 0
}
};
public void Start()
{
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
//IL_000f: 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_001b: Unknown result type (might be due to invalid IL or missing references)
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_0037: Unknown result type (might be due to invalid IL or missing references)
//IL_003f: Unknown result type (might be due to invalid IL or missing references)
ParticleSystem componentInChildren = ((Component)this).GetComponentInChildren<ParticleSystem>();
_emission = componentInChildren.emission;
_forceLifetime = componentInChildren.forceOverLifetime;
_material = ((Component)componentInChildren).GetComponent<Renderer>().material;
MainModule main = componentInChildren.main;
((MainModule)(ref main)).startLifetime = MinMaxCurve.op_Implicit(90f);
((MainModule)(ref main)).maxParticles = 1000;
GameObject obj = GameObject.Find("wind");
_wind = ((obj != null) ? obj.GetComponent<Wind>() : null);
}
public void Update()
{
UpdateEmissionState();
UpdateWindForce();
UpdateDayNightColor();
}
private void UpdateEmissionState()
{
if (_timer <= 0f)
{
float num = Random.Range(0f, 1f);
bool flag = true;
if (Configs.mtMaleficActivity.Value == 0)
{
flag = num < 0.33f;
_timer = (flag ? Random.Range(60f, 120f) : Random.Range(300f, 900f));
}
else if (Configs.mtMaleficActivity.Value == 1)
{
flag = num < 0.66f;
_timer = (flag ? Random.Range(300f, 600f) : Random.Range(120f, 300f));
}
((EmissionModule)(ref _emission)).enabled = flag;
}
_timer -= Time.deltaTime;
}
private void UpdateWindForce()
{
//IL_0007: 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)
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: 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_005e: Unknown result type (might be due to invalid IL or missing references)
Vector3 val = _wind.outCurrentBaseWind * _wind.outCurrentMagnitude;
((ForceOverLifetimeModule)(ref _forceLifetime)).x = new MinMaxCurve(val.x * Time.deltaTime / 18f);
((ForceOverLifetimeModule)(ref _forceLifetime)).y = new MinMaxCurve((0f - val.z) * Time.deltaTime / 18f);
}
private void UpdateDayNightColor()
{
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
//IL_007d: Unknown result type (might be due to invalid IL or missing references)
//IL_0082: 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_0096: Unknown result type (might be due to invalid IL or missing references)
//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
float localTime = Sun.sun.localTime;
Color32 val = _lightingColors[0];
if (localTime >= 4f && localTime < 20f)
{
TimeColorTransition[] colorTransitions = _colorTransitions;
for (int i = 0; i < colorTransitions.Length; i++)
{
TimeColorTransition timeColorTransition = colorTransitions[i];
if (localTime > timeColorTransition.startTime && localTime <= timeColorTransition.endTime)
{
Color32 val2 = _lightingColors[timeColorTransition.startColorIndex];
Color32 val3 = _lightingColors[timeColorTransition.endColorIndex];
float num = (localTime - timeColorTransition.startTime) / (timeColorTransition.endTime - timeColorTransition.startTime);
val = Color32.op_Implicit(Color.Lerp(Color32.op_Implicit(val2), Color32.op_Implicit(val3), num));
break;
}
}
}
_material.SetColor("_Color", Color32.op_Implicit(val));
}
}
internal class Configs
{
internal static ConfigEntry<bool> addDcGateLamps;
internal static ConfigEntry<bool> addMeteorShowers;
internal static ConfigEntry<bool> addMtMaleficSteam;
internal static ConfigEntry<int> mtMaleficActivity;
internal static ConfigEntry<bool> enablePlayerLight;
internal static ConfigEntry<bool> enableActivateInventoryLamp;
internal static ConfigEntry<bool> enableBlueTobacco;
internal static ConfigEntry<int> bluePotencyMult;
internal static ConfigEntry<int> meteorShowerRateMult;
internal static ConfigEntry<int> meteoriteChanceMult;
private static bool _lastAddDcGateLamps;
internal static void InitializeConfigs()
{
//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
//IL_0105: Expected O, but got Unknown
//IL_0128: Unknown result type (might be due to invalid IL or missing references)
//IL_0132: Expected O, but got Unknown
ConfigFile config = ((BaseUnityPlugin)BBRR_Plugin.Instance).Config;
addDcGateLamps = config.Bind<bool>("Additions", "Add Dragon Cliffs Gate Lamps", true, (ConfigDescription)null);
addMeteorShowers = config.Bind<bool>("Additions", "Add Meteor Showers", true, "Adds occasional shooting stars and northern hemisphere meteor showers on their respective days, day 0 and day 365 are January 1st.");
addMtMaleficSteam = config.Bind<bool>("Additions", "Add Mt. Malefic Steam", true, "Adds steam being emitted from Mt. Malefic");
mtMaleficActivity = config.Bind<int>("Additions", "Mt. Malefic Activity", 1, "Mt. Malefic activity level: 0 = occasional emissions, 1 = more frequent and longer duration emissions, 2 = constant emission");
enablePlayerLight = config.Bind<bool>("Options", "Ambient Player Light", false, "Light emanating from the player.");
enableActivateInventoryLamp = config.Bind<bool>("Options", "Activate Lamp In Inventory", true, "The ability to activate the lamp in an inventory slot by right-clicking it (or using other activation button).");
enableBlueTobacco = config.Bind<bool>("Options", "Increase Blue Tobacco Potency", true, (ConfigDescription)null);
bluePotencyMult = config.Bind<int>("Options", "Blue Tobacco Potency Multiplier", 6, "The potency multiplier of blue tobacco as compared to green tobacco.");
meteorShowerRateMult = config.Bind<int>("Options", "Meteor Shower Rate Multiplier", 10, new ConfigDescription("Increases the amount of shooting stars.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 100), Array.Empty<object>()));
meteoriteChanceMult = config.Bind<int>("Options", "Meteorite Chance Multiplier", 1, new ConfigDescription("Increases the chance of a meteorite spawning.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 100), Array.Empty<object>()));
_lastAddDcGateLamps = addDcGateLamps.Value;
}
internal static void UpdateConfigs()
{
//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)Setup.MeteorShowerGO != (Object)null && Setup.MeteorShowerGO.activeSelf != addMeteorShowers.Value)
{
Setup.MeteorShowerGO.SetActive(addMeteorShowers.Value);
}
if ((Object)(object)Setup.VolcanoSteamGO != (Object)null && Setup.VolcanoSteamGO.activeSelf != addMtMaleficSteam.Value)
{
Setup.VolcanoSteamGO.SetActive(addMtMaleficSteam.Value);
}
bool currentAddDcGateLamps = addDcGateLamps.Value;
if (currentAddDcGateLamps != _lastAddDcGateLamps && Setup.DCGateLampGOs != null)
{
Scene sceneByName = SceneManager.GetSceneByName("island 9 E Dragon Cliffs");
if (((Scene)(ref sceneByName)).isLoaded)
{
Setup.DCGateLampGOs.ForEach(delegate(GameObject lamp)
{
if (lamp != null)
{
lamp.SetActive(currentAddDcGateLamps);
}
});
}
_lastAddDcGateLamps = currentAddDcGateLamps;
}
if ((Object)(object)Setup.PlayerLight != (Object)null && ((Behaviour)Setup.PlayerLight).enabled != enablePlayerLight.Value)
{
((Behaviour)Setup.PlayerLight).enabled = enablePlayerLight.Value;
}
}
}