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 RustyBots v0.1.0
plugins/RustyBots.dll
Decompiled 2 hours ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.IO; using System.Linq; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Cryptography; using System.Security.Permissions; using System.Text; using BepInEx; using BepInEx.Configuration; using ExitGames.Client.Photon; using HarmonyLib; using MenuLib; using MenuLib.MonoBehaviors; using MenuLib.Structs; using Microsoft.CodeAnalysis; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using Photon.Pun; using Photon.Realtime; using REPOLib.Modules; using TMPro; using UnityEngine; using UnityEngine.Rendering; using UnityEngine.SceneManagement; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: IgnoresAccessChecksTo("Assembly-CSharp")] [assembly: AssemblyCompany("RustyBots")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("0.1.0.0")] [assembly: AssemblyInformationalVersion("0.1.0")] [assembly: AssemblyProduct("RustyBots")] [assembly: AssemblyTitle("RustyBots")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.1.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [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] [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] [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 RustyBots { internal sealed class AvatarAnatomy { private sealed class SlotMaterialBinding { public Part Part; public bool IsTorso; public Material SourceMaterial; public Material WrapperMaterial; } private static readonly int AlbedoColorId = Shader.PropertyToID("_AlbedoColor"); private static readonly int BaseColorId = Shader.PropertyToID("_Color"); private static readonly int EmissionColorId = Shader.PropertyToID("_EmissionColor"); private static readonly int FresnelColorId = Shader.PropertyToID("_FresnelColor"); private static readonly int SmoothnessId = Shader.PropertyToID("_Glossiness"); private static readonly Color RustTintLight = new Color(0.68f, 0.3f, 0.11f, 1f); private static readonly Color RustTintHeavy = new Color(0.38f, 0.14f, 0.06f, 1f); private readonly PlayerAvatar _avatar; private readonly MeshRenderer?[] _limbRenderers = (MeshRenderer?[])(object)new MeshRenderer[4]; private readonly List<MeshRenderer> _headRenderers = new List<MeshRenderer>(); private readonly GameObject?[] _stumpCaps = (GameObject?[])(object)new GameObject[4]; private readonly Dictionary<MeshRenderer, SlotMaterialBinding> _slotMaterials = new Dictionary<MeshRenderer, SlotMaterialBinding>(); private readonly Dictionary<Renderer, bool> _hiddenCosmeticRenderers = new Dictionary<Renderer, bool>(); private bool _wasRightArmDisabled; private Light? _suppressedGrabberLight; private bool _savedGrabberLightEnabled; private bool _wasLeftArmDisabled; private bool _savedHideFlashlight; private float _nextOneLegHopTime; private float _nextRollImpulseTime; public PlayerAvatar Avatar => _avatar; public bool IsValid { get { if (Object.op_Implicit((Object)(object)_avatar) && Object.op_Implicit((Object)(object)_avatar.playerAvatarVisuals)) { return Object.op_Implicit((Object)(object)_avatar.playerAvatarVisuals.meshParent); } return false; } } public IReadOnlyList<MeshRenderer> HeadRenderers => _headRenderers; internal static bool IsUpperTorsoMesh(string name) { switch (name) { case "mesh_body_top": case "mesh_body_top_sphere": case "mesh_body_top_flat": return true; default: return false; } } public AvatarAnatomy(PlayerAvatar avatar) { _avatar = avatar; BindRenderers(); } public void BindRenderers() { //IL_01e0: Unknown result type (might be due to invalid IL or missing references) //IL_01f4: Unknown result type (might be due to invalid IL or missing references) //IL_0231: Unknown result type (might be due to invalid IL or missing references) //IL_0245: Unknown result type (might be due to invalid IL or missing references) //IL_0282: Unknown result type (might be due to invalid IL or missing references) //IL_0296: Unknown result type (might be due to invalid IL or missing references) //IL_02d3: Unknown result type (might be due to invalid IL or missing references) //IL_02e7: Unknown result type (might be due to invalid IL or missing references) if (!IsValid) { return; } Transform transform = _avatar.playerAvatarVisuals.meshParent.transform; _headRenderers.Clear(); MeshRenderer[] componentsInChildren = ((Component)transform).GetComponentsInChildren<MeshRenderer>(true); foreach (MeshRenderer val in componentsInChildren) { if (!Object.op_Implicit((Object)(object)val)) { continue; } string name = ((Object)val).name; if (name != null) { int length = name.Length; if (length > 13) { if (length != 18) { if (length != 20 || !(name == "mesh_head_bot_sphere")) { goto IL_0147; } } else if (!(name == "mesh_head_bot_flat")) { goto IL_0147; } goto IL_02f8; } if (length != 10) { if (length == 13) { char c = name[5]; if (c != 'b') { if (c == 'h' && name == "mesh_head_top") { goto IL_02f8; } } else if (name == "mesh_body_bot") { goto IL_031a; } } } else { switch (name[5]) { case 'a': if (!(name == "mesh_arm_l")) { if (!(name == "mesh_arm_r")) { break; } _limbRenderers[1] = val; BindSlotMaterial(val, Part.RightArm); EnsureStumpCap(Part.RightArm, ((Component)val).transform, new Vector3(0f, 0.14f, 0f), Quaternion.Euler(-90f, 0f, 0f), 0.85f); continue; } _limbRenderers[0] = val; BindSlotMaterial(val, Part.LeftArm); EnsureStumpCap(Part.LeftArm, ((Component)val).transform, new Vector3(0f, 0.14f, 0f), Quaternion.Euler(-90f, 0f, 0f), 0.85f); continue; case 'l': if (!(name == "mesh_leg_l")) { if (!(name == "mesh_leg_r")) { break; } _limbRenderers[3] = val; BindSlotMaterial(val, Part.RightLeg); EnsureStumpCap(Part.RightLeg, ((Component)val).transform, new Vector3(0f, 0.16f, 0f), Quaternion.Euler(90f, 0f, 0f), 0.9f); continue; } _limbRenderers[2] = val; BindSlotMaterial(val, Part.LeftLeg); EnsureStumpCap(Part.LeftLeg, ((Component)val).transform, new Vector3(0f, 0.16f, 0f), Quaternion.Euler(90f, 0f, 0f), 0.9f); continue; } } } goto IL_0147; IL_0147: if (name == null) { continue; } if (!IsUpperTorsoMesh(name)) { switch (name) { case "mesh_eye_l": case "mesh_eye_r": case "mesh_pupil_l": case "mesh_pupil_r": case "eyelid_upper_mesh": case "eyelid_lower_mesh": _headRenderers.Add(val); break; } continue; } goto IL_031a; IL_031a: BindSlotMaterial(val, Part.Head, isTorso: true); continue; IL_02f8: _headRenderers.Add(val); BindSlotMaterial(val, Part.Head); } } internal Material[] GetUnrustedMaterials(MeshRenderer renderer) { Material[] sharedMaterials = ((Renderer)renderer).sharedMaterials; if (sharedMaterials.Length != 0 && _slotMaterials.TryGetValue(renderer, out SlotMaterialBinding value) && (Object)(object)sharedMaterials[0] == (Object)(object)value.WrapperMaterial && Object.op_Implicit((Object)(object)value.SourceMaterial)) { sharedMaterials[0] = value.SourceMaterial; } return sharedMaterials; } private void BindSlotMaterial(MeshRenderer renderer, Part part, bool isTorso = false) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Expected O, but got Unknown if (!_slotMaterials.ContainsKey(renderer) && Object.op_Implicit((Object)(object)((Renderer)renderer).sharedMaterial)) { Material sharedMaterial = ((Renderer)renderer).sharedMaterial; Material wrapperMaterial = (((Renderer)renderer).sharedMaterial = new Material(sharedMaterial) { name = ((Object)sharedMaterial).name + "_RustSlot_" + (isTorso ? "Torso" : part.ToString()) }); _slotMaterials[renderer] = new SlotMaterialBinding { Part = part, IsTorso = isTorso, SourceMaterial = sharedMaterial, WrapperMaterial = wrapperMaterial }; } } private void EnsureStumpCap(Part part, Transform limbMeshTransform, Vector3 localOffset, Quaternion localRot, float scale) { //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Expected O, but got Unknown //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0054: 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_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)_stumpCaps[(int)part] != (Object)null) && Object.op_Implicit((Object)(object)limbMeshTransform.parent)) { GameObject val = new GameObject($"RustyBots_Stump_{part}"); val.transform.SetParent(limbMeshTransform.parent, false); val.transform.localPosition = limbMeshTransform.localPosition + localOffset; val.transform.localRotation = localRot; val.transform.localScale = Vector3.one * scale; ModVisuals.AttachModel("joint_cap", val.transform, addMeshCollider: false, 5f, out GameObject _); val.SetActive(false); _stumpCaps[(int)part] = val; } } public Vector3 GetPartWorldPosition(Part part) { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0104: 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_010a: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0071: 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_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) if (!IsValid) { if (!Object.op_Implicit((Object)(object)_avatar)) { return Vector3.zero; } return ((Component)_avatar).transform.position + Vector3.up * 0.8f; } if (part == Part.Head) { Transform headUpTransform = _avatar.playerAvatarVisuals.headUpTransform; if (Object.op_Implicit((Object)(object)headUpTransform)) { return headUpTransform.position + headUpTransform.up * 0.15f; } if (_headRenderers.Count > 0 && Object.op_Implicit((Object)(object)_headRenderers[0])) { Bounds bounds = ((Renderer)_headRenderers[0]).bounds; return ((Bounds)(ref bounds)).center; } return ((Component)_avatar).transform.position + Vector3.up * 1.35f; } MeshRenderer val = _limbRenderers[(int)part]; if (Object.op_Implicit((Object)(object)val)) { return ((Component)val).transform.position; } Vector3 position = ((Component)_avatar).transform.position; Vector3 up = Vector3.up; bool flag = (uint)(part - 2) <= 1u; return position + up * (flag ? 0.35f : 0.9f); } public Quaternion GetPartWorldRotation(Part part) { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_008e: 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_007d: Unknown result type (might be due to invalid IL or missing references) if (!IsValid) { if (!Object.op_Implicit((Object)(object)_avatar)) { return Quaternion.identity; } return ((Component)_avatar).transform.rotation; } if (part == Part.Head && Object.op_Implicit((Object)(object)_avatar.playerAvatarVisuals.headUpTransform)) { return _avatar.playerAvatarVisuals.headUpTransform.rotation; } if (part != Part.Head && Object.op_Implicit((Object)(object)_limbRenderers[(int)part])) { return ((Component)_limbRenderers[(int)part]).transform.rotation; } return ((Component)_avatar).transform.rotation; } public MeshRenderer? GetLimbRenderer(Part part) { if (part != Part.Head) { return _limbRenderers[(int)part]; } if (_headRenderers.Count <= 0) { return null; } return _headRenderers[0]; } public Color GetAvatarBodyColor() { //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)_avatar) && Object.op_Implicit((Object)(object)_avatar.playerCosmetics) && Object.op_Implicit((Object)(object)MetaManager.instance)) { int[] colorsEquipped = _avatar.playerCosmetics.colorsEquipped; if (colorsEquipped != null && colorsEquipped.Length > 5) { int num = _avatar.playerCosmetics.colorsEquipped[5]; if (num >= 0 && num < MetaManager.instance.colors.Count) { return MetaManager.instance.colors[num].color; } } } MeshRenderer val = _limbRenderers[0] ?? _limbRenderers[1]; if (Object.op_Implicit((Object)(object)val) && _slotMaterials.TryGetValue(val, out SlotMaterialBinding value) && Object.op_Implicit((Object)(object)value.SourceMaterial)) { if (value.SourceMaterial.HasProperty(AlbedoColorId)) { return value.SourceMaterial.GetColor(AlbedoColorId); } if (value.SourceMaterial.HasProperty(BaseColorId)) { return value.SourceMaterial.GetColor(BaseColorId); } } return new Color(0.88f, 0.58f, 0.14f, 1f); } public void ApplyTick(RustState state, RustConfig cfg) { //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_01df: Unknown result type (might be due to invalid IL or missing references) //IL_01e4: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_02d2: Unknown result type (might be due to invalid IL or missing references) //IL_02d7: Unknown result type (might be due to invalid IL or missing references) //IL_02de: Unknown result type (might be due to invalid IL or missing references) //IL_02e3: Unknown result type (might be due to invalid IL or missing references) //IL_02e5: Unknown result type (might be due to invalid IL or missing references) //IL_02e7: Unknown result type (might be due to invalid IL or missing references) //IL_02f1: Unknown result type (might be due to invalid IL or missing references) //IL_02f6: Unknown result type (might be due to invalid IL or missing references) //IL_0317: Unknown result type (might be due to invalid IL or missing references) //IL_031c: Unknown result type (might be due to invalid IL or missing references) //IL_032a: Unknown result type (might be due to invalid IL or missing references) //IL_0331: Unknown result type (might be due to invalid IL or missing references) //IL_0338: Unknown result type (might be due to invalid IL or missing references) //IL_033f: Unknown result type (might be due to invalid IL or missing references) //IL_0346: Unknown result type (might be due to invalid IL or missing references) //IL_0551: Unknown result type (might be due to invalid IL or missing references) //IL_0557: Invalid comparison between Unknown and I4 //IL_036f: Unknown result type (might be due to invalid IL or missing references) //IL_0374: Unknown result type (might be due to invalid IL or missing references) //IL_0382: Unknown result type (might be due to invalid IL or missing references) //IL_0389: Unknown result type (might be due to invalid IL or missing references) //IL_0390: Unknown result type (might be due to invalid IL or missing references) //IL_0397: Unknown result type (might be due to invalid IL or missing references) //IL_039e: Unknown result type (might be due to invalid IL or missing references) //IL_03c7: Unknown result type (might be due to invalid IL or missing references) //IL_03cc: Unknown result type (might be due to invalid IL or missing references) //IL_03ce: Unknown result type (might be due to invalid IL or missing references) //IL_03d0: Unknown result type (might be due to invalid IL or missing references) //IL_03d7: Unknown result type (might be due to invalid IL or missing references) //IL_03e4: Unknown result type (might be due to invalid IL or missing references) //IL_03e9: Unknown result type (might be due to invalid IL or missing references) //IL_03f7: Unknown result type (might be due to invalid IL or missing references) //IL_03fe: Unknown result type (might be due to invalid IL or missing references) //IL_0405: Unknown result type (might be due to invalid IL or missing references) //IL_040c: Unknown result type (might be due to invalid IL or missing references) //IL_0413: Unknown result type (might be due to invalid IL or missing references) //IL_043c: Unknown result type (might be due to invalid IL or missing references) //IL_0441: Unknown result type (might be due to invalid IL or missing references) //IL_0443: Unknown result type (might be due to invalid IL or missing references) //IL_0445: Unknown result type (might be due to invalid IL or missing references) //IL_044c: Unknown result type (might be due to invalid IL or missing references) //IL_0459: Unknown result type (might be due to invalid IL or missing references) //IL_045e: Unknown result type (might be due to invalid IL or missing references) //IL_046c: 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_047a: Unknown result type (might be due to invalid IL or missing references) //IL_0481: Unknown result type (might be due to invalid IL or missing references) //IL_0488: Unknown result type (might be due to invalid IL or missing references) if (!IsValid) { return; } if ((Object)(object)_limbRenderers[0] == (Object)null && (Object)(object)_limbRenderers[1] == (Object)null) { BindRenderers(); } bool flag = !_avatar.playerAvatarVisuals.isMenuAvatar && (!GameManager.Multiplayer() || _avatar.photonView.IsMine) && !_avatar.playerAvatarVisuals.ShowSelfCheck(); ShadowCastingMode shadowCastingMode = (ShadowCastingMode)((!flag) ? 1 : 3); int num = LayerMask.NameToLayer("PlayerVisualsLocal"); for (int i = 0; i < 4; i++) { Part part = (Part)i; bool flag2 = state.Detached(part); MeshRenderer val = _limbRenderers[i]; if (Object.op_Implicit((Object)(object)val) && ((Renderer)val).enabled == flag2) { ((Renderer)val).enabled = !flag2; } GameObject val2 = _stumpCaps[i]; if (!Object.op_Implicit((Object)(object)val2)) { continue; } bool flag3 = flag2 && !_avatar.isDisabled; if (val2.activeSelf != flag3) { val2.SetActive(flag3); } if (!flag3) { continue; } Renderer[] componentsInChildren = val2.GetComponentsInChildren<Renderer>(); foreach (Renderer val3 in componentsInChildren) { if (flag && num >= 0) { ((Component)val3).gameObject.layer = num; } val3.shadowCastingMode = shadowCastingMode; } } bool flag4 = state.Detached(Part.Head); foreach (MeshRenderer headRenderer in _headRenderers) { if (Object.op_Implicit((Object)(object)headRenderer) && flag4 && ((Renderer)headRenderer).enabled) { ((Renderer)headRenderer).enabled = false; } else if (Object.op_Implicit((Object)(object)headRenderer) && !flag4 && !((Renderer)headRenderer).enabled && ((Component)headRenderer).gameObject.activeInHierarchy) { ((Renderer)headRenderer).enabled = true; } } SyncCosmeticPartVisibility(state); Color avatarBodyColor = GetAvatarBodyColor(); float num2 = state.TotalRust / 5f; foreach (KeyValuePair<MeshRenderer, SlotMaterialBinding> slotMaterial in _slotMaterials) { MeshRenderer key = slotMaterial.Key; SlotMaterialBinding value = slotMaterial.Value; if (!Object.op_Implicit((Object)(object)key) || !Object.op_Implicit((Object)(object)value.WrapperMaterial)) { continue; } if ((Object)(object)((Renderer)key).sharedMaterial != (Object)null && (Object)(object)((Renderer)key).sharedMaterial != (Object)(object)value.WrapperMaterial) { value.SourceMaterial = ((Renderer)key).sharedMaterial; ((Renderer)key).sharedMaterial = value.WrapperMaterial; } if (Object.op_Implicit((Object)(object)value.SourceMaterial)) { value.WrapperMaterial.CopyPropertiesFromMaterial(value.SourceMaterial); } float num3 = Mathf.Clamp01((value.IsTorso ? num2 : state.Rust(value.Part)) / 100f); if (num3 > 0.005f) { Color val4 = Color.Lerp(RustTintLight, RustTintHeavy, num3); Color val5 = Color.Lerp(avatarBodyColor, val4, num3 * 0.88f); if (value.WrapperMaterial.HasProperty(AlbedoColorId)) { Color color = value.WrapperMaterial.GetColor(AlbedoColorId); value.WrapperMaterial.SetColor(AlbedoColorId, new Color(val5.r, val5.g, val5.b, color.a)); } if (value.WrapperMaterial.HasProperty(BaseColorId)) { Color color2 = value.WrapperMaterial.GetColor(BaseColorId); value.WrapperMaterial.SetColor(BaseColorId, new Color(val5.r, val5.g, val5.b, color2.a)); } if (value.WrapperMaterial.HasProperty(EmissionColorId)) { Color color3 = value.WrapperMaterial.GetColor(EmissionColorId); Color val6 = Color.Lerp(color3, val4 * 0.28f, num3 * 0.9f); value.WrapperMaterial.SetColor(EmissionColorId, new Color(val6.r, val6.g, val6.b, color3.a)); } if (value.WrapperMaterial.HasProperty(FresnelColorId)) { Color color4 = value.WrapperMaterial.GetColor(FresnelColorId); Color val7 = Color.Lerp(color4, val4 * 0.55f, num3 * 0.85f); value.WrapperMaterial.SetColor(FresnelColorId, new Color(val7.r, val7.g, val7.b, color4.a)); } if (value.WrapperMaterial.HasProperty(SmoothnessId)) { float num4 = value.WrapperMaterial.GetFloat(SmoothnessId); value.WrapperMaterial.SetFloat(SmoothnessId, Mathf.Lerp(num4, 0.03f, num3)); } } } EnforceRightArmDevice(state); if (_avatar.isLocal && !_avatar.isDisabled && !_avatar.deadSet && Object.op_Implicit((Object)(object)LevelGenerator.Instance) && LevelGenerator.Instance.Generated && !SemiFunc.MenuLevel() && Object.op_Implicit((Object)(object)GameDirector.instance) && (int)GameDirector.instance.currentState == 2) { EnforceLocalLegLocomotion(state, cfg); } } public void ApplyLateTick(RustState state) { if (!Object.op_Implicit((Object)(object)_avatar)) { return; } FlashlightController flashlightController = _avatar.flashlightController; if (Object.op_Implicit((Object)(object)flashlightController)) { if (!state.CanUseFlashlight) { if (!_wasLeftArmDisabled) { _savedHideFlashlight = flashlightController.hideFlashlight; _wasLeftArmDisabled = true; } flashlightController.hideFlashlight = true; if (Object.op_Implicit((Object)(object)flashlightController.spotlight)) { ((Behaviour)flashlightController.spotlight).enabled = false; } if (Object.op_Implicit((Object)(object)flashlightController.halo)) { flashlightController.halo.enabled = false; } if (Object.op_Implicit((Object)(object)flashlightController.mesh)) { ((Renderer)flashlightController.mesh).enabled = false; } if (Object.op_Implicit((Object)(object)flashlightController.meshShadows)) { ((Renderer)flashlightController.meshShadows).enabled = false; } flashlightController.LightActive = false; } else { if (_wasLeftArmDisabled) { flashlightController.hideFlashlight = _savedHideFlashlight; _wasLeftArmDisabled = false; } float num = state.Rust(Part.LeftArm) / 100f; if (num > 0.25f && Object.op_Implicit((Object)(object)flashlightController.spotlight) && flashlightController.LightActive) { float num2 = 1f - (num - 0.25f) * 0.45f; Light spotlight = flashlightController.spotlight; spotlight.intensity *= Mathf.Clamp(num2, 0.45f, 1f); } } } if (!state.CanUseGrabber && Object.op_Implicit((Object)(object)_avatar.playerAvatarVisuals) && Object.op_Implicit((Object)(object)_avatar.playerAvatarVisuals.playerAvatarRightArm)) { PlayerAvatarRightArm playerAvatarRightArm = _avatar.playerAvatarVisuals.playerAvatarRightArm; if (Object.op_Implicit((Object)(object)playerAvatarRightArm.grabberClawParent) && ((Component)playerAvatarRightArm.grabberClawParent).gameObject.activeSelf) { ((Component)playerAvatarRightArm.grabberClawParent).gameObject.SetActive(false); } if (Object.op_Implicit((Object)(object)playerAvatarRightArm.grabberLight)) { if ((Object)(object)_suppressedGrabberLight != (Object)(object)playerAvatarRightArm.grabberLight) { RestoreGrabberLight(); _suppressedGrabberLight = playerAvatarRightArm.grabberLight; _savedGrabberLightEnabled = ((Behaviour)playerAvatarRightArm.grabberLight).enabled; } ((Behaviour)playerAvatarRightArm.grabberLight).enabled = false; } } else { RestoreGrabberLight(); } } private void RestoreGrabberLight() { if (Object.op_Implicit((Object)(object)_suppressedGrabberLight)) { ((Behaviour)_suppressedGrabberLight).enabled = _savedGrabberLightEnabled; } _suppressedGrabberLight = null; } private void EnforceRightArmDevice(RustState state) { if (!Object.op_Implicit((Object)(object)_avatar.physGrabber)) { return; } if (!state.CanUseGrabber) { if (!_wasRightArmDisabled || _avatar.physGrabber.grabbed) { if (_avatar.isLocal || SemiFunc.IsMasterClientOrSingleplayer()) { _avatar.physGrabber.OverrideGrabRelease(-1, 0.35f); } _wasRightArmDisabled = true; } _avatar.physGrabber.OverrideGrabDisable(0.3f); } else if (_wasRightArmDisabled) { _wasRightArmDisabled = false; } } private void EnforceLocalLegLocomotion(RustState state, RustConfig cfg) { //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_0241: Unknown result type (might be due to invalid IL or missing references) //IL_0246: Unknown result type (might be due to invalid IL or missing references) //IL_024b: Unknown result type (might be due to invalid IL or missing references) //IL_0250: Unknown result type (might be due to invalid IL or missing references) //IL_0254: Unknown result type (might be due to invalid IL or missing references) //IL_0259: Unknown result type (might be due to invalid IL or missing references) //IL_025b: Unknown result type (might be due to invalid IL or missing references) //IL_0260: Unknown result type (might be due to invalid IL or missing references) //IL_0265: Unknown result type (might be due to invalid IL or missing references) //IL_026a: Unknown result type (might be due to invalid IL or missing references) //IL_026e: Unknown result type (might be due to invalid IL or missing references) //IL_0273: Unknown result type (might be due to invalid IL or missing references) //IL_0275: Unknown result type (might be due to invalid IL or missing references) //IL_0277: Unknown result type (might be due to invalid IL or missing references) //IL_027e: Unknown result type (might be due to invalid IL or missing references) //IL_0283: Unknown result type (might be due to invalid IL or missing references) //IL_0285: Unknown result type (might be due to invalid IL or missing references) //IL_028c: Unknown result type (might be due to invalid IL or missing references) //IL_0291: Unknown result type (might be due to invalid IL or missing references) //IL_0296: Unknown result type (might be due to invalid IL or missing references) //IL_029a: Unknown result type (might be due to invalid IL or missing references) //IL_029f: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_02ba: Unknown result type (might be due to invalid IL or missing references) //IL_02c1: Unknown result type (might be due to invalid IL or missing references) //IL_02cb: Unknown result type (might be due to invalid IL or missing references) //IL_02d0: Unknown result type (might be due to invalid IL or missing references) //IL_02d2: Unknown result type (might be due to invalid IL or missing references) //IL_02d7: Unknown result type (might be due to invalid IL or missing references) //IL_02e4: Unknown result type (might be due to invalid IL or missing references) //IL_02eb: Unknown result type (might be due to invalid IL or missing references) PlayerController instance = PlayerController.instance; if (!Object.op_Implicit((Object)(object)instance) || (Object)(object)instance.playerAvatarScript != (Object)(object)_avatar) { return; } if (state.CanHopOnOneLeg && !_avatar.isTumbling) { if (SemiFunc.InputDown((InputKey)1) && Object.op_Implicit((Object)(object)instance.CollisionController) && instance.CollisionController.Grounded && Time.time >= _nextOneLegHopTime && instance.InputDisableTimer <= 0f) { _nextOneLegHopTime = Time.time + 0.42f; Vector3 val = default(Vector3); ((Vector3)(ref val))..ctor(SemiFunc.InputMovementX(), 0f, SemiFunc.InputMovementY()); Vector3 val2 = ((((Vector3)(ref val)).sqrMagnitude > 0.01f) ? ((Component)instance).transform.TransformDirection(((Vector3)(ref val)).normalized) : (((Component)instance).transform.forward * 0.5f)); float num = RustMechanics.LegSpeedMultiplier(state, Plugin.Instance?.Network.LegPenalty ?? cfg.MaxLegSpeedPenalty.Value); instance.ForceImpulse(val2 * (4.2f * num) + Vector3.up * 1.4f); } } else { if (!state.MustRollWithoutLegs) { return; } Vector2 val3 = default(Vector2); ((Vector2)(ref val3))..ctor(SemiFunc.InputMovementX(), SemiFunc.InputMovementY()); if (((Vector2)(ref val3)).sqrMagnitude > 0.02f && instance.InputDisableTimer <= 0f && !GameDirector.instance.DisableInput && Object.op_Implicit((Object)(object)_avatar.tumble) && _avatar.tumble.setup) { if (!_avatar.isTumbling) { _avatar.tumble.TumbleRequest(true, false); } _avatar.tumble.OverrideTumbleUIDisable(0.25f); _avatar.tumble.TumbleOverrideTime(0.35f); if (Time.time >= _nextRollImpulseTime) { _nextRollImpulseTime = Time.time + 0.14f; Transform obj = (Object.op_Implicit((Object)(object)_avatar.localCamera) ? _avatar.localCamera.GetOverrideTransform() : ((Component)instance).transform); Vector3 val4 = Vector3.ProjectOnPlane(obj.forward, Vector3.up); Vector3 normalized = ((Vector3)(ref val4)).normalized; val4 = Vector3.ProjectOnPlane(obj.right, Vector3.up); Vector3 normalized2 = ((Vector3)(ref val4)).normalized; val4 = normalized * val3.y + normalized2 * val3.x; Vector3 normalized3 = ((Vector3)(ref val4)).normalized; if (((Vector3)(ref normalized3)).sqrMagnitude > 0.01f) { _avatar.tumble.TumbleForce(normalized3 * 2.15f); Vector3 val5 = Vector3.Cross(Vector3.up, normalized3); _avatar.tumble.TumbleTorque(val5 * 1.85f); } } } else if (!_avatar.isTumbling) { instance.CrouchOverride(0.15f); } } } private void SyncCosmeticPartVisibility(RustState state) { //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Expected I4, but got Unknown PlayerCosmetics val = (Object.op_Implicit((Object)(object)_avatar) ? _avatar.playerCosmetics : null); if (!Object.op_Implicit((Object)(object)val) || val.cosmeticParents == null) { return; } Renderer[] componentsInChildren; foreach (CosmeticParent cosmeticParent in val.cosmeticParents) { if (cosmeticParent == null || !Object.op_Implicit((Object)(object)cosmeticParent.parent)) { continue; } CosmeticType cosmeticType = cosmeticParent.cosmeticType; Part? part; switch ((int)cosmeticType) { case 2: case 10: part = Part.LeftArm; break; case 1: case 9: case 13: part = Part.RightArm; break; case 4: case 12: part = Part.LeftLeg; break; case 3: case 11: part = Part.RightLeg; break; case 0: case 5: case 6: case 14: case 15: part = Part.Head; break; default: part = null; break; } Part? part2 = part; if (!part2.HasValue) { continue; } bool flag = state.Detached(part2.Value); componentsInChildren = ((Component)cosmeticParent.parent).GetComponentsInChildren<Renderer>(true); foreach (Renderer val2 in componentsInChildren) { if (!Object.op_Implicit((Object)(object)val2) || ((Object)val2).name.StartsWith("RustyBots_", StringComparison.Ordinal)) { continue; } Transform parent = ((Component)val2).transform.parent; if (parent != null && ((Object)parent).name.StartsWith("RustyBots_", StringComparison.Ordinal)) { continue; } if (flag) { if (val2.enabled) { _hiddenCosmeticRenderers[val2] = true; val2.enabled = false; } } else if (_hiddenCosmeticRenderers.Remove(val2)) { val2.enabled = true; } } } if (!Object.op_Implicit((Object)(object)val.playerCrown)) { return; } bool flag2 = state.Detached(Part.Head); componentsInChildren = ((Component)val.playerCrown).GetComponentsInChildren<Renderer>(true); foreach (Renderer val3 in componentsInChildren) { if (Object.op_Implicit((Object)(object)val3)) { if (flag2 && val3.enabled) { _hiddenCosmeticRenderers[val3] = true; val3.enabled = false; } else if (!flag2 && _hiddenCosmeticRenderers.Remove(val3)) { val3.enabled = true; } } } } public void Cleanup() { RestoreGrabberLight(); foreach (KeyValuePair<Renderer, bool> hiddenCosmeticRenderer in _hiddenCosmeticRenderers) { if (Object.op_Implicit((Object)(object)hiddenCosmeticRenderer.Key)) { hiddenCosmeticRenderer.Key.enabled = true; } } _hiddenCosmeticRenderers.Clear(); foreach (KeyValuePair<MeshRenderer, SlotMaterialBinding> slotMaterial in _slotMaterials) { if (Object.op_Implicit((Object)(object)slotMaterial.Key) && Object.op_Implicit((Object)(object)slotMaterial.Value.SourceMaterial)) { ((Renderer)slotMaterial.Key).sharedMaterial = slotMaterial.Value.SourceMaterial; } if (Object.op_Implicit((Object)(object)slotMaterial.Value.WrapperMaterial)) { Object.Destroy((Object)(object)slotMaterial.Value.WrapperMaterial); } } _slotMaterials.Clear(); for (int i = 0; i < _stumpCaps.Length; i++) { if (Object.op_Implicit((Object)(object)_stumpCaps[i])) { Object.Destroy((Object)(object)_stumpCaps[i]); } } } } internal static class BodyPartValuables { private static readonly Type[] PlainValuableTypes = new Type[6] { typeof(ValuableObject), typeof(PhysGrabObject), typeof(PhysGrabObjectImpactDetector), typeof(RoomVolumeCheck), typeof(PhotonView), typeof(PhotonTransformView) }; private static readonly PrefabRef?[] Prefabs = (PrefabRef?[])(object)new PrefabRef[5]; private static GameObject? _holder; private static bool _registered; internal static void RegisterAll() { //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Expected O, but got Unknown if (_registered) { return; } GameObject obj = Resources.Load<GameObject>("Valuables/01 Tiny/Valuable Arctic Eraser"); ValuableObject val = ((obj != null) ? obj.GetComponent<ValuableObject>() : null); if (!Object.op_Implicit((Object)(object)val)) { ValuableObject[] source = Resources.LoadAll<ValuableObject>("Valuables"); val = ((IEnumerable<ValuableObject>)source).FirstOrDefault((Func<ValuableObject, bool>)((ValuableObject v) => Object.op_Implicit((Object)(object)v) && ((Object)v).name == "Valuable Arctic Eraser")) ?? ((IEnumerable<ValuableObject>)source).FirstOrDefault((Func<ValuableObject, bool>)((ValuableObject v) => Object.op_Implicit((Object)(object)v) && ((Component)v).GetComponents<MonoBehaviour>().All((MonoBehaviour m) => Object.op_Implicit((Object)(object)m) && PlainValuableTypes.Contains(((object)m).GetType())))); } if (!Object.op_Implicit((Object)(object)val)) { Plugin.LogError("Could not locate plain vanilla ValuableObject template; detached valuables disabled."); return; } _holder = new GameObject("RustyBots_PartPrefabs"); _holder.SetActive(false); Object.DontDestroyOnLoad((Object)(object)_holder); Part[] all = PartInfo.All; foreach (Part part in all) { string text = $"RustyBots/Part_{part}"; GameObject val2 = Object.Instantiate<GameObject>(((Component)val).gameObject, _holder.transform); ((Object)val2).name = "Valuable Semibot " + PartInfo.DisplayName(part); ConfigurePartTemplate(val2, part); PrefabRef val3 = NetworkPrefabs.RegisterNetworkPrefab(text, val2); if (val3 == null) { Plugin.LogError("REPOLib failed to register " + text + "."); } else { Prefabs[(int)part] = val3; } } _registered = true; Plugin.LogInfo("Registered all 5 detachable body-part valuable prefabs from " + ((Object)val).name + "."); } private static void ConfigurePartTemplate(GameObject go, Part part) { //IL_0079: 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_0091: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_0220: Unknown result type (might be due to invalid IL or missing references) Renderer[] componentsInChildren = go.GetComponentsInChildren<Renderer>(true); for (int i = 0; i < componentsInChildren.Length; i++) { componentsInChildren[i].enabled = false; } Collider[] componentsInChildren2 = go.GetComponentsInChildren<Collider>(true); for (int i = 0; i < componentsInChildren2.Length; i++) { componentsInChildren2[i].enabled = false; } PhysGrabObjectCollider componentInChildren = go.GetComponentInChildren<PhysGrabObjectCollider>(true); if (Object.op_Implicit((Object)(object)componentInChildren)) { Transform transform = ((Component)componentInChildren).transform; transform.SetParent(go.transform, false); transform.localPosition = Vector3.zero; transform.localRotation = Quaternion.identity; transform.localScale = Vector3.one; BoxCollider val = ((Component)transform).GetComponent<BoxCollider>(); if (!Object.op_Implicit((Object)(object)val)) { val = ((Component)transform).gameObject.AddComponent<BoxCollider>(); } val.center = Vector3.zero; BoxCollider val2 = val; Vector3 size; switch (part) { case Part.Head: size = new Vector3(0.42f, 0.42f, 0.44f); break; case Part.LeftLeg: case Part.RightLeg: size = new Vector3(0.24f, 0.46f, 0.26f); break; default: size = new Vector3(0.22f, 0.46f, 0.22f); break; } val2.size = size; ((Collider)val).enabled = true; } ValuableObject component = go.GetComponent<ValuableObject>(); component.volumeType = (Type)((part != Part.Head) ? 1 : 2); Value val3 = ScriptableObject.CreateInstance<Value>(); ((Object)val3).name = $"RustyBots_{part}_DefaultValue"; val3.valueMin = 3000f; val3.valueMax = 3000f; ((Object)val3).hideFlags = (HideFlags)32; component.valuePreset = val3; Durability val4 = ScriptableObject.CreateInstance<Durability>(); ((Object)val4).name = $"RustyBots_{part}_Durability"; val4.fragility = 8f; val4.durability = 250f; ((Object)val4).hideFlags = (HideFlags)32; component.durabilityPreset = val4; PhysAttribute val5 = ScriptableObject.CreateInstance<PhysAttribute>(); ((Object)val5).name = $"RustyBots_{part}_Phys"; val5.mass = ((part == Part.Head) ? 2.8f : 1.9f); ((Object)val5).hideFlags = (HideFlags)32; component.physAttributePreset = val5; PhysGrabObjectImpactDetector component2 = go.GetComponent<PhysGrabObjectImpactDetector>(); if (Object.op_Implicit((Object)(object)component2)) { component2.destroyDisable = true; } new GameObject("SemibotPartVisual").transform.SetParent(go.transform, false); go.AddComponent<DetachedBodyPartBehaviour>().PartType = part; } internal static GameObject? SpawnOnHost(Part part, string ownerSteamId, int price, float rustAmount, Vector3 worldPos, Quaternion worldRot, bool revivalHead = false) { //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) if (!SemiFunc.IsMasterClientOrSingleplayer()) { return null; } PrefabRef val = Prefabs[(int)part]; if (val == null) { return null; } object[] array = new object[8] { 1f, 1f, 1f, price, (int)part, ownerSteamId ?? "", rustAmount, revivalHead }; GameObject val2 = NetworkPrefabs.SpawnNetworkPrefab(val, worldPos, worldRot, (byte)0, array); if (!Object.op_Implicit((Object)(object)val2)) { return null; } DetachedBodyPartBehaviour component = val2.GetComponent<DetachedBodyPartBehaviour>(); if (Object.op_Implicit((Object)(object)component)) { component.ConfigureImmediate(part, price, ownerSteamId ?? "", rustAmount, revivalHead); } Rigidbody component2 = val2.GetComponent<Rigidbody>(); if (Object.op_Implicit((Object)(object)component2) && !component2.isKinematic) { Vector3 val3 = Vector3.up * 1.8f + Random.insideUnitSphere * 0.75f; component2.AddForce(val3, (ForceMode)1); component2.AddTorque(Random.insideUnitSphere * 1.5f, (ForceMode)1); } return val2; } } public sealed class DetachedBodyPartBehaviour : MonoBehaviour { private static readonly int AlbedoColorId = Shader.PropertyToID("_AlbedoColor"); private static readonly int BaseColorId = Shader.PropertyToID("_Color"); private static readonly int EmissionColorId = Shader.PropertyToID("_EmissionColor"); private static readonly int FresnelColorId = Shader.PropertyToID("_FresnelColor"); private static readonly Color RustLight = new Color(0.68f, 0.3f, 0.11f, 1f); private static readonly Color RustDark = new Color(0.38f, 0.14f, 0.06f, 1f); public Part PartType; public int Price = 3000; public string OwnerSteamId = ""; public float RustAtSever; private bool _configured; private RoomVolumeCheck? _roomVolume; private float _truckTimer; private readonly List<Material> _createdMaterials = new List<Material>(); internal bool IsRevivalHead { get; private set; } private void Awake() { PhotonView component = ((Component)this).GetComponent<PhotonView>(); if (!Object.op_Implicit((Object)(object)component)) { return; } object[] instantiationData = component.InstantiationData; if (instantiationData != null && instantiationData.Length >= 7) { int price = ((instantiationData[3] is int num) ? num : 3000); Part part = ((instantiationData[4] is int num2 && num2 >= 0 && num2 < 5) ? ((Part)num2) : PartType); string ownerSteamId = (instantiationData[5] as string) ?? ""; float rustAmount = ((instantiationData[6] is float num3) ? num3 : 0f); int revivalHead; if (instantiationData.Length >= 8) { object obj = instantiationData[7]; revivalHead = ((obj is bool && (bool)obj) ? 1 : 0); } else { revivalHead = 0; } ConfigureImmediate(part, price, ownerSteamId, rustAmount, (byte)revivalHead != 0); } } public void ConfigureImmediate(Part part, int price, string ownerSteamId, float rustAmount, bool revivalHead = false) { if (!_configured || Price != price) { PartType = part; Price = Math.Max(100, price); OwnerSteamId = ownerSteamId; RustAtSever = rustAmount; IsRevivalHead = part == Part.Head && revivalHead; if (IsRevivalHead) { _roomVolume = ((Component)this).GetComponent<RoomVolumeCheck>(); } _configured = true; ValuableObject component = ((Component)this).GetComponent<ValuableObject>(); if (Object.op_Implicit((Object)(object)component)) { component.dollarValueOverride = Price; component.dollarValueOriginal = Price; component.dollarValueCurrent = Price; } } } internal bool TryReviveOwner(bool byTruck) { if (!IsRevivalHead || !Object.op_Implicit((Object)(object)GameDirector.instance) || !SemiFunc.IsMasterClientOrSingleplayer()) { return false; } PlayerAvatar val = ((IEnumerable<PlayerAvatar>)GameDirector.instance.PlayerList).FirstOrDefault((Func<PlayerAvatar, bool>)((PlayerAvatar p) => Object.op_Implicit((Object)(object)p) && p.steamID == OwnerSteamId)); if (!Object.op_Implicit((Object)(object)val) || !val.deadSet || !Object.op_Implicit((Object)(object)val.playerDeathHead)) { return false; } RustNetworkManager rustNetworkManager = Plugin.Instance?.Network; if (rustNetworkManager == null || !rustNetworkManager.GetOrCreateState(OwnerSteamId).Detached(Part.Head)) { return false; } val.Revive(byTruck); return !val.deadSet; } private void Update() { //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Invalid comparison between Unknown and I4 if (!IsRevivalHead || !SemiFunc.IsMasterClientOrSingleplayer()) { return; } if (!Object.op_Implicit((Object)(object)_roomVolume) || !_roomVolume.inTruck || !Object.op_Implicit((Object)(object)RoundDirector.instance) || !RoundDirector.instance.allExtractionPointsCompleted || !Object.op_Implicit((Object)(object)TruckHealer.instance) || (int)TruckHealer.instance.currentState != 2) { _truckTimer = 0f; return; } _truckTimer += Time.deltaTime; if (_truckTimer >= 2f && TryReviveOwner(byTruck: true)) { RustNetworkManager.DestroySpawnedObject(((Component)this).gameObject); } } private IEnumerator Start() { for (int attempt = 0; attempt < 150; attempt++) { PlayerAvatar val = FindDonorAvatar(); if (Object.op_Implicit((Object)(object)val) && Object.op_Implicit((Object)(object)val.playerAvatarVisuals) && Object.op_Implicit((Object)(object)val.playerAvatarVisuals.meshParent) && BuildVisualMeshFromAvatar(val)) { yield break; } yield return (object)new WaitForSeconds(0.1f); } Transform val2 = ((Component)this).transform.Find("SemibotPartVisual"); if (Object.op_Implicit((Object)(object)val2) && val2.childCount == 0) { ModVisuals.AttachModel((PartType == Part.Head) ? "neck_stump" : "joint_cap", val2, addMeshCollider: false, 5f, out GameObject _); } } private PlayerAvatar? FindDonorAvatar() { if (!string.IsNullOrEmpty(OwnerSteamId) && Object.op_Implicit((Object)(object)GameDirector.instance)) { foreach (PlayerAvatar player in GameDirector.instance.PlayerList) { if (Object.op_Implicit((Object)(object)player) && player.steamID == OwnerSteamId && Object.op_Implicit((Object)(object)player.playerAvatarVisuals) && Object.op_Implicit((Object)(object)player.playerAvatarVisuals.meshParent)) { return player; } } } PlayerAvatar val = SemiFunc.PlayerAvatarLocal(); if (Object.op_Implicit((Object)(object)val) && Object.op_Implicit((Object)(object)val.playerAvatarVisuals) && Object.op_Implicit((Object)(object)val.playerAvatarVisuals.meshParent)) { return val; } return ((IEnumerable<PlayerAvatar>)GameDirector.instance?.PlayerList).FirstOrDefault((Func<PlayerAvatar, bool>)((PlayerAvatar p) => Object.op_Implicit((Object)(object)p) && Object.op_Implicit((Object)(object)p.playerAvatarVisuals) && Object.op_Implicit((Object)(object)p.playerAvatarVisuals.meshParent))); } private bool BuildVisualMeshFromAvatar(PlayerAvatar donor) { //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_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Expected O, but got Unknown //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Unknown result type (might be due to invalid IL or missing references) //IL_0182: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_01a8: Unknown result type (might be due to invalid IL or missing references) //IL_01b9: Unknown result type (might be due to invalid IL or missing references) //IL_01c6: Unknown result type (might be due to invalid IL or missing references) //IL_01d7: Unknown result type (might be due to invalid IL or missing references) //IL_01e4: Unknown result type (might be due to invalid IL or missing references) //IL_01f5: Unknown result type (might be due to invalid IL or missing references) //IL_0220: Unknown result type (might be due to invalid IL or missing references) //IL_023d: Unknown result type (might be due to invalid IL or missing references) //IL_024e: Unknown result type (might be due to invalid IL or missing references) //IL_0258: Unknown result type (might be due to invalid IL or missing references) Transform val = ((Component)this).transform.Find("SemibotPartVisual"); if (!Object.op_Implicit((Object)(object)val)) { return false; } Transform transform = donor.playerAvatarVisuals.meshParent.transform; Color bodyColor = ResolveOwnerColor(donor); float rustRatio = Mathf.Clamp01(RustAtSever / 100f); if (PartType == Part.Head) { return BuildCompleteHeadMesh(donor, transform, val, bodyColor, rustRatio); } string targetName = PartType switch { Part.LeftArm => "mesh_arm_l", Part.RightArm => "mesh_arm_r", Part.LeftLeg => "mesh_leg_l", Part.RightLeg => "mesh_leg_r", _ => "mesh_arm_r", }; MeshRenderer val2 = ((IEnumerable<MeshRenderer>)((Component)transform).GetComponentsInChildren<MeshRenderer>(true)).FirstOrDefault((Func<MeshRenderer, bool>)((MeshRenderer r) => Object.op_Implicit((Object)(object)r) && ((Object)r).name == targetName)); MeshFilter val3 = default(MeshFilter); if (!Object.op_Implicit((Object)(object)val2) || !((Component)val2).TryGetComponent<MeshFilter>(ref val3) || !Object.op_Implicit((Object)(object)val3.sharedMesh)) { return false; } GameObject val4 = new GameObject("LimbMesh_" + PartType); val4.transform.SetParent(val, false); val4.transform.localPosition = Vector3.zero; val4.transform.localRotation = Quaternion.identity; val4.transform.localScale = ((Component)val2).transform.lossyScale; val4.AddComponent<MeshFilter>().sharedMesh = val3.sharedMesh; MeshRenderer obj = val4.AddComponent<MeshRenderer>(); ((Renderer)obj).sharedMaterials = CloneAndTintMaterials(((Renderer)val2).sharedMaterials, bodyColor, rustRatio, tintBody: true); ((Renderer)obj).shadowCastingMode = (ShadowCastingMode)1; Bounds bounds = val3.sharedMesh.bounds; Vector3 localPosition = default(Vector3); ((Vector3)(ref localPosition))..ctor(((Bounds)(ref bounds)).center.x * val4.transform.localScale.x, ((Bounds)(ref bounds)).max.y * val4.transform.localScale.y, ((Bounds)(ref bounds)).center.z * val4.transform.localScale.z); ModVisuals.AttachModel("joint_cap", val, addMeshCollider: false, 5f, out GameObject modelObject); modelObject.transform.localPosition = localPosition; modelObject.transform.localRotation = Quaternion.Euler(-90f, 0f, 0f); modelObject.transform.localScale = Vector3.one * 0.92f; return true; } private bool BuildCompleteHeadMesh(PlayerAvatar donor, Transform rig, Transform visualRoot, Color bodyColor, float rustRatio) { //IL_0231: Unknown result type (might be due to invalid IL or missing references) //IL_0251: Unknown result type (might be due to invalid IL or missing references) //IL_0262: Unknown result type (might be due to invalid IL or missing references) //IL_026c: Unknown result type (might be due to invalid IL or missing references) //IL_01d5: Unknown result type (might be due to invalid IL or missing references) Transform val = (Transform)((Object.op_Implicit((Object)(object)donor.playerAvatarVisuals) && Object.op_Implicit((Object)(object)donor.playerAvatarVisuals.headUpTransform)) ? ((object)donor.playerAvatarVisuals.headUpTransform) : ((object)rig)); MeshRenderer[] componentsInChildren = ((Component)val).GetComponentsInChildren<MeshRenderer>(true); if (componentsInChildren.Length == 0) { componentsInChildren = ((Component)rig).GetComponentsInChildren<MeshRenderer>(true); } string[] source = new string[9] { "mesh_head_top", "mesh_head_bot_sphere", "mesh_head_bot_flat", "mesh_eye_l", "mesh_eye_r", "mesh_pupil_l", "mesh_pupil_r", "eyelid_upper_mesh", "eyelid_lower_mesh" }; bool flag = componentsInChildren.Any((MeshRenderer r) => Object.op_Implicit((Object)(object)r) && ((Object)r).name == "mesh_head_bot_flat" && ((Component)r).gameObject.activeInHierarchy); Dictionary<Transform, Transform> clonedNodes = new Dictionary<Transform, Transform> { [val] = visualRoot }; int num = 0; MeshRenderer[] array = componentsInChildren; MeshFilter val3 = default(MeshFilter); foreach (MeshRenderer val2 in array) { if (Object.op_Implicit((Object)(object)val2) && source.Contains(((Object)val2).name) && (!(((Object)val2).name == "mesh_head_bot_flat") || flag) && !(((Object)val2).name == "mesh_head_bot_sphere" && flag) && ((Component)val2).TryGetComponent<MeshFilter>(ref val3) && Object.op_Implicit((Object)(object)val3.sharedMesh)) { Transform obj = GetOrCreateChain(((Component)val2).transform); ((Component)obj).gameObject.AddComponent<MeshFilter>().sharedMesh = val3.sharedMesh; MeshRenderer obj2 = ((Component)obj).gameObject.AddComponent<MeshRenderer>(); ((Renderer)obj2).sharedMaterials = CloneAndTintMaterials(tintBody: ((Object)val2).name.StartsWith("mesh_head", StringComparison.Ordinal) || ((Object)val2).name.StartsWith("eyelid", StringComparison.Ordinal), originals: ((Renderer)val2).sharedMaterials, bodyColor: bodyColor, rustRatio: rustRatio); ((Renderer)obj2).shadowCastingMode = (ShadowCastingMode)1; num++; } } ModVisuals.AttachModel("neck_stump", visualRoot, addMeshCollider: false, 4.5f, out GameObject modelObject); modelObject.transform.localPosition = new Vector3(0f, -0.04f, 0f); modelObject.transform.localRotation = Quaternion.Euler(90f, 0f, 0f); modelObject.transform.localScale = Vector3.one * 0.95f; return num > 0; Transform GetOrCreateChain(Transform node) { //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Expected O, but got Unknown //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) if (clonedNodes.TryGetValue(node, out Transform value)) { return value; } Transform val4 = ((Object.op_Implicit((Object)(object)node.parent) && (Object)(object)node != (Object)(object)rig) ? GetOrCreateChain(node.parent) : visualRoot); GameObject val5 = new GameObject("H_" + ((Object)node).name); val5.transform.SetParent(val4, false); val5.transform.localPosition = node.localPosition; val5.transform.localRotation = node.localRotation; val5.transform.localScale = node.localScale; clonedNodes[node] = val5.transform; return val5.transform; } } private Color ResolveOwnerColor(PlayerAvatar donor) { //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)donor.playerCosmetics) && Object.op_Implicit((Object)(object)MetaManager.instance)) { int[] colorsEquipped = donor.playerCosmetics.colorsEquipped; if (colorsEquipped != null && colorsEquipped.Length > 5) { int num = donor.playerCosmetics.colorsEquipped[5]; if (num >= 0 && num < MetaManager.instance.colors.Count) { return MetaManager.instance.colors[num].color; } } } return new Color(0.88f, 0.58f, 0.14f, 1f); } private Material[] CloneAndTintMaterials(Material[] originals, Color bodyColor, float rustRatio, bool tintBody) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0015: 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) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Expected O, but got Unknown //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008d: 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_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: 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_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0122: 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_0135: Unknown result type (might be due to invalid IL or missing references) Material[] array = (Material[])(object)new Material[originals.Length]; Color val = Color.Lerp(bodyColor, Color.Lerp(RustLight, RustDark, rustRatio), rustRatio * 0.82f); for (int i = 0; i < originals.Length; i++) { Material val2 = originals[i]; if (!Object.op_Implicit((Object)(object)val2)) { array[i] = ModVisuals.Surface("rust_fallback", val); continue; } Material val3 = new Material(val2) { name = ((Object)val2).name + "_DetachedInstance" }; if (tintBody) { Color val4 = Color.Lerp(RustLight, RustDark, rustRatio); if (val3.HasProperty(AlbedoColorId)) { val3.SetColor(AlbedoColorId, val); } if (val3.HasProperty(BaseColorId)) { val3.SetColor(BaseColorId, val); } if (val3.HasProperty(EmissionColorId)) { val3.SetColor(EmissionColorId, Color.Lerp(bodyColor * 0.45f, val4 * 0.25f, rustRatio * 0.9f)); } if (val3.HasProperty(FresnelColorId)) { val3.SetColor(FresnelColorId, Color.Lerp(bodyColor * 0.7f, val4 * 0.55f, rustRatio * 0.85f)); } } _createdMaterials.Add(val3); array[i] = val3; } return array; } private void OnDestroy() { foreach (Material createdMaterial in _createdMaterials) { if (Object.op_Implicit((Object)(object)createdMaterial)) { Object.Destroy((Object)(object)createdMaterial); } } _createdMaterials.Clear(); } } internal static class DamageContextTracker { public static bool HasWorldHit; public static Vector3 WorldHitPoint; public static bool IsPhysicsFromOtherPlayer; public static bool IsEnemyHit; public static bool InFallBreakImpact; public static float CapturedFallDistance; public static void ClearHit() { //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) HasWorldHit = false; WorldHitPoint = Vector3.zero; IsPhysicsFromOtherPlayer = false; IsEnemyHit = false; } public static void ClearFall() { InFallBreakImpact = false; CapturedFallDistance = 0f; } } [HarmonyPatch(typeof(HurtCollider), "PlayerHurt")] internal static class HurtColliderPlayerHurtPatch { private static void Prefix(HurtCollider __instance, PlayerAvatar _player) { //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)_player) && _player.isLocal) { Collider component = ((Component)__instance).GetComponent<Collider>(); DamageContextTracker.HasWorldHit = (Object)(object)component != (Object)null; Vector3 worldHitPoint; if (!Object.op_Implicit((Object)(object)component)) { worldHitPoint = ((Component)__instance).transform.position; } else { Bounds bounds = component.bounds; worldHitPoint = ((Bounds)(ref bounds)).center; } DamageContextTracker.WorldHitPoint = worldHitPoint; DamageContextTracker.IsPhysicsFromOtherPlayer = (Object)(object)__instance.playerCausingHurt != (Object)null && (Object)(object)__instance.playerCausingHurt != (Object)(object)_player; DamageContextTracker.IsEnemyHit = Object.op_Implicit((Object)(object)__instance.enemyHost); } } private static void Finalizer() { DamageContextTracker.ClearHit(); } } [HarmonyPatch(typeof(PlayerHealth), "HurtOtherRPC")] internal static class HurtOtherRpcContextPatch { private static void Prefix(PlayerHealth __instance, Vector3 hurtPosition, int enemyIndex) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)__instance) && Object.op_Implicit((Object)(object)__instance.playerAvatar) && __instance.playerAvatar.isLocal && hurtPosition != Vector3.zero) { DamageContextTracker.HasWorldHit = true; DamageContextTracker.WorldHitPoint = hurtPosition; DamageContextTracker.IsPhysicsFromOtherPlayer = enemyIndex < 0; } } private static void Finalizer() { DamageContextTracker.ClearHit(); } } [HarmonyPatch(typeof(EnemySpinny), "Update")] internal static class SpinnyDamageContextPatch { private static void Prefix(out bool __state) { __state = DamageContextTracker.IsEnemyHit; DamageContextTracker.IsEnemyHit = true; } private static void Finalizer(bool __state) { DamageContextTracker.IsEnemyHit = __state; } } [HarmonyPatch(typeof(PlayerTumble), "BreakImpact")] internal static class PlayerTumbleBreakImpactPatch { private static void Prefix(PlayerTumble __instance) { if (Object.op_Implicit((Object)(object)__instance) && Object.op_Implicit((Object)(object)__instance.playerAvatar) && __instance.playerAvatar.isLocal && __instance.impactHurtTimer > 0f && Object.op_Implicit((Object)(object)PlayerController.instance) && Object.op_Implicit((Object)(object)PlayerController.instance.CollisionController)) { DamageContextTracker.InFallBreakImpact = true; DamageContextTracker.CapturedFallDistance = PlayerController.instance.CollisionController.fallDistance; } } private static void Finalizer() { DamageContextTracker.ClearFall(); } } [HarmonyPatch(typeof(PlayerHealth), "Hurt")] internal static class PlayerHealthHurtPatch { private static void Prefix(PlayerHealth __instance, out int __state) { __state = (Object.op_Implicit((Object)(object)__instance) ? __instance.health : 0); } private static void Postfix(PlayerHealth __instance, int enemyIndex, bool hurtByHeal, int __state) { //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: 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) //IL_00b7: 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_011a: 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_00ea: 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_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)Plugin.Instance == (Object)null || !Object.op_Implicit((Object)(object)__instance) || !Object.op_Implicit((Object)(object)__instance.playerAvatar) || hurtByHeal || Plugin.Instance.Network.SuppressHurtSeverCheck) { return; } int num = __state - __instance.health; if (num <= 0) { return; } PlayerAvatar playerAvatar = __instance.playerAvatar; if (string.IsNullOrEmpty(playerAvatar.steamID)) { return; } bool flag = DamageContextTracker.InFallBreakImpact && DamageContextTracker.CapturedFallDistance > 0.5f; if (!flag && enemyIndex < 0 && !DamageContextTracker.IsEnemyHit && !DamageContextTracker.IsPhysicsFromOtherPlayer) { return; } float fallDistance = (flag ? DamageContextTracker.CapturedFallDistance : 0f); bool hasHitLocal = false; Vector3 localHitOffset = Vector3.zero; if (DamageContextTracker.HasWorldHit) { hasHitLocal = true; localHitOffset = ((Component)playerAvatar).transform.InverseTransformPoint(DamageContextTracker.WorldHitPoint); } else if (enemyIndex >= 0) { Enemy val = SemiFunc.EnemyGetFromIndex(enemyIndex); if (Object.op_Implicit((Object)(object)val)) { hasHitLocal = true; localHitOffset = ((Component)playerAvatar).transform.InverseTransformPoint(((Component)val).transform.position + Vector3.up * 0.6f); } } Plugin.Instance.Network.SendDamageReport(playerAvatar.steamID, num, flag, fallDistance, hasHitLocal, localHitOffset, DamageContextTracker.IsPhysicsFromOtherPlayer); } } [HarmonyPatch(typeof(PlayerDeathHead), "Trigger")] internal static class SuppressDuplicateDeathHeadPatch { private static bool Prefix(PlayerDeathHead __instance) { if ((Object)(object)Plugin.Instance == (Object)null || !Object.op_Implicit((Object)(object)__instance) || !Object.op_Implicit((Object)(object)__instance.playerAvatar)) { return true; } string steamID = __instance.playerAvatar.steamID; if (string.IsNullOrEmpty(steamID)) { return true; } if (!Plugin.Instance.Network.GetOrCreateState(steamID).Detached(Part.Head)) { return true; } if (!GameManager.Multiplayer() || PhotonNetwork.IsMasterClient) { if (__instance.playerAvatar.isLocal && Object.op_Implicit((Object)(object)PlayerController.instance) && Object.op_Implicit((Object)(object)PlayerController.instance.col)) { PlayerController.instance.col.enabled = false; } else if (Object.op_Implicit((Object)(object)__instance.playerAvatar.playerAvatarCollision) && Object.op_Implicit((Object)(object)__instance.playerAvatar.playerAvatarCollision.Collider)) { ((Collider)__instance.playerAvatar.playerAvatarCollision.Collider).enabled = false; } if (Object.op_Implicit((Object)(object)__instance.playerAvatar.tumble) && __instance.playerAvatar.tumble.colliders != null) { Collider[] colliders = __instance.playerAvatar.tumble.colliders; foreach (Collider val in colliders) { if (Object.op_Implicit((Object)(object)val)) { val.enabled = false; } } } } __instance.triggered = false; if (Object.op_Implicit((Object)(object)__instance.physGrabObject) && SemiFunc.IsMasterClientOrSingleplayer()) { __instance.physGrabObject.OverrideDeactivate(0.1f); } Plugin.LogInfo("Suppressed vanilla PlayerDeathHead for " + __instance.playerAvatar.playerName + " (head severed as valuable)."); return false; } } [HarmonyPatch(typeof(PlayerAvatar), "ReviveRPC")] internal static class PlayerAvatarRevivePatch { private static void Prefix(PlayerAvatar __instance, out bool __state) { //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_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: 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) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) __state = __instance.deadSet; if (__state && !((Object)(object)Plugin.Instance == (Object)null) && Object.op_Implicit((Object)(object)__instance.playerDeathHead) && Object.op_Implicit((Object)(object)__instance.playerDeathHead.physGrabObject) && Plugin.Instance.Network.GetOrCreateState(__instance.steamID).Detached(Part.Head)) { DetachedBodyPartBehaviour detachedBodyPartBehaviour = Object.FindObjectsByType<DetachedBodyPartBehaviour>((FindObjectsSortMode)0).FirstOrDefault((DetachedBodyPartBehaviour head) => head.IsRevivalHead && head.OwnerSteamId == __instance.steamID); PhysGrabObject val = default(PhysGrabObject); if (Object.op_Implicit((Object)(object)detachedBodyPartBehaviour) && ((Component)detachedBodyPartBehaviour).TryGetComponent<PhysGrabObject>(ref val)) { __instance.playerDeathHead.physGrabObject.centerPoint = val.centerPoint; } else { __instance.playerDeathHead.physGrabObject.centerPoint = ((Component)__instance).transform.position + Vector3.up * 0.25f; } } } private static void Postfix(PlayerAvatar __instance, bool __state) { if (__state && !((Object)(object)Plugin.Instance == (Object)null) && Object.op_Implicit((Object)(object)__instance) && !__instance.deadSet && !string.IsNullOrEmpty(__instance.steamID) && Plugin.Instance.Network.GetOrCreateState(__instance.steamID).RestoreHeadOnRevive() && SemiFunc.IsMasterClientOrSingleplayer()) { Plugin.Instance.Network.BroadcastFullState(); } } } [HarmonyPatch(typeof(ExtractionPoint), "DestroyAllPhysObjectsInHaulList")] internal static class SeveredHeadExtractionPatch { private static void Prefix() { if ((Object)(object)Plugin.Instance == (Object)null || !SemiFunc.IsMasterClientOrSingleplayer() || !Object.op_Implicit((Object)(object)RoundDirector.instance)) { return; } GameObject[] array = RoundDirector.instance.dollarHaulList.ToArray(); DetachedBodyPartBehaviour detachedBodyPartBehaviour = default(DetachedBodyPartBehaviour); foreach (GameObject val in array) { if (Object.op_Implicit((Object)(object)val) && val.TryGetComponent<DetachedBodyPartBehaviour>(ref detachedBodyPartBehaviour)) { detachedBodyPartBehaviour.TryReviveOwner(byTruck: false); } } } } [HarmonyPatch(typeof(PlayerController), "FixedUpdate")] internal static class PlayerControllerLegRustPatch { private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions) { FieldInfo move = AccessTools.Field(typeof(PlayerController), "MoveSpeed"); FieldInfo sprint = AccessTools.Field(typeof(PlayerController), "SprintSpeed"); FieldInfo crouch = AccessTools.Field(typeof(PlayerController), "CrouchSpeed"); MethodInfo scale = AccessTools.Method(typeof(PlayerControllerLegRustPatch), "ScaleMovementSpeed", (Type[])null, (Type[])null); int matches = 0; foreach (CodeInstruction instruction in instructions) { yield return instruction; if (!(instruction.opcode != OpCodes.Ldfld) && (object.Equals(instruction.operand, move) || object.Equals(instruction.operand, sprint) || object.Equals(instruction.operand, crouch))) { yield return new CodeInstruction(OpCodes.Ldarg_0, (object)null); yield return new CodeInstruction(OpCodes.Call, (object)scale); matches++; } } if (matches == 0) { Plugin.LogWarning("No movement speed reads found in PlayerController.FixedUpdate."); } } private static float ScaleMovementSpeed(float speed, PlayerController controller) { if ((Object)(object)Plugin.Instance == (Object)null || !Object.op_Implicit((Object)(object)controller.playerAvatarScript)) { return speed; } PlayerAvatar playerAvatarScript = controller.playerAvatarScript; if (playerAvatarScript.deadSet || playerAvatarScript.isDisabled || string.IsNullOrEmpty(playerAvatarScript.steamID)) { return speed; } RustState orCreateState = Plugin.Instance.Network.GetOrCreateState(playerAvatarScript.steamID); float num = RustMechanics.LegSpeedMultiplier(orCreateState, Plugin.Instance.Network.LegPenalty); return speed * num * orCreateState.AttachedLegCount switch { 2 => 1f, 1 => 0.12f, _ => 0.04f, }; } } [HarmonyPatch(typeof(PhysGrabber), "FixedUpdate")] internal static class PhysGrabberArmRustPatch { private static void Postfix(PhysGrabber __instance) { if (!((Object)(object)Plugin.Instance == (Object)null) && Object.op_Implicit((Object)(object)__instance) && Object.op_Implicit((Object)(object)__instance.playerAvatar) && !SemiFunc.MenuLevel()) { string steamID = __instance.playerAvatar.steamID; if (!string.IsNullOrEmpty(steamID) && Object.op_Implicit((Object)(object)StatsManager.instance)) { int valueOrDefault = StatsManager.instance.playerUpgradeStrength.GetValueOrDefault(steamID, 0); float num = 1f + (float)valueOrDefault * 0.2f; float num2 = RustMechanics.ArmGrabMultiplier(Plugin.Instance.Network.GetOrCreateState(steamID), Plugin.Instance.Network.ArmPenalty); __instance.grabStrength = Mathf.Max(0.15f, num * num2); } } } } [HarmonyPatch(typeof(StatsManager), "SaveGame")] internal static class StatsManagerSavePatch { private static bool Prefix(string fileName) { return !RustyTestLab.OwnsSave(fileName); } private static void Postfix(string fileName) { if (!RustyTestLab.OwnsSave(fileName)) { Plugin.Instance?.Network.SaveSidecarForRun(fileName); } } } [HarmonyPatch(typeof(StatsManager), "LoadGame")] internal static class StatsManagerLoadPatch { private static void Postfix(string fileName) { Plugin.Instance?.Network.LoadSidecarForRun(fileName); } } [HarmonyPatch(typeof(StatsManager), "SaveFileDelete")] internal static class StatsManagerDeletePatch { private static void Postfix(string saveFileName) { Plugin.Instance?.Network.DeleteSidecarForRun(saveFileName); } } [HarmonyPatch(typeof(StatsManager), "ResetAllStats")] internal static class StatsManagerResetPatch { private static void Postfix() { Plugin.Instance?.Network.ResetAllRunState(); } } [HarmonyPatch(typeof(NetworkManager), "OnPlayerEnteredRoom")] internal static class LateJoinerSyncPatch { private static void Postfix(Player newPlayer) { if ((Object)(object)Plugin.Instance != (Object)null && SemiFunc.IsMasterClient() && newPlayer != null) { Plugin.Instance.Network.BroadcastFullState(newPlayer.ActorNumber); } } } internal static class InGameAutoTester { private sealed class CheckEntry { public string Name = ""; public bool Passed; public string Details = ""; } private static bool _running; private static string? _pendingAutoDir; internal static string LastResult { get; private set; } = "Not run"; internal static bool IsRunningOrPending { get { if (!_running) { return _pendingAutoDir != null; } return true; } } internal static void CheckLaunchArgs() { string[] commandLineArgs = Environment.GetCommandLineArgs(); for (int i = 0; i < commandLineArgs.Length - 1; i++) { if (string.Equals(commandLineArgs[i], "--rustybots-autotest", StringComparison.OrdinalIgnoreCase)) { _pendingAutoDir = commandLineArgs[i + 1].Trim('"'); Application.runInBackground = true; Plugin.LogInfo("[AutoTest] Queued automated verification -> " + _pendingAutoDir); break; } } } internal static void TickPending() { if (IsRunningOrPending && !Application.runInBackground) { Application.runInBackground = true; } if (_pendingAutoDir != null && !_running && RustyTestLab.CanStart) { string? pendingAutoDir = _pendingAutoDir; _pendingAutoDir = null; StartSuite(pendingAutoDir); } } internal static bool StartSuite(string? outputDir) { if (_running || (Object)(object)Plugin.Instance == (Object)null || !RustyTestLab.CanStart) { return false; } string text = (string.IsNullOrWhiteSpace(outputDir) ? Path.Combine(Paths.BepInExRootPath, "RustyBots_Screenshots") : outputDir); try { Directory.CreateDirectory(text); RunPersistence.WriteAtomic(Path.Combine(text, "autotest_done.txt"), "RUNNING"); } catch (Exception ex) { LastResult = "FAIL: " + ex.Message; Plugin.LogError(LastResult); return false; } _running = true; LastResult = "Running"; ((MonoBehaviour)Plugin.Instance).StartCoroutine(RunAndReport(text)); return true; } private static IEnumerator RunAndReport(string outDir) { List<CheckEntry> checks = new List<CheckEntry>(); List<GameObject> spawnedCleanup = new List<GameObject>(); Stack<IEnumerator> frames = new Stack<IEnumerator>(); frames.Push(RunSuiteCoroutine(outDir, checks, spawnedCleanup)); try { while (frames.Count > 0) { IEnumerator enumerator = frames.Peek(); object obj = null; bool flag; try { flag = enumerator.MoveNext(); if (flag) { obj = enumerator.Current; } } catch (Exception ex) { checks.Add(new CheckEntry { Name = "Suite execution", Details = ex.Message }); Plugin.LogError(ex.ToString()); break; } if (!flag) { (frames.Pop() as IDisposable)?.Dispose(); } else if (obj is IEnumerator item) { frames.Push(item); } else { yield return obj; } } } finally { _running = false; if (frames.Count > 0) { checks.Add(new CheckEntry { Name = "Suite completion", Details = "Suite ended before the last check." }); } LastResult = ((checks.Count > 0 && checks.All((CheckEntry check) => check.Passed)) ? "PASS" : "FAIL"); try { WriteReport(outDir, checks); RunPersistence.WriteAtomic(Path.Combine(outDir, "autotest_done.txt"), LastResult); } catch (Exception ex2) { LastResult = "FAIL: " + ex2.Message; Plugin.LogError(LastResult); } while (frames.Count > 0) { (frames.Pop() as IDisposable)?.Dispose(); } foreach (GameObject item2 in spawnedCleanup) { if (Object.op_Implicit((Object)(object)item2)) { RustNetworkManager.DestroySpawnedObject(item2); } } RustyTestLab.Exit(); Plugin.LogInfo($"[AutoTest] {LastResult} · {checks.Count((CheckEntry c) => c.Passed)}/{checks.Count} checks"); } } private static IEnumerator RunSuiteCoroutine(string outDir, List<CheckEntry> checks, List<GameObject> spawnedCleanup) { Plugin.LogInfo("[AutoTest] Starting real-game test suite -> " + outDir); yield return (object)new WaitForSecondsRealtime(2.5f); yield return CaptureRawScreen(Path.Combine(outDir, "00a_main_menu_button.png")); RustyMenu.OpenHub(); yield return (object)new WaitForSecondsRealtime(0.75f); Record("MenuLib Hub & 3D Avatar Preview", RustyMenu.IsOpen, "Two-pane Hub opened with REPOAvatarPreview"); yield return CaptureRawScreen(Path.Combine(outDir, "00b_menu_hub.png")); RustyMenu.OpenSettings(fromHub: true); yield return (object)new WaitForSecondsRealtime(0.75f); Record("MenuLib Settings Page", RustyMenu.IsOpen, "All 21 RustConfig sliders & toggles opened"); yield return CaptureRawScreen(Path.Combine(outDir, "00c_menu_settings.png")); RustyMenu.OpenTestLab(fromHub: true); yield return (object)new WaitForSecondsRealtime(0.75f); Record("MenuLib Test Lab Page", RustyMenu.IsOpen, "Two-pane Test Lab & 24 Scenarios opened"); yield return CaptureRawScreen(Path.Combine(outDir, "00d_menu_testlab.png")); RustyMenu.CloseAll(); yield return (object)new WaitForSecondsRealtime(0.55f); int previousGenId = (Object.op_Implicit((Object)(object)LevelGenerator.Instance) ? ((Object)LevelGenerator.Instance).GetInstanceID() : 0); if (!RustyTestLab.Start()) { throw new InvalidOperationException("Could not start isolated test lab."); } Record("Start isolated singleplayer run", RustyTestLab.IsActive, "Temporary run with saving disabled"); yield return WaitForPlayableLevel(previousGenId, expectShop: false, 60f); yield return (object)new WaitForSeconds(2.2f); PlayerAvatar local = SemiFunc.PlayerAvatarLocal(); if (!Object.op_Implicit((Object)(object)local) || string.IsNullOrEmpty(local.steamID) || (Object)(object)Plugin.Instance == (Object)null) { Record("Locate Local Semibot Avatar", passed: false, "PlayerAvatarLocal was null after level load."); yield break; } RustNetworkManager net = Plugin.Instance.Network; RustConfig cfg = Plugin.Instance.ConfigData; RustyMenu.ToggleTestLab(); yield return (object)new WaitForSecondsRealtime(0.25f); RustyMenu.OpenTestLab(fromHub: false); yield return (object)new WaitForSecondsRealtime(0.25f); RustyMenu.OpenTestLab(fromHub: false); yield return (object)new WaitForSecondsRealtime(0.25f); bool openedMidGame = RustyMenu.IsOpen; RustyMenu.CloseAll(); yield return (object)new WaitForSecondsRealtime(0.45f); bool flag = !RustyMenu.IsOpen && (!Object.op_Implicit((Object)(object)MenuManager.instance) || (Object)(object)MenuManager.instance.currentMenuPage == (Object)null); Record("Mid-game Test Lab refresh & close", openedMidGame && flag, string.Format("Opened={0}, ClosedCleanly={1}, CurrentPage={2}", openedMidGame, flag, (Object.op_Implicit((Object)(object)MenuManager.instance) && Object.op_Implicit((Object)(object)MenuManager.instance.currentMenuPage)) ? ((Object)MenuManager.instance.currentMenuPage).name : "null")); if (TestCompanion.Spawn(local)) { PlayerAvatar avatar = TestCompanion.Avatar; if (avatar != null) { try { int num = avatar.playerAvatarVisuals.meshParent.GetComponentsInChildren<MeshRenderer>().Count((MeshRenderer renderer) => ((Renderer)renderer).enabled && AvatarAnatomy.IsUpperTorsoMesh(((Object)renderer).name)); Record("Local P2 has one active upper torso mesh", num == 1, $"Active upper torso meshes: {num}"); RustState orCreateState = net.GetOrCreateState(avatar.steamID); float num2 = net.GetOrCreateState(local.steamID).Rust(Part.RightArm); orCreateState.Corrode(Part.RightArm, 60f); bool flag2 = net.ApplySandpaperOnHost(local, avatar, Part.RightArm, ((Component)avatar).transform.position); float num3 = Mathf.Max(0f, 60f - cfg.SandpaperUnits.Value); Record("Local P2 has independent rust and maintenance damage", flag2 && orCreateState.Rust(Part.RightArm) == num3 && net.GetOrCreateState(local.steamID).Rust(Part.RightArm) == num2 && TestCompanion.Health < 100, $"P2 right arm rust={orCreateState.Rust(Part.RightArm):0.0}, P2 HP={TestCompanion.Health}"); } finally { TestCompanion.Remove(); } goto IL_0671; } } Record("Local P2 rig initialization", passed: false, "No usable practice companion rig."); goto IL_0671; IL_0c7e: int passed; int num4; int num5; int num6; Record("Spawn Custom 3D Shop Items & Prices", (byte)passed != 0, $"Stainless=${num4}K, Sandpaper=${num5}K, RepairPod=${num6}K"); GameObject goSandpaper; Vector3 openDir; Vector3 studioPos; Vector3 val = (Object.op_Implicit((Object)(object)goSandpaper) ? goSandpaper.transform.position : (studioPos + openDir * 1.15f)); Vector3 camPos = val + openDir * 1.05f + Vector3.up * 0.62f; Vector3 lookPos = val + Vector3.up * 0.14f; Plugin.Instance.ShowLocalNotice("Test 3/9: Custom 3D Items — Stainless Cleaner, Rust Sandpaper, Semibot Repair Pod"); yield return CaptureShot(Path.Combine(outDir, "03_custom_3d_items.png"), local, camPos, lookPos, showSelfRig: false, 0f); foreach (GameObject item in spawnedCleanup) { if (Object.op_Implicit((Object)(object)item)) { RustNetworkManager.DestroySpawnedObject(item); } } spawnedCleanup.Clear(); yield return (object)new WaitForSeconds(0.2f); int hpBeforeSand = local.playerHealth.health; RustState st; st.ApplySandpaper(Part.RightArm, 100f); int num7 = Random.Range(cfg.SandpaperMinDamage.Value, cfg.SandpaperMaxDamage.Value + 1); net.SuppressHurtSeverCheck = true; try { local.playerHealth.Hurt(num7, true, -1, false); } finally { net.SuppressHurtSeverCheck = false; } for (int num8 = 0; num8 < 13; num8++) { net.ApplyStainlessOnHost(local); } float blockedRust = st.Corrode(Part.RightArm, 5f); net.BroadcastFullState(); yield return (object)new WaitForSeconds(0.35f); int num9 = hpBeforeSand - local.playerHealth.health; Record("Stainless Cleaner & Sandpaper Reserves", st.TotalRust < 0.5f && num9 >= 2 && num9 <= 3 && Mathf.Approximately(blockedRust, 0f) && st.WholeBodyCleaner > 5f && st.PartCleaner(Part.RightArm) > 5f, $"TotalRust={st.TotalRust:0.0}, SandpaperHPLoss={num9}, BlockedIncomingRust={blockedRust:0.0}, Coat={st.WholeBodyCleaner:0.0}, RightArmCoat={st.PartCleaner(Part.RightArm):0.0}"); Plugin.Instance.ShowLocalNotice($"Test 4/9: Cleaned & Coated (Sandpaper -{num9} HP, Anti-Rust Reserves Active)"); Vector3 heroCamPos; Vector3 heroLookPos; yield return CaptureShot(Path.Combine(outDir, "04_cleaned_and_coated.png"), local, heroCamPos, heroLookPos, showSelfRig: true, 166f); Vector3 sideDir; Vector3 value = studioPos + openDir * 0.72f - sideDir * 0.28f + Vector3.up * 0.25f; Vector3 value2 = studioPos + openDir * 0.72f + sideDir * 0.28f + Vector3.up * 0.25f; Quaternion itemRot; bool sevLA = net.SeverAndSpawnOnHost(local, Part.LeftArm, "autotest", value, itemRot); bool sevRA = net.SeverAndSpawnOnHost(local, Part.RightArm, "autotest", value2, itemRot); yield return (object)new WaitForSeconds(0.75f); ValuableObject[] array = (from v in Object.FindObjectsByType<ValuableObject>((FindObjectsSortMode)0) where Object.op_Implicit((Object)(object)v) && ((Object)v).name.Contains("Valuable Semibot", StringComparison.Ordinal) select v).ToArray(); bool flag3 = Object.op_Implicit((Object)(object)local.playerAvatarVisuals.playerAvatarRightArm) && Object.op_Implicit((Object)(object)local.playerAvatarVisuals.playerAvatarRightArm.grabberClawParent) && !((Component)local.playerAvatarVisuals.playerAvatarRightArm.grabberClawParent).gameObject.activeSelf; Record("Sever Arms -> Valuables, Stumps & Tool Disable", sevLA && sevRA && st.Detached(Part.LeftArm) && st.Detached(Part.RightArm) && array.Length >= 2 && flag3, $"ValuablesSpawned={array.Length} (${((array.Length != 0) ? array[0].dollarValueCurrent : 0f):0} ea), GrabberClawHidden={flag3}"); Plugin.Instance.ShowLocalNotice("Test 5/9: Both Arms Severed — Mechanical Stumps, Grabber/Light Disabled & Quota Valuables"); yield return CaptureShot(Path.Combine(outDir, "05_severed_arms_stumps.png"), local, heroCamPos, studioPos + Vector3.up * 0.44f, showSelfRig: true, 166f); Vector3 value3 = studioPos + openDir * 0.52f - sideDir * 0.48f + Vector3.up * 0.25f; Vector3 value4 = studioPos + openDir * 0.52f + sideDir * 0.48f + Vector3.up * 0.25f; bool sevLL = net.SeverAndSpawnOnHost(local, Part.LeftLeg, "autotest", value3, itemRot); bool sevRL = net.SeverAndSpawnOnHost(local, Part.RightLeg, "autotest", value4, itemRot); yield return (object)new WaitForSeconds(0.75f); ValuableObject[] array2 = (from v in Object.FindObjectsByType<ValuableObject>((FindObjectsSortMode)0) where Object.op_Implicit((Object)(object)v) && ((Object)v).name.Contains("Valuable Semibot", StringComparison.Ordinal) select v).ToArray(); Record("Sever Legs -> 4 Valuables & 0-Leg State", sevLL && sevRL && st.AttachedLegCount == 0 && array2.Length >= 4, $"AttachedLegs={st.AttachedLegCount}, TotalLimbValuables={array2.Length}"); Plugin.Instance.ShowLocalNotice("Test 6/9: All 4 Limbs Severed — Shoulder/Hip Stumps & 4 Quota Valuables"); yield return CaptureShot(Path.Combine(outDir, "06_severed_all_limbs.png"), local, heroCamPos, studioPos + Vector3.up * 0.4f, showSelfRig: true, 166f); Vector3 headShowcasePos = studioPos + openDir * 1.05f + Vector3.up * 0.42f; Quaternion val2 = Quaternion.LookRotation(openDir, Vector3.up) * Quaternion.Euler(-22f, 12f, 0f); GameObject headValGo = BodyPartValuables.SpawnOnHost(Part.Head, local.steamID, 3000, 18f, headShowcasePos, val2); Rigidbody headRb = (Object.op_Implicit((Object)(object)headValGo) ? headValGo.GetComponent<Rigidbody>() : null); if (Object.op_Implicit((Object)(object)headRb)) { headRb.linearVelocity = Vector3.zero; headRb.angularVelocity = Vector3.zero; headRb.isKinematic = true; headValGo.transform.SetPositionAndRotation(headShowcasePos, val2); } yield return (object)new WaitForSeconds(0.45f); ValuableObject val3 = (Object.op_Implicit((Object)(object)headValGo) ? headValGo.GetComponent<ValuableObject>() : null); Record("Valuable Semibot Head Mesh & Price", (Object)(object)val3 != (Object)null && val3.dollarValueCurrent >= 3000f, string.Format("HeadValuable={0}, Value=${1:0}", Object.op_Implicit((Object)(object)val3) ? ((Object)val3).name : "null", Object.op_Implicit((Object)(object)val3) ? val3.dollarValueCurrent : 0f)); Vector3 val4 = (Object.op_Implicit((Object)(object)headValGo) ? headValGo.transform.position : headShowcasePos); Vector3 camPos2 = val4 + openDir * 0.88f + sideDir * 0.12f + Vector3.up * 0.14f; Vector3 lookPos2 = val4 + Vector3.up * 0.04f; Plugin.Instance.ShowLocalNotice($"Test 7/9: Valuable Semibot Head (${(Object.op_Implicit((Object)(object)val3) ? val3.dollarValueCurrent : 2500f):0} Composite Head + Neck Stump)"); yield return CaptureShot(Path.Combine(outDir, "07_severed_head_valuable.png"), local, camPos2, lookPos2, showSelfRig: false, 0f); if (Object.op_Implicit((Object)(object)headRb)) { headRb.isKinematic = false; } bool fatalHeadSever = net.SeverAndSpawnOnHost(local, Part.Head, "autotest-fatal", headShowcasePos + sideDir * 0.4f, Quaternion.identity); float deathDeadline = Time.realtimeSinceStartup + 6f; while (Object.op_Implicit((Object)(object)local) && !local.isDisabled && Time.realtimeSinceStartup < deathDeadline) { yield return null; } if (!Object.op_Implicit((Object)(object)local)) { throw new InvalidOperationException("Test player disappeared after fatal head sever."); } bool flag4 = (Object)(object)local.playerDeathHead != (Object)null && !local.playerDeathHead.triggered; bool deadSet = local.deadSet; Record("Fatal Head Sever & Duplicate PlayerDeathHead Suppression", fatalHeadSever && deadSet && st.Detached(Part.Head) && flag4, $"DeadSet={deadSet}, HeadDetached={st.Detached(Part.Head)}, VanillaDeathHeadTriggered={local.playerDeathHead?.triggered}"); DetachedBodyPartBehaviour detachedBodyPartBehaviour = Object.FindObjectsByType<DetachedBodyPartBehaviour>((FindObjectsSortMode)0).FirstOrDefault((DetachedBodyPartBehaviour head) => head.IsRevivalHead && head.OwnerSteamId == local.steamID); bool revived = (Object)(object)detachedBodyPartBehaviour != (Object)null && detachedBodyPartBehaviour.TryReviveOwner(byTruck: false); yield return (object)new WaitForSeconds(0.25f); Record("ReviveRPC Restores Head & Preserves Missing Limbs", revived && !local.deadSet && !st.Detached(Part.Head) && st.DetachedCount == 4, $"HeadDetachedAfterRevive={st.Detached(Part.Head)}, MissingLimbsKept={st.DetachedCount}"); int previousGenId2 = (Object.op_Implicit((Object)(object)LevelGenerator.Instance) ? ((Object)LevelGenerator.Instance).GetInstanceID() : 0); Plugin.LogInfo("[AutoTest] Transitioning to Shop level to test auto-spawned Semibot Repair Station..."); if (Object.op_Implicit((Object)(object)RunManager.instance)) { RunManager.instance.ChangeLevel(true, false, (ChangeLevelType)5); } yield return WaitForPlayableLevel(previousGenId2, expectShop: true, 60f); yield return (object)new WaitForSeconds(1.2f); local = SemiFunc.PlayerAvatarLocal(); st = net.GetOrCreateState(local.steamID); SemiFunc.StatSetRunCurrency(50); if (Object.op_Implicit((Object)(object)ShopManager.instance)) { ShopManager.instance.totalCurrency = 50; } float stationWait = 0f; while (!ShopRepairStationBay.IsSpawned && stationWait < 5f) { stationWait += Time.deltaTime; yield return null; } Record("Shop Auto-Spawned Semibot Repair Station", ShopRepairStationBay.IsSpawned && SemiFunc.RunIsShop(), $"IsShop={SemiFunc.RunIsShop()}, StationPad={ShopRepairStationBay.PadPosition}"); Vector3 val5; if (Object.op_Implicit((Object)(object)ShopRepairStationBay.StationObject)) { Transform transform = ShopRepairStationBay.StationObject.transform; val5 = tran