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 Minecraft Mobs v0.3.69
plugins/CreeperRunner/CreeperRunner.dll
Decompiled 36 minutes 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.Globalization; using System.IO; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Text; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using Photon.Pun; using UnityEngine; using UnityEngine.Rendering; using UnityEngine.SceneManagement; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("CreeperRunner")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("CreeperRunner")] [assembly: AssemblyTitle("CreeperRunner")] [assembly: AssemblyVersion("1.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [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 FanRunnerTestClone { internal sealed class BakedMeshAnimationPlayer : MonoBehaviour { private sealed class PartData { public string ObjectName; public string MaterialName; public Vector2[] UVs; public int[] Triangles; public bool IsAnimated = true; public Mesh Mesh; public Vector3[] BlendVertices; public Vector3[] BlendNormals; public Bounds AnimationBounds; } private sealed class ClipData { public string Name; public float FramesPerSecond; public int FrameCount; public int LoopFrameCount; public bool Loop; public Vector3[][][] Positions; public Vector3[][][] Normals; } private sealed class AnimationCacheEntry { public PartData[] Parts; public Dictionary<string, ClipData> Clips; } private static readonly Dictionary<string, AnimationCacheEntry> SharedAnimationCache = new Dictionary<string, AnimationCacheEntry>(StringComparer.OrdinalIgnoreCase); private static GameObject WitchVisualTemplate; private static string WitchTemplateAnimationPath; private static string WitchTemplateObjPath; private static bool WitchVisualPreloadAttempted; private static Exception WitchVisualPreloadFailure; private static readonly BindingFlags InstanceFlags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic; private const string Magic = "FANIM001"; private const int LegacyFormatVersion = 1; private const int OptimizedFormatVersion = 2; [SerializeField] private string _animationPath; [SerializeField] private string _objPath; [SerializeField] private string _fallbackSkinPath; [SerializeField] private string _walkClipName = "Creeper_Walk"; [SerializeField] private string _attackClipName = "Creeper_Fuse"; [SerializeField] private bool _useRunnerState = true; private PartData[] _parts; private Dictionary<string, ClipData> _clips = new Dictionary<string, ClipData>(StringComparer.Ordinal); private Component _runner; private Transform _movementTransform; private FieldInfo _stateField; private ClipData _currentClip; private float _framePosition; private bool _attackActive; private bool _externallyPoseFrozen; private bool _fuseLocked; private bool _initialized; private bool _runtimeStartCompleted; private bool _walkHasAdvanced; private bool _loggedFirstWitchAdvance; private float _walkMaxVertexDisplacement; private int _walkMovedVertexCount; private int _walkMovedPartCount; private float _witchUpdateAccumulator; private const float WitchWalkVisualUpdateRate = 30f; private const float WitchWalkVertexMotionThreshold = 0.00025f; private const float WitchWalkMinimumDeformation = 0.0005f; private bool _reportedAttackMissing; private Action _attackCompletionCallback; private Vector3 _lastRunnerPosition; private bool _hasLastRunnerPosition; private float _runnerPlanarSpeed; private bool _hasAppliedFrame; private bool _standalonePlayback; private bool _standaloneMovementDriven; private Vector3[][] _transitionStartVertices; private Vector3[][] _transitionStartNormals; private float _transitionElapsed; private float _transitionDuration; private const float HuntsmanPoseTransitionSeconds = 0.32f; private ClipData _lastAppliedClip; private int _lastAppliedFrameA = -1; private int _lastAppliedFrameB = -1; private float _lastAppliedBlend = -1f; internal static bool IsWitchVisualTemplateReady => (Object)(object)WitchVisualTemplate != (Object)null; internal static bool DidWitchVisualPreloadFail { get { if (WitchVisualPreloadAttempted) { return WitchVisualPreloadFailure != null; } return false; } } internal static string WitchVisualPreloadFailureMessage { get { if (WitchVisualPreloadFailure == null) { return string.Empty; } return WitchVisualPreloadFailure.ToString(); } } public bool IsInitialized { get { if (_initialized) { if (string.IsNullOrEmpty(_attackClipName)) { return _clips.ContainsKey(_walkClipName); } return _clips.ContainsKey(_attackClipName); } return false; } } public bool RuntimeReady { get { if (!_runtimeStartCompleted || !_initialized || !((Behaviour)this).enabled || !_hasAppliedFrame || _parts == null || _currentClip == null || !string.Equals(_currentClip.Name, _walkClipName, StringComparison.Ordinal)) { return false; } for (int i = 0; i < _parts.Length; i++) { if (_parts[i] == null || (Object)(object)_parts[i].Mesh == (Object)null) { return false; } } if (string.Equals(_walkClipName, "Witch_Walk", StringComparison.Ordinal) && !_walkHasAdvanced) { return false; } return true; } } public bool HasWalkClip { get { if (_clips != null && !string.IsNullOrEmpty(_walkClipName)) { return _clips.ContainsKey(_walkClipName); } return false; } } public string ActiveClipName { get { if (_currentClip == null) { return string.Empty; } return _currentClip.Name; } } public int WalkFrameCount { get { if (_clips == null || !_clips.TryGetValue(_walkClipName, out var value)) { return 0; } return value.FrameCount; } } public float WalkFramesPerSecond { get { if (_clips == null || !_clips.TryGetValue(_walkClipName, out var value)) { return 0f; } return value.FramesPerSecond; } } public int MeshPartCount { get { if (_parts == null) { return 0; } return _parts.Length; } } public float AttackDurationSeconds { get { if (!_clips.TryGetValue(_attackClipName, out var value)) { return 0.5f; } return Mathf.Max(0.02f, (float)(value.FrameCount - 1) / Mathf.Max(1f, value.FramesPerSecond)); } } public static GameObject Load(string animationPath, string objPath, string fallbackSkinPath, Action<string> warning) { return LoadConfigured(animationPath, objPath, fallbackSkinPath, "Creeper_Walk", "Creeper_Fuse", useRunnerState: true, "Fan_CreeperRunner_AnimatedVisual", warning); } public static GameObject LoadHuntsman(string animationPath, string objPath, string fallbackSkinPath, Action<string> warning) { return LoadConfigured(animationPath, objPath, fallbackSkinPath, "Huntsman_Walk", "Huntsman_Attack", useRunnerState: false, "Fan_Huntsman_AnimatedVisual", warning); } public static GameObject LoadOoglyDragon(string animationPath, string objPath, string fallbackSkinPath, Action<string> warning) { GameObject val = LoadConfigured(animationPath, objPath, fallbackSkinPath, "Oogly_Fly", string.Empty, useRunnerState: false, "Fan_Oogly_Dragon_AnimatedVisual", warning); if ((Object)(object)val != (Object)null) { BakedMeshAnimationPlayer component = val.GetComponent<BakedMeshAnimationPlayer>(); if ((Object)(object)component != (Object)null) { component._standalonePlayback = true; } } return val; } public static void PreloadWitch(string animationPath, string objPath, Action<string> warning) { if ((Object)(object)WitchVisualTemplate != (Object)null) { return; } if (WitchVisualPreloadAttempted) { throw new InvalidOperationException("Witch visual preload was already attempted and failed.", WitchVisualPreloadFailure); } WitchVisualPreloadAttempted = true; GameObject val = null; try { val = LoadConfigured(animationPath, objPath, null, "Witch_Walk", string.Empty, useRunnerState: false, "Fan_MinecraftWitch_AnimatedVisual_Template", warning); if ((Object)(object)val == (Object)null) { throw new InvalidOperationException("Could not build the Witch visual template."); } BakedMeshAnimationPlayer component = val.GetComponent<BakedMeshAnimationPlayer>(); if ((Object)(object)component == (Object)null) { throw new InvalidOperationException("Witch visual template has no BakedMeshAnimationPlayer."); } component._standalonePlayback = true; component._standaloneMovementDriven = false; Object.DontDestroyOnLoad((Object)(object)val); val.SetActive(false); WitchVisualTemplate = val; WitchTemplateAnimationPath = Path.GetFullPath(animationPath); WitchTemplateObjPath = Path.GetFullPath(objPath); Debug.Log((object)"[BakedModel] Preloaded Witch visual template, OBJ/MTL, textures and immutable Walk cache before spawn."); } catch (Exception witchVisualPreloadFailure) { WitchVisualPreloadFailure = witchVisualPreloadFailure; if ((Object)(object)val != (Object)null) { Object.Destroy((Object)(object)val); } throw; } } public static GameObject LoadWitch(string animationPath, string objPath, Action<string> warning) { if ((Object)(object)WitchVisualTemplate == (Object)null) { throw new InvalidOperationException("Witch visual template is not preloaded; spawn-time model construction is disabled to prevent frame hitches.", WitchVisualPreloadFailure); } string fullPath = Path.GetFullPath(animationPath); string fullPath2 = Path.GetFullPath(objPath); if (!string.Equals(fullPath, WitchTemplateAnimationPath, StringComparison.OrdinalIgnoreCase) || !string.Equals(fullPath2, WitchTemplateObjPath, StringComparison.OrdinalIgnoreCase)) { throw new InvalidOperationException("Witch spawn assets do not match the preloaded visual template paths."); } GameObject val = Object.Instantiate<GameObject>(WitchVisualTemplate); ((Object)val).name = "Fan_MinecraftWitch_AnimatedVisual"; BakedMeshAnimationPlayer component = val.GetComponent<BakedMeshAnimationPlayer>(); if ((Object)(object)component == (Object)null) { Object.Destroy((Object)(object)val); throw new InvalidOperationException("Preloaded Witch template has no animation player."); } component.PrepareWitchSpawnInstance(); val.SetActive(true); return val; } private void PrepareWitchSpawnInstance() { //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) _initialized = false; _runtimeStartCompleted = false; _walkHasAdvanced = false; _loggedFirstWitchAdvance = false; _walkMaxVertexDisplacement = 0f; _walkMovedVertexCount = 0; _walkMovedPartCount = 0; _witchUpdateAccumulator = 0f; _hasAppliedFrame = false; _currentClip = null; _parts = null; _clips = new Dictionary<string, ClipData>(StringComparer.Ordinal); _runner = null; _movementTransform = null; _stateField = null; _attackActive = false; _externallyPoseFrozen = false; _fuseLocked = false; _reportedAttackMissing = false; _attackCompletionCallback = null; _lastRunnerPosition = Vector3.zero; _hasLastRunnerPosition = false; _runnerPlanarSpeed = 0f; _lastAppliedClip = null; _lastAppliedFrameA = -1; _lastAppliedFrameB = -1; _lastAppliedBlend = -1f; _transitionStartVertices = null; _transitionStartNormals = null; _transitionElapsed = 0f; _transitionDuration = 0f; _standalonePlayback = true; _standaloneMovementDriven = false; _useRunnerState = false; } private static GameObject LoadConfigured(string animationPath, string objPath, string fallbackSkinPath, string walkClipName, string attackClipName, bool useRunnerState, string objectName, Action<string> warning) { //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Expected O, but got Unknown if (string.IsNullOrEmpty(animationPath) || !File.Exists(animationPath)) { return null; } if (string.IsNullOrEmpty(objPath) || !File.Exists(objPath)) { throw new FileNotFoundException("The exported OBJ model was not found.", objPath); } GameObject val = new GameObject(objectName); try { BakedMeshAnimationPlayer bakedMeshAnimationPlayer = val.AddComponent<BakedMeshAnimationPlayer>(); bakedMeshAnimationPlayer._animationPath = animationPath; bakedMeshAnimationPlayer._objPath = objPath; bakedMeshAnimationPlayer._fallbackSkinPath = fallbackSkinPath; bakedMeshAnimationPlayer._walkClipName = walkClipName; bakedMeshAnimationPlayer._attackClipName = attackClipName; bakedMeshAnimationPlayer._useRunnerState = useRunnerState; bakedMeshAnimationPlayer.ReadAnimationFile(animationPath); bakedMeshAnimationPlayer.CreateRenderers(objPath, fallbackSkinPath, warning); bakedMeshAnimationPlayer.SelectClip(bakedMeshAnimationPlayer._walkClipName, loop: true, restart: true); bakedMeshAnimationPlayer.ApplyFrame(0, 0f); bakedMeshAnimationPlayer._initialized = true; return val; } catch { Object.Destroy((Object)(object)val); throw; } } internal bool TryGetCombinedAnimationBounds(out Bounds bounds) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0071: 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_0066: Unknown result type (might be due to invalid IL or missing references) bounds = new Bounds(Vector3.zero, Vector3.zero); if (!_initialized || _parts == null || _parts.Length == 0) { return false; } bool flag = false; for (int i = 0; i < _parts.Length; i++) { PartData partData = _parts[i]; if (partData == null) { continue; } Vector3 size = ((Bounds)(ref partData.AnimationBounds)).size; if (!(((Vector3)(ref size)).sqrMagnitude < 1E-06f)) { if (!flag) { bounds = partData.AnimationBounds; flag = true; } else { ((Bounds)(ref bounds)).Encapsulate(partData.AnimationBounds); } } } return flag; } public bool PlayLoopClip(string clipName) { if (!_initialized || string.IsNullOrEmpty(clipName) || !_clips.ContainsKey(clipName)) { return false; } _attackActive = false; _fuseLocked = false; _attackCompletionCallback = null; BeginPoseTransition(0.32f); SelectClip(clipName, loop: true, restart: false); return true; } public void BindRunner(Component runner) { BindController(runner, useRunnerState: true); } public void BindHunter(Component hunter) { BindController(hunter, useRunnerState: false); } public void SetExternalPoseFrozen(bool frozen) { //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) if (_externallyPoseFrozen != frozen) { _externallyPoseFrozen = frozen; if (!frozen && (Object)(object)_runner != (Object)null) { _lastRunnerPosition = (((Object)(object)_movementTransform != (Object)null) ? _movementTransform.position : _runner.transform.position); _hasLastRunnerPosition = true; _runnerPlanarSpeed = 0f; } } } private void BindController(Component controller, bool useRunnerState) { //IL_007e: 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_0083: Unknown result type (might be due to invalid IL or missing references) _runner = controller; _movementTransform = (((Object)(object)controller != (Object)null) ? controller.transform : null); _useRunnerState = useRunnerState; _stateField = ((useRunnerState && (Object)(object)controller != (Object)null) ? ((object)controller).GetType().GetField("currentState", InstanceFlags) : null); _hasLastRunnerPosition = (Object)(object)_movementTransform != (Object)null; _lastRunnerPosition = (((Object)(object)_movementTransform != (Object)null) ? _movementTransform.position : Vector3.zero); _runnerPlanarSpeed = 0f; _hasAppliedFrame = false; } public void BindMovementTransform(Transform movementTransform) { //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_002d: 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) if (!((Object)(object)_movementTransform == (Object)(object)movementTransform)) { _movementTransform = movementTransform; _hasLastRunnerPosition = (Object)(object)movementTransform != (Object)null; _lastRunnerPosition = (((Object)(object)movementTransform != (Object)null) ? movementTransform.position : Vector3.zero); _runnerPlanarSpeed = 0f; } } public void SetStandaloneMovementDriven(bool enabled) { //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) _standaloneMovementDriven = enabled; _hasLastRunnerPosition = (Object)(object)_movementTransform != (Object)null; _lastRunnerPosition = (((Object)(object)_movementTransform != (Object)null) ? _movementTransform.position : Vector3.zero); _runnerPlanarSpeed = 0f; } private void Start() { _runtimeStartCompleted = false; _walkHasAdvanced = false; _loggedFirstWitchAdvance = false; _walkMaxVertexDisplacement = 0f; _walkMovedVertexCount = 0; _walkMovedPartCount = 0; _witchUpdateAccumulator = 0f; if (string.Equals(_walkClipName, "Oogly_Fly", StringComparison.OrdinalIgnoreCase) || string.Equals(_walkClipName, "Witch_Walk", StringComparison.OrdinalIgnoreCase)) { _standalonePlayback = true; _useRunnerState = false; Debug.Log((object)("[BakedModel] " + _walkClipName + " standalone playback restored on spawned instance.")); } try { _clips.Clear(); ReadAnimationFile(_animationPath); BindExistingMeshesAndMakeUniqueCopies(); SelectClip(_walkClipName, loop: true, restart: true); ApplyFrame(0, 0f); if (!_standalonePlayback) { ResolveControllerAncestor(); } _initialized = true; _runtimeStartCompleted = true; Debug.Log((object)("[BakedModel] Runtime animation initialized: clip=" + ((_currentClip != null) ? _currentClip.Name : "<none>") + "; frames=" + ((_currentClip != null) ? _currentClip.FrameCount : 0) + "; fps=" + ((_currentClip != null) ? _currentClip.FramesPerSecond : 0f).ToString("0.0") + "; meshParts=" + ((_parts != null) ? _parts.Length : 0) + "; standalone=" + _standalonePlayback + "; movementDriven=" + _standaloneMovementDriven + ".")); } catch (Exception ex) { _initialized = false; _runtimeStartCompleted = false; Debug.LogError((object)("[BakedModel] Could not initialize per-instance animation playback: " + ex)); ((Behaviour)this).enabled = false; } } public void PlayFuse() { if (!_clips.TryGetValue(_attackClipName, out var _)) { if (!_reportedAttackMissing) { Debug.LogWarning((object)("[BakedModel] " + _attackClipName + " was not found in the animation cache.")); _reportedAttackMissing = true; } } else if (!_fuseLocked || _currentClip == null || !(_currentClip.Name == _attackClipName)) { _fuseLocked = true; _attackActive = true; SelectClip(_attackClipName, loop: false, restart: true); Debug.Log((object)("[BakedModel] " + _attackClipName + " started.")); } } public void PlayAttack() { PlayAttack(null); } public bool PlayAttack(Action onCompleted) { if (!_initialized) { return false; } if (_useRunnerState) { PlayFuse(); return false; } if (!_clips.ContainsKey(_attackClipName)) { return false; } if (_attackActive && _currentClip != null && _currentClip.Name == _attackClipName) { if (onCompleted != null) { _attackCompletionCallback = onCompleted; } return true; } _attackCompletionCallback = onCompleted; _fuseLocked = false; _attackActive = true; BeginPoseTransition(0.32f); SelectClip(_attackClipName, loop: false, restart: true); return true; } public void ResetFuse() { _fuseLocked = false; _attackActive = false; _attackCompletionCallback = null; SelectClip(_walkClipName, loop: true, restart: true); ApplyFrame(0, 0f); } private void LateUpdate() { //IL_0060: 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_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0070: 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) if (!_initialized || _currentClip == null) { return; } if (_standalonePlayback) { if (_transitionStartVertices != null) { _transitionElapsed = Mathf.Min(_transitionDuration, _transitionElapsed + Time.deltaTime); } if (_standaloneMovementDriven && (Object)(object)_movementTransform != (Object)null) { Vector3 position = _movementTransform.position; if (!_hasLastRunnerPosition) { _lastRunnerPosition = position; _hasLastRunnerPosition = true; } Vector3 val = position - _lastRunnerPosition; _lastRunnerPosition = position; val.y = 0f; if (((Vector3)(ref val)).magnitude / Mathf.Max(Time.deltaTime, 0.0001f) <= 0.06f) { ApplyFrame(0, 0f); return; } } if (string.Equals(_walkClipName, "Witch_Walk", StringComparison.Ordinal)) { _witchUpdateAccumulator += Time.deltaTime; float num = 1f / 30f; if (!(_witchUpdateAccumulator < num)) { float num2 = (float)Mathf.Max(1, Mathf.FloorToInt(_witchUpdateAccumulator / num)) * num; _witchUpdateAccumulator = Mathf.Max(0f, _witchUpdateAccumulator - num2); Advance(num2); } } else { Advance(Time.deltaTime); } } else { if (_externallyPoseFrozen && !_attackActive) { return; } if ((Object)(object)_runner == (Object)null || (_useRunnerState && _stateField == null)) { ResolveControllerAncestor(); } if ((Object)(object)_runner == (Object)null || (_useRunnerState && _stateField == null)) { return; } string text = ""; if (_useRunnerState) { try { object value = _stateField.GetValue(_runner); if (value != null) { text = value.ToString(); } } catch { return; } } UpdateRunnerPlanarSpeed(); if (_transitionStartVertices != null) { _transitionElapsed = Mathf.Min(_transitionDuration, _transitionElapsed + Time.deltaTime); } if (!_useRunnerState) { if (_attackActive) { Advance(Time.deltaTime); return; } if (_currentClip != null && _currentClip.Name == _attackClipName) { BeginPoseTransition(0.32f); } SelectClip(_walkClipName, loop: true, restart: false); if (_runnerPlanarSpeed <= 0.08f) { ApplyFrame(0, 0f); } else { Advance(Time.deltaTime); } } else if (_fuseLocked) { if (_attackActive) { Advance(Time.deltaTime); } else { ApplyCurrentFrame(); } } else if (text == "Stun") { ApplyCurrentFrame(); } else if (_attackActive) { Advance(Time.deltaTime); } else { bool flag = IsRunningState(text); bool flag2 = IsMovingState(text); bool flag3 = _runnerPlanarSpeed > 0.08f; bool num3 = flag || flag2 || flag3; SelectClip(_walkClipName, loop: true, restart: false); if (!num3) { ApplyFrame(0, 0f); } else { Advance(Time.deltaTime * (flag ? 1.3f : 1f)); } } } } private void BeginPoseTransition(float duration) { if (_parts == null || _parts.Length == 0 || duration <= 0f) { return; } Vector3[][] array = new Vector3[_parts.Length][]; Vector3[][] array2 = new Vector3[_parts.Length][]; for (int i = 0; i < _parts.Length; i++) { PartData partData = _parts[i]; if ((Object)(object)partData.Mesh == (Object)null) { return; } array[i] = partData.Mesh.vertices; array2[i] = partData.Mesh.normals; if (array[i] == null || array2[i] == null || array[i].Length != partData.UVs.Length || array2[i].Length != partData.UVs.Length) { return; } } _transitionStartVertices = array; _transitionStartNormals = array2; _transitionElapsed = 0f; _transitionDuration = duration; _hasAppliedFrame = false; } private void UpdateRunnerPlanarSpeed() { //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)_runner == (Object)null)) { Vector3 val = (((Object)(object)_movementTransform != (Object)null) ? _movementTransform.position : _runner.transform.position); if (_hasLastRunnerPosition && Time.deltaTime > 0.0001f) { Vector3 val2 = val - _lastRunnerPosition; val2.y = 0f; float num = ((Vector3)(ref val2)).magnitude / Time.deltaTime; _runnerPlanarSpeed = Mathf.Lerp(_runnerPlanarSpeed, num, Mathf.Clamp01(Time.deltaTime * 14f)); } else { _runnerPlanarSpeed = 0f; _hasLastRunnerPosition = true; } _lastRunnerPosition = val; } } private static bool IsRunningState(string state) { switch (state) { default: return state == "LookUnderStart"; case "AttackPlayer": case "AttackPlayerOver": case "AttackPlayerBackToNavMesh": return true; } } private static bool IsMovingState(string state) { switch (state) { default: return state == "Leave"; case "Roam": case "Investigate": case "SeekPlayer": case "Sneak": return true; } } private void ReadAnimationFile(string path) { //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) string fullPath = Path.GetFullPath(path); if (SharedAnimationCache.TryGetValue(fullPath, out var value)) { UseSharedAnimationData(value); return; } using (FileStream fileStream = File.OpenRead(path)) { using BinaryReader binaryReader = new BinaryReader(fileStream, Encoding.UTF8); string text = Encoding.ASCII.GetString(binaryReader.ReadBytes(8)); if (text != "FANIM001") { throw new InvalidDataException("Unsupported animation cache header: " + text); } int num = binaryReader.ReadInt32(); if (num != 1 && num != 2) { throw new InvalidDataException("Unsupported animation cache version: " + num); } int num2 = ReadBoundedCount(binaryReader, 1, 256, "mesh part"); _parts = new PartData[num2]; for (int i = 0; i < num2; i++) { PartData partData = new PartData(); partData.ObjectName = ReadSafeString(binaryReader); partData.MaterialName = ReadSafeString(binaryReader); int num3 = ReadBoundedCount(binaryReader, 3, 200000, "vertex"); int num4 = ReadBoundedCount(binaryReader, 3, 600000, "triangle index"); if (num4 % 3 != 0) { throw new InvalidDataException("Mesh part has a non-triangular index count: " + partData.ObjectName); } partData.UVs = (Vector2[])(object)new Vector2[num3]; for (int j = 0; j < num3; j++) { partData.UVs[j] = new Vector2(binaryReader.ReadSingle(), binaryReader.ReadSingle()); } partData.Triangles = new int[num4]; for (int k = 0; k < num4; k++) { int num5 = binaryReader.ReadInt32(); if (num5 < 0 || num5 >= num3) { throw new InvalidDataException("Mesh part contains an out-of-range triangle index."); } partData.Triangles[k] = num5; } if (num >= 2) { int num6 = binaryReader.ReadInt32(); if (num6 != 0 && num6 != 1) { throw new InvalidDataException("Mesh part has an invalid animated/static flag: " + num6 + "."); } partData.IsAnimated = num6 == 1; } else { partData.IsAnimated = true; } _parts[i] = partData; } int num7 = ReadBoundedCount(binaryReader, 1, 16, "animation clip"); for (int l = 0; l < num7; l++) { ClipData clipData = new ClipData(); clipData.Name = ReadSafeString(binaryReader); float num8 = binaryReader.ReadSingle(); if (!IsFinite(num8) || num8 <= 0f || num8 > 120f) { throw new InvalidDataException("Animation clip has an invalid FPS value: " + num8 + "."); } clipData.FramesPerSecond = num8; clipData.FrameCount = ReadBoundedCount(binaryReader, 2, 1200, "animation frame"); clipData.LoopFrameCount = ReadBoundedCount(binaryReader, 1, clipData.FrameCount, "loop frame"); int num9 = binaryReader.ReadInt32(); if (num9 != 0 && num9 != 1) { throw new InvalidDataException("Animation clip has an invalid loop flag: " + num9 + "."); } clipData.Loop = num9 == 1; if (clipData.Loop && clipData.LoopFrameCount < 2) { throw new InvalidDataException("Looping animation must contain at least two distinct playable frames: " + clipData.Name + "."); } if (!clipData.Loop) { clipData.LoopFrameCount = clipData.FrameCount; } clipData.Positions = new Vector3[clipData.FrameCount][][]; clipData.Normals = new Vector3[clipData.FrameCount][][]; Vector3[][] array = new Vector3[num2][]; Vector3[][] array2 = new Vector3[num2][]; if (num >= 2) { for (int m = 0; m < num2; m++) { if (!_parts[m].IsAnimated) { int count = _parts[m].UVs.Length; array[m] = ReadFiniteVectorArray(binaryReader, count, clipData.Name, "static vertex"); array2[m] = ReadFiniteVectorArray(binaryReader, count, clipData.Name, "static normal"); } } } for (int n = 0; n < clipData.FrameCount; n++) { clipData.Positions[n] = new Vector3[num2][]; clipData.Normals[n] = new Vector3[num2][]; for (int num10 = 0; num10 < num2; num10++) { if (!_parts[num10].IsAnimated) { clipData.Positions[n][num10] = array[num10]; clipData.Normals[n][num10] = array2[num10]; } else { int count2 = _parts[num10].UVs.Length; clipData.Positions[n][num10] = ReadFiniteVectorArray(binaryReader, count2, clipData.Name, "vertex"); clipData.Normals[n][num10] = ReadFiniteVectorArray(binaryReader, count2, clipData.Name, "normal"); } } } if (_clips.ContainsKey(clipData.Name)) { throw new InvalidDataException("Duplicate animation clip: " + clipData.Name); } _clips.Add(clipData.Name, clipData); } if (fileStream.Position != fileStream.Length) { Debug.LogWarning((object)("[CreeperRunner] Animation cache has " + (fileStream.Length - fileStream.Position) + " unused trailing bytes.")); } } if (!_clips.ContainsKey(_walkClipName)) { throw new InvalidDataException("Animation cache must contain the default clip " + _walkClipName + "."); } if (!string.IsNullOrEmpty(_attackClipName) && !_clips.ContainsKey(_attackClipName)) { throw new InvalidDataException("Animation cache must contain the attack clip " + _attackClipName + "."); } BuildAnimationBounds(); StoreSharedAnimationData(fullPath); } private void BuildAnimationBounds() { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: 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_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_006f: 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_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005f: 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) Bounds val = default(Bounds); for (int i = 0; i < _parts.Length; i++) { bool flag = false; ((Bounds)(ref val))..ctor(Vector3.zero, Vector3.zero); foreach (ClipData value in _clips.Values) { for (int j = 0; j < value.FrameCount; j++) { Vector3[] array = value.Positions[j][i]; for (int k = 0; k < array.Length; k++) { if (!flag) { val = new Bounds(array[k], Vector3.zero); flag = true; } else { ((Bounds)(ref val)).Encapsulate(array[k]); } } } } _parts[i].AnimationBounds = (Bounds)(flag ? val : new Bounds(Vector3.zero, Vector3.one)); } } private void StoreSharedAnimationData(string cacheKey) { //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) AnimationCacheEntry animationCacheEntry = new AnimationCacheEntry(); animationCacheEntry.Parts = new PartData[_parts.Length]; for (int i = 0; i < _parts.Length; i++) { PartData partData = _parts[i]; animationCacheEntry.Parts[i] = new PartData { ObjectName = partData.ObjectName, MaterialName = partData.MaterialName, UVs = partData.UVs, Triangles = partData.Triangles, IsAnimated = partData.IsAnimated, AnimationBounds = partData.AnimationBounds }; } animationCacheEntry.Clips = new Dictionary<string, ClipData>(_clips, StringComparer.Ordinal); SharedAnimationCache[cacheKey] = animationCacheEntry; } private void UseSharedAnimationData(AnimationCacheEntry entry) { //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) _parts = new PartData[entry.Parts.Length]; for (int i = 0; i < entry.Parts.Length; i++) { PartData partData = entry.Parts[i]; _parts[i] = new PartData { ObjectName = partData.ObjectName, MaterialName = partData.MaterialName, UVs = partData.UVs, Triangles = partData.Triangles, IsAnimated = partData.IsAnimated, AnimationBounds = partData.AnimationBounds }; } _clips.Clear(); foreach (KeyValuePair<string, ClipData> clip in entry.Clips) { _clips.Add(clip.Key, clip.Value); } _hasAppliedFrame = false; } private void CreateRenderers(string objPath, string fallbackSkinPath, Action<string> warning) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Expected O, but got Unknown //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) ClipData clipData = _clips[_walkClipName]; for (int i = 0; i < _parts.Length; i++) { PartData partData = _parts[i]; Mesh val = new Mesh(); ((Object)val).name = "CreeperRunner_Animated_" + SafeName(partData.ObjectName) + "_" + SafeName(partData.MaterialName); if (partData.UVs.Length > 65535) { val.indexFormat = (IndexFormat)1; } val.MarkDynamic(); val.vertices = clipData.Positions[0][i]; val.uv = partData.UVs; val.triangles = partData.Triangles; val.normals = clipData.Normals[0][i]; val.bounds = partData.AnimationBounds; partData.Mesh = val; partData.BlendVertices = (Vector3[])(object)new Vector3[partData.UVs.Length]; partData.BlendNormals = (Vector3[])(object)new Vector3[partData.UVs.Length]; GameObject val2 = new GameObject("AnimatedMeshPart_" + i.ToString(CultureInfo.InvariantCulture) + "_" + SafeName(partData.ObjectName) + "_" + SafeName(partData.MaterialName)); val2.transform.SetParent(((Component)this).transform, false); val2.AddComponent<MeshFilter>().sharedMesh = val; ((Renderer)val2.AddComponent<MeshRenderer>()).sharedMaterial = RuntimeObjModel.LoadMaterialForAnimation(partData.MaterialName, objPath, fallbackSkinPath, warning); } } private void BindExistingMeshesAndMakeUniqueCopies() { //IL_00ee: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < _parts.Length; i++) { PartData partData = _parts[i]; string text = "AnimatedMeshPart_" + i.ToString(CultureInfo.InvariantCulture) + "_" + SafeName(partData.ObjectName) + "_" + SafeName(partData.MaterialName); Transform obj = ((Component)this).transform.Find(text); if ((Object)(object)obj == (Object)null) { throw new InvalidDataException("Animated mesh child was not found in the spawned prefab: " + text); } MeshFilter component = ((Component)obj).GetComponent<MeshFilter>(); if ((Object)(object)component == (Object)null || (Object)(object)component.sharedMesh == (Object)null) { throw new InvalidDataException("Animated mesh child has no MeshFilter/Mesh: " + text); } Mesh val = Object.Instantiate<Mesh>(component.sharedMesh); ((Object)val).name = ((Object)component.sharedMesh).name + "_Instance"; val.MarkDynamic(); component.sharedMesh = val; val.bounds = partData.AnimationBounds; partData.Mesh = val; partData.BlendVertices = (Vector3[])(object)new Vector3[partData.UVs.Length]; partData.BlendNormals = (Vector3[])(object)new Vector3[partData.UVs.Length]; } } private void ResolveControllerAncestor() { string b = (_useRunnerState ? "EnemyRunner" : "EnemyHunter"); Transform parent = ((Component)this).transform.parent; while ((Object)(object)parent != (Object)null) { Component[] components = ((Component)parent).GetComponents<Component>(); foreach (Component val in components) { if (!((Object)(object)val == (Object)null) && string.Equals(((object)val).GetType().Name, b, StringComparison.Ordinal)) { BindController(val, _useRunnerState); if (!_useRunnerState || _stateField != null) { return; } } } parent = parent.parent; } } private void SelectClip(string name, bool loop, bool restart) { if (_clips.TryGetValue(name, out var value) && (_currentClip != value || restart) && (_currentClip != value || loop || restart)) { string text = ((_currentClip != null) ? _currentClip.Name : "<none>"); _currentClip = value; _framePosition = 0f; _hasAppliedFrame = false; if (string.Equals(_walkClipName, "Witch_Walk", StringComparison.Ordinal) && string.Equals(name, "Witch_Walk", StringComparison.Ordinal)) { _walkHasAdvanced = false; _loggedFirstWitchAdvance = false; _walkMaxVertexDisplacement = 0f; _walkMovedVertexCount = 0; _walkMovedPartCount = 0; } if (name == _attackClipName) { _attackActive = true; } if (!string.Equals(text, name, StringComparison.Ordinal)) { Debug.Log((object)("[CreeperRunner] Animation changed: " + text + " -> " + name + ".")); } } } private void Advance(float deltaTime) { if (_currentClip == null || deltaTime <= 0f) { ApplyCurrentFrame(); return; } _framePosition += deltaTime * _currentClip.FramesPerSecond; int num = (_currentClip.Loop ? _currentClip.LoopFrameCount : _currentClip.FrameCount); bool flag = false; if (_currentClip.Loop) { if (_framePosition >= (float)num) { _framePosition %= num; } } else if (_framePosition >= (float)(_currentClip.FrameCount - 1)) { _framePosition = _currentClip.FrameCount - 1; if (_currentClip.Name == _attackClipName && _attackActive) { _attackActive = false; flag = true; } } int num2 = Mathf.Clamp(Mathf.FloorToInt(_framePosition), 0, _currentClip.FrameCount - 1); int num3 = num2 + 1; ApplyFrame(frameB: (!_currentClip.Loop) ? Mathf.Min(num3, _currentClip.FrameCount - 1) : (num3 % num), frameA: num2, blend: _framePosition - (float)num2); if (!flag) { return; } Action attackCompletionCallback = _attackCompletionCallback; _attackCompletionCallback = null; if (attackCompletionCallback == null) { return; } try { attackCompletionCallback(); } catch (Exception ex) { Debug.LogError((object)("[BakedModel] Attack completion callback failed: " + ex)); } } private void ApplyCurrentFrame() { if (_currentClip != null) { int num = Mathf.Clamp(Mathf.FloorToInt(_framePosition), 0, _currentClip.FrameCount - 1); int frameB = (_currentClip.Loop ? ((num + 1) % _currentClip.LoopFrameCount) : Mathf.Min(num + 1, _currentClip.FrameCount - 1)); ApplyFrame(num, _framePosition - (float)num, frameB); } } private void ApplyFrame(int frameA, float blend) { int frameB = (_currentClip.Loop ? ((frameA + 1) % _currentClip.LoopFrameCount) : Mathf.Min(frameA + 1, _currentClip.FrameCount - 1)); ApplyFrame(frameA, blend, frameB); } private void ApplyFrame(int frameA, float blend, int frameB) { //IL_0192: Unknown result type (might be due to invalid IL or missing references) //IL_0278: Unknown result type (might be due to invalid IL or missing references) //IL_0281: Unknown result type (might be due to invalid IL or missing references) //IL_0287: 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_0295: Unknown result type (might be due to invalid IL or missing references) //IL_029e: Unknown result type (might be due to invalid IL or missing references) //IL_02a4: Unknown result type (might be due to invalid IL or missing references) //IL_02a9: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_0181: Unknown result type (might be due to invalid IL or missing references) //IL_0187: 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_0320: Unknown result type (might be due to invalid IL or missing references) //IL_0325: 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_02cc: Unknown result type (might be due to invalid IL or missing references) //IL_02db: Unknown result type (might be due to invalid IL or missing references) //IL_02c5: Unknown result type (might be due to invalid IL or missing references) //IL_01c3: Unknown result type (might be due to invalid IL or missing references) //IL_02e0: Unknown result type (might be due to invalid IL or missing references) //IL_01c8: Unknown result type (might be due to invalid IL or missing references) //IL_01d2: 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_01da: 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_01e8: Unknown result type (might be due to invalid IL or missing references) //IL_01ed: Unknown result type (might be due to invalid IL or missing references) //IL_01f0: 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_01a9: Unknown result type (might be due to invalid IL or missing references) //IL_01b2: Unknown result type (might be due to invalid IL or missing references) //IL_01b8: Unknown result type (might be due to invalid IL or missing references) //IL_0211: 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_020d: Unknown result type (might be due to invalid IL or missing references) //IL_0225: Unknown result type (might be due to invalid IL or missing references) if (_currentClip == null) { return; } blend = Mathf.Clamp01(blend); bool flag = _transitionStartVertices != null && _transitionStartNormals != null && _transitionDuration > 0f; float num = (flag ? Mathf.Clamp01(_transitionElapsed / _transitionDuration) : 1f); bool flag2 = string.Equals(_walkClipName, "Witch_Walk", StringComparison.Ordinal) && string.Equals(_currentClip.Name, "Witch_Walk", StringComparison.Ordinal); float num2 = 0f; int num3 = 0; int num4 = 0; if (!flag && _hasAppliedFrame && _lastAppliedClip == _currentClip && _lastAppliedFrameA == frameA && _lastAppliedFrameB == frameB && Mathf.Abs(_lastAppliedBlend - blend) < 1E-05f) { return; } for (int i = 0; i < _parts.Length; i++) { PartData partData = _parts[i]; if (!partData.IsAnimated && !flag) { continue; } Vector3[] array = _currentClip.Positions[frameA][i]; Vector3[] array2 = _currentClip.Positions[frameB][i]; Vector3[] array3 = _currentClip.Normals[frameA][i]; Vector3[] array4 = _currentClip.Normals[frameB][i]; Vector3[] array5; Vector3[] array6; if (flag) { array5 = partData.BlendVertices; array6 = partData.BlendNormals; Vector3[] array7 = _transitionStartVertices[i]; Vector3[] array8 = _transitionStartNormals[i]; for (int j = 0; j < array5.Length; j++) { Vector3 val = ((blend <= 0.001f || frameA == frameB) ? array[j] : Vector3.LerpUnclamped(array[j], array2[j], blend)); Vector3 val2 = ((blend <= 0.001f || frameA == frameB) ? array3[j] : Vector3.LerpUnclamped(array3[j], array4[j], blend)); array5[j] = Vector3.LerpUnclamped(array7[j], val, num); Vector3 val3 = Vector3.LerpUnclamped(array8[j], val2, num); float sqrMagnitude = ((Vector3)(ref val3)).sqrMagnitude; array6[j] = ((sqrMagnitude > 1E-06f) ? (val3 * (1f / Mathf.Sqrt(sqrMagnitude))) : val2); } } else if (blend <= 0.001f || frameA == frameB) { array5 = array; array6 = array3; } else { array5 = partData.BlendVertices; array6 = partData.BlendNormals; for (int k = 0; k < array5.Length; k++) { array5[k] = Vector3.LerpUnclamped(array[k], array2[k], blend); Vector3 val4 = Vector3.LerpUnclamped(array3[k], array4[k], blend); float sqrMagnitude2 = ((Vector3)(ref val4)).sqrMagnitude; array6[k] = ((sqrMagnitude2 > 1E-06f) ? (val4 * (1f / Mathf.Sqrt(sqrMagnitude2))) : array3[k]); } } if (flag2) { Vector3[] array9 = _currentClip.Positions[0][i]; int num5 = 0; for (int l = 0; l < array5.Length; l++) { Vector3 val5 = array5[l] - array9[l]; float magnitude = ((Vector3)(ref val5)).magnitude; if (magnitude > num2) { num2 = magnitude; } if (magnitude >= 0.00025f) { num5++; } } if (num5 > 0) { num4++; } num3 += num5; } partData.Mesh.vertices = array5; partData.Mesh.normals = array6; } if (flag && num >= 1f) { _transitionStartVertices = null; _transitionStartNormals = null; _transitionElapsed = 0f; _transitionDuration = 0f; } if (flag2) { if (num2 > _walkMaxVertexDisplacement) { _walkMaxVertexDisplacement = num2; } _walkMovedVertexCount = num3; _walkMovedPartCount = num4; _walkHasAdvanced = _walkHasAdvanced || (num2 >= 0.0005f && num3 >= 3 && num4 > 0); if (_walkHasAdvanced && !_loggedFirstWitchAdvance) { _loggedFirstWitchAdvance = true; Debug.Log((object)("[BakedModel] Witch_Walk deformed the replacement mesh: frameDelta=" + num2.ToString("0.0000") + "m; maxDelta=" + _walkMaxVertexDisplacement.ToString("0.0000") + "m; movedVerticesInFrame=" + _walkMovedVertexCount + "; movedParts=" + _walkMovedPartCount + "; appliedFrames=" + frameA + "/" + frameB + "; blend=" + blend.ToString("0.00") + ".")); } } _lastAppliedClip = _currentClip; _lastAppliedFrameA = frameA; _lastAppliedFrameB = frameB; _lastAppliedBlend = blend; _hasAppliedFrame = true; } private static Vector3[] ReadFiniteVectorArray(BinaryReader reader, int count, string clipName, string label) { //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) Vector3[] array = (Vector3[])(object)new Vector3[count]; for (int i = 0; i < count; i++) { float num = reader.ReadSingle(); float num2 = reader.ReadSingle(); float num3 = reader.ReadSingle(); if (!IsFinite(num) || !IsFinite(num2) || !IsFinite(num3)) { throw new InvalidDataException("Animation cache contains a non-finite " + label + " coordinate in " + clipName + "."); } array[i] = new Vector3(num, num2, num3); } return array; } private static bool IsFinite(float value) { if (!float.IsNaN(value)) { return !float.IsInfinity(value); } return false; } private static int ReadBoundedCount(BinaryReader reader, int min, int max, string label) { int num = reader.ReadInt32(); if (num < min || num > max) { throw new InvalidDataException("Invalid " + label + " count in animation cache: " + num); } return num; } private static string ReadSafeString(BinaryReader reader) { int num = ReadBoundedCount(reader, 0, 4096, "string byte"); byte[] array = reader.ReadBytes(num); if (array.Length != num) { throw new EndOfStreamException("Unexpected end of animation cache string."); } return Encoding.UTF8.GetString(array); } private static string SafeName(string value) { if (string.IsNullOrEmpty(value)) { return "unnamed"; } StringBuilder stringBuilder = new StringBuilder(value.Length); foreach (char c in value) { stringBuilder.Append((char.IsLetterOrDigit(c) || c == '_' || c == '-') ? c : '_'); } return stringBuilder.ToString(); } } internal sealed class CreeperFuseBehavior : MonoBehaviour { private static readonly BindingFlags InstanceFlags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic; private static readonly BindingFlags StaticFlags = BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic; private static readonly string[] TargetMemberNames = new string[4] { "playerTarget", "targetPlayer", "currentTarget", "onVisionTriggeredPlayer" }; private static MethodInfo _hostCheckMethod; private static bool _hostCheckMethodResolved; private static bool _cachedHostRole; private static float _nextHostRoleCheck; private static Texture2D _cachedSoftParticleTexture; private static Texture2D _cachedSparkParticleTexture; private static Material _cachedSoftParticleMaterial; private static Material _cachedSparkParticleMaterial; private static Material _cachedSmokeParticleMaterial; private static Material _cachedShockwaveMaterial; [SerializeField] private Component _runner; [SerializeField] private BakedMeshAnimationPlayer _animationPlayer; [SerializeField] private Component _explosion; [SerializeField] private PhotonView _photonView; [SerializeField] private float _activationDistance = 2f; [SerializeField] private float _fuseSeconds = 3f; [SerializeField] private float _explosionRadius = 3f; [SerializeField] private int _playerDamage = 100; [SerializeField] private float _knockback = 1.25f; [SerializeField] private float _screenShake = 1f; private bool _startRequested; private bool _fusing; private bool _detonated; private bool _selfDestructStarted; private bool _warnedMissingTarget; private bool _warnedDamageMethod; private bool _damageSuppressionLogged; private float _detonateAt; private float _nextProximityCheck; private float _nextDamageSuppressionCheck; private Component[] _cachedVisionComponents; private Component[] _cachedPlayerAvatars; private Type _playerAvatarType; private float _nextVisionRefresh; private float _nextAvatarRefresh; private float _nextReferenceResolve; public void Initialize(Component runner, BakedMeshAnimationPlayer animationPlayer, Component explosion, PhotonView photonView, float activationDistance, float fuseSeconds, float explosionRadius, int playerDamage, float knockback, float screenShake) { _runner = runner; _animationPlayer = animationPlayer; _explosion = explosion; _photonView = photonView; _activationDistance = Mathf.Clamp(activationDistance, 0.5f, 6f); _fuseSeconds = Mathf.Clamp(fuseSeconds, 0.5f, 10f); _explosionRadius = Mathf.Clamp(explosionRadius, 0.5f, 10f); _playerDamage = Mathf.Clamp(playerDamage, 1, 500); _knockback = Mathf.Clamp(knockback, 0f, 8f); _screenShake = Mathf.Clamp(screenShake, 0f, 5f); } private void Start() { ResolveReferences(); ApplyOriginalRunnerDamageSuppression(); RefreshPhotonRpcCache(); } private void Update() { //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_0196: Unknown result type (might be due to invalid IL or missing references) //IL_019c: Unknown result type (might be due to invalid IL or missing references) if (((Object)(object)_runner == (Object)null || (Object)(object)_animationPlayer == (Object)null || (Object)(object)_photonView == (Object)null) && Time.time >= _nextReferenceResolve) { _nextReferenceResolve = Time.time + 0.5f; ResolveReferences(); } if (_detonated || (Object)(object)_runner == (Object)null) { return; } if (Time.time >= _nextDamageSuppressionCheck) { _nextDamageSuppressionCheck = Time.time + 0.5f; ApplyOriginalRunnerDamageSuppression(); } if (Time.time < _nextProximityCheck) { return; } _nextProximityCheck = Time.time + 0.1f; if (!IsHostOrSinglePlayer()) { return; } Transform val = ResolveCurrentTarget(); if (_fusing) { float num = Mathf.Max(_activationDistance, _explosionRadius); if ((Object)(object)val == (Object)null || PlanarDistance(_runner.transform.position, val.position) > num) { CancelFuseOnHost(((Object)(object)val == (Object)null) ? "target lost" : "target left blast radius"); return; } EnsureRunnerChaseDuringFuse(); if (Time.time >= _detonateAt) { DetonateOnHost(); } return; } object obj = ReadMember(_runner, "currentState"); string text = ((obj != null) ? obj.ToString() : string.Empty); if (!IsRunnerInChaseState(text) && !string.Equals(text, "StuckAttack", StringComparison.OrdinalIgnoreCase)) { return; } if ((Object)(object)val == (Object)null) { if (!_warnedMissingTarget) { Debug.LogWarning((object)"[CreeperRunner] Runner is in a chase/attack state, but no player target could be resolved yet."); _warnedMissingTarget = true; } } else if (PlanarDistance(_runner.transform.position, val.position) <= _activationDistance) { StartFuseOnHost(); } } internal void ResetForSpawn() { _startRequested = false; _fusing = false; _detonated = false; _selfDestructStarted = false; _detonateAt = 0f; _nextProximityCheck = 0f; _nextDamageSuppressionCheck = 0f; _warnedMissingTarget = false; _warnedDamageMethod = false; _cachedVisionComponents = null; _cachedPlayerAvatars = null; _playerAvatarType = null; _nextVisionRefresh = 0f; _nextAvatarRefresh = 0f; _nextReferenceResolve = 0f; if ((Object)(object)_animationPlayer != (Object)null) { _animationPlayer.ResetFuse(); } } internal void HandleRunnerAttackState() { //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_runner == (Object)null || _detonated || !IsHostOrSinglePlayer()) { return; } if (_fusing) { EnsureRunnerChaseDuringFuse(); return; } Transform val = ResolveCurrentTarget(); if (!((Object)(object)val == (Object)null)) { if (PlanarDistance(_runner.transform.position, val.position) <= _activationDistance) { StartFuseOnHost(); } else { ForceRunnerChase(); } } } private void StartFuseOnHost() { if (_startRequested || _fusing || _detonated) { return; } _startRequested = true; if ((Object)(object)_photonView != (Object)null && _photonView.ViewID != 0) { try { _photonView.RPC("FuseStartRPC", (RpcTarget)0, Array.Empty<object>()); return; } catch (Exception ex) { Debug.LogWarning((object)("[CreeperRunner] Fuse RPC could not be sent; starting locally as a fallback: " + ex.Message)); } } FuseStartRPC(); } [PunRPC] private void FuseStartRPC() { //IL_0088: 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) if (!_fusing && !_detonated) { _startRequested = true; _fusing = true; _detonateAt = Time.time + _fuseSeconds; _nextProximityCheck = 0f; if (IsHostOrSinglePlayer()) { EnsureRunnerChaseDuringFuse(); } if ((Object)(object)_animationPlayer != (Object)null) { _animationPlayer.PlayFuse(); } MobAudio.PlayCreeperFuse(((Object)(object)_runner != (Object)null) ? _runner.transform.position : ((Component)this).transform.position); Debug.Log((object)("[CreeperRunner] FUSE STARTED: activation distance=" + _activationDistance.ToString("F1") + " m; detonation in " + _fuseSeconds.ToString("F1") + " s; blast radius=" + _explosionRadius.ToString("F1") + " m; player damage=" + _playerDamage + ".")); } } private void CancelFuseOnHost(string reason) { if (!_fusing || _detonated || !IsHostOrSinglePlayer()) { return; } Debug.Log((object)("[CreeperRunner] FUSE CANCELLED: " + reason + "; target left the " + Mathf.Max(_activationDistance, _explosionRadius).ToString("F1") + " m danger radius.")); if ((Object)(object)_photonView != (Object)null && _photonView.ViewID != 0) { try { _photonView.RPC("FuseCancelRPC", (RpcTarget)0, Array.Empty<object>()); return; } catch (Exception ex) { Debug.LogWarning((object)("[CreeperRunner] Fuse-cancel RPC failed; cancelling locally: " + ex.Message)); } } FuseCancelRPC(); } [PunRPC] private void FuseCancelRPC() { if (!_detonated) { _fusing = false; _startRequested = false; _detonateAt = 0f; _nextProximityCheck = 0f; if ((Object)(object)_animationPlayer != (Object)null) { _animationPlayer.ResetFuse(); } if (IsHostOrSinglePlayer()) { ForceRunnerChase(); } } } private void DetonateOnHost() { //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_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_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: 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_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) if (_detonated || !_fusing || !IsHostOrSinglePlayer()) { return; } Transform val = ResolveCurrentTarget(); float num = Mathf.Max(_activationDistance, _explosionRadius); if ((Object)(object)val == (Object)null || PlanarDistance(_runner.transform.position, val.position) > num) { CancelFuseOnHost(((Object)(object)val == (Object)null) ? "target lost at detonation check" : "target left danger radius at detonation check"); return; } _detonated = true; _fusing = false; Vector3 center = (((Object)(object)_runner != (Object)null) ? (_runner.transform.position + Vector3.up * 0.55f) : ((Component)this).transform.position); bool nativeEffectOnHost = TrySpawnNativeExplosion(center); BroadcastFallbackVisual(center, nativeEffectOnHost); int num2 = ApplyAreaDamage(center); Debug.Log((object)("[CreeperRunner] DETONATED once. Native Bang effect=" + nativeEffectOnHost + "; players damaged=" + num2 + "; damage=" + _playerDamage + "; radius=" + _explosionRadius.ToString("F1") + " m.")); if (!_selfDestructStarted) { _selfDestructStarted = true; ((MonoBehaviour)this).StartCoroutine(KillCreeperAfterBlast()); } } private bool TrySpawnNativeExplosion(Vector3 center) { //IL_017e: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_explosion == (Object)null) { ResolveNativeExplosionOnThisObject(); } if ((Object)(object)_explosion == (Object)null) { return false; } MethodInfo[] methods = ((object)_explosion).GetType().GetMethods(InstanceFlags); foreach (MethodInfo methodInfo in methods) { if (!string.Equals(methodInfo.Name, "Spawn", StringComparison.Ordinal)) { continue; } ParameterInfo[] parameters = methodInfo.GetParameters(); if ((parameters.Length != 8 && parameters.Length != 9) || parameters[0].ParameterType != typeof(Vector3) || parameters[1].ParameterType != typeof(float) || parameters[2].ParameterType != typeof(int) || parameters[3].ParameterType != typeof(int) || parameters[4].ParameterType != typeof(float) || parameters[5].ParameterType != typeof(bool) || parameters[6].ParameterType != typeof(bool) || parameters[7].ParameterType != typeof(float) || (parameters.Length == 9 && parameters[8].ParameterType != typeof(float))) { continue; } try { object[] array = new object[8] { center, _explosionRadius, 0, 0, _knockback, false, false, _screenShake }; if (parameters.Length == 9) { Array.Resize(ref array, 9); array[8] = 0f; } methodInfo.Invoke(_explosion, array); return true; } catch (Exception exception) { Debug.LogWarning((object)("[CreeperRunner] Native Bang visual/force call failed: " + Unwrap(exception).Message)); } } return false; } private void ResolveNativeExplosionOnThisObject() { Type type = FindLoadedType("ParticleScriptExplosion"); if (type == null) { return; } Component val = null; Type type2 = FindLoadedType("EnemyBang"); if (type2 != null) { Object[] array = Resources.FindObjectsOfTypeAll(type2); for (int i = 0; i < array.Length; i++) { if (!((Object)(object)val == (Object)null)) { break; } Object obj = array[i]; Component val2 = (Component)(object)((obj is Component) ? obj : null); if ((Object)(object)val2 != (Object)null) { object obj2 = ReadMember(val2, "particleScriptExplosion"); val = (Component)((obj2 is Component) ? obj2 : null); } } } Component val3 = ((Component)this).GetComponent(type); if ((Object)(object)val3 == (Object)null) { try { val3 = ((Component)this).gameObject.AddComponent(type); } catch (Exception ex) { Debug.LogWarning((object)("[CreeperRunner] Could not attach native Bang effect component: " + ex.Message)); return; } } if ((Object)(object)val != (Object)null && (Object)(object)val3 != (Object)(object)val) { CopySerializedFields(val, val3); } _explosion = val3; RefreshPhotonRpcCache(); } private int ApplyAreaDamage(Vector3 center) { //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) Type type = FindLoadedType("PlayerAvatar"); if (type == null) { Debug.LogError((object)"[CreeperRunner] PlayerAvatar type was not found; the blast could not damage players."); return 0; } Object[] array = Object.FindObjectsOfType(type); int num = 0; int num2 = 0; foreach (Object obj in array) { Component val = (Component)(object)((obj is Component) ? obj : null); if (!((Object)(object)val == (Object)null) && val.gameObject.activeInHierarchy && !IsPlayerUnavailable(val) && !(Vector3.Distance(center, val.transform.position) > _explosionRadius)) { num2++; Component val2 = ResolvePlayerHealth(val); if ((Object)(object)val2 == (Object)null) { Debug.LogWarning((object)("[CreeperRunner] PlayerHealth component missing for nearby player " + ((Object)val).name + ".")); } else if (TryHurtOther(val2, _playerDamage)) { num++; } else if (!_warnedDamageMethod) { Debug.LogError((object)"[CreeperRunner] No compatible PlayerHealth.HurtOther method was found. Nearby players were not damaged; inspect the game version/API."); _warnedDamageMethod = true; } } } if (num2 == 0) { Debug.Log((object)"[CreeperRunner] No players were inside the explosion radius at detonation."); } else if (num < num2) { Debug.LogWarning((object)("[CreeperRunner] AoE damage applied to " + num + " of " + num2 + " nearby players.")); } return num; } private static Component ResolvePlayerHealth(Component avatar) { Type type = FindLoadedType("PlayerHealth"); if (type == null) { return null; } object obj = ReadMember(avatar, "playerHealth"); Component val = (Component)((obj is Component) ? obj : null); if ((Object)(object)val != (Object)null) { return val; } val = avatar.GetComponent(type); if ((Object)(object)val != (Object)null) { return val; } return avatar.GetComponentInChildren(type, true); } private static bool IsPlayerUnavailable(Component avatar) { object obj = ReadMember(avatar, "isDisabled"); if (obj is bool && (bool)obj) { return true; } object obj2 = ReadMember(avatar, "deadSet"); if (obj2 is bool && (bool)obj2) { return true; } Component instance = ResolvePlayerHealth(avatar); object obj3 = ReadMember(instance, "health"); if (obj3 is int && (int)obj3 <= 0) { return true; } object obj4 = ReadMember(instance, "dead"); if (obj4 is bool) { return (bool)obj4; } return false; } private static bool TryHurtOther(Component playerHealth, int damage) { //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_021b: Unknown result type (might be due to invalid IL or missing references) Type type = ((object)playerHealth).GetType(); Type[] types = new Type[5] { typeof(int), typeof(Vector3), typeof(bool), typeof(int), typeof(bool) }; Type[] types2 = new Type[4] { typeof(int), typeof(Vector3), typeof(bool), typeof(int) }; MethodInfo method = type.GetMethod("HurtOther", InstanceFlags, null, types, null); object[] parameters = new object[5] { damage, Vector3.zero, false, -1, false }; if (method == null) { method = type.GetMethod("HurtOther", InstanceFlags, null, types2, null); parameters = new object[4] { damage, Vector3.zero, false, -1 }; } if (method != null) { try { method.Invoke(playerHealth, parameters); return true; } catch (Exception exception) { Debug.LogWarning((object)("[CreeperRunner] PlayerHealth.HurtOther exact overload failed: " + Unwrap(exception).Message)); return false; } } MethodInfo methodInfo = null; object[] parameters2 = null; int num = int.MaxValue; MethodInfo[] methods = type.GetMethods(InstanceFlags); foreach (MethodInfo methodInfo2 in methods) { if (!string.Equals(methodInfo2.Name, "HurtOther", StringComparison.Ordinal)) { continue; } ParameterInfo[] parameters3 = methodInfo2.GetParameters(); if (parameters3.Length == 0 || parameters3[0].ParameterType != typeof(int)) { continue; } object[] array = new object[parameters3.Length]; array[0] = damage; int num2 = parameters3.Length; bool flag = true; for (int j = 1; j < parameters3.Length; j++) { Type parameterType = parameters3[j].ParameterType; if (parameterType == typeof(Vector3)) { array[j] = Vector3.zero; continue; } if (parameterType == typeof(bool)) { array[j] = false; continue; } if (parameterType == typeof(int)) { array[j] = -1; continue; } if (parameters3[j].HasDefaultValue) { array[j] = parameters3[j].DefaultValue; continue; } if (parameterType.IsValueType) { array[j] = Activator.CreateInstance(parameterType); continue; } if (!parameterType.IsPointer) { array[j] = null; continue; } flag = false; break; } if (flag && num2 < num) { methodInfo = methodInfo2; parameters2 = array; num = num2; } } if (methodInfo == null) { return false; } try { methodInfo.Invoke(playerHealth, parameters2); return true; } catch (Exception exception2) { Debug.LogWarning((object)("[CreeperRunner] PlayerHealth.HurtOther compatibility overload failed: " + Unwrap(exception2).Message)); return false; } } private IEnumerator KillCreeperAfterBlast() { yield return (object)new WaitForSeconds(0.12f); if ((Object)(object)_runner == (Object)null) { ResolveReferences(); } if ((Object)(object)_runner == (Object)null) { Debug.LogError((object)"[CreeperRunner] Cannot self-destruct: EnemyRunner reference is missing."); yield break; } Type type = FindLoadedType("EnemyHealth"); Component val = ((type != null) ? _runner.GetComponentInParent(type) : null); if ((Object)(object)val == (Object)null && type != null) { val = ((Component)_runner.transform.root).GetComponentInChildren(type, true); } if ((Object)(object)val == (Object)null) { Debug.LogError((object)"[CreeperRunner] Cannot self-destruct: EnemyHealth component was not found on the cloned Runner."); yield break; } object obj = ReadMember(val, "dead"); if (obj is bool && (bool)obj) { yield break; } MethodInfo[] methods = ((object)val).GetType().GetMethods(InstanceFlags); bool flag = false; foreach (MethodInfo methodInfo in methods) { if (!string.Equals(methodInfo.Name, "Hurt", StringComparison.Ordinal)) { continue; } ParameterInfo[] parameters = methodInfo.GetParameters(); if (parameters.Length >= 2 && !(parameters[0].ParameterType != typeof(int)) && !(parameters[1].ParameterType != typeof(Vector3))) { object[] array = new object[parameters.Length]; array[0] = 9999; array[1] = Vector3.up; for (int j = 2; j < parameters.Length; j++) { array[j] = (parameters[j].HasDefaultValue ? parameters[j].DefaultValue : GetDefault(parameters[j].ParameterType)); } try { methodInfo.Invoke(val, array); flag = true; } catch (Exception exception) { Debug.LogWarning((object)("[CreeperRunner] EnemyHealth.Hurt self-destruct overload failed: " + Unwrap(exception).Message)); continue; } break; } } if (flag) { CloneVisualLifetime.HideForRunner(_runner); Debug.Log((object)"[CreeperRunner] Self-destruct damage applied and Creeper visual hidden. The original Runner death/despawn lifecycle should remove the network enemy."); } else { Debug.LogError((object)"[CreeperRunner] Could not invoke EnemyHealth.Hurt; the Creeper may remain after detonation."); } } private void EnsureRunnerChaseDuringFuse() { if (!((Object)(object)_runner == (Object)null)) { object obj = ReadMember(_runner, "currentState"); string stateName = ((obj != null) ? obj.ToString() : string.Empty); if (!IsRunnerInChaseState(stateName) || IsRunnerNavigationStopped()) { ForceRunnerChase(); } } } private bool IsRunnerNavigationStopped() { try { object instance = ReadMember(_runner, "enemy"); object obj = ReadMember(ReadMember(instance, "NavMeshAgent") ?? ReadMember(instance, "navMeshAgent"), "isStopped"); return obj is bool && (bool)obj; } catch { return false; } } private void ApplyOriginalRunnerDamageSuppression() { if ((Object)(object)_runner == (Object)null) { return; } bool flag = false; object obj = ReadMember(_runner, "hurtCollider"); if (obj != null) { flag |= TrySetBooleanMember(obj, "playerLogic", value: false); flag |= TrySetIntegerMember(obj, "playerDamage", 0); } Component[] componentsInChildren = ((Component)_runner.transform.root).GetComponentsInChildren<Component>(true); foreach (Component val in componentsInChildren) { if (!((Object)(object)val == (Object)null) && string.Equals(((object)val).GetType().Name, "HurtCollider", StringComparison.Ordinal)) { flag |= TrySetBooleanMember(val, "playerLogic", value: false); flag |= TrySetIntegerMember(val, "playerDamage", 0); } } if (flag && !_damageSuppressionLogged) { _damageSuppressionLogged = true; Debug.Log((object)"[CreeperRunner] Original Runner player damage disabled: HurtCollider.playerLogic=false and playerDamage=0. Creeper explosion damage remains separate."); } } private static bool TrySetBooleanMember(object instance, string memberName, bool value) { if (instance == null) { return false; } FieldInfo fieldInfo = FindField(instance.GetType(), memberName); if (fieldInfo != null && fieldInfo.FieldType == typeof(bool)) { try { fieldInfo.SetValue(instance, value); return true; } catch { } } Type type = instance.GetType(); while (type != null) { PropertyInfo property = type.GetProperty(memberName, InstanceFlags | BindingFlags.DeclaredOnly); if (!(property == null) && !(property.PropertyType != typeof(bool))) { MethodInfo setMethod = property.GetSetMethod(nonPublic: true); if (!(setMethod == null)) { try { setMethod.Invoke(instance, new object[1] { value }); return true; } catch { } } } type = type.BaseType; } return false; } private static bool TrySetIntegerMember(object instance, string memberName, int value) { if (instance == null) { return false; } FieldInfo fieldInfo = FindField(instance.GetType(), memberName); if (fieldInfo != null && fieldInfo.FieldType == typeof(int)) { try { fieldInfo.SetValue(instance, value); return true; } catch { } } Type type = instance.GetType(); while (type != null) { PropertyInfo property = type.GetProperty(memberName, InstanceFlags | BindingFlags.DeclaredOnly); if (!(property == null) && !(property.PropertyType != typeof(int))) { MethodInfo setMethod = property.GetSetMethod(nonPublic: true); if (!(setMethod == null)) { try { setMethod.Invoke(instance, new object[1] { value }); return true; } catch { } } } type = type.BaseType; } return false; } private void ForceRunnerChase() { if ((Object)(object)_runner == (Object)null) { return; } try { object instance = ReadMember(_runner, "enemy"); object obj = ReadMember(instance, "NavMeshAgent") ?? ReadMember(instance, "navMeshAgent"); if (obj != null) { Type type = obj.GetType(); while (type != null) { PropertyInfo property = type.GetProperty("isStopped", InstanceFlags | BindingFlags.DeclaredOnly); if (property != null && property.PropertyType == typeof(bool)) { MethodInfo setMethod = property.GetSetMethod(nonPublic: true); if (setMethod != null) { setMethod.Invoke(obj, new object[1] { false }); } } type = type.BaseType; } MethodInfo[] methods = obj.GetType().GetMethods(InstanceFlags); for (int i = 0; i < methods.Length; i++) { if (string.Equals(methods[i].Name, "Resume", StringComparison.Ordinal) && methods[i].GetParameters().Length == 0) { methods[i].Invoke(obj, null); break; } } } FieldInfo fieldInfo = FindField(((object)_runner).GetType(), "currentState"); if (!(fieldInfo == null) && fieldInfo.FieldType.IsEnum) { MethodInfo method = ((object)_runner).GetType().GetMethod("UpdateState", InstanceFlags, null, new Type[1] { fieldInfo.FieldType }, null); if (!(method == null)) { object obj2 = Enum.Parse(fieldInfo.FieldType, "AttackPlayer", ignoreCase: true); method.Invoke(_runner, new object[1] { obj2 }); } } } catch (Exception exception) { Debug.LogWarning((object)("[CreeperRunner] Could not return Runner to pursuit: " + Unwrap(exception).Message)); } } private Transform ResolveCurrentTarget() { //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < TargetMemberNames.Length; i++) { Transform val = AsTransform(ReadMember(_runner, TargetMemberNames[i])); if ((Object)(object)val != (Object)null) { return val; } } if (_cachedVisionComponents == null || Time.time >= _nextVisionRefresh) { RefreshVisionComponentCache(); } if (_cachedVisionComponents != null) { for (int j = 0; j < _cachedVisionComponents.Length; j++) { Component val2 = _cachedVisionComponents[j]; if (!((Object)(object)val2 == (Object)null)) { Transform val3 = AsTransform(ReadMember(val2, "onVisionTriggeredPlayer")); if ((Object)(object)val3 != (Object)null) { return val3; } } } } if ((Object)(object)_runner == (Object)null) { return null; } if (_playerAvatarType == null) { _playerAvatarType = FindLoadedType("PlayerAvatar"); } if (_playerAvatarType == null) { return null; } if (_cachedPlayerAvatars == null || Time.time >= _nextAvatarRefresh) { RefreshPlayerAvatarCache(); } Transform result = null; float num = float.MaxValue; if (_cachedPlayerAvatars == null) { return null; } for (int k = 0; k < _cachedPlayerAvatars.Length; k++) { Component val4 = _cachedPlayerAvatars[k]; if (!((Object)(object)val4 == (Object)null) && val4.gameObject.activeInHierarchy && !IsPlayerUnavailable(val4)) { float num2 = PlanarDistance(_runner.transform.position, val4.transform.position); if (num2 < num) { num = num2; result = val4.transform; } } } return result; } private void RefreshVisionComponentCache() { _nextVisionRefresh = Time.time + 2f; if ((Object)(object)_runner == (Object)null) { _cachedVisionComponents = Array.Empty<Component>(); return; } Component[] componentsInChildren = ((Component)_runner.transform.root).GetComponentsInChildren<Component>(true); List<Component> list = new List<Component>(2); foreach (Component val in componentsInChildren) { if ((Object)(object)val != (Object)null && string.Equals(((object)val).GetType().Name, "EnemyVision", StringComparison.Ordinal)) { list.Add(val); } } _cachedVisionComponents = list.ToArray(); } private void RefreshPlayerAvatarCache() { _nextAvatarRefresh = Time.time + 1f; Object[] array = Object.FindObjectsOfType(_playerAvatarType); List<Component> list = new List<Component>(array.Length); foreach (Object obj in array) { Component val = (Component)(object)((obj is Component) ? obj : null); if ((Object)(object)val != (Object)null) { list.Add(val); } } _cachedPlayerAvatars = list.ToArray(); } private void BroadcastFallbackVisual(Vector3 center, bool nativeEffectOnHost) { //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_photonView != (Object)null && _photonView.ViewID != 0) { try { _photonView.RPC("ExplosionVisualRPC", (RpcTarget)0, new object[2] { center, nativeEffectOnHost }); return; } catch (Exception ex) { Debug.LogWarning((object)("[CreeperRunner] Explosion visual RPC failed: " + ex.Message)); } } ExplosionVisualRPC(center, nativeEffectOnHost); } [PunRPC] private void ExplosionVisualRPC(Vector3 center, bool nativeEffectOnHost) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) _startRequested = true; _fusing = false; _detonated = true; SpawnExplosionParticles(center); MobAudio.PlayCreeperExplosion(center); GameObject obj = GameObject.CreatePrimitive((PrimitiveType)0); ((Object)obj).name = "CreeperRunner_ExplosionFlash"; obj.transform.position = center; obj.transform.localScale = Vector3.one * 0.25f; Collider component = obj.GetComponent<Collider>(); if ((Object)(object)component != (Object)null) { Object.Destroy((Object)(object)component); } Renderer component2 = obj.GetComponent<Renderer>(); if ((Object)(object)component2 != (Object)null) { Material material = component2.material; Color val = default(Color); ((Color)(ref val))..ctor(1f, 0.48f, 0.08f, 0.9f); if (material.HasProperty("_Color")) { material.SetColor("_Color", val); } if (material.HasProperty("_BaseColor")) { material.SetColor("_BaseColor", val); } if (material.HasProperty("_EmissionColor")) { material.EnableKeyword("_EMISSION"); material.SetColor("_EmissionColor", new Color(1f, 0.32f, 0.04f, 1f) * 2f); } } obj.AddComponent<CreeperExplosionFlash>(); } private static void SpawnExplosionParticles(Vector3 center) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0010: 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_0058: 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_008a: 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_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: 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_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0125: 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_017d: Unknown result type (might be due to invalid IL or missing references) //IL_0196: Unknown result type (might be due to invalid IL or missing references) //IL_01af: Unknown result type (might be due to invalid IL or missing references) //IL_01c5: Unknown result type (might be due to invalid IL or missing references) //IL_0204: Unknown result type (might be due to invalid IL or missing references) //IL_021d: Unknown result type (might be due to invalid IL or missing references) //IL_0236: Unknown result type (might be due to invalid IL or missing references) //IL_024c: Unknown result type (might be due to invalid IL or missing references) //IL_024d: Unknown result type (might be due to invalid IL or missing references) //IL_0257: Unknown result type (might be due to invalid IL or missing references) //IL_025c: 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_02b8: Unknown result type (might be due to invalid IL or missing references) //IL_02d1: 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_02e8: Unknown result type (might be due to invalid IL or missing references) //IL_02f2: Unknown result type (might be due to invalid IL or missing references) //IL_02f7: Unknown result type (might be due to invalid IL or missing references) //IL_033a: Unknown result type (might be due to invalid IL or missing references) //IL_0353: Unknown result type (might be due to invalid IL or missing references) //IL_036c: 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_0383: Unknown result type (might be due to invalid IL or missing references) //IL_038d: Unknown result type (might be due to invalid IL or missing references) //IL_0392: Unknown result type (might be due to invalid IL or missing references) //IL_03d5: Unknown result type (might be due to invalid IL or missing references) //IL_03ee: Unknown result type (might be due to invalid IL or missing references) //IL_0407: Unknown result type (might be due to invalid IL or missing references) //IL_0418: Unknown result type (might be due to invalid IL or missing references) //IL_0419: Unknown result type (might be due to invalid IL or missing references) //IL_0423: Unknown result type (might be due to invalid IL or missing references) //IL_0428: Unknown result type (might be due to invalid IL or missing references) CreateParticleBurst("CreeperRunner_FX_Fireball", center + Vector3.up * 0.1f, 86, 3f, 6.2f, 0.45f, 1.1f, 0.34f, 0.72f, -0.2f, 0.34f, new Color(1f, 0.96f, 0.72f, 1f), new Color(1f, 0.52f, 0.1f, 0.96f), new Color(0.42f, 0.08f, 0.015f, 0f), growOverLife: false, 0.22f, stretched: false); CreateParticleBurst("CreeperRunner_FX_FlameFragments", center + Vector3.up * 0.08f, 58, 5f, 9f, 0.12f, 0.32f, 0.3f, 0.62f, -0.34f, 0.22f, new Color(1f, 0.92f, 0.48f, 1f), new Color(1f, 0.3f, 0.035f, 0.88f), new Color(0.2f, 0.035f, 0.01f, 0f), growOverLife: false, 0.42f, stretched: false); CreateParticleBurst("CreeperRunner_FX_HotSparks", center, 132, 7f, 15f, 0.025f, 0.095f, 0.55f, 1.65f, 1.15f, 0.28f, new Color(1f, 1f, 0.82f, 1f), new Color(1f, 0.57f, 0.12f, 0.94f), new Color(0.32f, 0.055f, 0.008f, 0f), growOverLife: false, 0.18f, stretched: true); CreateParticleBurst("CreeperRunner_FX_FloatingEmbers", center, 38, 1.8f, 4.6f, 0.045f, 0.12f, 0.95f, 2.15f, 0.26f, 0.36f, new Color(1f, 0.9f, 0.46f, 1f), new Color(0.95f, 0.27f, 0.035f, 0.9f), new Color(0.22f, 0.035f, 0.01f, 0f), growOverLife: false, 0.28f, stretched: true); CreateParticleBurst("CreeperRunner_FX_InnerSmoke", center + Vector3.up * 0.12f, 18, 0.12f, 0.48f, 0.18f, 0.38f, 1.4f, 2.1f, -0.01f, 0.17f, new Color(0.29f, 0.28f, 0.26f, 0.6f), new Color(0.22f, 0.21f, 0.2f, 0.42f), new Color(0.16f, 0.15f, 0.14f, 0f), growOverLife: true, 0.1f, stretched: false); CreateParticleBurst("CreeperRunner_FX_OuterSmoke", center + Vector3.up * 0.28f, 10, 0.04f, 0.25f, 0.28f, 0.52f, 1.65f, 2.45f, -0.008f, 0.22f, new Color(0.33f, 0.31f, 0.28f, 0.48f), new Color(0.25f, 0.24f, 0.22f, 0.34f), new Color(0.18f, 0.17f, 0.16f, 0f), growOverLife: true, 0.06f, stretched: false); CreateParticleBurst("CreeperRunner_FX_GroundDust", center - Vector3.up * 0.34f, 44, 2f, 4.6f, 0.42f, 1.05f, 0.9f, 1.85f, 0.16f, 0.28f, new Color(0.48f, 0.42f, 0.32f, 0.6f), new Color(0.29f, 0.26f, 0.22f, 0.42f), new Color(0.16f, 0.145f, 0.13f, 0f), growOverLife: true, 0.62f, stretched: false); CreateShockwaveRing(center - Vector3.up * 0.42f); } private static void CreateParticleBurst(string objectName, Vector3 center, int count, float speedMin, float speedMax, float sizeMin, float sizeMax, float lifetimeMin, float lifetimeMax, float gravity, float shapeRadius, Color startColor, Color middleColor, Color endColor, bool growOverLife, float noiseStrength, bool stretched) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Expected O, but got Unknown //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0075: 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_0093: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: 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_00ba: 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_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_0112: 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_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Expected O, but got Unknown //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Unknown result type (might be due to invalid IL or missing references) //IL_017d: 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_0189: Unknown result type (might be due to invalid IL or missing references) //IL_0195: Unknown result type (might be due to invalid IL or missing references) //IL_019a: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: Unknown result type (might be due to invalid IL or missing references) //IL_01b0: Unknown result type (might be due to invalid IL or missing references) //IL_01be: Unknown result type (might be due to invalid IL or missing references) //IL_01c9: Unknown result type (might be due to invalid IL or missing references) //IL_01ce: Unknown result type (might be due to invalid IL or missing references) //IL_0295: 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_02ab: Unknown result type (might be due to invalid IL or missing references) //IL_02b0: 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_02c6: 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_02d2: Expected O, but got Unknown //IL_02db: 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_025c: Unknown result type (might be due to invalid IL or missing references) //IL_0261: Unknown result type (might be due to invalid IL or missing references) //IL_0272: 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_027c: 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_01f9: Unknown result type (might be due to invalid IL or missing references) //IL_020a: Unknown result type (might be due to invalid IL or missing references) //IL_020f: 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_0225: Unknown result type (might be due to invalid IL or missing references) //IL_022a: Unknown result type (might be due to invalid IL or missing references) //IL_02ef: Unknown result type (might be due to invalid IL or missing references) //IL_02f4: Unknown result type (might be due to invalid IL or missing references) //IL_0302: Unknown result type (might be due to invalid IL or missing references) //IL_0333: Unknown result type (might be due to invalid IL or missing references) bool flag = objectName.IndexOf("Smoke", StringComparison.OrdinalIgnoreCase) >= 0; GameObject val = new GameObject(objectName); val.transform.position = center; ParticleSystem val2 = val.AddComponent<ParticleSystem>(); MainModule main = val2.main; ((MainModule)(ref main)).duration = 0.2f; ((MainModule)(ref main)).loop = false; ((MainModule)(ref main)).playOnAwake = false; ((MainModule)(ref main)).maxParticles = count; ((MainModule)(ref main)).simulationSpace = (ParticleSystemSimulationSpace)1; ((MainModule)(ref main)).startLifetime = new MinMaxCurve(lifetimeMin, lifetimeMax); ((MainModule)(ref main)).startSpeed = new MinMaxCurve(speedMin, speedMax); ((MainModule)(ref main)).startSize = new MinMaxCurve(sizeMin, sizeMax); ((MainModule)(ref main)).startColor = MinMaxGradient.op_Implicit(startColor); ((MainModule)(ref main)).gravityModifier = MinMaxCurve.op_Implicit(gravity); EmissionModule emission = val2.emission; ((EmissionModule)(ref emission)).rateOverTime = MinMaxCurve.op_Implicit(0f); ((EmissionModule)(ref emission)).SetBursts((Burst[])(object)new Burst[1] { new Burst(0f, (short)count) }); ShapeModule shape = val2.shape; ((ShapeModule)(ref shape)).enabled = true; ((ShapeModule)(ref shape)).shapeType = (ParticleSystemShapeType)0; ((ShapeModule)(ref shape)).radius = shapeRadius; ((ShapeModule)(ref shape)).radiusThickness = 0.85f; ColorOverLifetimeModule colorOverLifetime = val2.colorOverLifetime; ((ColorOverLifetimeModule)(ref colorOverLifetime)).enabled = true; Gradient val3 = new Gradient(); val3.SetKeys((GradientColorKey[])(object)new GradientColorKey[3] { new GradientColorKey(startColor, 0f), new GradientColorKey(middleColor, 0.42f), new GradientColorKey(endColor, 1f) }, (GradientAlphaKey[])(object)new GradientAlphaKey[3] { new GradientAlphaKey(startColor.a, 0f), new GradientAlphaKey(middleColor.a, 0.42f), new GradientAlphaKey(0f, 1f) }); ((ColorOverLifetimeModule)(ref colorOverLifetime)).color = new MinMaxGradient(val3); SizeOverLifetimeModule sizeOverLifetime = val2.sizeOverLifetime; ((SizeOverLifetimeModule)(ref sizeOverLifetime)).enabled = true; AnimationCurve val4 = (flag ? new AnimationCurve((Keyframe[])(object)new Keyframe[3] { new Keyframe(0f, 0.48f), new Keyframe(0.42f, 0.82f), new Keyframe(1f,
plugins/MCWitchMod/Witch.dll
Decompiled 36 minutes agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using Photon.Pun; using REPOLib.Modules; using UnityEngine; using UnityEngine.Events; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: IgnoresAccessChecksTo("Assembly-CSharp")] [assembly: AssemblyCompany("Luca")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyDescription("Witch enemy behaviour for R.E.P.O.")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+b97fc97bfc2f376bc73dfcf422f5129157d65c4e")] [assembly: AssemblyProduct("Witch")] [assembly: AssemblyTitle("Witch")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.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.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace Witch { public class LandingCircle : MonoBehaviour { private LineRenderer _line; private float _lifetime; private float _elapsed; private Color _color; public static LandingCircle Create(Vector3 center, float radius, Color color, float lifetime) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("LandingCircle"); LandingCircle landingCircle = val.AddComponent<LandingCircle>(); landingCircle.Initialize(center, radius, color, lifetime); return landingCircle; } private void Initialize(Vector3 center, float radius, Color color, float lifetime) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: 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_007e: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Expected O, but got Unknown //IL_00cf: 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_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_0114: 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) _color = color; _lifetime = lifetime; _line = ((Component)this).gameObject.AddComponent<LineRenderer>(); _line.useWorldSpace = true; _line.loop = true; _line.positionCount = 48; _line.startWidth = 0.08f; _line.endWidth = 0.08f; _line.startColor = color; _line.endColor = color; Shader val = Shader.Find("Sprites/Default"); if ((Object)(object)val == (Object)null) { val = Shader.Find("Unlit/Color"); } if ((Object)(object)val != (Object)null) { ((Renderer)_line).material = new Material(val); ((Renderer)_line).material.color = color; } for (int i = 0; i < 48; i++) { float num = (float)i * MathF.PI * 2f / 48f; Vector3 val2 = center + new Vector3(Mathf.Cos(num) * radius, 0.05f, Mathf.Sin(num) * radius); _line.SetPosition(i, val2); } } private void Update() { //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_0086: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) _elapsed += Time.deltaTime; if (_elapsed >= _lifetime) { Object.Destroy((Object)(object)((Component)this).gameObject); return; } float num = _lifetime - _elapsed; if (num < 1f) { float a = (Mathf.Sin(_elapsed * 20f) + 1f) * 0.5f; Color color = _color; color.a = a; _line.startColor = color; _line.endColor = color; } } } public sealed class WitchBat : MonoBehaviour { [SerializeField] private float modelYawOffset; [SerializeField] private Sound soundAppear; private const float ShrinkDuration = 0.5f; private Vector3 _velocity; private float _speed = 3f; private float _lifeTime = 2.5f; private float _age; private float _turnTimer; private float _wobblePhase; private float _wobbleFrequency = 5f; private float _wobbleAmplitude = 0.5f; private float _rollAmplitude = 15f; private Vector3 _initialScale = Vector3.one; private void Awake() { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) _initialScale = ((Component)this).transform.localScale; } private void Start() { //IL_0013: Unknown result type (might be due to invalid IL or missing references) Sound obj = soundAppear; if (obj != null) { obj.Play(((Component)this).transform.position, 1f, 1f, 1f, 1f); } Animator componentInChildren = ((Component)this).GetComponentInChildren<Animator>(); if ((Object)(object)componentInChildren != (Object)null && (Object)(object)componentInChildren.runtimeAnimatorController != (Object)null) { componentInChildren.Update(Random.Range(0f, 1f)); } } public void Initialize(Vector3 velocity, float lifeTime) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) _velocity = velocity; _speed = Mathf.Max(0.5f, ((Vector3)(ref velocity)).magnitude); _lifeTime = Mathf.Max(0.6f, lifeTime); _age = 0f; _turnTimer = 0f; _wobblePhase = Random.Range(0f, MathF.PI * 2f); _wobbleFrequency = Random.Range(4f, 7f); _wobbleAmplitude = Random.Range(0.2f, 0.55f); _rollAmplitude = Random.Range(12f, 28f); } private void Update() { //IL_00d7: 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_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_0139: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_0184: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Unknown result type (might be due to invalid IL or missing references) //IL_01ac: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: Unknown result type (might be due to invalid IL or missing references) //IL_01b6: Unknown result type (might be due to invalid IL or missing references) //IL_01b8: Unknown result type (might be due to invalid IL or missing references) //IL_01e7: Unknown result type (might be due to invalid IL or missing references) //IL_01fd: Unknown result type (might be due to invalid IL or missing references) _age += Time.deltaTime; if (_age >= _lifeTime) { Object.Destroy((Object)(object)((Component)this).gameObject); return; } _turnTimer -= Time.deltaTime; if (_turnTimer <= 0f) { _turnTimer = Random.Range(0.15f, 0.45f); Vector3 val = Vector3.Slerp(((Vector3)(ref _velocity)).normalized, Random.onUnitSphere, Random.Range(0.35f, 0.7f)); val.y = Mathf.Clamp(val.y, -0.35f, 0.75f); _velocity = ((Vector3)(ref val)).normalized * _speed; } Transform transform = ((Component)this).transform; transform.position += _velocity * Time.deltaTime; _wobblePhase += _wobbleFrequency * Time.deltaTime; Transform transform2 = ((Component)this).transform; transform2.position += Vector3.up * (Mathf.Sin(_wobblePhase) * _wobbleAmplitude * Time.deltaTime); if (((Vector3)(ref _velocity)).sqrMagnitude > 0.0001f) { Quaternion val2 = Quaternion.Euler(0f, 0f, Mathf.Sin(_wobblePhase * 1.2f) * _rollAmplitude); ((Component)this).transform.rotation = Quaternion.LookRotation(_velocity) * Quaternion.Euler(0f, modelYawOffset, 0f) * val2; } float num = _lifeTime - _age; if (num < 0.5f) { ((Component)this).transform.localScale = _initialScale * Mathf.Max(0f, num / 0.5f); } } } [BepInPlugin("com.luca.witch", "Witch", "1.2.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInProcess("REPO.exe")] public sealed class Plugin : BaseUnityPlugin { internal static ManualLogSource Log; private Harmony _harmony; internal static ConfigEntry<int> MaxHealth; internal static ConfigEntry<int> HealAmount; internal static ConfigEntry<float> HealCooldown; internal static ConfigEntry<float> AttackCooldown; internal static ConfigEntry<float> AttackRange; internal static ConfigEntry<float> ThrowSpeed; internal static ConfigEntry<float> HealthPackDropChance; internal static ConfigEntry<float> PoisonChance; internal static ConfigEntry<bool> ShowLandingCircle; private void Awake() { //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_0159: Expected O, but got Unknown Log = ((BaseUnityPlugin)this).Logger; MaxHealth = ((BaseUnityPlugin)this).Config.Bind<int>("Witch", "MaxHealth", 250, "女巫最大生命值"); HealAmount = ((BaseUnityPlugin)this).Config.Bind<int>("Witch", "HealAmount", 60, "每次回血量"); HealCooldown = ((BaseUnityPlugin)this).Config.Bind<float>("Witch", "HealCooldown", 8f, "回血间隔(秒)"); AttackCooldown = ((BaseUnityPlugin)this).Config.Bind<float>("Witch", "AttackCooldown", 4f, "攻击冷却(秒)"); AttackRange = ((BaseUnityPlugin)this).Config.Bind<float>("Witch", "AttackRange", 8f, "攻击/索敌范围(米)"); ThrowSpeed = ((BaseUnityPlugin)this).Config.Bind<float>("Witch", "ThrowSpeed", 8f, "药水初速度(m/s)"); HealthPackDropChance = ((BaseUnityPlugin)this).Config.Bind<float>("Witch", "HealthPackDropChance", 0.3f, "医疗包掉落爆率(0.3=30%,1=100%)"); PoisonChance = ((BaseUnityPlugin)this).Config.Bind<float>("Witch", "PoisonChance", 0.5f, "毒药水概率(0.5=1:1,0=全伤害,1=全毒)"); ShowLandingCircle = ((BaseUnityPlugin)this).Config.Bind<bool>("Witch", "ShowLandingCircle", true, "是否显示药水落点的预警圈。默认开。这是每个玩家各自的本地显示设置——关掉只影响你自己的画面,不影响其他玩家,也不影响女巫的投掷僵直(战斗难度不变)。"); _harmony = new Harmony("com.luca.witch"); _harmony.PatchAll(); Log.LogInfo((object)"Witch behaviour plugin loaded."); } } public sealed class WitchBehaviour : MonoBehaviour { private enum SoundType { Notice, Ambient, Death, Drink, Hurt, Throw } public const float LandingRadius = 1.2f; private const float WarnDuration = 0.5f; private const float DespawnDelay = 1.17f; private float _aimingUntil; private PlayerAvatar _aimTarget; private float _windupUntil; private static FieldInfo _rotationTargetField; private static bool _rotationTargetFieldWarned; [SerializeField] private GameObject potionPrefab; [SerializeField] private Transform throwOrigin; [SerializeField] private GameObject healPotionPrefab; [SerializeField] private Transform healOrigin; [SerializeField] private GameObject healthPackDrop; [SerializeField] private GameObject batSwarmPrefab; [SerializeField] private int batSwarmCount = 5; [SerializeField] private float batLifeTime = 2.5f; [SerializeField] private float batSpeedMin = 1.2f; [SerializeField] private float batSpeedMax = 2.2f; [SerializeField] private Sound soundNotice; [SerializeField] private Sound soundAmbient; [SerializeField] private Sound soundDeath; [SerializeField] private Sound soundDrink; [SerializeField] private Sound soundHurt; [SerializeField] private Sound soundThrow; private Enemy _enemy; private EnemyHealth _health; private EnemyBombThrower _bombThrower; private float _attackTimer; private float _healTimer; private float _ambientTimer; private float _footstepTimer; private bool _hasNoticedPlayer; private bool _despawning; private float _despawnTimer; private PrefabRef _potionNetworkRef; private PrefabRef _healthPackNetworkRef; private static PrefabRef _cachedPotionNetworkRef; private static PrefabRef _cachedHealthPackNetworkRef; private PhotonView _photonView; private static readonly Color LandingDamageColor = new Color(1f, 0.35f, 0.35f, 1f); private static readonly Color LandingPoisonColor = new Color(0.45f, 0.85f, 0.45f, 1f); private int _lastSyncedHealthMax = -1; private int _lastSyncedHealthCurrent = -1; private static bool ShowLandingCircle => Plugin.ShowLandingCircle == null || Plugin.ShowLandingCircle.Value; internal bool IsAiming => Time.time < _aimingUntil; internal bool IsThrowWindup => Time.time < _windupUntil; private void Start() { //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Expected O, but got Unknown //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Expected O, but got Unknown _enemy = ((Component)this).GetComponent<Enemy>() ?? ((Component)this).GetComponentInParent<Enemy>(); _health = _enemy?.Health ?? ((Component)this).GetComponent<EnemyHealth>(); _bombThrower = ((Component)this).GetComponent<EnemyBombThrower>(); _photonView = ((Component)this).GetComponent<PhotonView>(); if ((Object)(object)_enemy == (Object)null || (Object)(object)_health == (Object)null) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogWarning((object)"WitchBehaviour requires Enemy and EnemyHealth on the same or parent object."); } ((Behaviour)this).enabled = false; return; } if (SemiFunc.IsMasterClientOrSingleplayer()) { _health.health = Plugin.MaxHealth.Value; _health.OnSpawn(); } else if (SemiFunc.IsMultiplayer() && (Object)(object)_photonView != (Object)null) { _photonView.RPC("RequestHealthSyncRPC", (RpcTarget)2, Array.Empty<object>()); } _healTimer = Plugin.HealCooldown.Value; EnemyHealth health = _health; if (health.onHurt == null) { health.onHurt = new UnityEvent(); } _health.onHurt.AddListener(new UnityAction(OnHurtSound)); PhotonTransformView[] componentsInChildren = ((Component)this).GetComponentsInChildren<PhotonTransformView>(true); PhotonTransformView[] array = componentsInChildren; foreach (PhotonTransformView val in array) { FieldInfo field = typeof(PhotonTransformView).GetField("m_PositionModel", BindingFlags.Instance | BindingFlags.NonPublic); FieldInfo field2 = typeof(PhotonTransformView).GetField("m_RotationModel", BindingFlags.Instance | BindingFlags.NonPublic); object obj = ((field != null) ? field.GetValue(val) : null); object obj2 = ((field2 != null) ? field2.GetValue(val) : null); ManualLogSource log2 = Plugin.Log; if (log2 != null) { log2.LogWarning((object)$"[Witch] PTV on '{((Object)((Component)val).gameObject).name}': positionModel={obj != null}, rotationModel={obj2 != null}, photonView={(Object)(object)((MonoBehaviourPun)val).photonView != (Object)null}, isMine={(Object)(object)((MonoBehaviourPun)val).photonView != (Object)null && ((MonoBehaviourPun)val).photonView.IsMine}"); } } _potionNetworkRef = GetOrRegisterNetworkPrefab(potionPrefab, ref _cachedPotionNetworkRef); _healthPackNetworkRef = GetOrRegisterNetworkPrefab(healthPackDrop, ref _cachedHealthPackNetworkRef); ManualLogSource log3 = Plugin.Log; if (log3 != null) { log3.LogInfo((object)$"WitchBehaviour initialized. Health = {_health.health}"); } } private static PrefabRef GetOrRegisterNetworkPrefab(GameObject prefab, ref PrefabRef cachedRef) { if ((Object)(object)prefab == (Object)null) { return null; } if (cachedRef != null) { return cachedRef; } string name = ((Object)prefab).name; if (NetworkPrefabs.HasNetworkPrefab(name)) { cachedRef = NetworkPrefabs.GetNetworkPrefabRef(name); return cachedRef; } PrefabRef val = NetworkPrefabs.RegisterNetworkPrefab(prefab); if (val != null) { cachedRef = val; } return val; } private void OnDestroy() { //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Expected O, but got Unknown if ((Object)(object)_health != (Object)null && _health.onHurt != null) { _health.onHurt.RemoveListener(new UnityAction(OnHurtSound)); } } private void Update() { if (!SemiFunc.IsMasterClientOrSingleplayer() || (Object)(object)_enemy == (Object)null || (Object)(object)_health == (Object)null) { return; } SyncHealthToClients(); UpdateDespawn(); UpdateAmbient(); UpdateFootsteps(); if (_enemy.IsStunned()) { _healTimer = Plugin.HealCooldown.Value; return; } if (_attackTimer > 0f) { _attackTimer -= Time.deltaTime; } if (_attackTimer <= 0f) { PlayerAvatar val = FindNearestTarget(); if ((Object)(object)val != (Object)null && IsEngaged(val)) { if (!_hasNoticedPlayer) { _hasNoticedPlayer = true; PlayWitchSound(SoundType.Notice); } _attackTimer = Plugin.AttackCooldown.Value; ((MonoBehaviour)this).StartCoroutine(ThrowPotionRoutine(val)); } } _healTimer -= Time.deltaTime; if (_healTimer <= 0f) { _healTimer = Plugin.HealCooldown.Value; if (_health.healthCurrent < Plugin.MaxHealth.Value) { TryHeal(); } } } private void UpdateDespawn() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Invalid comparison between Unknown and I4 if ((int)_enemy.CurrentState != 11) { if (_despawning) { _despawning = false; _despawnTimer = 0f; } return; } EnemyParent enemyParent = _enemy.EnemyParent; if ((Object)(object)enemyParent == (Object)null) { return; } if (!_despawning) { _despawning = true; _despawnTimer = 1.17f; return; } _despawnTimer -= Time.deltaTime; if (!(_despawnTimer > 0f)) { _despawning = false; if (enemyParent.Spawned && _health.healthCurrent > 0) { PlayVanishBats(); enemyParent.Despawn(); } } } private void UpdateAmbient() { if (soundAmbient != null) { _ambientTimer -= Time.deltaTime; if (_ambientTimer <= 0f) { _ambientTimer = Random.Range(4f, 7f); PlayWitchSound(SoundType.Ambient); } } } private void UpdateFootsteps() { //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006c: 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) if ((Object)(object)_bombThrower == (Object)null || (Object)(object)_bombThrower.anim == (Object)null || !((Object)(object)_enemy.Rigidbody != (Object)null) || !((Object)(object)_enemy.Rigidbody.rb != (Object)null)) { return; } Vector3 velocity = _enemy.Rigidbody.rb.velocity; if (!(((Vector3)(ref velocity)).magnitude > 0.5f)) { return; } _footstepTimer -= Time.deltaTime; if (_footstepTimer <= 0f) { _footstepTimer = Random.Range(0.35f, 0.5f); if (_bombThrower.anim.soundFootstepBootLight != null) { _bombThrower.anim.soundFootstepBootLight.Play(((Component)this).transform.position, 1f, 1f, 1f, 1f); } } } private void OnHurtSound() { PlayWitchSound(SoundType.Hurt); } private void PlayWitchSound(SoundType type) { if (SemiFunc.IsMultiplayer() && (Object)(object)_photonView != (Object)null) { _photonView.RPC("PlaySoundRPC", (RpcTarget)0, new object[1] { (int)type }); } else { PlaySoundRPC((int)type); } } [PunRPC] public void PlaySoundRPC(int type) { //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) switch ((SoundType)type) { case SoundType.Notice: { Sound obj4 = soundNotice; if (obj4 != null) { obj4.Play(((Component)this).transform.position, 1f, 1f, 1f, 1f); } break; } case SoundType.Ambient: { Sound obj6 = soundAmbient; if (obj6 != null) { obj6.Play(((Component)this).transform.position, 1f, 1f, 1f, 1f); } break; } case SoundType.Death: { Sound obj2 = soundDeath; if (obj2 != null) { obj2.Play(((Component)this).transform.position, 1f, 1f, 1f, 1f); } break; } case SoundType.Drink: { Sound obj5 = soundDrink; if (obj5 != null) { obj5.Play(((Component)this).transform.position, 1f, 1f, 1f, 1f); } break; } case SoundType.Hurt: { Sound obj3 = soundHurt; if (obj3 != null) { obj3.Play(((Component)this).transform.position, 1f, 1f, 1f, 1f); } break; } case SoundType.Throw: { Sound obj = soundThrow; if (obj != null) { obj.Play(((Component)this).transform.position, 1f, 1f, 1f, 1f); } break; } } } [PunRPC] public void ShowLandingCircleRPC(Vector3 pos, int type) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) if (ShowLandingCircle) { Color color = ((type == 0) ? LandingDamageColor : LandingPoisonColor); LandingCircle.Create(pos, 1.2f, color, 2.5f); } } private IEnumerator ThrowPotionRoutine(PlayerAvatar target) { BeginAiming(target, 2.5f); float waited = 0f; while (waited < 2.5f && !IsFacingTarget(target)) { if (!IsThrowTargetValid(target)) { EndAiming(); yield break; } waited += Time.deltaTime; yield return null; } if (!IsFacingTarget(target)) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogInfo((object)$"[Witch] 面向超时({2.5f}s 内没转过来),放弃本次投掷"); } EndAiming(); _attackTimer = 0.5f; yield break; } if (!IsThrowTargetValid(target)) { EndAiming(); yield break; } WitchPotionProjectile.PotionType type = ((Random.value < Plugin.PoisonChance.Value) ? WitchPotionProjectile.PotionType.Poison : WitchPotionProjectile.PotionType.Damage); float warn = 0.5f; _aimingUntil = Time.time + warn + 0.15f; FreezeForThrow(warn + 0.15f); Vector3 startPos = ThrowOriginPosition(); Vector3 velocity = CalculateThrowVelocity(startPos, ((Component)target).transform.position); Vector3 landing = CalculateLandingPoint(startPos, velocity); if (SemiFunc.IsMultiplayer() && (Object)(object)_photonView != (Object)null) { _photonView.RPC("ShowLandingCircleRPC", (RpcTarget)0, new object[2] { landing, (int)type }); } else { ShowLandingCircleRPC(landing, (int)type); } yield return (object)new WaitForSeconds(warn); if (!IsThrowTargetValid(target)) { EndAiming(); yield break; } ThrowPotion(startPos, velocity, type); EndAiming(); } private void FreezeForThrow(float duration) { _windupUntil = Time.time + duration; if ((Object)(object)_enemy != (Object)null && (Object)(object)_enemy.NavMeshAgent != (Object)null) { _enemy.NavMeshAgent.Stop(duration); } } private Vector3 ThrowOriginPosition() { //IL_0036: 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_001a: 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_0029: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) return ((Object)(object)throwOrigin != (Object)null) ? throwOrigin.position : (((Component)this).transform.position + Vector3.up * 1.5f); } private bool IsThrowTargetValid(PlayerAvatar target) { if ((Object)(object)_enemy == (Object)null || _enemy.IsStunned()) { return false; } return IsEngaged(target); } private bool IsEngaged(PlayerAvatar target) { //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Invalid comparison between Unknown and I4 //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_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_007b: 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) //IL_0080: Invalid comparison between Unknown and I4 if ((Object)(object)target == (Object)null || target.deadSet || target.isDisabled) { return false; } if ((Object)(object)_enemy == (Object)null) { return false; } if ((int)_enemy.CurrentState == 11) { return false; } if ((Object)(object)_bombThrower == (Object)null) { return true; } State currentState = _bombThrower.currentState; State val = currentState; if (val - 4 > 5) { return false; } if ((Object)(object)_enemy.Vision == (Object)null || (Object)(object)_enemy.Vision.VisionTransform == (Object)null) { return true; } return !_bombThrower.VisionBlocked(); } private void BeginAiming(PlayerAvatar target, float duration) { _aimTarget = target; _aimingUntil = Time.time + duration; ForceFaceTarget(_bombThrower); } private void EndAiming() { _aimTarget = null; _aimingUntil = 0f; } internal void ForceFaceTarget(EnemyBombThrower bt) { //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: 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_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_010e: 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_0114: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)bt == (Object)null || (Object)(object)_aimTarget == (Object)null) { return; } if (_rotationTargetField == null) { _rotationTargetField = typeof(EnemyBombThrower).GetField("horizontalRotationTarget", BindingFlags.Instance | BindingFlags.NonPublic); } if (_rotationTargetField == null) { if (!_rotationTargetFieldWarned) { _rotationTargetFieldWarned = true; ManualLogSource log = Plugin.Log; if (log != null) { log.LogWarning((object)"[Witch] 取不到 EnemyBombThrower.horizontalRotationTarget,无法接管瞄准朝向,会退回原版转向(可能出现『先扔后转身』)。"); } } return; } Vector3 val = (((Object)(object)bt.enemy != (Object)null && (Object)(object)bt.enemy.Rigidbody != (Object)null) ? ((Component)bt.enemy.Rigidbody).transform.position : ((Component)bt).transform.position); Vector3 val2 = ((Component)_aimTarget).transform.position - val; val2.y = 0f; if (!(((Vector3)(ref val2)).sqrMagnitude < 0.0001f)) { Quaternion val3 = Quaternion.LookRotation(val2); ((Quaternion)(ref val3)).eulerAngles = new Vector3(0f, ((Quaternion)(ref val3)).eulerAngles.y, 0f); _rotationTargetField.SetValue(bt, val3); if (bt.horizontalRotationSpring != null) { bt.horizontalRotationSpring.speed = 8f; bt.horizontalRotationSpring.damping = 0.7f; } } } private bool IsFacingTarget(PlayerAvatar target) { //IL_0016: 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_002b: 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_0059: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)target == (Object)null) { return false; } Vector3 val = ((Component)target).transform.position - ((Component)this).transform.position; val.y = 0f; if (((Vector3)(ref val)).sqrMagnitude < 0.01f) { return true; } return Vector3.Angle(((Component)this).transform.forward, val) <= 25f; } private void ThrowPotion(Vector3 startPos, Vector3 velocity, WitchPotionProjectile.PotionType type) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0058: 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_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: 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_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)potionPrefab == (Object)null) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogWarning((object)"WitchBehaviour.potionPrefab is not assigned."); } return; } Vector3 val = velocity; val.y = 0f; Quaternion val2 = ((((Vector3)(ref val)).sqrMagnitude > 0.01f) ? Quaternion.LookRotation(val) : Quaternion.identity); Quaternion val3 = val2 * Quaternion.Euler(0f, 90f, 0f); object[] array = new object[2] { (int)type, velocity }; GameObject val4 = ((_potionNetworkRef != null) ? NetworkPrefabs.SpawnNetworkPrefab(_potionNetworkRef, startPos, val3, (byte)0, array) : Object.Instantiate<GameObject>(potionPrefab, startPos, val3)); if ((Object)(object)val4 == (Object)null) { ManualLogSource log2 = Plugin.Log; if (log2 != null) { log2.LogWarning((object)"[Witch] Failed to spawn potion."); } return; } WitchPotionProjectile componentInChildren = val4.GetComponentInChildren<WitchPotionProjectile>(); if ((Object)(object)componentInChildren == (Object)null) { ManualLogSource log3 = Plugin.Log; if (log3 != null) { log3.LogWarning((object)"potionPrefab is missing WitchPotionProjectile component."); } Object.Destroy((Object)(object)val4); return; } componentInChildren.enemyHost = _enemy; componentInChildren.potionType = type; PlayWitchSound(SoundType.Throw); if (!SemiFunc.IsMultiplayer()) { componentInChildren.Launch(velocity); } } private Vector3 CalculateLandingPoint(Vector3 start, Vector3 velocity) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0078: 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_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: 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_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: 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_00b4: Unknown result type (might be due to invalid IL or missing references) Vector3 val = start; Vector3 val2 = velocity; float y = Physics.gravity.y; float num = 0.04f; LayerMask val3 = LayerMask.op_Implicit(LayerMask.GetMask(new string[5] { "Default", "PhysGrabObject", "PhysGrabObjectCart", "PhysGrabObjectHinge", "StaticGrabObject" })); for (int i = 0; i < 250; i++) { Vector3 val4 = val; val2.y += y * num; val += val2 * num; Vector3 val5 = val - val4; float magnitude = ((Vector3)(ref val5)).magnitude; if (magnitude > 0.001f && Physics.Raycast(val4, ((Vector3)(ref val5)).normalized, magnitude, LayerMask.op_Implicit(val3))) { return val4; } } return val; } private Vector3 CalculateThrowVelocity(Vector3 start, Vector3 target) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0050: 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_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0033: 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_0047: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0105: 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_0118: 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) Vector3 val = target - start; float y = val.y; val.y = 0f; float magnitude = ((Vector3)(ref val)).magnitude; if (magnitude < 0.1f) { return Vector3.up * Plugin.ThrowSpeed.Value; } Vector3 val2 = val / magnitude; float num = Mathf.Abs(Physics.gravity.y); float value = Plugin.ThrowSpeed.Value; float num2 = num * magnitude * magnitude / (2f * value * value); float num3 = magnitude * magnitude - 4f * num2 * (y + num2); float num4; if (num3 < 0f) { num4 = 1f; } else { num4 = (magnitude - Mathf.Sqrt(num3)) / (2f * num2); if (num4 < 0f) { num4 = 0f; } } float num5 = 1f / Mathf.Sqrt(1f + num4 * num4); float num6 = num4 * num5; Vector3 result = val2 * (value * num5); result.y = value * num6; return result; } private PlayerAvatar FindNearestTarget() { //IL_0056: 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_00fa: 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 ((Object)(object)_bombThrower != (Object)null) { PlayerAvatar playerTarget = _bombThrower.playerTarget; if ((Object)(object)playerTarget != (Object)null && !playerTarget.isDisabled && !playerTarget.deadSet && (Object)(object)playerTarget.playerHealth != (Object)null) { float num = Vector3.Distance(((Component)this).transform.position, ((Component)playerTarget).transform.position); if (num <= Plugin.AttackRange.Value) { return playerTarget; } } return null; } PlayerAvatar result = null; float num2 = Plugin.AttackRange.Value; foreach (PlayerAvatar player in GameDirector.instance.PlayerList) { if (!((Object)(object)player == (Object)null) && !player.isDisabled && !player.deadSet && !((Object)(object)player.playerHealth == (Object)null)) { float num3 = Vector3.Distance(((Component)this).transform.position, ((Component)player).transform.position); if (num3 <= num2) { num2 = num3; result = player; } } } return result; } private void TryHeal() { int num = Mathf.Min(Plugin.HealAmount.Value, Plugin.MaxHealth.Value - _health.healthCurrent); if (num > 0) { _health.Heal(num); SpawnHealPotionVisual(); PlayWitchSound(SoundType.Drink); ManualLogSource log = Plugin.Log; if (log != null) { log.LogInfo((object)$"[Witch] Healed {num}, current = {_health.healthCurrent}"); } } } private void SpawnHealPotionVisual() { ManualLogSource log = Plugin.Log; if (log != null) { log.LogWarning((object)$"[Witch] SpawnHealPotionVisual, mp={SemiFunc.IsMultiplayer()}, pv={(Object)(object)_photonView != (Object)null}"); } if (SemiFunc.IsMultiplayer() && (Object)(object)_photonView != (Object)null) { _photonView.RPC("SpawnHealPotionVisualRPC", (RpcTarget)0, Array.Empty<object>()); } else { SpawnHealPotionVisualRPC(); } } private void SpawnHealPotionVisualLocal() { //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: 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_0139: Unknown result type (might be due to invalid IL or missing references) GameObject val = (((Object)(object)healPotionPrefab != (Object)null) ? healPotionPrefab : potionPrefab); ManualLogSource log = Plugin.Log; if (log != null) { log.LogWarning((object)$"[Witch] SpawnHealPotionVisualLocal, healPrefab={(Object)(object)healPotionPrefab != (Object)null}, potionPrefab={(Object)(object)potionPrefab != (Object)null}"); } if (!((Object)(object)val == (Object)null)) { Transform val2 = (((Object)(object)healOrigin != (Object)null) ? healOrigin : ((Component)this).transform); Vector3 localPosition = (Vector3)(((Object)(object)healOrigin != (Object)null) ? Vector3.zero : new Vector3(0f, 1.2f, 0.6f)); GameObject val3 = Object.Instantiate<GameObject>(val, val2); ManualLogSource log2 = Plugin.Log; if (log2 != null) { log2.LogWarning((object)string.Format("[Witch] SpawnHealPotionVisualLocal: visual={0}, prefab={1}, parent={2}, isClient={3}", ((Object)(object)val3 != (Object)null) ? "OK" : "NULL", ((Object)val).name, ((Object)val2).name, !SemiFunc.IsMasterClientOrSingleplayer())); } val3.transform.localPosition = localPosition; val3.transform.localRotation = Quaternion.Euler(0f, 90f, 0f); Rigidbody componentInChildren = val3.GetComponentInChildren<Rigidbody>(); if ((Object)(object)componentInChildren != (Object)null) { componentInChildren.isKinematic = true; } WitchPotionProjectile componentInChildren2 = val3.GetComponentInChildren<WitchPotionProjectile>(); if ((Object)(object)componentInChildren2 != (Object)null) { ((Behaviour)componentInChildren2).enabled = false; } PlayHealPotionParticles(val3); Object.Destroy((Object)(object)val3, 1f); } } [PunRPC] public void SpawnHealPotionVisualRPC() { ManualLogSource log = Plugin.Log; if (log != null) { log.LogWarning((object)"[Witch] SpawnHealPotionVisualRPC received (client)"); } SpawnHealPotionVisualLocal(); } private void PlayHealPotionParticles(GameObject visual) { //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_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0052: 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) ParticleSystem[] componentsInChildren = visual.GetComponentsInChildren<ParticleSystem>(true); ParticleSystem[] array = componentsInChildren; foreach (ParticleSystem val in array) { if (!((Object)(object)val == (Object)null)) { ((Component)val).transform.SetParent((Transform)null, true); val.Play(); MainModule main = val.main; float duration = ((MainModule)(ref main)).duration; main = val.main; MinMaxCurve startLifetime = ((MainModule)(ref main)).startLifetime; float num = duration + ((MinMaxCurve)(ref startLifetime)).constantMax; Object.Destroy((Object)(object)((Component)val).gameObject, Mathf.Max(num, 1f)); } } } public void TryDropHealthPack() { //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_006e: 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) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)healthPackDrop == (Object)null) && !(Random.value > Plugin.HealthPackDropChance.Value)) { Vector3 val = (((Object)(object)_enemy != (Object)null && (Object)(object)_enemy.CenterTransform != (Object)null) ? _enemy.CenterTransform.position : ((Component)this).transform.position); Quaternion val2 = Quaternion.Euler(0f, 90f, 0f); if (_healthPackNetworkRef != null) { NetworkPrefabs.SpawnNetworkPrefab(_healthPackNetworkRef, val, val2, (byte)0, (object[])null); } else { Object.Instantiate<GameObject>(healthPackDrop, val, val2); } } } public void PlayDeathSound() { PlayWitchSound(SoundType.Death); } public void PlayVanishBats() { //IL_003d: 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_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)batSwarmPrefab == (Object)null)) { Vector3 val = (((Object)(object)_enemy != (Object)null && (Object)(object)_enemy.CenterTransform != (Object)null) ? _enemy.CenterTransform.position : (((Component)this).transform.position + Vector3.up * 1.2f)); if (SemiFunc.IsMultiplayer() && (Object)(object)_photonView != (Object)null) { _photonView.RPC("SpawnBatSwarmRPC", (RpcTarget)0, new object[1] { val }); } else { SpawnBatSwarmRPC(val); } } } [PunRPC] public void SpawnBatSwarmRPC(Vector3 position) { //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_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_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007c: 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_007e: 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_0092: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)batSwarmPrefab == (Object)null) { return; } for (int i = 0; i < batSwarmCount; i++) { Vector3 val = Quaternion.Euler(0f, Random.Range(0f, 360f), 0f) * Vector3.forward; Vector3 velocity = val * Random.Range(batSpeedMin, batSpeedMax) + Vector3.up * Random.Range(0.3f, 0.9f); Vector3 val2 = position + Random.insideUnitSphere * 0.35f; GameObject val3 = Object.Instantiate<GameObject>(batSwarmPrefab, val2, Quaternion.identity); WitchBat witchBat = val3.GetComponent<WitchBat>() ?? val3.GetComponentInChildren<WitchBat>(); if ((Object)(object)witchBat != (Object)null) { witchBat.Initialize(velocity, batLifeTime); } } } private void SyncHealthToClients() { if (!((Object)(object)_photonView == (Object)null) && SemiFunc.IsMultiplayer() && (_lastSyncedHealthMax != _health.health || _lastSyncedHealthCurrent != _health.healthCurrent)) { _lastSyncedHealthMax = _health.health; _lastSyncedHealthCurrent = _health.healthCurrent; _photonView.RPC("SyncHealthRPC", (RpcTarget)1, new object[2] { _health.health, _health.healthCurrent }); } } [PunRPC] public void SyncHealthRPC(int maxHealth, int currentHealth) { if (!((Object)(object)_health == (Object)null)) { _health.health = maxHealth; _health.healthCurrent = currentHealth; } } [PunRPC] public void RequestHealthSyncRPC(PhotonMessageInfo info = default(PhotonMessageInfo)) { _lastSyncedHealthMax = -1; _lastSyncedHealthCurrent = -1; } } [HarmonyPatch(typeof(EnemyBombThrower), "UpdateState")] internal static class PatchBombThrowerNoThrow { private static bool Prefix(EnemyBombThrower __instance, State _state) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Invalid comparison between Unknown and I4 //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Invalid comparison between Unknown and I4 if (((int)_state == 8 || (int)_state == 9) && (Object)(object)((Component)__instance).GetComponent<WitchBehaviour>() != (Object)null) { return false; } return true; } } [HarmonyPatch(typeof(EnemyBombThrower), "OnDeath")] internal static class PatchBombThrowerNoDeathBomb { private static bool Prefix(EnemyBombThrower __instance) { if ((Object)(object)((Component)__instance).GetComponent<WitchBehaviour>() == (Object)null) { return true; } if (SemiFunc.IsMasterClientOrSingleplayer()) { WitchBehaviour component = ((Component)__instance).GetComponent<WitchBehaviour>(); component.PlayVanishBats(); component.TryDropHealthPack(); component.PlayDeathSound(); __instance.enemy.EnemyParent.Despawn(); } return false; } } [HarmonyPatch(typeof(EnemyBombThrower), "RotationStateSet")] internal static class PatchWitchAimDuringWindup { private static bool Prefix(EnemyBombThrower __instance) { WitchBehaviour component = ((Component)__instance).GetComponent<WitchBehaviour>(); if ((Object)(object)component == (Object)null || !component.IsAiming) { return true; } component.ForceFaceTarget(__instance); return false; } } [HarmonyPatch(typeof(EnemyBombThrower), "BackAwayLogic")] internal static class PatchWitchNoBackAwayDuringWindup { private static bool Prefix(EnemyBombThrower __instance) { WitchBehaviour component = ((Component)__instance).GetComponent<WitchBehaviour>(); return (Object)(object)component == (Object)null || !component.IsThrowWindup; } } [HarmonyPatch(typeof(EnemyBombThrower), "OnHurt")] internal static class PatchBombThrowerNoHurtSound { private static bool Prefix(EnemyBombThrower __instance) { if ((Object)(object)((Component)__instance).GetComponent<WitchBehaviour>() == (Object)null) { return true; } return false; } } public class WitchEnemyPoisonDebuff : MonoBehaviour { private Enemy _target; private int _damagePerSecond; private float _duration; private float _stopThreshold; private float _timeUntilNextTick = 1f; private float _elapsed; private GameObject _particlesInstance; private Material _particlesMaterial; public void Initialize(Enemy target, int damagePerSecond, float duration, float stopThreshold, Material particlesMaterial = null) { _target = target; _damagePerSecond = damagePerSecond; _duration = duration; _stopThreshold = stopThreshold; _particlesMaterial = particlesMaterial; } public void Refresh() { _elapsed = 0f; _timeUntilNextTick = 1f; } private void Update() { //IL_019f: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_target == (Object)null || !_target.HasHealth || (Object)(object)_target.Health == (Object)null) { Object.Destroy((Object)(object)this); return; } if (_target.Health.dead || _target.Health.healthCurrent <= 0) { Object.Destroy((Object)(object)this); return; } if ((Object)(object)_target.EnemyParent != (Object)null && !_target.EnemyParent.Spawned) { Object.Destroy((Object)(object)this); return; } _elapsed += Time.deltaTime; if (_elapsed >= _duration) { Object.Destroy((Object)(object)this); return; } if ((Object)(object)_particlesInstance == (Object)null) { _particlesInstance = CreateParticles(); } if (!SemiFunc.IsMasterClientOrSingleplayer()) { return; } if ((float)_target.Health.healthCurrent <= _stopThreshold) { Object.Destroy((Object)(object)this); return; } _timeUntilNextTick -= Time.deltaTime; if (_timeUntilNextTick <= 0f) { _timeUntilNextTick += 1f; _target.Health.Hurt(_damagePerSecond, ((Component)_target).transform.up); } } private GameObject CreateParticles() { //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) float num = 1f; if ((Object)(object)_target.Rigidbody != (Object)null) { float y = ((Component)_target).transform.InverseTransformPoint(((Component)_target.Rigidbody).transform.position).y; if (y > 0.05f && y <= 6f) { num = y; } } return WitchPoisonParticles.Create(((Component)_target).transform, new Vector3(0f, num, 0f), 1f, _particlesMaterial); } private void OnDestroy() { if ((Object)(object)_particlesInstance != (Object)null) { Object.Destroy((Object)(object)_particlesInstance); } } } internal static class WitchPoisonParticles { internal static readonly Color PoisonColor = new Color(0.529f, 0.639f, 0.388f); internal static GameObject Create(Transform parent, Vector3 localPosition, float radius, Material material) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005f: 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_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: 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_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00df: 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_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Expected O, but got Unknown //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Unknown result type (might be due to invalid IL or missing references) //IL_0159: Unknown result type (might be due to invalid IL or missing references) //IL_0170: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Unknown result type (might be due to invalid IL or missing references) //IL_0186: Unknown result type (might be due to invalid IL or missing references) //IL_018b: Unknown result type (might be due to invalid IL or missing references) //IL_019a: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("WitchPoisonParticles"); val.transform.SetParent(parent, false); val.transform.localPosition = localPosition; ParticleSystem val2 = val.AddComponent<ParticleSystem>(); MainModule main = val2.main; ((MainModule)(ref main)).startColor = MinMaxGradient.op_Implicit(new Color(PoisonColor.r, PoisonColor.g, PoisonColor.b, 0.7f)); ((MainModule)(ref main)).startSize = MinMaxCurve.op_Implicit(0.25f); ((MainModule)(ref main)).startLifetime = MinMaxCurve.op_Implicit(1.2f); ((MainModule)(ref main)).startSpeed = MinMaxCurve.op_Implicit(0.5f); ((MainModule)(ref main)).maxParticles = 80; ((MainModule)(ref main)).loop = true; ((MainModule)(ref main)).gravityModifier = MinMaxCurve.op_Implicit(-0.05f); EmissionModule emission = val2.emission; ((EmissionModule)(ref emission)).rateOverTime = MinMaxCurve.op_Implicit(30f); ShapeModule shape = val2.shape; ((ShapeModule)(ref shape)).shapeType = (ParticleSystemShapeType)0; ((ShapeModule)(ref shape)).radius = radius; if ((Object)(object)material != (Object)null) { ((Renderer)((Component)val2).GetComponent<ParticleSystemRenderer>()).material = material; } ColorOverLifetimeModule colorOverLifetime = val2.colorOverLifetime; ((ColorOverLifetimeModule)(ref colorOverLifetime)).enabled = true; Gradient val3 = new Gradient(); val3.SetKeys((GradientColorKey[])(object)new GradientColorKey[2] { new GradientColorKey(PoisonColor, 0f), new GradientColorKey(PoisonColor, 1f) }, (GradientAlphaKey[])(object)new GradientAlphaKey[2] { new GradientAlphaKey(0.8f, 0f), new GradientAlphaKey(0f, 1f) }); ((ColorOverLifetimeModule)(ref colorOverLifetime)).color = MinMaxGradient.op_Implicit(val3); val2.Play(); return val; } } public class WitchPotionProjectile : MonoBehaviour, IPunInstantiateMagicCallback, IPunObservable { public enum PotionType { Damage, Poison } public PotionType potionType = PotionType.Damage; public Enemy enemyHost; public int damage = 50; public int enemyDamage = 25; public int poisonDamagePerSecond = 4; public float poisonDuration = 20f; public float poisonStopThreshold = 4f; public float hitRadius = 1.2f; public float collisionRadius = 0.4f; public float balloonPopRadius = 1.5f; public Sound breakSound; public Material poisonParticlesMaterial; private bool exploded; private bool _remotePhysicsStarted; private Vector3 _remotePosition; private Vector3 _remoteVelocity; private double _remoteTimestamp; private Rigidbody _rb; private static readonly Color DamageColor = new Color(0.6588f, 0.3961f, 0.4157f); private static readonly Color PoisonColor = new Color(0.529f, 0.639f, 0.388f); private Vector3 Position => ((Object)(object)_rb != (Object)null) ? _rb.position : ((Component)this).transform.position; private void Awake() { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) _rb = ((Component)this).GetComponentInChildren<Rigidbody>(); _remotePosition = Position; } public void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info) { //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_000e: 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_002d: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) if (stream.IsWriting) { stream.SendNext((object)Position); stream.SendNext((object)(((Object)(object)_rb != (Object)null) ? _rb.velocity : Vector3.zero)); stream.SendNext((object)exploded); return; } _remotePosition = (Vector3)stream.ReceiveNext(); _remoteVelocity = (Vector3)stream.ReceiveNext(); if ((bool)stream.ReceiveNext() && !exploded) { exploded = true; } _remoteTimestamp = PhotonNetwork.Time; _remotePhysicsStarted = true; if ((Object)(object)_rb != (Object)null) { _rb.isKinematic = true; _rb.position = _remotePosition; } } private void Update() { //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005c: 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_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: 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 (!exploded && !SemiFunc.IsMasterClientOrSingleplayer() && _remotePhysicsStarted && !((Object)(object)_rb == (Object)null)) { float num = Mathf.Clamp((float)(PhotonNetwork.Time - _remoteTimestamp), 0f, 0.1f); Vector3 val = _remotePosition + _remoteVelocity * num; _rb.position = Vector3.Lerp(_rb.position, val, 0.75f); } } public void Launch(Vector3 velocity) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) Rigidbody componentInChildren = ((Component)this).GetComponentInChildren<Rigidbody>(); if ((Object)(object)componentInChildren != (Object)null) { componentInChildren.useGravity = true; componentInChildren.isKinematic = false; componentInChildren.velocity = velocity; } ApplyColor(); } public void OnPhotonInstantiate(PhotonMessageInfo info) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) object[] array = (((Object)(object)info.photonView != (Object)null) ? info.photonView.InstantiationData : null); if (array != null && array.Length != 0) { potionType = (PotionType)(int)array[0]; } ApplyColor(); if (array != null && array.Length > 1 && array[1] is Vector3 velocity) { Launch(velocity); } } private void ApplyColor() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0009: 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_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) Color val = ((potionType == PotionType.Damage) ? DamageColor : PoisonColor); Renderer[] componentsInChildren = ((Component)this).GetComponentsInChildren<Renderer>(); Renderer[] array = componentsInChildren; foreach (Renderer val2 in array) { if (!((Object)(object)val2.sharedMaterial == (Object)null)) { Material material = val2.material; if (material.HasProperty("_BaseColor")) { material.SetColor("_BaseColor", val); } if (material.HasProperty("_Color")) { material.SetColor("_Color", val); } if (material.HasProperty("_EmissionColor")) { material.EnableKeyword("_EMISSION"); material.SetColor("_EmissionColor", val * 2f); } } } } private void FixedUpdate() { //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_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) if (exploded || !SemiFunc.IsMasterClientOrSingleplayer()) { return; } LayerMask val = SemiFunc.LayerMaskGetShouldHits(); Collider[] array = Physics.OverlapSphere(Position, collisionRadius, LayerMask.op_Implicit(val)); Collider[] array2 = array; foreach (Collider val2 in array2) { if (!((Component)val2).transform.IsChildOf(((Component)this).transform) && (!((Object)(object)enemyHost != (Object)null) || !((Object)(object)enemyHost.EnemyParent != (Object)null) || !((Component)val2).transform.IsChildOf(((Component)enemyHost.EnemyParent).transform))) { Explode(); break; } } } private void Explode() { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0301: 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_02bb: Unknown result type (might be due to invalid IL or missing references) if (exploded) { return; } exploded = true; HashSet<PlayerAvatar> hashSet = new HashSet<PlayerAvatar>(); HashSet<Enemy> hashSet2 = new HashSet<Enemy>(); Collider[] array = Physics.OverlapSphere(Position, hitRadius); Collider[] array2 = array; foreach (Collider val in array2) { if ((Object)(object)enemyHost != (Object)null && (Object)(object)enemyHost.EnemyParent != (Object)null && ((Component)val).transform.IsChildOf(((Component)enemyHost.EnemyParent).transform)) { continue; } PlayerAvatar componentInParent = ((Component)val).GetComponentInParent<PlayerAvatar>(); if ((Object)(object)componentInParent != (Object)null) { if (componentInParent.isDisabled || componentInParent.deadSet || (Object)(object)componentInParent.playerHealth == (Object)null || !hashSet.Add(componentInParent)) { continue; } if (potionType == PotionType.Damage) { componentInParent.playerHealth.HurtOther(damage, Position, false, SemiFunc.EnemyGetIndex(enemyHost), false); continue; } WitchPoisonDebuff component = ((Component)componentInParent).GetComponent<WitchPoisonDebuff>(); if ((Object)(object)component != (Object)null) { component.Refresh(); } else { component = ((Component)componentInParent).gameObject.AddComponent<WitchPoisonDebuff>(); component.Initialize(enemyHost, poisonDamagePerSecond, poisonDuration, poisonStopThreshold, poisonParticlesMaterial); } if (SemiFunc.IsMultiplayer()) { PhotonView componentInChildren = ((Component)this).GetComponentInChildren<PhotonView>(); if ((Object)(object)componentInChildren != (Object)null && (Object)(object)componentInParent.photonView != (Object)null) { componentInChildren.RPC("AddPoisonDebuffRPC", (RpcTarget)0, new object[4] { componentInParent.photonView.ViewID, poisonDamagePerSecond, poisonDuration, poisonStopThreshold }); } } continue; } Enemy val2 = ResolveEnemy(val); if (!((Object)(object)val2 == (Object)null) && !((Object)(object)val2 == (Object)(object)enemyHost) && hashSet2.Add(val2) && val2.HasHealth && !((Object)(object)val2.Health == (Object)null) && !val2.Health.dead && !val2.Health.deadImpulse) { if (potionType == PotionType.Damage) { val2.Health.Hurt(enemyDamage, DirFromExplosionTo(val2)); } else { ApplyEnemyPoison(val2); } } } PopNearbyBalloons(); if (breakSound != null) { breakSound.Play(Position, 1f, 1f, 1f, 1f); if (SemiFunc.IsMultiplayer()) { PhotonView componentInChildren2 = ((Component)this).GetComponentInChildren<PhotonView>(); if ((Object)(object)componentInChildren2 != (Object)null) { componentInChildren2.RPC("PlayBreakSoundRPC", (RpcTarget)1, Array.Empty<object>()); } } } DetachAndPlayExplosionParticles(); if (SemiFunc.IsMultiplayer()) { PhotonView componentInChildren3 = ((Component)this).GetComponentInChildren<PhotonView>(); if ((Object)(object)componentInChildren3 != (Object)null) { componentInChildren3.RPC("PlayExplosionParticlesRPC", (RpcTarget)1, Array.Empty<object>()); } } if (SemiFunc.IsMultiplayer()) { PhotonNetwork.Destroy(((Component)((Component)this).gameObject.transform.root).gameObject); } else { Object.Destroy((Object)(object)((Component)((Component)this).gameObject.transform.root).gameObject); } } private static Enemy ResolveEnemy(Collider hit) { EnemyParent componentInParent = ((Component)hit).GetComponentInParent<EnemyParent>(); if ((Object)(object)componentInParent != (Object)null && (Object)(object)componentInParent.Enemy != (Object)null) { return componentInParent.Enemy; } EnemyRigidbody componentInParent2 = ((Component)hit).GetComponentInParent<EnemyRigidbody>(); if ((Object)(object)componentInParent2 != (Object)null && (Object)(object)componentInParent2.enemy != (Object)null) { return componentInParent2.enemy; } return ((Component)hit).GetComponentInParent<Enemy>(); } private Vector3 DirFromExplosionTo(Enemy enemy) { //IL_0022: 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_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) Vector3 val = (((Object)(object)enemy.CenterTransform != (Object)null) ? enemy.CenterTransform.position : ((Component)enemy).transform.position); Vector3 val2 = val - Position; return (((Vector3)(ref val2)).sqrMagnitude > 0.0001f) ? ((Vector3)(ref val2)).normalized : Vector3.up; } private void ApplyEnemyPoison(Enemy target) { WitchEnemyPoisonDebuff component = ((Component)target).GetComponent<WitchEnemyPoisonDebuff>(); if ((Object)(object)component != (Object)null) { component.Refresh(); } else { component = ((Component)target).gameObject.AddComponent<WitchEnemyPoisonDebuff>(); component.Initialize(target, poisonDamagePerSecond, poisonDuration, poisonStopThreshold, poisonParticlesMaterial); } if (SemiFunc.IsMultiplayer()) { PhotonView componentInChildren = ((Component)this).GetComponentInChildren<PhotonView>(); PhotonView photonView = target.PhotonView; if ((Object)(object)componentInChildren != (Object)null && (Object)(object)photonView != (Object)null) { componentInChildren.RPC("AddEnemyPoisonDebuffRPC", (RpcTarget)0, new object[4] { photonView.ViewID, poisonDamagePerSecond, poisonDuration, poisonStopThreshold }); } } } private void PopNearbyBalloons() { //IL_0002: Unknown result type (might be due to invalid IL or missing references) Collider[] array = Physics.OverlapSphere(Position, balloonPopRadius); if (array.Length == 0) { return; } HashSet<BirthdayBoyBalloon> hashSet = new HashSet<BirthdayBoyBalloon>(); Collider[] array2 = array; foreach (Collider val in array2) { BirthdayBoyBalloon componentInParent = ((Component)val).GetComponentInParent<BirthdayBoyBalloon>(); if (!((Object)(object)componentInParent == (Object)null) && !componentInParent.popped && hashSet.Add(componentInParent)) { componentInParent.popped = true; } } } [PunRPC] public void PlayBreakSoundRPC() { //IL_000e: Unknown result type (might be due to invalid IL or missing references) Sound obj = breakSound; if (obj != null) { obj.Play(Position, 1f, 1f, 1f, 1f); } } [PunRPC] public void PlayExplosionParticlesRPC() { DetachAndPlayExplosionParticles(); } [PunRPC] public void AddPoisonDebuffRPC(int playerViewID, int dps, float duration, float stopThreshold, PhotonMessageInfo info = default(PhotonMessageInfo)) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) if (!SemiFunc.MasterOnlyRPC(info)) { return; } foreach (PlayerAvatar item in SemiFunc.PlayerGetList()) { if ((Object)(object)item == (Object)null || (Object)(object)item.photonView == (Object)null || item.photonView.ViewID != playerViewID) { continue; } WitchPoisonDebuff component = ((Component)item).GetComponent<WitchPoisonDebuff>(); if ((Object)(object)component == (Object)null) { component = ((Component)item).gameObject.AddComponent<WitchPoisonDebuff>(); component.Initialize(null, dps, duration, stopThreshold, poisonParticlesMaterial); } else { component.Refresh(); } break; } } [PunRPC] public void AddEnemyPoisonDebuffRPC(int enemyViewID, int dps, float duration, float stopThreshold, PhotonMessageInfo info = default(PhotonMessageInfo)) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) if (!SemiFunc.MasterOnlyRPC(info)) { return; } PhotonView val = PhotonView.Find(enemyViewID); if ((Object)(object)val == (Object)null) { return; } Enemy component = ((Component)val).GetComponent<Enemy>(); if (!((Object)(object)component == (Object)null) && component.HasHealth && !((Object)(object)component.Health == (Object)null) && !component.Health.dead && component.Health.healthCurrent > 0 && (!((Object)(object)component.EnemyParent != (Object)null) || component.EnemyParent.Spawned)) { WitchEnemyPoisonDebuff component2 = ((Component)component).GetComponent<WitchEnemyPoisonDebuff>(); if ((Object)(object)component2 == (Object)null) { component2 = ((Component)component).gameObject.AddComponent<WitchEnemyPoisonDebuff>(); component2.Initialize(component, dps, duration, stopThreshold, poisonParticlesMaterial); } else { component2.Refresh(); } } } private void DetachAndPlayExplosionParticles() { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_005f: 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) ParticleSystem[] componentsInChildren = ((Component)this).GetComponentsInChildren<ParticleSystem>(true); ParticleSystem[] array = componentsInChildren; foreach (ParticleSystem val in array) { ((Component)val).transform.SetParent((Transform)null, true); MainModule main = val.main; if (!((MainModule)(ref main)).loop) { val.Play(); main = val.main; float duration = ((MainModule)(ref main)).duration; main = val.main; MinMaxCurve startLifetime = ((MainModule)(ref main)).startLifetime; float num = duration + ((MinMaxCurve)(ref startLifetime)).constantMax; Object.Destroy((Object)(object)((Component)val).gameObject, Mathf.Max(num, 2f)); } else { val.Play(); Object.Destroy((Object)(object)((Component)val).gameObject, 2f); } } } } public class WitchPoisonDebuff : MonoBehaviour { private Enemy _enemyHost; private int _damagePerSecond; private float _duration; private float _stopThreshold; private float _timeUntilNextTick = 1f; private float _elapsed; private GameObject _particlesInstance; private Material _particlesMaterial; private static readonly Color PoisonColor = new Color(0.529f, 0.639f, 0.388f); public void Initialize(Enemy enemyHost, int damagePerSecond, float duration, float stopThreshold, Material particlesMaterial = null) { _enemyHost = enemyHost; _damagePerSecond = damagePerSecond; _duration = duration; _stopThreshold = stopThreshold; _particlesMaterial = particlesMaterial; } public void Refresh() { _elapsed = 0f; _timeUntilNextTick = 1f; } private void Update() { //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Unknown result type (might be due to invalid IL or missing references) PlayerAvatar component = ((Component)this).GetComponent<PlayerAvatar>(); if ((Object)(object)component == (Object)null || (Object)(object)component.playerHealth == (Object)null) { Object.Destroy((Object)(object)this); return; } _elapsed += Time.deltaTime; if (_elapsed >= _duration) { Object.Destroy((Object)(object)this); return; } if (component.isLocal) { PostProcessing.Instance.VignetteOverride(PoisonColor, 0.7f, 0.5f, 1.5f, 1.5f, 1.5f, ((Component)this).gameObject, 999); } if ((Object)(object)_particlesInstance == (Object)null) { _particlesInstance = CreatePoisonParticles(component); } if (!SemiFunc.IsMasterClientOrSingleplayer()) { return; } if ((float)component.playerHealth.health <= _stopThreshold) { Object.Destroy((Object)(object)this); return; } _timeUntilNextTick -= Time.deltaTime; if (_timeUntilNextTick <= 0f) { _timeUntilNextTick += 1f; component.playerHealth.HurtOther(_damagePerSecond, ((Component)component).transform.position, false, SemiFunc.EnemyGetIndex(_enemyHost), false); } } private GameObject CreatePoisonParticles(PlayerAvatar player) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) return WitchPoisonParticles.Create(((Component)player).transform, new Vector3(0f, 0.6f, 0f), 0.7f, _particlesMaterial); } private void OnDestroy() { if ((Object)(object)_particlesInstance != (Object)null) { Object.Destroy((Object)(object)_particlesInstance); } } } }