using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
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.Bootstrap;
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("RadFixes")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("raddude")]
[assembly: AssemblyProduct("RadFixes")]
[assembly: AssemblyCopyright("Copyright © 2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("56796b16-fa96-4077-8440-cc4ba31a62f5")]
[assembly: AssemblyFileVersion("1.3.3.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.3.3.0")]
[module: UnverifiableCode]
namespace RadFixes;
internal class BoatDamageFixes
{
[HarmonyPatch(typeof(BoatDamage), "Impact")]
public static class BoatDamagePatches
{
public static bool Prefix()
{
if (inIFrames)
{
RF_Plugin.LogDebug("In IFrames, no damage received");
}
return !inIFrames;
}
}
[HarmonyPatch(typeof(Shipyard), "DischargeShip")]
public static class ShipyardPatches
{
public static void Postfix(Shipyard __instance)
{
((MonoBehaviour)__instance).StartCoroutine(IFrameCoroutine());
}
}
internal static bool inIFrames;
private static IEnumerator IFrameCoroutine()
{
inIFrames = true;
yield return (object)new WaitForSeconds(5f);
inIFrames = false;
}
}
internal class ContinueMenuFixes
{
[HarmonyPatch(typeof(BackupSavesListUI), "Awake")]
private class BackupSavesListUIPatches
{
public static void Postfix(ref int ___showingListFor)
{
___showingListFor = -1;
}
}
}
internal class HangableFixes
{
[HarmonyPatch(typeof(HangableItem), "DisconnectJoint")]
private class HangableItemPatches
{
[HarmonyPatch("DisconnectJoint")]
public static bool Prefix(ItemRigidbody ___itemRigidbodyC, ref Collider ___currentHook, ShipItem ___shipItem)
{
if ((Object)(object)___currentHook == (Object)null)
{
return false;
}
((Component)___currentHook).GetComponent<ShipItemLampHook>().RemoveJoint();
___currentHook = null;
___itemRigidbodyC.attached = false;
___itemRigidbodyC.disableCol = false;
___itemRigidbodyC.inStove = false;
___shipItem.ToggleDisallowDisembarking(false);
RF_Plugin.LogInfo("Disconnected joint.");
return false;
}
[HarmonyPatch("OnTriggerEnter")]
public static bool Prefix(ShipItem ___shipItem)
{
if (!___shipItem.sold)
{
return false;
}
return true;
}
}
}
internal class OtherModFixes
{
internal static Type cargoControllerType;
internal static Type cargoControllerUIType;
public static void PatchCargoControllerMod()
{
//IL_004f: Unknown result type (might be due to invalid IL or missing references)
//IL_005d: Expected O, but got Unknown
cargoControllerUIType = AccessTools.TypeByName("CargoControllerUI");
cargoControllerType = AccessTools.TypeByName("CargoController.CargoController");
MethodInfo methodInfo = AccessTools.Method(cargoControllerUIType, "OnGUI", (Type[])null, (Type[])null);
MethodInfo methodInfo2 = AccessTools.Method(typeof(CargoControllerPatches), "ApplyMyGuiStyles", (Type[])null, (Type[])null);
RF_Plugin.HarmonyInstance.Patch((MethodBase)methodInfo, new HarmonyMethod(methodInfo2), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
}
}
public class CargoControllerPatches
{
private static GUISkin myGuiSkin;
[HarmonyPrefix]
public static bool ApplyMyGuiStyles(object __instance, bool ___m_visible, Font ___immortalFont, Texture2D ___reddishTexture, Texture2D ___lightBrownTexture, Font ___architectsFont)
{
//IL_0079: Unknown result type (might be due to invalid IL or missing references)
//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
if (!OtherModFixes.cargoControllerType.GetStaticProperty<bool>("Enabled") || !___m_visible)
{
return false;
}
if ((Object)(object)myGuiSkin == (Object)null)
{
myGuiSkin = Object.Instantiate<GUISkin>(GUI.skin);
myGuiSkin.label.font = ___immortalFont;
myGuiSkin.label.fontSize = 18;
myGuiSkin.label.normal.textColor = Color.black;
myGuiSkin.label.normal.background = ___reddishTexture;
myGuiSkin.label.alignment = (TextAnchor)4;
myGuiSkin.button.font = ___architectsFont;
myGuiSkin.button.fontSize = 14;
myGuiSkin.button.normal.background = ___lightBrownTexture;
myGuiSkin.button.normal.textColor = Color.black;
myGuiSkin.button.alignment = (TextAnchor)4;
}
GUISkin skin = GUI.skin;
GUI.skin = myGuiSkin;
try
{
__instance.InvokePrivateMethod("DoBoatGoodsUI");
__instance.InvokePrivateMethod("DoPortGoodsUI");
}
finally
{
GUI.skin = skin;
}
return false;
}
}
internal class Configs
{
internal static ConfigEntry<bool> enableFishingReelFix;
internal static ConfigEntry<string> boatCameraMenuZoom;
internal static ConfigEntry<bool> enableSinkingItemsFix;
internal static ConfigEntry<bool> enableModGUIFix;
internal static void InitializeConfigs()
{
//IL_007b: Unknown result type (might be due to invalid IL or missing references)
//IL_0085: Expected O, but got Unknown
ConfigFile config = ((BaseUnityPlugin)RF_Plugin.Instance).Config;
enableFishingReelFix = config.Bind<bool>("Settings", "Fishing rod reel fix", true, "If enabled will rotate the fishing rod reel in the direction it should.");
enableSinkingItemsFix = config.Bind<bool>("Settings", "Sinking items fix", true, (ConfigDescription)null);
boatCameraMenuZoom = config.Bind<string>("Settings", "Boat camera settings menu zoom fix", "DisableZoom", new ConfigDescription("While paused in boat camera mode: DisableZoom will disable zooming in and out, DisableMenu will disable the menu, None will leave it as it is.", (AcceptableValueBase)(object)new AcceptableValueList<string>(new string[3] { "DisableZoom", "DisableMenu", "None" }), Array.Empty<object>()));
enableModGUIFix = config.Bind<bool>("Settings", "Stop CargoController from affecting other GUIs", true, (ConfigDescription)null);
}
}
internal static class Extensions
{
public static T GetPrivateField<T>(this object obj, string field)
{
return (T)Traverse.Create(obj).Field(field).GetValue();
}
public static void SetPrivateField(this object obj, string field, object value)
{
Traverse.Create(obj).Field(field).SetValue(value);
}
public static object InvokePrivateMethod(this object obj, string method, params object[] parameters)
{
return AccessTools.Method(obj.GetType(), method, (Type[])null, (Type[])null).Invoke(obj, parameters);
}
public static T GetStaticProperty<T>(this object obj, string property)
{
return (T)Traverse.Create(obj.GetType()).Property(property, (object[])null).GetValue();
}
public static T GetStaticProperty<T>(this Type type, string property)
{
return (T)Traverse.Create(type).Property(property, (object[])null).GetValue();
}
}
internal class SettingsMenuFixes
{
[HarmonyPatch(typeof(StartMenu))]
private class StartMenuPatches
{
[HarmonyPrefix]
[HarmonyPatch("GameToSettings")]
public static void PauseSound()
{
AudioListener.pause = true;
}
[HarmonyPrefix]
[HarmonyPatch("SettingsToGame")]
public static void UnPauseSound()
{
AudioListener.pause = false;
}
[HarmonyPrefix]
[HarmonyPatch("EnableSettingsMenu")]
public static bool BoatCameraNoMenu(GameObject ___logo)
{
if (BoatCamera.on && !Object.op_Implicit((Object)(object)GameState.currentShipyard) && Configs.boatCameraMenuZoom.Value.Equals("DisableMenu"))
{
___logo.SetActive(false);
return false;
}
return true;
}
[HarmonyPrefix]
[HarmonyPatch("LateUpdate")]
public static bool BoatCameraNoMenuSettingsToGame(StartMenu __instance)
{
if ((Input.GetKeyDown("escape") || Input.GetKeyDown("f10") || Input.GetKeyDown((KeyCode)336)) && GameState.playing && !GameState.currentlyLoading && !Object.op_Implicit((Object)(object)GameState.currentShipyard) && BoatCamera.on && GameState.wasInSettingsMenu && Configs.boatCameraMenuZoom.Value.Equals("DisableMenu"))
{
__instance.InvokePrivateMethod("SettingsToGame");
return false;
}
return true;
}
}
[HarmonyPatch(typeof(MouseButtonPointer))]
private class MouseButtonPointerPatches
{
[HarmonyPrefix]
[HarmonyPatch("LateUpdate")]
public static bool DisableMouseInputLostFocus()
{
if (!Application.isFocused)
{
return false;
}
return true;
}
}
[HarmonyPatch(typeof(BoatCamera))]
private class BoatCameraPatches
{
[HarmonyPrefix]
[HarmonyPatch("Update")]
public static bool BoatCameraSettingsMenu(bool ___on)
{
if (GameState.playing && !GameState.currentlyLoading && !Object.op_Implicit((Object)(object)GameState.currentShipyard) && GameState.wasInSettingsMenu && !___on && GameInput.GetKeyDown((InputName)16))
{
return false;
}
if (GameState.wasInSettingsMenu && !Object.op_Implicit((Object)(object)GameState.currentShipyard) && ___on && Configs.boatCameraMenuZoom.Value.Equals("DisableZoom"))
{
return false;
}
if (GameState.wasInSettingsMenu && !Object.op_Implicit((Object)(object)GameState.currentShipyard) && ___on && GameInput.GetKeyDown((InputName)16) && Configs.boatCameraMenuZoom.Value.Equals("DisableMenu"))
{
return false;
}
return true;
}
}
}
internal class ItemFixes
{
[HarmonyPatch(typeof(ShipItemFishingRod))]
private class ShipItemFishingRodPatches
{
[HarmonyPostfix]
[HarmonyPatch("OnLoad")]
public static void OnLoadSetReverseSpinner(ref float ___spinnerSpeed)
{
if (Configs.enableFishingReelFix.Value)
{
___spinnerSpeed = -40f;
}
}
[HarmonyPostfix]
[HarmonyPatch("OnBuy")]
public static void OnBuySetReverseSpinner(ref float ___spinnerSpeed)
{
if (Configs.enableFishingReelFix.Value)
{
___spinnerSpeed = -40f;
}
}
}
[HarmonyPatch(typeof(GoPointer))]
private static class GoPointerPatches
{
[HarmonyPatch("DoRaycast")]
public static bool Prefix(GoPointer __instance)
{
if (GameState.playing && !GameState.currentlyLoading)
{
PickupableItem heldItem = __instance.GetHeldItem();
if ((Object)(object)heldItem != (Object)null && ((Component)heldItem).GetComponent<ShipItem>()?.name == "spyglass" && ((PickupableItem)((Component)heldItem).GetComponent<ShipItemSpyglass>()).heldRotationOffset != -22f)
{
((Component)__instance.lookUI).gameObject.SetActive(false);
return false;
}
((Component)__instance.lookUI).gameObject.SetActive(true);
}
return true;
}
[HarmonyPatch("LateUpdate")]
public static bool Prefix(GoPointer __instance, PickupableItem ___heldItem, GoPointerButton ___pointedAtButton)
{
if (GameState.playing && !GameState.currentlyLoading && (Object)(object)___heldItem != (Object)null && ((Component)___heldItem).GetComponent<ShipItem>()?.name == "spyglass" && Object.op_Implicit((Object)(object)___pointedAtButton) && ___pointedAtButton.allowPlacingItems && __instance.AltButtonDown())
{
return false;
}
return true;
}
}
[HarmonyPatch(typeof(ShipItemChipLog), "OnBuy")]
private class ShipItemChipLogPatches
{
public static bool Prefix(ShipItemChipLog __instance, ref Rigidbody ___bobberBody, ConfigurableJoint ___bobberJoint, ref Vector3 ___initialBobberPos, ref SimpleFloatingObject ___bobberFloater)
{
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
___bobberBody = ((Component)___bobberJoint).GetComponent<Rigidbody>();
((Component)___bobberJoint).transform.parent = Refs.shiftingWorld;
___initialBobberPos = ((Joint)___bobberJoint).connectedAnchor;
___bobberFloater = ((Component)___bobberBody).GetComponent<SimpleFloatingObject>();
_ = ((ShipItem)__instance).sold;
return false;
}
}
[HarmonyPatch(typeof(ItemRigidbody), "ToggleCollider")]
private class ItemRigidbodyPatches
{
public static bool Prefix(bool state, SimpleFloatingObject ___floater, BoxCollider ___boxCol, MeshCollider ___meshCol, CapsuleCollider ___capsuleCol)
{
if (!Configs.enableSinkingItemsFix.Value)
{
return true;
}
if (Object.op_Implicit((Object)(object)___floater))
{
((Behaviour)___floater).enabled = state;
}
if (Object.op_Implicit((Object)(object)___boxCol))
{
((Collider)___boxCol).enabled = state;
}
if (Object.op_Implicit((Object)(object)___meshCol))
{
((Collider)___meshCol).enabled = state;
}
if (Object.op_Implicit((Object)(object)___capsuleCol))
{
((Collider)___capsuleCol).enabled = state;
}
return false;
}
}
}
internal class NREFixes
{
[HarmonyPatch(typeof(Refs), "SetPlayerControl")]
private class RefsPatches
{
public static bool Prefix()
{
if ((Object)(object)Refs.ovrController == (Object)null || (Object)(object)Refs.charController == (Object)null)
{
return false;
}
return true;
}
}
[HarmonyPatch(typeof(NPCBoatController))]
private class NPCBoatControllerPatches
{
[HarmonyPatch("OnTriggerEnter")]
public static bool Prefix(Collider other, NPCBoatController __instance)
{
if (!GameState.currentlyLoading && GameState.playing && (Object)(object)((Component)other).transform == (Object)(object)__instance.currentTarget)
{
NPCBoatWaypoint component = ((Component)other).GetComponent<NPCBoatWaypoint>();
if (Object.op_Implicit((Object)(object)component) && component.navigationWaypoint)
{
__instance.currentTarget = ((Component)component.GetNextDestination()).transform;
__instance.currentTargetIndex = component.GetNextDestination().index;
return false;
}
Transform currentTarget = __instance.currentTarget;
int currentDockIndex = ((!((Object)(object)((currentTarget != null) ? ((Component)currentTarget).GetComponent<NPCBoatWaypoint>() : null) == (Object)null)) ? ((Component)__instance.currentTarget).GetComponent<NPCBoatWaypoint>().index : (-1));
__instance.currentDock = __instance.currentTarget;
__instance.currentDockIndex = currentDockIndex;
__instance.currentTarget = null;
__instance.currentTargetIndex = -1;
}
return false;
}
}
[HarmonyPatch(typeof(PortDude), "OnTriggerEnter")]
private class PortDudePatches
{
public static bool Prefix(Collider other)
{
if (((Component)other).CompareTag("Player") || !((Component)other).CompareTag("Good"))
{
return false;
}
Good component = ((Component)other).GetComponent<Good>();
if ((Object)(object)component == (Object)null || component.GetMissionIndex() == -1)
{
return false;
}
return true;
}
}
}
internal class UIFixes
{
[HarmonyPatch(typeof(EconomyUI))]
private class EconomyUIPatches
{
[HarmonyPatch("OpenUI")]
public static void Postfix(EconomyUI __instance, EconomyUIButton[] ___goodsListButtons, ref TextMesh ___textPageNumber, int ___currentGoodsListPage)
{
int num = Mathf.CeilToInt((float)__instance.goodCount / (float)___goodsListButtons.Length);
int num2 = ___currentGoodsListPage;
if (num2 < 0)
{
num2 = 0;
}
if (num2 > num - 1)
{
num2 = num - 1;
}
___textPageNumber.text = $"{num2 + 1} / {num}";
}
[HarmonyPatch("RefreshGoodsList")]
public static bool Prefix(EconomyUI __instance, EconomyUIButton[] ___goodsListButtons, int ___currentGoodsListPage, EconomyUIGoodsOrder ___goodsOrder, Material[] ___buttonMaterials, IslandMarket ___currentIsland)
{
int num = ___goodsListButtons.Length;
for (int i = 0; i < num; i++)
{
int num2 = num * ___currentGoodsListPage + i + 1;
if (num2 >= ___goodsOrder.goods.Length)
{
((Component)___goodsListButtons[i]).gameObject.SetActive(false);
continue;
}
ShipItem goodAt = ___goodsOrder.GetGoodAt(num2);
int goodIndex = ___goodsOrder.GetGoodIndex(num2);
if (Object.op_Implicit((Object)(object)goodAt) && goodIndex != 51)
{
___goodsListButtons[i].SetButtonText(goodAt.name);
}
else
{
___goodsListButtons[i].SetButtonText("---");
}
if (!Object.op_Implicit((Object)(object)goodAt))
{
___goodsListButtons[i].SetButtonMaterial(___buttonMaterials[1]);
}
else if (__instance.currentSelectedGood == goodIndex)
{
___goodsListButtons[i].SetButtonMaterial(___buttonMaterials[2]);
}
else if (___currentIsland.currentPlayerGoods[goodIndex] > 0)
{
___goodsListButtons[i].SetButtonMaterial(___buttonMaterials[3]);
}
else if (___currentIsland.HasGood(goodIndex))
{
___goodsListButtons[i].SetButtonMaterial(___buttonMaterials[0]);
}
else
{
___goodsListButtons[i].SetButtonMaterial(___buttonMaterials[1]);
}
___goodsListButtons[i].SetButtonIndex(goodIndex);
((Component)___goodsListButtons[i]).gameObject.SetActive(true);
}
return false;
}
}
[HarmonyBefore(new string[] { "com.raddude.radrefinements" })]
[HarmonyPatch(typeof(GPButtonInventorySlot), "OnItemClick")]
private class GPButtonInventorySlotPatches
{
public static void Prefix()
{
if (BuyItemUI.instance.menu.activeInHierarchy)
{
BuyItemUI.instance.DeactivateUI();
}
}
}
}
[BepInPlugin("com.raddude.radfixes", "RadFixes", "1.3.3")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class RF_Plugin : BaseUnityPlugin
{
public const string PLUGIN_GUID = "com.raddude.radfixes";
public const string PLUGIN_NAME = "RadFixes";
public const string PLUGIN_VERSION = "1.3.3";
public const string RADREFINEMENTS_GUID = "com.raddude.radrefinements";
public const string CARGOCONTROLLER_GUID = "com.jakeinaboat.cargocontroller";
private static ManualLogSource _logger;
internal static RF_Plugin Instance { get; private set; }
internal static Harmony HarmonyInstance { 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;
Configs.InitializeConfigs();
HarmonyInstance = Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "com.raddude.radfixes");
SceneManager.sceneLoaded += SceneFixes.SceneLoaded;
foreach (KeyValuePair<string, PluginInfo> pluginInfo in Chainloader.PluginInfos)
{
BepInPlugin metadata = pluginInfo.Value.Metadata;
if (Configs.enableModGUIFix.Value && metadata.GUID.Equals("com.jakeinaboat.cargocontroller"))
{
LogInfo("CargoController mod found");
OtherModFixes.PatchCargoControllerMod();
}
}
}
}
internal class SceneFixes
{
internal static void SceneLoaded(Scene scene, LoadSceneMode loadSceneMode)
{
if (((Scene)(ref scene)).name == "island 1 A Gold Rock")
{
GoldRockCity();
}
if (((Scene)(ref scene)).name == "island 13 E (Sage Hills)")
{
SageHills();
}
if (((Scene)(ref scene)).name == "island 18 M (Oasis)")
{
HappyBay();
}
if (((Scene)(ref scene)).name == "island 19 M (Eastwind)")
{
Eastwind();
}
if (((Scene)(ref scene)).name == "island 25 (chronos)")
{
Chronos();
}
}
private static void GoldRockCity()
{
GameObject islandScenery = GameObject.Find("island 1 A (gold rock) scenery");
SetShopkeeper(islandScenery, "shop (3)", "shopkeeper (5)");
SetShopkeeper(islandScenery, "shop (7)", "shopkeeper (9)");
}
private static void SetShopkeeper(GameObject islandScenery, string shopName, string shopkeeperName)
{
ShopArea val = ((islandScenery != null) ? ((IEnumerable<ShopArea>)islandScenery.GetComponentsInChildren<ShopArea>()).FirstOrDefault((Func<ShopArea, bool>)((ShopArea k) => ((Object)k).name == shopName)) : null);
Shopkeeper val2 = ((islandScenery != null) ? ((IEnumerable<Shopkeeper>)islandScenery.GetComponentsInChildren<Shopkeeper>()).FirstOrDefault((Func<Shopkeeper, bool>)((Shopkeeper k) => ((Object)k).name == shopkeeperName)) : null);
if (!((Object)(object)val == (Object)null) && !((Object)(object)val2 == (Object)null))
{
if ((Object)(object)val.GetShopkeeper() == (Object)(object)val2 && (Object)(object)val2.GetPrivateField<ShopArea>("shop") == (Object)(object)val)
{
RF_Plugin.LogWarning("Gold Rock City shop fix not needed for " + shopkeeperName + " - " + shopName);
return;
}
val.SetPrivateField("keeper", val2);
val2.SetPrivateField("shop", val);
}
}
private static void SageHills()
{
GameObject val = GameObject.Find("island 13 E (sage hills) scenery");
ShopArea val2 = ((val != null) ? ((IEnumerable<ShopArea>)val.GetComponentsInChildren<ShopArea>()).FirstOrDefault((Func<ShopArea, bool>)((ShopArea k) => ((Object)k).name == "shop area (2)")) : null);
if (!((Object)(object)val2 == (Object)null))
{
if (val2.openAtNight)
{
RF_Plugin.LogWarning("Sage Hills shop fix not needed");
}
else
{
val2.openAtNight = true;
}
}
}
private static void HappyBay()
{
GameObject val = GameObject.Find("island 18 M (Oasis) scenery");
Shopkeeper val2 = ((val != null) ? ((IEnumerable<Shopkeeper>)val.GetComponentsInChildren<Shopkeeper>()).FirstOrDefault((Func<Shopkeeper, bool>)((Shopkeeper k) => ((Object)k).name == "shopkeeper")) : null);
if (!((Object)(object)val2 == (Object)null))
{
RF_NPCSchedule obj = val.gameObject.AddComponent<RF_NPCSchedule>();
obj.SetPrivateField("_keeper", val2);
}
}
private static void Eastwind()
{
GameObject val = GameObject.Find("island 19 M (Eastwind) scenery");
IEnumerable<Shopkeeper> enumerable = ((val != null) ? (from k in val.GetComponentsInChildren<Shopkeeper>()
where ((Object)k).name == "shopkeeper (1)"
select k) : null);
Shopkeeper val2 = null;
foreach (Shopkeeper item in enumerable)
{
val2 = item;
if ((Object)(object)item.GetPrivateField<ShopArea>("shop") == (Object)null)
{
((Object)item).name = "shopkeeper (3)";
break;
}
}
ShopArea val3 = ((val != null) ? ((IEnumerable<ShopArea>)val.GetComponentsInChildren<ShopArea>()).FirstOrDefault((Func<ShopArea, bool>)((ShopArea k) => ((Object)k).name == "shop area (2)")) : null);
if (!((Object)(object)val3 == (Object)null) && !((Object)(object)val2 == (Object)null))
{
if ((Object)(object)val3.GetShopkeeper() == (Object)(object)val2 && (Object)(object)val2.GetPrivateField<ShopArea>("shop") == (Object)(object)val3)
{
RF_Plugin.LogWarning("Eastwind shop fix not needed");
return;
}
val3.SetPrivateField("keeper", val2);
val2.SetPrivateField("shop", val3);
}
}
private static void Chronos()
{
GameObject val = GameObject.Find("island 25 (chronos) scenery");
IEnumerable<ShopArea> enumerable = ((val != null) ? (from k in val.GetComponentsInChildren<ShopArea>()
where ((Object)k).name == "shop area"
select k) : null);
ShopArea val2 = null;
ShopArea val3 = null;
foreach (ShopArea item in enumerable)
{
if (item.itemsForSale.Count > 0 && item.itemsForSale[0].name == "bun")
{
val2 = item;
}
if (item.itemsForSale.Count > 0 && item.itemsForSale[0].name == "trout")
{
val3 = item;
}
}
Shopkeeper val4 = ((val != null) ? ((IEnumerable<Shopkeeper>)val.GetComponentsInChildren<Shopkeeper>()).FirstOrDefault((Func<Shopkeeper, bool>)((Shopkeeper k) => ((Object)k).name == "shopkeeper (3)")) : null);
Shopkeeper val5 = ((val != null) ? ((IEnumerable<Shopkeeper>)val.GetComponentsInChildren<Shopkeeper>()).FirstOrDefault((Func<Shopkeeper, bool>)((Shopkeeper k) => ((Object)k).name == "shopkeeper (4)")) : null);
if ((Object)(object)val3 != (Object)null && (Object)(object)val5 != (Object)null)
{
if ((Object)(object)val3.GetShopkeeper() == (Object)(object)val5 && (Object)(object)val5.GetPrivateField<ShopArea>("shop") == (Object)(object)val3)
{
RF_Plugin.LogWarning("Chronos shop fix not needed for " + ((Object)val5).name + " - " + ((Object)val3).name);
}
val3.SetPrivateField("keeper", val5);
val5.SetPrivateField("shop", val3);
}
if ((Object)(object)val2 != (Object)null && (Object)(object)val4 != (Object)null)
{
if ((Object)(object)val2.GetShopkeeper() == (Object)(object)val4 && (Object)(object)val4.GetPrivateField<ShopArea>("shop") == (Object)(object)val2)
{
RF_Plugin.LogWarning("Chronos shop fix not needed for " + ((Object)val4).name + " - " + ((Object)val2).name);
}
val2.SetPrivateField("keeper", val4);
val4.SetPrivateField("shop", val2);
}
}
}
public class RF_NPCSchedule : MonoBehaviour
{
[SerializeField]
private Shopkeeper _keeper;
private void Awake()
{
_keeper = null;
}
public void Update()
{
if (!Object.op_Implicit((Object)(object)_keeper))
{
return;
}
if (Sun.sun.localTime >= 18f || Sun.sun.localTime < 7f)
{
if (((Component)_keeper).gameObject.activeInHierarchy)
{
((Component)_keeper).gameObject.SetActive(false);
}
}
else if (!((Component)_keeper).gameObject.activeInHierarchy)
{
((Component)_keeper).gameObject.SetActive(true);
}
}
}