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.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using Photon.Realtime;
using UnityEngine;
[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("ropecut")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("0.1.0.0")]
[assembly: AssemblyInformationalVersion("0.1.0")]
[assembly: AssemblyProduct("ropecut")]
[assembly: AssemblyTitle("RopeCut")]
[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 RopeCutterMod
{
[BepInPlugin("com.xammen.ropecut", "RopeCut", "1.1.2")]
public class RopeCutterPlugin : BaseUnityPlugin
{
public static ConfigEntry<KeyCode>? CutKey;
private void Awake()
{
//IL_0045: 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_0069: Expected O, but got Unknown
CutKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("General", "Cut Rope Key", (KeyCode)102, "Key to press to cut the rope.");
((BaseUnityPlugin)this).Logger.LogInfo((object)string.Format("Plugin {0} is loading. CutKey set to: {1}.", "RopeCut", CutKey?.Value));
Harmony val = new Harmony("com.xammen.ropecut");
val.PatchAll();
((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin RopeCut is loaded!");
}
}
[HarmonyPatch(typeof(Character), "Awake")]
public static class CharacterAwakePatch
{
[HarmonyPostfix]
public static void Postfix(Character __instance)
{
if ((Object)(object)__instance == (Object)(object)Character.localCharacter)
{
if ((Object)(object)((Component)__instance).GetComponent<RopeCutterInteractionHandler>() == (Object)null)
{
((Component)__instance).gameObject.AddComponent<RopeCutterInteractionHandler>();
Debug.Log((object)("[RopeCutterMod] RopeCutterInteractionHandler ADDED to local character: " + ((Object)__instance).name + "."));
}
else
{
Debug.Log((object)("[RopeCutterMod] RopeCutterInteractionHandler already EXISTS on local character: " + ((Object)__instance).name + "."));
}
}
}
}
[HarmonyPatch(typeof(Rope), "Awake")]
public static class RopeAwakePatch
{
[HarmonyPostfix]
public static void Postfix(Rope __instance)
{
if ((Object)(object)((Component)__instance).GetComponent<RopeCutterComponent>() == (Object)null)
{
((Component)__instance).gameObject.AddComponent<RopeCutterComponent>();
Debug.Log((object)$"[RopeCutterMod] RopeCutterComponent ADDED to Rope: {((Object)__instance).name} (ID: {((Object)__instance).GetInstanceID()}).");
}
else
{
Debug.Log((object)("[RopeCutterMod] RopeCutterComponent already EXISTS on Rope: " + ((Object)__instance).name + "."));
}
}
}
public class RopeCutterInteractionHandler : MonoBehaviour
{
private float maxRaycastDistance = 5f;
private void Update()
{
//IL_000d: 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_0085: 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_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_00ca: Unknown result type (might be due to invalid IL or missing references)
//IL_0109: Unknown result type (might be due to invalid IL or missing references)
//IL_0118: Unknown result type (might be due to invalid IL or missing references)
if (RopeCutterPlugin.CutKey == null || !Input.GetKeyDown(RopeCutterPlugin.CutKey.Value))
{
return;
}
Debug.Log((object)$"[RopeCutterMod-InteractionHandler] Cut key ({RopeCutterPlugin.CutKey.Value}) WAS JUST PRESSED!");
if ((Object)(object)MainCamera.instance == (Object)null)
{
Debug.LogError((object)"[RopeCutterMod-InteractionHandler] MainCamera.instance is NULL. Cannot perform raycast.");
return;
}
int num = LayerMask.NameToLayer("Rope");
int num2 = 1 << num;
if (num == -1)
{
Debug.LogWarning((object)"[RopeCutterMod-InteractionHandler] Layer 'Rope' not found! Falling back to all layers except IgnoreRaycast.");
num2 = -1;
num2 &= -5;
}
Debug.DrawRay(((Component)MainCamera.instance).transform.position, ((Component)MainCamera.instance).transform.forward * maxRaycastDistance, Color.cyan, 1f);
Debug.Log((object)$"[RopeCutterMod-InteractionHandler] Performing raycast from {((Component)MainCamera.instance).transform.position} for {maxRaycastDistance}m on layers: {LayerMask.LayerToName(num2)} (Value: {num2}).");
RaycastHit val = default(RaycastHit);
if (Physics.Raycast(((Component)MainCamera.instance).transform.position, ((Component)MainCamera.instance).transform.forward, ref val, maxRaycastDistance, num2))
{
Debug.Log((object)$"[RopeCutterMod-InteractionHandler] Raycast HIT: {((Object)((RaycastHit)(ref val)).collider).name} (Layer: {LayerMask.LayerToName(((Component)((RaycastHit)(ref val)).collider).gameObject.layer)}) at distance {((RaycastHit)(ref val)).distance:F2}m.");
RopeSegment val2 = ((Component)((RaycastHit)(ref val)).collider).GetComponent<RopeSegment>();
if ((Object)(object)val2 == (Object)null)
{
val2 = ((Component)((RaycastHit)(ref val)).collider).GetComponentInParent<RopeSegment>();
}
if ((Object)(object)val2 != (Object)null)
{
Debug.Log((object)("[RopeCutterMod-InteractionHandler] Raycast successfully hit a RopeSegment: " + ((Object)val2).name + "."));
Rope rope = val2.rope;
if ((Object)(object)rope != (Object)null)
{
PhotonView component = ((Component)rope).GetComponent<PhotonView>();
if ((Object)(object)component != (Object)null)
{
Debug.Log((object)$"[RopeCutterMod-InteractionHandler] Found Rope PhotonView. IsMine: {component.IsMine}.");
if (!component.IsMine)
{
component.RequestOwnership();
Debug.Log((object)("[RopeCutterMod-InteractionHandler] Requested ownership for rope: " + ((Object)rope).name + ". Waiting for transfer to cut."));
return;
}
RopeCutterComponent component2 = ((Component)rope).GetComponent<RopeCutterComponent>();
if ((Object)(object)component2 != (Object)null)
{
((MonoBehaviourPun)component2).photonView.RPC("CutRope_RPC", (RpcTarget)0, new object[1] { ((Component)val2).transform.GetSiblingIndex() });
Debug.Log((object)$"[RopeCutterMod-InteractionHandler] Sent CutRope_RPC for segment {((Object)val2).name} (index: {((Component)val2).transform.GetSiblingIndex()}).");
}
else
{
Debug.LogError((object)"[RopeCutterMod-InteractionHandler] ERROR: RopeCutterComponent not found on the hit Rope object! This should have been added by RopeAwakePatch.");
}
}
else
{
Debug.LogError((object)"[RopeCutterMod-InteractionHandler] ERROR: PhotonView not found on the hit Rope object!");
}
}
else
{
Debug.LogError((object)"[RopeCutterMod-InteractionHandler] ERROR: Rope component (parent) not found on RopeSegment!");
}
}
else
{
Debug.Log((object)("[RopeCutterMod-InteractionHandler] Raycast hit " + ((Object)((RaycastHit)(ref val)).collider).name + " but it is NOT a RopeSegment (or parent of one). Its Layer: " + LayerMask.LayerToName(((Component)((RaycastHit)(ref val)).collider).gameObject.layer) + "."));
}
}
else
{
Debug.Log((object)$"[RopeCutterMod-InteractionHandler] Raycast did not hit anything within {maxRaycastDistance}m on specified layers.");
}
}
}
public struct FadeRendererInfo
{
public Renderer Renderer;
public Material Material;
public string ColorPropertyName;
public Color InitialColor;
}
public class RopeCutterComponent : MonoBehaviourPunCallbacks, IPunOwnershipCallbacks
{
[CompilerGenerated]
private sealed class <FadeOutAndDestroyRope>d__8 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public RopeCutterComponent <>4__this;
private float <fadeDuration>5__2;
private float <timer>5__3;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <FadeOutAndDestroyRope>d__8(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
//IL_0370: Unknown result type (might be due to invalid IL or missing references)
//IL_0375: Unknown result type (might be due to invalid IL or missing references)
//IL_0391: Unknown result type (might be due to invalid IL or missing references)
//IL_0473: Unknown result type (might be due to invalid IL or missing references)
//IL_0475: Unknown result type (might be due to invalid IL or missing references)
//IL_048f: Unknown result type (might be due to invalid IL or missing references)
//IL_0523: Unknown result type (might be due to invalid IL or missing references)
//IL_0528: Unknown result type (might be due to invalid IL or missing references)
//IL_0541: Unknown result type (might be due to invalid IL or missing references)
//IL_05dc: Unknown result type (might be due to invalid IL or missing references)
//IL_05e1: Unknown result type (might be due to invalid IL or missing references)
//IL_05fd: Unknown result type (might be due to invalid IL or missing references)
//IL_0309: Unknown result type (might be due to invalid IL or missing references)
//IL_030e: Unknown result type (might be due to invalid IL or missing references)
int num = <>1__state;
RopeCutterComponent ropeCutterComponent = <>4__this;
switch (num)
{
default:
return false;
case 0:
{
<>1__state = -1;
<fadeDuration>5__2 = 2f;
<timer>5__3 = 0f;
Debug.Log((object)$"[RopeCutterMod] FadeOutAndDestroyRope coroutine started. Total duration: {<fadeDuration>5__2}s.");
if ((Object)(object)ropeCutterComponent._rope == (Object)null)
{
Debug.LogError((object)"[RopeCutterMod] ERROR: _rope is null in FadeOutAndDestroyRope. Aborting fade process.");
return false;
}
ropeCutterComponent._fadeMaterialInfos.Clear();
RopeBoneVisualizer componentInChildren = ((Component)ropeCutterComponent._rope).GetComponentInChildren<RopeBoneVisualizer>();
SkinnedMeshRenderer val = ((componentInChildren != null) ? ((Component)componentInChildren).GetComponentInChildren<SkinnedMeshRenderer>() : null);
List<Renderer> list = new List<Renderer>();
if ((Object)(object)val != (Object)null && ((Renderer)val).enabled)
{
list.Add((Renderer)(object)val);
Debug.Log((object)("[RopeCutterMod] Found main SkinnedMeshRenderer '" + ((Object)val).name + "' for fading."));
}
else
{
Debug.LogWarning((object)"[RopeCutterMod] Main SkinnedMeshRenderer not found or not enabled. Falling back to all renderers on rope root object.");
list = (from r in ((Component)ropeCutterComponent._rope).gameObject.GetComponentsInChildren<Renderer>()
where r.enabled
select r).ToList();
}
Debug.Log((object)$"[RopeCutterMod] Total {list.Count} renderers identified for fading.");
if (list.Count == 0)
{
Debug.LogWarning((object)"[RopeCutterMod] No renderers found for rope. Skipping fade animation and proceeding to destruction.");
if (((MonoBehaviourPun)ropeCutterComponent).photonView.IsMine)
{
PhotonNetwork.Destroy(((Component)ropeCutterComponent._rope).gameObject);
Debug.Log((object)("[RopeCutterMod] Rope " + ((Object)ropeCutterComponent._rope).name + " destroyed immediately as no renderers were found."));
}
return false;
}
foreach (Renderer item in list)
{
if ((Object)(object)item == (Object)null || (Object)(object)item.material == (Object)null)
{
Debug.LogWarning((object)("[RopeCutterMod] Skipping null renderer or material for '" + (((item != null) ? ((Object)item).name : null) ?? "N/A") + "'."));
continue;
}
Material material = item.material;
Debug.Log((object)("[RopeCutterMod] Preparing material '" + ((Object)material).name + "' (Shader: '" + ((Object)material.shader).name + "') on '" + ((Object)item).name + "' for fading."));
if (material.HasProperty("_Mode"))
{
material.SetInt("_Mode", 2);
Debug.Log((object)("[RopeCutterMod] Material '" + ((Object)material).name + "': Set _Mode to Fade (2)."));
}
else if (material.HasProperty("_Surface"))
{
material.SetInt("_Surface", 1);
Debug.Log((object)("[RopeCutterMod] Material '" + ((Object)material).name + "': Set _Surface to Transparent (1)."));
}
material.SetOverrideTag("RenderType", "Transparent");
material.EnableKeyword("_ALPHABLEND_ON");
material.DisableKeyword("_ALPHAPREMULTIPLY_ON");
material.DisableKeyword("_ALPHATEST_ON");
material.renderQueue = 3000;
Debug.Log((object)("[RopeCutterMod] Material '" + ((Object)material).name + "': Configured RenderType, Keywords, and RenderQueue."));
string text = "_Color";
Color val2 = Color.white;
string[] array = new string[6] { "_Color", "_BaseColor", "_MainColor", "_Albedo", "_TintColor", "_RopeColor" };
bool flag = false;
string[] array2 = array;
foreach (string text2 in array2)
{
if (material.HasProperty(text2))
{
try
{
val2 = material.GetColor(text2);
text = text2;
flag = true;
Debug.Log((object)$"[RopeCutterMod] FOUND main color property: '{text}' for shader '{((Object)material.shader).name}'. Initial Alpha: {val2.a}");
}
catch (Exception ex)
{
Debug.LogWarning((object)("[RopeCutterMod] Property '" + text2 + "' on material '" + ((Object)material).name + "' exists but could not be read as Color. Trying next. Error: " + ex.Message));
continue;
}
break;
}
}
if (!flag)
{
Debug.LogError((object)("[RopeCutterMod] ERROR: Material '" + ((Object)material).name + "' with Shader '" + ((Object)material.shader).name + "' does NOT have common color properties (_Color, _BaseColor, etc.). CANNOT FADE ALPHA. You MUST find the correct color property name in DnSpy!"));
}
else
{
ropeCutterComponent._fadeMaterialInfos[material] = new FadeRendererInfo
{
Renderer = item,
Material = material,
ColorPropertyName = text,
InitialColor = val2
};
Debug.Log((object)$"[RopeCutterMod] Material '{((Object)material).name}': Added to fade list. Color property: '{text}'. Initial Alpha: {val2.a}");
}
}
break;
}
case 1:
<>1__state = -1;
break;
}
if (<timer>5__3 < <fadeDuration>5__2)
{
float a = Mathf.Lerp(1f, 0f, <timer>5__3 / <fadeDuration>5__2);
foreach (KeyValuePair<Material, FadeRendererInfo> fadeMaterialInfo in ropeCutterComponent._fadeMaterialInfos)
{
FadeRendererInfo value = fadeMaterialInfo.Value;
if (!((Object)(object)value.Renderer == (Object)null) && !((Object)(object)value.Material == (Object)null))
{
Color initialColor = value.InitialColor;
initialColor.a = a;
value.Material.SetColor(value.ColorPropertyName, initialColor);
}
}
<timer>5__3 += Time.deltaTime;
<>2__current = null;
<>1__state = 1;
return true;
}
foreach (KeyValuePair<Material, FadeRendererInfo> fadeMaterialInfo2 in ropeCutterComponent._fadeMaterialInfos)
{
FadeRendererInfo value2 = fadeMaterialInfo2.Value;
if (!((Object)(object)value2.Renderer == (Object)null) && !((Object)(object)value2.Material == (Object)null))
{
Color initialColor2 = value2.InitialColor;
initialColor2.a = 0f;
value2.Material.SetColor(value2.ColorPropertyName, initialColor2);
}
}
Debug.Log((object)"[RopeCutterMod] Fade complete. All material alphas set to 0.");
foreach (KeyValuePair<Material, FadeRendererInfo> fadeMaterialInfo3 in ropeCutterComponent._fadeMaterialInfos)
{
FadeRendererInfo value3 = fadeMaterialInfo3.Value;
if (!((Object)(object)value3.Renderer == (Object)null))
{
value3.Renderer.enabled = false;
}
}
if (((MonoBehaviourPun)ropeCutterComponent).photonView.IsMine && (Object)(object)ropeCutterComponent._rope != (Object)null)
{
PhotonNetwork.Destroy(((Component)ropeCutterComponent._rope).gameObject);
Debug.Log((object)$"[RopeCutterMod] Rope '{((Object)ropeCutterComponent._rope).name}' (ID: {((Object)ropeCutterComponent._rope).GetInstanceID()}) destroyed via PhotonNetwork.Destroy by owner.");
}
else if (!((MonoBehaviourPun)ropeCutterComponent).photonView.IsMine)
{
string[] obj = new string[5] { "[RopeCutterMod] Not the owner of rope '", null, null, null, null };
Rope? rope = ropeCutterComponent._rope;
obj[1] = ((rope != null) ? ((Object)rope).name : null) ?? "NULL";
obj[2] = "' (ID: ";
Rope? rope2 = ropeCutterComponent._rope;
obj[3] = ((rope2 != null) ? ((Object)rope2).GetInstanceID().ToString() : null) ?? "N/A";
obj[4] = "). Owner will handle destruction.";
Debug.Log((object)string.Concat(obj));
}
else
{
Debug.LogError((object)"[RopeCutterMod] ERROR: _rope is NULL during final destruction attempt. This state should not be reached if previous checks are correct.");
}
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();
}
}
private Rope? _rope;
private Coroutine? _fadeCoroutine;
private Dictionary<Material, FadeRendererInfo> _fadeMaterialInfos = new Dictionary<Material, FadeRendererInfo>();
private void Awake()
{
_rope = ((Component)this).GetComponent<Rope>();
Debug.Log((object)$"[RopeCutterMod] RopeCutterComponent Awake on {((Object)((Component)this).gameObject).name}. Rope reference set: {(Object)(object)_rope != (Object)null}.");
}
public void OnOwnershipRequest(PhotonView targetView, Player requestingPlayer)
{
Debug.Log((object)("[RopeCutterMod] OnOwnershipRequest received for " + ((Object)targetView).name + " from " + requestingPlayer.NickName + ". Granting ownership."));
if ((Object)(object)targetView == (Object)(object)((MonoBehaviourPun)this).photonView)
{
((MonoBehaviourPun)this).photonView.TransferOwnership(requestingPlayer);
}
}
public void OnOwnershipTransfered(PhotonView targetView, Player previousOwner)
{
Debug.Log((object)$"[RopeCutterMod] OnOwnershipTransfered for {((Object)targetView).name} from {previousOwner.NickName}. Is Local Player now owner: {PhotonNetwork.LocalPlayer == targetView.Owner}.");
if ((Object)(object)targetView == (Object)(object)((MonoBehaviourPun)this).photonView && PhotonNetwork.LocalPlayer == targetView.Owner)
{
Debug.Log((object)("[RopeCutterMod] OWNERSHIP TRANSFERRED TO ME for rope: " + ((Object)targetView).name + ". Please try pressing the cut key again."));
}
}
public void OnOwnershipTransferFailed(PhotonView targetView, Player senderOfFailedRequest)
{
Debug.LogWarning((object)("[RopeCutterMod] OnOwnershipTransferFailed for " + ((Object)targetView).name + " to " + senderOfFailedRequest.NickName + "."));
}
[PunRPC]
public void CutRope_RPC(int segmentIndexToCut)
{
//IL_01f7: Unknown result type (might be due to invalid IL or missing references)
//IL_01fd: Invalid comparison between Unknown and I4
//IL_0246: Unknown result type (might be due to invalid IL or missing references)
Debug.Log((object)$"[RopeCutterMod] RPC 'CutRope_RPC' received for segment index: {segmentIndexToCut}. Executing on {PhotonNetwork.LocalPlayer.NickName}. Is this client owner: {((MonoBehaviourPun)this).photonView.IsMine}.");
if ((Object)(object)_rope == (Object)null)
{
Debug.LogError((object)"[RopeCutterMod] ERROR: Rope reference is NULL in CutRope_RPC. Cannot proceed with cutting.");
return;
}
Debug.Log((object)("[RopeCutterMod] Initiating rope cut process for rope: " + ((Object)_rope).name + ". Setting isClimbable to FALSE."));
_rope.isClimbable = false;
List<Transform> ropeSegments = _rope.GetRopeSegments();
Debug.Log((object)$"[RopeCutterMod] Total rope segments found: {ropeSegments.Count}.");
if (ropeSegments.Any())
{
Transform val = null;
int num = Mathf.Clamp(segmentIndexToCut, 0, ropeSegments.Count - 1);
val = ropeSegments[num];
Debug.Log((object)$"[RopeCutterMod] Target segment for physical cut (index {num}): {((Object)val).name}.");
if ((Object)(object)val != (Object)null)
{
Rigidbody component = ((Component)val).GetComponent<Rigidbody>();
if ((Object)(object)component != (Object)null)
{
component.isKinematic = false;
component.useGravity = true;
Debug.Log((object)("[RopeCutterMod] Segment " + ((Object)val).name + ": Rigidbody set to non-kinematic (false) and useGravity (true)."));
}
else
{
Debug.LogWarning((object)("[RopeCutterMod] Segment " + ((Object)val).name + " has no Rigidbody. Cannot apply physics effects."));
}
Collider component2 = ((Component)val).GetComponent<Collider>();
if ((Object)(object)component2 != (Object)null)
{
component2.enabled = false;
Debug.Log((object)("[RopeCutterMod] Segment " + ((Object)val).name + ": Collider disabled."));
}
else
{
Debug.LogWarning((object)("[RopeCutterMod] Segment " + ((Object)val).name + " has no Collider."));
}
ConfigurableJoint component3 = ((Component)val).GetComponent<ConfigurableJoint>();
if ((Object)(object)component3 != (Object)null)
{
((Joint)component3).connectedBody = null;
component3.xMotion = (ConfigurableJointMotion)2;
component3.yMotion = (ConfigurableJointMotion)2;
component3.zMotion = (ConfigurableJointMotion)2;
Debug.Log((object)("[RopeCutterMod] Segment " + ((Object)val).name + ": Joint detached and motions set to Free."));
}
else
{
Debug.LogWarning((object)("[RopeCutterMod] Segment " + ((Object)val).name + " has no ConfigurableJoint. Cannot detach from previous segment."));
}
if ((int)_rope.attachmenState == 2)
{
Debug.Log((object)("[RopeCutterMod] Rope was anchored. Calling Detach_Rpc on rope " + ((Object)_rope).name + " via its PhotonView."));
_rope.view.RPC("Detach_Rpc", (RpcTarget)0, Array.Empty<object>());
}
else
{
Debug.Log((object)$"[RopeCutterMod] Rope was not anchored. Attachment state: {_rope.attachmenState}. No Detach_Rpc needed.");
}
}
else
{
Debug.LogWarning((object)"[RopeCutterMod] No valid segment to affect found after index selection logic. This should not happen.");
}
if (_fadeCoroutine != null)
{
((MonoBehaviour)this).StopCoroutine(_fadeCoroutine);
Debug.Log((object)"[RopeCutterMod] Stopped previous fade coroutine.");
}
_fadeCoroutine = ((MonoBehaviour)this).StartCoroutine(FadeOutAndDestroyRope());
Debug.Log((object)"[RopeCutterMod] Started FadeOutAndDestroyRope coroutine.");
}
else
{
Debug.LogWarning((object)"[RopeCutterMod] No rope segments available to cut. Is rope initialized?");
}
}
[IteratorStateMachine(typeof(<FadeOutAndDestroyRope>d__8))]
private IEnumerator FadeOutAndDestroyRope()
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <FadeOutAndDestroyRope>d__8(0)
{
<>4__this = this
};
}
}
public static class PluginInfo
{
public const string PLUGIN_GUID = "com.xammen.ropecut";
public const string PLUGIN_NAME = "RopeCut";
public const string PLUGIN_VERSION = "1.1.2";
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
public IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}