using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.ResourceManagement.AsyncOperations;
using UnityEngine.ResourceManagement.ResourceProviders;
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: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("shermaInBellhome")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("0.1.0.0")]
[assembly: AssemblyInformationalVersion("0.1.0")]
[assembly: AssemblyProduct("shermaInBellhome")]
[assembly: AssemblyTitle("shermaInbellhome")]
[assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/w-nityammm/shermaInBellhome")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.1.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
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;
}
}
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace BepInEx
{
[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
[Conditional("CodeGeneration")]
internal sealed class BepInAutoPluginAttribute : Attribute
{
public BepInAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
{
}
}
}
namespace BepInEx.Preloader.Core.Patching
{
[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
[Conditional("CodeGeneration")]
internal sealed class PatcherAutoPluginAttribute : Attribute
{
public PatcherAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
{
}
}
}
namespace ShermaInBellHome
{
[BepInPlugin("com.w-nityammm.ShermaInBellHome", "ShermaInBellHome", "1.0.0")]
public class Plugin : BaseUnityPlugin
{
[CompilerGenerated]
private sealed class <AddInspect>d__17 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public Plugin <>4__this;
private string <shermaPath>5__1;
private GameObject <sherma>5__2;
private BoxCollider2D <col>5__3;
private InteractEvents <ie>5__4;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <AddInspect>d__17(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<shermaPath>5__1 = null;
<sherma>5__2 = null;
<col>5__3 = null;
<ie>5__4 = null;
<>1__state = -2;
}
private bool MoveNext()
{
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Expected O, but got Unknown
//IL_00a5: 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_00c4: Expected O, but got Unknown
//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
<>2__current = (object)new WaitForSeconds(0.1f);
<>1__state = 1;
return true;
case 1:
<>1__state = -1;
<shermaPath>5__1 = "Black Thread States/Black Thread World/Enclave Act 3/Sherma Caretaker";
<sherma>5__2 = GameObject.Find(<shermaPath>5__1);
if ((Object)(object)<sherma>5__2 == (Object)null)
{
Log.LogError((object)("ShermaInBellHome: Could not find Sherma at path '" + <shermaPath>5__1 + "'"));
return false;
}
Log.LogInfo((object)"ShermaInBellHome: Found Sherma");
<>4__this.inspect = Object.Instantiate<GameObject>(new GameObject(), <sherma>5__2.transform.position, Quaternion.identity);
<col>5__3 = <>4__this.inspect.AddComponent<BoxCollider2D>();
((Collider2D)<col>5__3).isTrigger = true;
<col>5__3.size = new Vector2(4f, 4f);
<ie>5__4 = <>4__this.inspect.AddComponent<InteractEvents>();
((InteractableBase)<ie>5__4).InteractLabel = (PromptLabels)0;
<ie>5__4.Interacted += delegate
{
if (!((Object)(object)<>4__this.heroController == (Object)null))
{
<>4__this.heroController.RelinquishControl();
DialogueYesNoBox.Open((Action)delegate
{
<>4__this.heroController.RegainControl();
<>4__this.InspectDialogue(answer: true);
}, (Action)delegate
{
<>4__this.heroController.RegainControl();
<>4__this.InspectDialogue(answer: false);
}, true, "Take Sherma to Bellhome", (SavedItem)null);
}
};
return false;
}
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
[CompilerGenerated]
private sealed class <LoadSherma>d__14 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public Plugin <>4__this;
private AsyncOperationHandle<SceneInstance> <handle>5__1;
private SceneInstance <sceneInstance>5__2;
private Scene <shermaScene>5__3;
private GameObject[] <>s__4;
private int <>s__5;
private GameObject <root>5__6;
private Transform <shermaTransform>5__7;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <LoadSherma>d__14(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
//IL_0006: 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)
<handle>5__1 = default(AsyncOperationHandle<SceneInstance>);
<sceneInstance>5__2 = default(SceneInstance);
<>s__4 = null;
<root>5__6 = null;
<shermaTransform>5__7 = null;
<>1__state = -2;
}
private bool MoveNext()
{
//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_0051: 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_007c: Invalid comparison between Unknown and I4
//IL_008d: 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_009e: Unknown result type (might be due to invalid IL or missing references)
//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
//IL_00af: Unknown result type (might be due to invalid IL or missing references)
//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
//IL_0256: Unknown result type (might be due to invalid IL or missing references)
//IL_020a: Unknown result type (might be due to invalid IL or missing references)
//IL_01e6: Unknown result type (might be due to invalid IL or missing references)
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
<>4__this.loadedInBellHome = true;
<handle>5__1 = Addressables.LoadSceneAsync((object)"Scenes/Song_Enclave", (LoadSceneMode)1, true, 100, (SceneReleaseMode)0);
<>2__current = <handle>5__1;
<>1__state = 1;
return true;
case 1:
<>1__state = -1;
if ((int)<handle>5__1.Status == 1)
{
<sceneInstance>5__2 = <handle>5__1.Result;
<>4__this.shermaSceneLoadOp = <handle>5__1;
<shermaScene>5__3 = ((SceneInstance)(ref <sceneInstance>5__2)).Scene;
<>2__current = null;
<>1__state = 2;
return true;
}
break;
case 2:
<>1__state = -1;
<>4__this.shermaSceneLoaded = true;
if (((Scene)(ref <shermaScene>5__3)).IsValid() && ((Scene)(ref <shermaScene>5__3)).isLoaded)
{
<>s__4 = ((Scene)(ref <shermaScene>5__3)).GetRootGameObjects();
for (<>s__5 = 0; <>s__5 < <>s__4.Length; <>s__5++)
{
<root>5__6 = <>s__4[<>s__5];
<shermaTransform>5__7 = <>4__this.FindChild(<root>5__6.transform, "Sherma Caretaker");
if ((Object)(object)<shermaTransform>5__7 == (Object)null)
{
Object.Destroy((Object)(object)<root>5__6.gameObject);
}
else
{
<shermaTransform>5__7.SetParent((Transform)null, true);
Object.Destroy((Object)(object)<root>5__6.gameObject);
if ((Object)(object)<>4__this.heroController != (Object)null && <>4__this.heroController.playerData.GetBool("BelltownFurnishingSpa"))
{
<shermaTransform>5__7.position = new Vector3(22.45f, 13.9f, 0.0051f);
}
else
{
<shermaTransform>5__7.position = new Vector3(21f, 7.1f, 0.0051f);
}
}
<shermaTransform>5__7 = null;
<root>5__6 = null;
}
<>s__4 = null;
}
<sceneInstance>5__2 = default(SceneInstance);
break;
}
<>4__this.loadedInBellHome = false;
return false;
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
[CompilerGenerated]
private sealed class <RemoveSherma>d__16 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public Plugin <>4__this;
private string <shermaPath>5__1;
private GameObject <sherma>5__2;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <RemoveSherma>d__16(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<shermaPath>5__1 = null;
<sherma>5__2 = null;
<>1__state = -2;
}
private bool MoveNext()
{
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Expected O, but got Unknown
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
<>2__current = (object)new WaitForSeconds(0.1f);
<>1__state = 1;
return true;
case 1:
<>1__state = -1;
<shermaPath>5__1 = "Black Thread States/Black Thread World/Enclave Act 3/Sherma Caretaker";
<sherma>5__2 = GameObject.Find(<shermaPath>5__1);
if ((Object)(object)<sherma>5__2 != (Object)null)
{
Object.Destroy((Object)(object)<sherma>5__2);
Log.LogInfo((object)"ShermaInBellHome: Removed Sherma from scene.");
}
else
{
Log.LogWarning((object)("ShermaInBellHome: Could not find Sherma at path '" + <shermaPath>5__1 + "' to remove!"));
}
return false;
}
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
internal static ManualLogSource Log;
private HeroController heroController;
private int saveFileIdx;
private GameObject inspect;
private List<ConfigEntry<bool>> shermaTakenConfigs = new List<ConfigEntry<bool>>();
private List<ConfigEntry<bool>> shermaInBellHomeConfigs = new List<ConfigEntry<bool>>();
private bool loadedInBellHome = false;
private List<string> noNoSceneNames = new List<string> { "Pre_Menu_Loader", "Pre_Menu_Intro", "Menu_Title", "Song_Enclave" };
private bool shermaSceneLoaded = false;
private AsyncOperationHandle<SceneInstance> shermaSceneLoadOp;
private void Awake()
{
Log = ((BaseUnityPlugin)this).Logger;
SceneManager.sceneLoaded += OnSceneLoaded;
for (int i = 0; i < 3; i++)
{
shermaTakenConfigs.Add(((BaseUnityPlugin)this).Config.Bind<bool>($"Save File {i}", "shermaTaken", false, ""));
shermaInBellHomeConfigs.Add(((BaseUnityPlugin)this).Config.Bind<bool>($"Save File {i}", "shermaInBellHome", false, ""));
}
}
private void Update()
{
if ((Object)(object)heroController == (Object)null)
{
heroController = HeroController.instance;
}
}
private void OnDisable()
{
SceneManager.sceneLoaded -= OnSceneLoaded;
}
private void OnSceneLoaded(Scene scene, LoadSceneMode mode)
{
//IL_006f: 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)
if ((Object)(object)heroController != (Object)null)
{
try
{
saveFileIdx = heroController.playerData.profileID - 1;
}
catch (Exception)
{
Log.LogWarning((object)"Could not get saveFileIdx.");
}
}
if (((Scene)(ref scene)).name != "Belltown_Room_Spare" && shermaSceneLoaded)
{
Addressables.UnloadSceneAsync(shermaSceneLoadOp.Result, true);
shermaSceneLoaded = false;
}
if (saveFileIdx >= 0 && saveFileIdx < 3)
{
if (((Scene)(ref scene)).name == "Belltown_Room_Spare" && shermaInBellHomeConfigs[saveFileIdx].Value)
{
((MonoBehaviour)this).StartCoroutine(LoadSherma());
}
if (!noNoSceneNames.Contains(((Scene)(ref scene)).name) && shermaTakenConfigs[saveFileIdx].Value && !shermaInBellHomeConfigs[saveFileIdx].Value)
{
shermaInBellHomeConfigs[saveFileIdx].Value = true;
((BaseUnityPlugin)this).Config.Save();
}
}
if (((Scene)(ref scene)).name == "Song_Enclave" && (Object)(object)heroController != (Object)null && heroController.playerData.GetBool("shermaCaretakerConvo1") && saveFileIdx >= 0 && saveFileIdx < 3)
{
if (!shermaInBellHomeConfigs[saveFileIdx].Value)
{
((MonoBehaviour)this).StartCoroutine(AddInspect());
}
else
{
((MonoBehaviour)this).StartCoroutine(RemoveSherma());
}
}
}
[IteratorStateMachine(typeof(<LoadSherma>d__14))]
private IEnumerator LoadSherma()
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <LoadSherma>d__14(0)
{
<>4__this = this
};
}
private Transform FindChild(Transform parent, string name)
{
if (((Object)parent).name == name)
{
return parent;
}
for (int i = 0; i < parent.childCount; i++)
{
Transform child = parent.GetChild(i);
Transform val = FindChild(child, name);
if ((Object)(object)val != (Object)null)
{
return val;
}
}
return null;
}
[IteratorStateMachine(typeof(<RemoveSherma>d__16))]
private IEnumerator RemoveSherma()
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <RemoveSherma>d__16(0)
{
<>4__this = this
};
}
[IteratorStateMachine(typeof(<AddInspect>d__17))]
private IEnumerator AddInspect()
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <AddInspect>d__17(0)
{
<>4__this = this
};
}
private void InspectDialogue(bool answer)
{
if (answer)
{
if (saveFileIdx >= 0 && saveFileIdx < 3)
{
shermaTakenConfigs[saveFileIdx].Value = true;
((BaseUnityPlugin)this).Config.Save();
}
Object.Destroy((Object)(object)inspect);
((MonoBehaviour)this).StartCoroutine(RemoveSherma());
}
}
}
}