Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of Reina Kuroda v1.0.1
BepInEx/plugins/Omniscye-UwU_Naruto/UwUNaruto.dll
Decompiled 3 months agousing System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using UnityEngine; using UnityEngine.Rendering; using UnityEngine.SceneManagement; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("Empress")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("UwUNaruto")] [assembly: AssemblyTitle("UwUNaruto")] [assembly: AssemblyVersion("1.0.0.0")] namespace Empress.REPO.UwUNaruto; internal static class UwUNarutoAccess { private static readonly FieldInfo VisualsPlayerAvatarField = AccessTools.Field(typeof(PlayerAvatarVisuals), "playerAvatar"); private static readonly FieldInfo VisualsMeshParentField = AccessTools.Field(typeof(PlayerAvatarVisuals), "meshParent"); private static readonly FieldInfo VisualsShowSelfOverrideTimerField = AccessTools.Field(typeof(PlayerAvatarVisuals), "showSelfOverrideTimer"); private static readonly FieldInfo PlayerIsLocalField = AccessTools.Field(typeof(PlayerAvatar), "isLocal"); private static readonly FieldInfo PlayerIsMovingField = AccessTools.Field(typeof(PlayerAvatar), "isMoving"); private static readonly FieldInfo PlayerIsSprintingField = AccessTools.Field(typeof(PlayerAvatar), "isSprinting"); private static readonly FieldInfo PlayerIsCrouchingField = AccessTools.Field(typeof(PlayerAvatar), "isCrouching"); private static readonly FieldInfo PlayerIsCrawlingField = AccessTools.Field(typeof(PlayerAvatar), "isCrawling"); private static readonly FieldInfo PlayerIsSlidingField = AccessTools.Field(typeof(PlayerAvatar), "isSliding"); private static readonly FieldInfo PlayerIsTumblingField = AccessTools.Field(typeof(PlayerAvatar), "isTumbling"); private static readonly FieldInfo PlayerFlashlightField = AccessTools.Field(typeof(PlayerAvatar), "flashlightController"); private static readonly FieldInfo FlashlightFollowLocalField = AccessTools.Field(typeof(FlashlightController), "FollowTransformLocal"); private static readonly FieldInfo FlashlightFollowClientField = AccessTools.Field(typeof(FlashlightController), "FollowTransformClient"); private static readonly FieldInfo FlashlightMeshField = AccessTools.Field(typeof(FlashlightController), "mesh"); private static readonly FieldInfo FlashlightMeshShadowsField = AccessTools.Field(typeof(FlashlightController), "meshShadows"); private static readonly FieldInfo CameraPositionInstanceField = AccessTools.Field(typeof(CameraPosition), "instance"); private static readonly MethodInfo CameraPositionOverridePositionMethod = AccessTools.Method(typeof(CameraPosition), "OverridePosition", new Type[2] { typeof(Vector3), typeof(float) }, (Type[])null); private static readonly FieldInfo CameraAimInstanceField = AccessTools.Field(typeof(CameraAim), "Instance"); private static readonly MethodInfo VisualsShowSelfOverrideMethod = AccessTools.Method(typeof(PlayerAvatarVisuals), "ShowSelfOverride", new Type[1] { typeof(float) }, (Type[])null); internal static PlayerAvatar GetAvatar(PlayerAvatarVisuals visuals) { return Get<PlayerAvatar>(VisualsPlayerAvatarField, visuals); } internal static GameObject GetMeshParent(PlayerAvatarVisuals visuals) { return Get<GameObject>(VisualsMeshParentField, visuals); } internal static float GetShowSelfOverrideTimer(PlayerAvatarVisuals visuals) { return GetFloat(VisualsShowSelfOverrideTimerField, visuals); } internal static bool IsLocal(PlayerAvatar avatar) { return GetBool(PlayerIsLocalField, avatar); } internal static bool IsMoving(PlayerAvatar avatar) { return GetBool(PlayerIsMovingField, avatar); } internal static bool IsSprinting(PlayerAvatar avatar) { return GetBool(PlayerIsSprintingField, avatar); } internal static bool IsCrouching(PlayerAvatar avatar) { return GetBool(PlayerIsCrouchingField, avatar); } internal static bool IsCrawling(PlayerAvatar avatar) { return GetBool(PlayerIsCrawlingField, avatar); } internal static bool IsSliding(PlayerAvatar avatar) { return GetBool(PlayerIsSlidingField, avatar); } internal static bool IsTumbling(PlayerAvatar avatar) { return GetBool(PlayerIsTumblingField, avatar); } internal static FlashlightController GetFlashlight(PlayerAvatar avatar) { FlashlightController val = Get<FlashlightController>(PlayerFlashlightField, avatar); if ((Object)(object)val != (Object)null) { return val; } if (!((Object)(object)avatar != (Object)null)) { return null; } return ((Component)avatar).GetComponentInChildren<FlashlightController>(true); } internal static Transform GetFlashlightLocal(FlashlightController flashlight) { return Get<Transform>(FlashlightFollowLocalField, flashlight); } internal static Transform GetFlashlightClient(FlashlightController flashlight) { return Get<Transform>(FlashlightFollowClientField, flashlight); } internal static void SetFlashlightLocal(FlashlightController flashlight, Transform follow) { Set(FlashlightFollowLocalField, flashlight, follow); } internal static void SetFlashlightClient(FlashlightController flashlight, Transform follow) { Set(FlashlightFollowClientField, flashlight, follow); } internal static MeshRenderer GetFlashlightMesh(FlashlightController flashlight) { return Get<MeshRenderer>(FlashlightMeshField, flashlight); } internal static MeshRenderer GetFlashlightMeshShadows(FlashlightController flashlight) { return Get<MeshRenderer>(FlashlightMeshShadowsField, flashlight); } internal static CameraPosition GetCameraPosition() { CameraPosition val = Get<CameraPosition>(CameraPositionInstanceField, null); if ((Object)(object)val != (Object)null) { return val; } return Object.FindObjectOfType<CameraPosition>(); } internal static CameraAim GetCameraAim() { CameraAim val = Get<CameraAim>(CameraAimInstanceField, null); if ((Object)(object)val != (Object)null) { return val; } return Object.FindObjectOfType<CameraAim>(); } internal static void OverrideCameraPosition(CameraPosition cameraPosition, Vector3 position, float time) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)cameraPosition == (Object)null) && !(CameraPositionOverridePositionMethod == null)) { CameraPositionOverridePositionMethod.Invoke(cameraPosition, new object[2] { position, time }); } } internal static void ShowSelf(PlayerAvatarVisuals visuals, float time) { if (!((Object)(object)visuals == (Object)null) && !(VisualsShowSelfOverrideMethod == null)) { VisualsShowSelfOverrideMethod.Invoke(visuals, new object[1] { time }); } } private static T Get<T>(FieldInfo field, object target) where T : class { if (field == null || (target == null && !field.IsStatic)) { return null; } return field.GetValue(target) as T; } private static bool GetBool(FieldInfo field, object target) { if (field == null || (target == null && !field.IsStatic)) { return false; } object value = field.GetValue(target); bool flag = default(bool); int num; if (value is bool) { flag = (bool)value; num = 1; } else { num = 0; } return (byte)((uint)num & (flag ? 1u : 0u)) != 0; } private static float GetFloat(FieldInfo field, object target) { if (field == null || (target == null && !field.IsStatic)) { return 0f; } object value = field.GetValue(target); if (value is float) { return (float)value; } return 0f; } private static void Set(FieldInfo field, object target, object value) { if (!(field == null) && (target != null || field.IsStatic)) { field.SetValue(target, value); } } } internal static class UwUNarutoAssets { private static AssetBundle _bundle; private static GameObject _prefab; internal static bool Ready => (Object)(object)_prefab != (Object)null; internal static void Load() { if ((Object)(object)_prefab != (Object)null) { return; } string[] array = new string[4] { Path.Combine(UwUNarutoPlugin.PluginDirectory, "uwunaruto"), Path.Combine(UwUNarutoPlugin.PluginDirectory, "uwunaruto.bundle"), Path.Combine(UwUNarutoPlugin.PluginDirectory, "UwUNaruto"), Path.Combine(UwUNarutoPlugin.PluginDirectory, "UwUNaruto.bundle") }; for (int i = 0; i < array.Length; i++) { if (File.Exists(array[i])) { _bundle = AssetBundle.LoadFromFile(array[i]); if ((Object)(object)_bundle != (Object)null) { break; } } } if ((Object)(object)_bundle == (Object)null) { UwUNarutoPlugin.Log.LogError((object)"Reina Kuroda asset bundle was not found beside the DLL."); return; } GameObject[] array2 = _bundle.LoadAllAssets<GameObject>(); for (int j = 0; j < array2.Length; j++) { if ((Object)(object)array2[j] != (Object)null && ((Object)array2[j]).name == "UwUTemariPrefab") { _prefab = array2[j]; break; } } if ((Object)(object)_prefab == (Object)null && array2.Length != 0) { _prefab = array2[0]; } if ((Object)(object)_prefab == (Object)null) { UwUNarutoPlugin.Log.LogError((object)"Reina Kuroda asset bundle did not contain a player prefab."); } } internal static GameObject Create(Transform parent) { if ((Object)(object)_prefab == (Object)null) { return null; } return Object.Instantiate<GameObject>(_prefab, parent, false); } } internal sealed class UwUNarutoAvatar : MonoBehaviour { private const float WalkAnimationMultiplier = 1.72f; private const float ThirdPersonDefaultDistance = 2.55f; private const float ThirdPersonMinDistance = 1.25f; private const float ThirdPersonMaxDistance = 4.25f; private const float ThirdPersonZoomSpeed = 3f; private const float ThirdPersonHeight = 0.45f; private PlayerAvatarVisuals _visuals; private PlayerAvatar _avatar; private GameObject _model; private GameObject _meshParent; private Animator _animator; private Animation _animation; private Renderer[] _modelRenderers; private readonly Dictionary<Renderer, bool> _originalRenderers = new Dictionary<Renderer, bool>(); private readonly HashSet<string> _clips = new HashSet<string>(); private FlashlightController _flashlight; private Transform _flashlightFollowPoint; private Transform _originalFlashlightLocal; private Transform _originalFlashlightClient; private Vector3 _lastPosition; private string _state; private float _moveSpeed; private float _movingTimer; private float _sprintingTimer; private float _thirdPersonDistance = 2.55f; private GameObject _thirdPersonMarker; private bool _capturedRenderers; private bool _capturedMeshParent; private bool _meshParentWasActive; private bool _capturedFlashlight; private bool _trackedPosition; private bool _thirdPersonActive; private Light[] _fillLights; private bool _fillBuilt; private bool _unlitApplied; private bool _skinFixApplied; private static Shader _unlitShader; private static bool _unlitShaderLookup; private static Texture2D _skinFixTexture; private static bool _skinFixLookup; internal static void Attach(PlayerAvatarVisuals visuals) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)visuals == (Object)null || (Object)(object)((Component)visuals).gameObject == (Object)null) { return; } Scene scene = ((Component)visuals).gameObject.scene; if (((Scene)(ref scene)).IsValid()) { UwUNarutoAvatar component = ((Component)visuals).GetComponent<UwUNarutoAvatar>(); if ((Object)(object)component != (Object)null) { component.Bind(visuals); } else { ((Component)visuals).gameObject.AddComponent<UwUNarutoAvatar>().Bind(visuals); } } } private void Awake() { if ((Object)(object)_visuals == (Object)null) { _visuals = ((Component)this).GetComponent<PlayerAvatarVisuals>(); } } internal void Bind(PlayerAvatarVisuals visuals) { if (!((Object)(object)visuals == (Object)null)) { _visuals = visuals; _avatar = UwUNarutoAccess.GetAvatar(_visuals); EnsureModel(); } } private void LateUpdate() { if ((Object)(object)_visuals == (Object)null) { _visuals = ((Component)this).GetComponent<PlayerAvatarVisuals>(); } if ((Object)(object)_visuals == (Object)null) { return; } if ((Object)(object)_avatar == (Object)null) { _avatar = UwUNarutoAccess.GetAvatar(_visuals); } EnsureModel(); if ((Object)(object)_model == (Object)null) { return; } UwUNarutoSettings settings = UwUNarutoPlugin.Settings; if (settings == null) { _model.SetActive(false); SetOriginalHidden(hidden: false); SetThirdPersonActive(active: false); RestoreFlashlight(); return; } TrackMovement(); bool flag = (Object)(object)_avatar != (Object)null && UwUNarutoAccess.IsLocal(_avatar); HandleThirdPerson(flag, settings); bool flag2 = flag && (_thirdPersonActive || (settings.ShowLocalPlayer.Value && UwUNarutoAccess.GetShowSelfOverrideTimer(_visuals) > 0f)); bool flag3 = !flag && settings.ShowRemotePlayers.Value; bool flag4 = settings.Enabled.Value && (flag2 || flag3); _model.SetActive(flag4); SetOriginalHidden(flag4 && settings.HideOriginalPlayer.Value); if (!flag4) { RestoreFlashlight(); return; } ApplyTransform(settings); RedirectFlashlight(flag); HideRemoteFlashlight(flag); UpdateAnimation(settings); } private void OnDisable() { SetOriginalHidden(hidden: false); SetThirdPersonActive(active: false); RestoreFlashlight(); } private void OnDestroy() { SetOriginalHidden(hidden: false); SetThirdPersonActive(active: false); RestoreFlashlight(); if ((Object)(object)_model != (Object)null) { Object.Destroy((Object)(object)_model); } } private void EnsureModel() { if ((Object)(object)_model != (Object)null || !UwUNarutoAssets.Ready) { return; } _model = UwUNarutoAssets.Create(((Component)this).transform); if ((Object)(object)_model == (Object)null) { return; } ((Object)_model).name = "Empress Reina Kuroda"; _model.transform.SetParent(((Component)this).transform, false); _model.SetActive(false); _modelRenderers = _model.GetComponentsInChildren<Renderer>(true); _animator = _model.GetComponentInChildren<Animator>(true); _animation = _model.GetComponentInChildren<Animation>(true); if (!((Object)(object)_animator != (Object)null) || !((Object)(object)_animator.runtimeAnimatorController != (Object)null)) { return; } AnimationClip[] animationClips = _animator.runtimeAnimatorController.animationClips; for (int i = 0; i < animationClips.Length; i++) { if ((Object)(object)animationClips[i] != (Object)null) { animationClips[i].wrapMode = (WrapMode)2; _clips.Add(((Object)animationClips[i]).name); } } _animator.applyRootMotion = false; _animator.cullingMode = (AnimatorCullingMode)0; } private void ApplySkinFix() { //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Expected O, but got Unknown if (_skinFixApplied || _modelRenderers == null) { return; } if (!_skinFixLookup) { _skinFixLookup = true; string path = Path.Combine(UwUNarutoPlugin.PluginDirectory, "reina_skin_fix.png"); if (File.Exists(path)) { Texture2D val = new Texture2D(2, 2, (TextureFormat)4, true); if (ImageConversion.LoadImage(val, File.ReadAllBytes(path))) { ((Object)val).name = "Empress Reina Kuroda Skin"; ((Texture)val).wrapMode = (TextureWrapMode)1; _skinFixTexture = val; } } } if ((Object)(object)_skinFixTexture == (Object)null) { return; } _skinFixApplied = true; for (int i = 0; i < _modelRenderers.Length; i++) { Renderer val2 = _modelRenderers[i]; if ((Object)(object)val2 == (Object)null) { continue; } Material[] materials = val2.materials; foreach (Material val3 in materials) { if (!((Object)(object)val3 == (Object)null) && ((Object)val3).name.IndexOf("Body", StringComparison.OrdinalIgnoreCase) >= 0 && val3.HasProperty("_MainTex")) { val3.SetTexture("_MainTex", (Texture)(object)_skinFixTexture); } } } } private void ApplyUnlitShader() { //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: 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) if (_unlitApplied || _modelRenderers == null) { return; } if (!_unlitShaderLookup) { _unlitShaderLookup = true; _unlitShader = Shader.Find("Unlit/Texture"); if ((Object)(object)_unlitShader == (Object)null) { _unlitShader = Shader.Find("Unlit/Transparent Cutout"); } if ((Object)(object)_unlitShader == (Object)null) { _unlitShader = Shader.Find("Sprites/Default"); } } if ((Object)(object)_unlitShader == (Object)null) { return; } _unlitApplied = true; for (int i = 0; i < _modelRenderers.Length; i++) { Renderer val = _modelRenderers[i]; if ((Object)(object)val == (Object)null) { continue; } Material[] materials = val.materials; foreach (Material val2 in materials) { if (!((Object)(object)val2 == (Object)null)) { Texture val3 = (val2.HasProperty("_MainTex") ? val2.GetTexture("_MainTex") : null); Color val4 = (val2.HasProperty("_Color") ? val2.GetColor("_Color") : Color.white); val2.shader = _unlitShader; if ((Object)(object)val3 != (Object)null && val2.HasProperty("_MainTex")) { val2.SetTexture("_MainTex", val3); } if (val2.HasProperty("_Color")) { val2.SetColor("_Color", val4); } } } } } private void UpdateFillLights(UwUNarutoSettings settings) { if (settings == null || !settings.BrightenModel.Value) { SetFillLightsEnabled(enabled: false); return; } if (!_fillBuilt) { BuildFillLights(); } if (_fillLights == null) { return; } float value = settings.BrightenIntensity.Value; float value2 = settings.BrightenRange.Value; for (int i = 0; i < _fillLights.Length; i++) { Light val = _fillLights[i]; if (!((Object)(object)val == (Object)null)) { ((Behaviour)val).enabled = true; val.intensity = value; val.range = value2; } } } private void SetFillLightsEnabled(bool enabled) { if (_fillLights == null) { return; } for (int i = 0; i < _fillLights.Length; i++) { if ((Object)(object)_fillLights[i] != (Object)null) { ((Behaviour)_fillLights[i]).enabled = enabled; } } } private void BuildFillLights() { //IL_0020: 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_008c: 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_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Expected O, but got Unknown //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0116: 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_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0140: 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_0158: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_0055: 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_004c: Unknown result type (might be due to invalid IL or missing references) //IL_018c: Unknown result type (might be due to invalid IL or missing references) //IL_0191: Unknown result type (might be due to invalid IL or missing references) //IL_01a4: Unknown result type (might be due to invalid IL or missing references) //IL_01ae: 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) _fillBuilt = true; if ((Object)(object)_model == (Object)null || _modelRenderers == null) { return; } Bounds val = default(Bounds); bool flag = false; for (int i = 0; i < _modelRenderers.Length; i++) { Renderer val2 = _modelRenderers[i]; if (!((Object)(object)val2 == (Object)null)) { if (!flag) { val = val2.bounds; flag = true; } else { ((Bounds)(ref val)).Encapsulate(val2.bounds); } } } if (flag) { QualitySettings.pixelLightCount = Mathf.Max(QualitySettings.pixelLightCount, 8); Vector3 center = ((Bounds)(ref val)).center; float num = Mathf.Max(((Bounds)(ref val)).extents.x, ((Bounds)(ref val)).extents.z) + 0.35f; GameObject val3 = new GameObject("Empress Reina Kuroda Light"); val3.transform.SetParent(_model.transform, true); val3.transform.position = center; val3.transform.rotation = _model.transform.rotation; Vector3[] array = (Vector3[])(object)new Vector3[4] { new Vector3(0f, 0f, num), new Vector3(0f, 0f, 0f - num), new Vector3(num, 0f, 0f), new Vector3(0f - num, 0f, 0f) }; _fillLights = (Light[])(object)new Light[array.Length]; for (int j = 0; j < array.Length; j++) { GameObject val4 = new GameObject("Empress Reina Kuroda Light " + j); val4.transform.SetParent(val3.transform, false); val4.transform.localPosition = array[j]; Light val5 = val4.AddComponent<Light>(); val5.type = (LightType)2; val5.color = new Color(1f, 0.98f, 0.95f); val5.shadows = (LightShadows)0; val5.renderMode = (LightRenderMode)1; val5.bounceIntensity = 0f; val5.cullingMask = -1; _fillLights[j] = val5; } } } private void ApplyTransform(UwUNarutoSettings settings) { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0057: 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) Transform transform = _model.transform; transform.localPosition = new Vector3(settings.SideOffset.Value, settings.HeightOffset.Value, settings.ForwardOffset.Value); transform.localRotation = Quaternion.Euler(0f, settings.YawOffset.Value, 0f); transform.localScale = Vector3.one * settings.ModelScale.Value; if (_modelRenderers == null) { return; } if (settings.FixSkinTexture.Value) { ApplySkinFix(); } if (settings.UnlitModel.Value) { ApplyUnlitShader(); SetFillLightsEnabled(enabled: false); } else { UpdateFillLights(settings); } for (int i = 0; i < _modelRenderers.Length; i++) { Renderer val = _modelRenderers[i]; if (!((Object)(object)val == (Object)null)) { val.shadowCastingMode = (ShadowCastingMode)0; val.receiveShadows = false; val.enabled = true; SkinnedMeshRenderer val2 = (SkinnedMeshRenderer)(object)((val is SkinnedMeshRenderer) ? val : null); if ((Object)(object)val2 != (Object)null) { val2.updateWhenOffscreen = true; } } } } private void SetOriginalHidden(bool hidden) { CaptureOriginalRenderers(); CaptureMeshParent(); if ((Object)(object)_meshParent != (Object)null && _capturedMeshParent) { _meshParent.SetActive(!hidden && _meshParentWasActive); } foreach (KeyValuePair<Renderer, bool> originalRenderer in _originalRenderers) { Renderer key = originalRenderer.Key; if (!((Object)(object)key == (Object)null)) { key.enabled = !hidden && originalRenderer.Value; } } } private void CaptureMeshParent() { if (!((Object)(object)_visuals == (Object)null)) { GameObject meshParent = UwUNarutoAccess.GetMeshParent(_visuals); if (!((Object)(object)meshParent == (Object)null) && (!((Object)(object)_meshParent == (Object)(object)meshParent) || !_capturedMeshParent)) { _meshParent = meshParent; _meshParentWasActive = meshParent.activeSelf; _capturedMeshParent = true; } } } private void CaptureOriginalRenderers() { if (_capturedRenderers || (Object)(object)_visuals == (Object)null) { return; } GameObject val = UwUNarutoAccess.GetMeshParent(_visuals); if ((Object)(object)val == (Object)null) { val = ((Component)_visuals).gameObject; } Renderer[] componentsInChildren = val.GetComponentsInChildren<Renderer>(true); foreach (Renderer val2 in componentsInChildren) { if (!((Object)(object)val2 == (Object)null) && (!((Object)(object)_model != (Object)null) || !((Component)val2).transform.IsChildOf(_model.transform)) && !_originalRenderers.ContainsKey(val2)) { _originalRenderers.Add(val2, val2.enabled); } } _capturedRenderers = true; } private void RedirectFlashlight(bool local) { //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_avatar == (Object)null) { return; } FlashlightController flashlight = UwUNarutoAccess.GetFlashlight(_avatar); if ((Object)(object)flashlight == (Object)null) { return; } EnsureFlashlightFollowPoint(); if ((Object)(object)_flashlightFollowPoint == (Object)null) { return; } if ((Object)(object)_flashlight != (Object)(object)flashlight) { RestoreFlashlight(); _flashlight = flashlight; _originalFlashlightLocal = UwUNarutoAccess.GetFlashlightLocal(flashlight); _originalFlashlightClient = UwUNarutoAccess.GetFlashlightClient(flashlight); _capturedFlashlight = true; } UwUNarutoAccess.SetFlashlightClient(flashlight, _flashlightFollowPoint); if (local) { UwUNarutoAccess.SetFlashlightLocal(flashlight, _flashlightFollowPoint); ((Component)flashlight).transform.SetParent(_flashlightFollowPoint, false); ((Component)flashlight).transform.localPosition = Vector3.zero; ((Component)flashlight).transform.localRotation = Quaternion.identity; Camera main = Camera.main; if ((Object)(object)main != (Object)null) { _flashlightFollowPoint.rotation = ((Component)main).transform.rotation; } } } private void RestoreFlashlight() { if (!((Object)(object)_flashlight == (Object)null) && _capturedFlashlight) { if ((Object)(object)UwUNarutoAccess.GetFlashlightClient(_flashlight) == (Object)(object)_flashlightFollowPoint) { UwUNarutoAccess.SetFlashlightClient(_flashlight, _originalFlashlightClient); } if ((Object)(object)UwUNarutoAccess.GetFlashlightLocal(_flashlight) == (Object)(object)_flashlightFollowPoint) { UwUNarutoAccess.SetFlashlightLocal(_flashlight, _originalFlashlightLocal); } _flashlight = null; _originalFlashlightLocal = null; _originalFlashlightClient = null; _capturedFlashlight = false; } } private void HideRemoteFlashlight(bool local) { if (!local && !((Object)(object)_flashlight == (Object)null)) { MeshRenderer flashlightMesh = UwUNarutoAccess.GetFlashlightMesh(_flashlight); if ((Object)(object)flashlightMesh != (Object)null) { ((Renderer)flashlightMesh).enabled = false; } MeshRenderer flashlightMeshShadows = UwUNarutoAccess.GetFlashlightMeshShadows(_flashlight); if ((Object)(object)flashlightMeshShadows != (Object)null) { ((Renderer)flashlightMeshShadows).enabled = false; } } } private void EnsureFlashlightFollowPoint() { //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Expected O, but got Unknown //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)_flashlightFollowPoint != (Object)null) && !((Object)(object)_model == (Object)null)) { Transform val = FindModelBone("Bip01_Hand.R_Temari_Skeleton", "RightHand", "Hand.R", "R_Hand"); if ((Object)(object)val == (Object)null) { val = FindModelBone("Bip01_Head_Temari_Skeleton", "Head"); } if ((Object)(object)val == (Object)null) { val = _model.transform; } GameObject val2 = new GameObject("Empress Reina Kuroda Flashlight Follow"); val2.transform.SetParent(val, false); val2.transform.localPosition = new Vector3(0.02f, 0.02f, 0.08f); val2.transform.localRotation = Quaternion.identity; val2.transform.localScale = Vector3.one; _flashlightFollowPoint = val2.transform; } } private Transform FindModelBone(params string[] names) { if ((Object)(object)_model == (Object)null || names == null) { return null; } Transform[] componentsInChildren = _model.GetComponentsInChildren<Transform>(true); foreach (string text in names) { foreach (Transform val in componentsInChildren) { if ((Object)(object)val != (Object)null && ((Object)val).name == text) { return val; } } } foreach (string value in names) { foreach (Transform val2 in componentsInChildren) { if ((Object)(object)val2 != (Object)null && ((Object)val2).name.Contains(value)) { return val2; } } } return null; } private void TrackMovement() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: 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_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0014: 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_0020: Unknown result type (might be due to invalid IL or missing references) Vector3 position = ((Component)this).transform.position; if (_trackedPosition) { Vector3 val = position - _lastPosition; val.y = 0f; _moveSpeed = ((Vector3)(ref val)).magnitude / Mathf.Max(Time.deltaTime, 0.001f); } _lastPosition = position; _trackedPosition = true; } private void UpdateAnimation(UwUNarutoSettings settings) { string text = ChooseAnimation(); float animationSpeed = GetAnimationSpeed(text, settings); if ((Object)(object)_animator != (Object)null && (Object)(object)_animator.runtimeAnimatorController != (Object)null && HasClip(text)) { if (_state != text) { _animator.CrossFadeInFixedTime(text, 0.12f); _state = text; } _animator.speed = animationSpeed; } else if ((Object)(object)_animation != (Object)null && (Object)(object)_animation.GetClip(text) != (Object)null) { if (_state != text) { _animation.CrossFade(text, 0.12f); _state = text; } _animation[text].speed = animationSpeed; } } private float GetAnimationSpeed(string clip, UwUNarutoSettings settings) { float num = settings?.AnimationSpeed.Value ?? 1f; if (clip == "Walk_Forward" || clip == "Walk_Forward_Sexy") { num *= 1.72f; } return num; } private void HandleThirdPerson(bool local, UwUNarutoSettings settings) { if (!local || settings == null || !settings.Enabled.Value) { SetThirdPersonActive(active: false); return; } if (Input.GetKeyDown((KeyCode)118)) { SetThirdPersonActive(!_thirdPersonActive); } if (_thirdPersonActive) { float axis = Input.GetAxis("Mouse ScrollWheel"); if (Mathf.Abs(axis) > 0.001f) { _thirdPersonDistance = Mathf.Clamp(_thirdPersonDistance - axis * 3f, 1.25f, 4.25f); } ApplyThirdPersonCamera(); } } private void SetThirdPersonActive(bool active) { if (_thirdPersonActive == active) { return; } _thirdPersonActive = active; if (active) { EnsureThirdPersonMarker(); return; } ClearThirdPersonCamera(); if ((Object)(object)_thirdPersonMarker != (Object)null) { Object.Destroy((Object)(object)_thirdPersonMarker); _thirdPersonMarker = null; } } private void EnsureThirdPersonMarker() { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Expected O, but got Unknown if (!((Object)(object)_thirdPersonMarker != (Object)null)) { _thirdPersonMarker = new GameObject("EmpressTPC"); ((Object)_thirdPersonMarker).hideFlags = (HideFlags)61; _thirdPersonMarker.transform.SetParent(((Component)this).transform, false); } } private void ApplyThirdPersonCamera() { //IL_0025: 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_0034: 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_0086: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006b: 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) //IL_00bb: 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_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) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //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_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) CameraPosition cameraPosition = UwUNarutoAccess.GetCameraPosition(); CameraAim cameraAim = UwUNarutoAccess.GetCameraAim(); if (!((Object)(object)cameraPosition == (Object)null) && !((Object)(object)cameraAim == (Object)null)) { Vector3 val = ((Component)this).transform.position + Vector3.up * 1.35f; Transform val2 = FindModelBone("Bip01_Head_Temari_Skeleton", "Head"); if ((Object)(object)val2 != (Object)null) { val = val2.position + Vector3.up * 0.05f; } Vector3 forward = ((Component)cameraAim).transform.forward; forward.y = 0f; if (((Vector3)(ref forward)).sqrMagnitude < 0.001f) { forward = ((Component)this).transform.forward; } ((Vector3)(ref forward)).Normalize(); Vector3 position = val - forward * _thirdPersonDistance + Vector3.up * 0.45f; UwUNarutoAccess.OverrideCameraPosition(cameraPosition, position, 0.15f); UwUNarutoAccess.ShowSelf(_visuals, 0.2f); } } private void ClearThirdPersonCamera() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) CameraPosition cameraPosition = UwUNarutoAccess.GetCameraPosition(); if ((Object)(object)cameraPosition != (Object)null) { UwUNarutoAccess.OverrideCameraPosition(cameraPosition, Vector3.zero, 0f); } } private string ChooseAnimation() { bool flag = (Object)(object)_avatar != (Object)null && UwUNarutoAccess.IsMoving(_avatar); bool flag2 = (Object)(object)_avatar != (Object)null && UwUNarutoAccess.IsSprinting(_avatar); if (_moveSpeed > 0.05f) { flag = true; } if (flag) { _movingTimer = 0.18f; } else { _movingTimer = Mathf.Max(0f, _movingTimer - Time.deltaTime); } if (flag2) { _sprintingTimer = 0.12f; } else { _sprintingTimer = Mathf.Max(0f, _sprintingTimer - Time.deltaTime); } flag = _movingTimer > 0f; flag2 = _sprintingTimer > 0f; if ((Object)(object)_avatar != (Object)null && (UwUNarutoAccess.IsTumbling(_avatar) || UwUNarutoAccess.IsSliding(_avatar))) { flag = false; flag2 = false; _movingTimer = 0f; _sprintingTimer = 0f; } if (flag) { if (flag2 && HasClip("Run_Forward")) { return "Run_Forward"; } if (HasClip("Walk_Forward")) { return "Walk_Forward"; } if (HasClip("Walk_Forward_Sexy")) { return "Walk_Forward_Sexy"; } } if (HasClip("Idle_Sexy")) { return "Idle_Sexy"; } if (HasClip("Walk_Forward")) { return "Walk_Forward"; } return "Idle_Sexy"; } private bool HasClip(string clip) { if (_clips.Count == 0) { return true; } return _clips.Contains(clip); } } internal static class UwUNarutoPatches { internal static void Apply(Harmony harmony) { //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Expected O, but got Unknown MethodInfo methodInfo = AccessTools.Method(typeof(PlayerAvatarVisuals), "Start", (Type[])null, (Type[])null); MethodInfo methodInfo2 = AccessTools.Method(typeof(UwUNarutoPatches), "PlayerAvatarVisualsStartPostfix", (Type[])null, (Type[])null); if (methodInfo != null && methodInfo2 != null) { harmony.Patch((MethodBase)methodInfo, (HarmonyMethod)null, new HarmonyMethod(methodInfo2), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } } private static void PlayerAvatarVisualsStartPostfix(PlayerAvatarVisuals __instance) { UwUNarutoAvatar.Attach(__instance); } } [BepInPlugin("com.empress.repo.uwunaruto", "Reina Kuroda", "1.0.0")] public sealed class UwUNarutoPlugin : BaseUnityPlugin { public const string PluginGuid = "com.empress.repo.uwunaruto"; public const string PluginName = "Reina Kuroda"; public const string PluginVersion = "1.0.0"; private static Harmony _harmony; private static GameObject _runtime; internal static ManualLogSource Log { get; private set; } internal static UwUNarutoSettings Settings { get; private set; } internal static string PluginDirectory { get; private set; } private void Awake() { //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Expected O, but got Unknown //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Expected O, but got Unknown Log = ((BaseUnityPlugin)this).Logger; PluginDirectory = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location); Settings = new UwUNarutoSettings(((BaseUnityPlugin)this).Config); ((Component)this).transform.parent = null; ((Object)this).hideFlags = (HideFlags)61; Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject); if (_harmony == null) { _harmony = new Harmony("com.empress.repo.uwunaruto"); UwUNarutoPatches.Apply(_harmony); } UwUNarutoAssets.Load(); if ((Object)(object)_runtime == (Object)null) { _runtime = new GameObject("Empress Reina Kuroda Runtime"); _runtime.transform.parent = null; ((Object)_runtime).hideFlags = (HideFlags)61; Object.DontDestroyOnLoad((Object)(object)_runtime); _runtime.AddComponent<UwUNarutoScanner>(); } ((BaseUnityPlugin)this).Logger.LogInfo((object)"Reina Kuroda v1.0.0 loaded."); } internal static void DebugLog(string message) { if (Settings != null && Settings.DebugLogs.Value) { Log.LogInfo((object)message); } } } internal sealed class UwUNarutoSettings { public readonly ConfigEntry<bool> Enabled; public readonly ConfigEntry<bool> HideOriginalPlayer; public readonly ConfigEntry<bool> ShowLocalPlayer; public readonly ConfigEntry<bool> ShowRemotePlayers; public readonly ConfigEntry<float> ModelScale; public readonly ConfigEntry<float> HeightOffset; public readonly ConfigEntry<float> ForwardOffset; public readonly ConfigEntry<float> SideOffset; public readonly ConfigEntry<float> YawOffset; public readonly ConfigEntry<float> AnimationSpeed; public readonly ConfigEntry<bool> FixSkinTexture; public readonly ConfigEntry<bool> UnlitModel; public readonly ConfigEntry<bool> BrightenModel; public readonly ConfigEntry<float> BrightenIntensity; public readonly ConfigEntry<float> BrightenRange; public readonly ConfigEntry<bool> DebugLogs; public UwUNarutoSettings(ConfigFile config) { //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Expected O, but got Unknown //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Expected O, but got Unknown //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Expected O, but got Unknown //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Expected O, but got Unknown //IL_0184: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Expected O, but got Unknown //IL_01bd: Unknown result type (might be due to invalid IL or missing references) //IL_01c7: Expected O, but got Unknown //IL_024a: Unknown result type (might be due to invalid IL or missing references) //IL_0254: Expected O, but got Unknown //IL_0283: Unknown result type (might be due to invalid IL or missing references) //IL_028d: Expected O, but got Unknown Enabled = config.Bind<bool>("Reina Kuroda", "Enabled", true, "Enable the Reina Kuroda player model swap."); HideOriginalPlayer = config.Bind<bool>("Reina Kuroda", "HideOriginalPlayer", true, "Hide the original R.E.P.O. player mesh while Reina Kuroda is active."); ShowLocalPlayer = config.Bind<bool>("Reina Kuroda", "ShowLocalPlayer", false, "Show Reina Kuroda on the local first-person player."); ShowRemotePlayers = config.Bind<bool>("Reina Kuroda", "ShowRemotePlayers", true, "Show Reina Kuroda on other players."); ModelScale = config.Bind<float>("Reina Kuroda", "ModelScale", 1f, new ConfigDescription("Reina Kuroda model scale.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.2f, 3f), Array.Empty<object>())); HeightOffset = config.Bind<float>("Reina Kuroda", "HeightOffset", 0f, new ConfigDescription("Reina Kuroda vertical offset.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(-2f, 2f), Array.Empty<object>())); ForwardOffset = config.Bind<float>("Reina Kuroda", "ForwardOffset", 0f, new ConfigDescription("Reina Kuroda forward offset.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(-2f, 2f), Array.Empty<object>())); SideOffset = config.Bind<float>("Reina Kuroda", "SideOffset", 0f, new ConfigDescription("Reina Kuroda side offset.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(-2f, 2f), Array.Empty<object>())); YawOffset = config.Bind<float>("Reina Kuroda", "YawOffset", 0f, new ConfigDescription("Reina Kuroda yaw offset.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(-180f, 180f), Array.Empty<object>())); AnimationSpeed = config.Bind<float>("Reina Kuroda", "AnimationSpeed", 1f, new ConfigDescription("Reina Kuroda animation speed.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 3f), Array.Empty<object>())); FixSkinTexture = config.Bind<bool>("Rendering", "FixSkinTexture", true, "Replace Reina Kuroda's body texture with a repaired copy that fills the black regions her mesh maps onto. This is what removes the black patches on her body."); UnlitModel = config.Bind<bool>("Rendering", "UnlitModel", false, "Render Reina Kuroda with a flat unlit shader. Off keeps normal scene lighting. Only turn on if you want a flat, fully self-lit look."); BrightenModel = config.Bind<bool>("Lighting", "BrightenModel", false, "Attach a soft fill light rig so Reina Kuroda never goes black on her shaded side in dark rooms. Only used when UnlitModel is off."); BrightenIntensity = config.Bind<float>("Lighting", "BrightenIntensity", 1.6f, new ConfigDescription("Fill light strength. Raise if she still darkens in dim rooms, lower if she looks too bright.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 6f), Array.Empty<object>())); BrightenRange = config.Bind<float>("Lighting", "BrightenRange", 3.5f, new ConfigDescription("Fill light reach around Reina Kuroda.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 10f), Array.Empty<object>())); DebugLogs = config.Bind<bool>("Debug", "DebugLogs", false, "Logs verbose Reina Kuroda diagnostics."); } } internal sealed class UwUNarutoScanner : MonoBehaviour { private float _nextScan; private void Update() { //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) if (UwUNarutoPlugin.Settings == null || !UwUNarutoPlugin.Settings.Enabled.Value || !UwUNarutoAssets.Ready || Time.unscaledTime < _nextScan) { return; } _nextScan = Time.unscaledTime + 0.75f; PlayerAvatarVisuals[] array = Resources.FindObjectsOfTypeAll<PlayerAvatarVisuals>(); foreach (PlayerAvatarVisuals val in array) { if (!((Object)(object)val == (Object)null) && !((Object)(object)((Component)val).gameObject == (Object)null)) { Scene scene = ((Component)val).gameObject.scene; if (((Scene)(ref scene)).IsValid()) { UwUNarutoAvatar.Attach(val); } } } } }