Decompiled source of ThumbnailStudio v1.0.0
plugins\ThumbnailStudio.dll
Decompiled 3 days 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.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using Newtonsoft.Json; using Photon.Pun; using Photon.Realtime; using UnityEngine; using UnityEngine.Rendering; using UnityEngine.Rendering.Universal; using UnityEngine.SceneManagement; using Zorro.Core; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: IgnoresAccessChecksTo("Assembly-CSharp")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.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; } } [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public string AssemblyName { get; } public IgnoresAccessChecksToAttribute(string assemblyName) { AssemblyName = assemblyName; } } } namespace ThumbnailStudio { public enum ActorMode { Posed, Frozen, Physics, AI } public class CharacterActor : StudioObject { public static readonly Dictionary<Character, CharacterActor> ByCharacter = new Dictionary<Character, CharacterActor>(); public static readonly BodypartType[] PosableParts; public readonly Character Ch; public readonly bool IsPlayer; public readonly MushroomZombie Zombie; public Quaternion PoseRot = Quaternion.identity; private Quaternion _frozenRot = Quaternion.identity; public readonly List<AnimationClip> Clips = new List<AnimationClip>(); public AnimationClip Clip; public float ClipTime; public bool ClipPlaying = true; public float ClipSpeed = 1f; public bool AnimatorMode; private string _animatorStatePlayed; public readonly Dictionary<BodypartType, Vector3> LimbOffsets = new Dictionary<BodypartType, Vector3>(); public float HeadTilt; public float HeadTurn; public int Eyes = -1; public int Mouth = -1; public bool Mushrooms = true; public string LookPlayer; private readonly List<Behaviour> _ai = new List<Behaviour>(); private Texture[] _origEyes; private AnimatedMouth _mouth; public Vector3 PosePos; private bool _poseCaptured; private Vector3[] _poseOffsets = (Vector3[])(object)new Vector3[0]; private Quaternion[] _poseRots = (Quaternion[])(object)new Quaternion[0]; private int[] _order; private int[] _parentIdx; private Vector3[] _solvedPos = (Vector3[])(object)new Vector3[0]; private int _hipIdx = -1; public ActorMode Mode { get; private set; } = ActorMode.Physics; public override GameObject Go { get { if (!Object.op_Implicit((Object)(object)Ch)) { return null; } return ((Component)Ch).gameObject; } } public override bool CanDelete => !IsPlayer; public override bool CanScale => false; public override string KindLabel { get { if (!IsPlayer) { return "Actor"; } return "Player"; } } public bool HasAI => _ai.Count > 0; public Transform HipTf { get { Bodypart obj = Part((BodypartType)0); if (obj == null) { return null; } return obj.transform; } } public override Vector3 Position { get { //IL_0025: 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_0031: Unknown result type (might be due to invalid IL or missing references) if (Mode != ActorMode.Posed || !_poseCaptured) { if (!Alive || !Object.op_Implicit((Object)(object)HipTf)) { return Vector3.zero; } return HipTf.position; } return PosePos; } } public override Quaternion Rotation => (Quaternion)(Mode switch { ActorMode.Posed => PoseRot, ActorMode.Frozen => _frozenRot, _ => YawRotation(), }); public override float BottomY { get { //IL_0048: Unknown result type (might be due to invalid IL or missing references) if (!Alive) { return 0f; } float num = float.MaxValue; foreach (Bodypart part in Ch.refs.ragdoll.partList) { if (Object.op_Implicit((Object)(object)part)) { num = Mathf.Min(num, part.transform.position.y); } } return num - 0.12f; } } public int MouthCount { get { if (!Object.op_Implicit((Object)(object)_mouth) || _mouth.mouthTextures == null) { return 0; } return _mouth.mouthTextures.Length; } } public CharacterActor(Character ch, bool isPlayer, SpawnType spawnType, string prefab, string name) { //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) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0134: 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_0140: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) Ch = ch; IsPlayer = isPlayer; SpawnType = spawnType; Prefab = prefab; Name = name; Kind = ObjKind.Actor; Zombie = ((Component)ch).GetComponent<MushroomZombie>(); ByCharacter[ch] = this; Behaviour[] components = ((Component)ch).GetComponents<Behaviour>(); foreach (Behaviour val in components) { if (val is MushroomZombie || val is Scoutmaster || val is Bot || val is BotToCharacterTranslator) { _ai.Add(val); } } RefreshClips(); _mouth = ((Component)ch).GetComponentInChildren<AnimatedMouth>(true); PoseRot = YawRotation(); _frozenRot = PoseRot; } private Bodypart Part(BodypartType t) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) try { return Ch.GetBodypart(t); } catch { return null; } } private Quaternion YawRotation() { //IL_0019: 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_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0070: 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_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) if (!Alive) { return Quaternion.identity; } Vector3 val = Ch.data.lookDirection_Flat; if (((Vector3)(ref val)).sqrMagnitude < 0.001f && Object.op_Implicit((Object)(object)HipTf)) { val = Vector3.ProjectOnPlane(HipTf.forward, Vector3.up); } if (((Vector3)(ref val)).sqrMagnitude < 0.001f) { val = Vector3.forward; } return Quaternion.LookRotation(((Vector3)(ref val)).normalized, Vector3.up); } public void RefreshClips() { Clips.Clear(); Animator animator = Ch.refs.animator; if (Object.op_Implicit((Object)(object)animator) && Object.op_Implicit((Object)(object)animator.runtimeAnimatorController)) { Clips.AddRange(animator.runtimeAnimatorController.animationClips.Where((AnimationClip c) => Object.op_Implicit((Object)(object)c)).Distinct()); } if (Object.op_Implicit((Object)(object)Zombie) && Object.op_Implicit((Object)(object)Zombie.animatorMushroomMan)) { Clips.AddRange(Zombie.animatorMushroomMan.animationClips.Where((AnimationClip c) => Object.op_Implicit((Object)(object)c) && Clips.All((AnimationClip x) => ((Object)x).name != ((Object)c).name))); } List<AnimationClip> collection = (from c in Clips group c by ((Object)c).name into g select g.First() into c orderby ((Object)c).name select c).ToList(); Clips.Clear(); Clips.AddRange(collection); } public AnimationClip DefaultIdleClip() { string[] bad = new string[12] { "item", "climb", "crouch", "hang", "rope", "vine", "swim", "carry", "web", "sit", "fall", "lie" }; return (from c in Clips where Has(c, "idle") && !bad.Any((string b) => Has(c, b)) orderby ((Object)c).name.Length select c).FirstOrDefault() ?? ((IEnumerable<AnimationClip>)Clips).FirstOrDefault((Func<AnimationClip, bool>)((AnimationClip c) => Has(c, "idle"))); static bool Has(AnimationClip c, string w) { return ((Object)c).name.IndexOf(w, StringComparison.OrdinalIgnoreCase) >= 0; } } public void SetMode(ActorMode mode) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0098: 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_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) if (!Alive) { return; } Quaternion rotation = Rotation; Vector3 position = Position; if (mode == ActorMode.Posed && Mode != ActorMode.Posed) { PosePos = position; _poseCaptured = false; } Mode = mode; CharacterRagdoll ragdoll = Ch.refs.ragdoll; switch (mode) { case ActorMode.Posed: SetAI(on: false); ragdoll.ToggleKinematic(true); Ch.data.passedOut = false; Ch.data.fallSeconds = 0f; PoseRot = rotation; if ((Object)(object)Clip == (Object)null && !AnimatorMode) { Clip = DefaultIdleClip(); } _animatorStatePlayed = null; break; case ActorMode.Frozen: SetAI(on: false); ragdoll.ToggleKinematic(true); _frozenRot = rotation; break; case ActorMode.Physics: SetAI(on: false); ragdoll.ToggleKinematic(false); ragdoll.HaltBodyVelocity(true); Ch.refs.animations.ResetForceSpeed(); SyncLook(rotation); break; case ActorMode.AI: ragdoll.ToggleKinematic(false); ragdoll.HaltBodyVelocity(true); Ch.refs.animations.ResetForceSpeed(); SetAI(on: true); break; } base.Frozen = mode == ActorMode.Posed || mode == ActorMode.Frozen; } public override void SetFrozen(bool frozen) { if (frozen) { SetMode((Mode != ActorMode.Posed) ? ActorMode.Frozen : ActorMode.Posed); } else { SetMode(IsPlayer ? ActorMode.Physics : ((Mode == ActorMode.Frozen || Mode == ActorMode.Posed) ? ActorMode.Physics : Mode)); } } private void SetAI(bool on) { foreach (Behaviour item in _ai) { if (Object.op_Implicit((Object)(object)item)) { item.enabled = on; } } if (Object.op_Implicit((Object)(object)Zombie) && !on && Object.op_Implicit((Object)(object)Zombie.biteColliderObject)) { Zombie.biteColliderObject.SetActive(false); } } public override void MoveTo(Vector3 pos, Quaternion rot) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001c: 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_003b: 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_0042: 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_0049: 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_0063: 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_006d: 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_0074: 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_010a: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: 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_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_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) if (!Alive) { return; } CharacterRagdoll ragdoll = Ch.refs.ragdoll; Vector3 val = pos - Position; switch (Mode) { case ActorMode.Posed: PosePos = pos; PoseRot = rot; SyncLook(rot); if (_poseCaptured) { ApplyPuppetPose(); } break; case ActorMode.Frozen: { Quaternion val2 = rot * Quaternion.Inverse(_frozenRot); Vector3 position = Position; foreach (Bodypart part in ragdoll.partList) { if (Object.op_Implicit((Object)(object)part)) { Transform transform = part.transform; SetPart(part, pos + val2 * (transform.position - position), val2 * transform.rotation); } } _frozenRot = rot; break; } default: if (((Vector3)(ref val)).sqrMagnitude > 1E-08f) { ragdoll.MoveAllRigsInDirection(val); } SyncLook(rot); break; } } private static void SetPart(Bodypart p, Vector3 pos, Quaternion rot) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) Rigidbody rig = p.Rig; if (Object.op_Implicit((Object)(object)rig)) { rig.position = pos; rig.rotation = rot; } p.transform.SetPositionAndRotation(pos, rot); } private void CapturePose() { //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_0083: 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_0089: 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_00a1: 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) List<Bodypart> partList = Ch.refs.ragdoll.partList; Transform hipTf = HipTf; if (!Object.op_Implicit((Object)(object)hipTf)) { return; } if (_poseOffsets.Length != partList.Count) { _poseOffsets = (Vector3[])(object)new Vector3[partList.Count]; _poseRots = (Quaternion[])(object)new Quaternion[partList.Count]; } Vector3 position = hipTf.position; for (int i = 0; i < partList.Count; i++) { Bodypart val = partList[i]; if (Object.op_Implicit((Object)(object)val)) { _poseOffsets[i] = val.transform.position - position; _poseRots[i] = val.transform.rotation; } } _poseCaptured = true; } private void BuildChain(List<Bodypart> parts) { //IL_0080: Unknown result type (might be due to invalid IL or missing references) int count = parts.Count; _parentIdx = new int[count]; for (int i = 0; i < count; i++) { _parentIdx[i] = -1; Bodypart val = (Object.op_Implicit((Object)(object)parts[i]) ? parts[i].jointParent : null); if (Object.op_Implicit((Object)(object)val) && Object.op_Implicit((Object)(object)parts[i].joint)) { _parentIdx[i] = parts.IndexOf(val); } if (Object.op_Implicit((Object)(object)parts[i]) && (int)parts[i].partType == 0) { _hipIdx = i; } } List<int> list = new List<int>(); bool[] array = new bool[count]; for (int j = 0; j < count; j++) { if (list.Count >= count) { break; } for (int k = 0; k < count; k++) { if (!array[k] && (_parentIdx[k] < 0 || array[_parentIdx[k]])) { array[k] = true; list.Add(k); } } } for (int l = 0; l < count; l++) { if (!array[l]) { _parentIdx[l] = -1; list.Add(l); } } _order = list.ToArray(); _solvedPos = (Vector3[])(object)new Vector3[count]; } public void ApplyPuppetPose() { //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_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Unknown result type (might be due to invalid IL or missing references) //IL_0169: 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_017a: Unknown result type (might be due to invalid IL or missing references) //IL_017c: 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_0186: Unknown result type (might be due to invalid IL or missing references) //IL_0161: 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_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_0100: 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_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_0118: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_018f: Unknown result type (might be due to invalid IL or missing references) //IL_0191: Unknown result type (might be due to invalid IL or missing references) //IL_01c1: 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) if (Mode != ActorMode.Posed || !_poseCaptured || !Alive) { return; } List<Bodypart> partList = Ch.refs.ragdoll.partList; int num = Mathf.Min(partList.Count, _poseOffsets.Length); if (_order == null || _order.Length != partList.Count) { BuildChain(partList); } for (int i = 0; i < _order.Length; i++) { int num2 = _order[i]; if (num2 >= num) { continue; } Bodypart val = partList[num2]; if (Object.op_Implicit((Object)(object)val)) { Quaternion val2 = _poseRots[num2]; int num3 = _parentIdx[num2]; Vector3 val4; if (num3 >= 0 && num3 < num && Object.op_Implicit((Object)(object)partList[num3])) { ConfigurableJoint joint = val.joint; Bodypart val3 = partList[num3]; val4 = _solvedPos[num3] + _poseRots[num3] * Vector3.Scale(((Joint)joint).connectedAnchor, val3.transform.lossyScale) - val2 * Vector3.Scale(((Joint)joint).anchor, val.transform.lossyScale); } else { Vector3 val5 = ((_hipIdx >= 0 && _hipIdx < num) ? _poseOffsets[_hipIdx] : Vector3.zero); val4 = PosePos + (_poseOffsets[num2] - val5); } _solvedPos[num2] = val4; if (Object.op_Implicit((Object)(object)val.Rig) && !val.Rig.isKinematic) { val.Rig.isKinematic = true; } SetPart(val, val4, val2); } } } private void SyncLook(Quaternion rot) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //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_0015: 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_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_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_0039: 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_004f: 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_0088: Unknown result type (might be due to invalid IL or missing references) Vector3 val = Vector3.ProjectOnPlane(rot * Vector3.forward, Vector3.up); if (((Vector3)(ref val)).sqrMagnitude < 0.0001f) { val = Vector3.ProjectOnPlane(rot * Vector3.up, Vector3.up); } if (!(((Vector3)(ref val)).sqrMagnitude < 0.0001f)) { float num = Mathf.Atan2(val.x, val.z) * 57.29578f; Ch.data.lookValues = new Vector2(num, Mathf.Clamp(0f - HeadTilt, -85f, 85f)); Ch.RecalculateLookDirections(); } } public override Bounds GetBounds() { //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_0012: 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_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) //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_0092: Unknown result type (might be due to invalid IL or missing references) Bounds result = default(Bounds); ((Bounds)(ref result))..ctor(Position, Vector3.one * 0.3f); if (!Alive) { return result; } foreach (Bodypart part in Ch.refs.ragdoll.partList) { if (Object.op_Implicit((Object)(object)part)) { ((Bounds)(ref result)).Encapsulate(new Bounds(part.transform.position, Vector3.one * 0.35f)); } } return result; } public override bool Raycast(Ray ray, out float dist) { //IL_0046: 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_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_0063: Unknown result type (might be due to invalid IL or missing references) dist = float.MaxValue; bool result = false; if (!Alive) { return false; } float num = default(float); foreach (Bodypart part in Ch.refs.ragdoll.partList) { if (Object.op_Implicit((Object)(object)part)) { Bounds val = new Bounds(part.transform.position, Vector3.one * 0.45f); if (((Bounds)(ref val)).IntersectRay(ray, ref num) && num < dist) { dist = num; result = true; } } } return result; } public override void Update() { //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) if (!Alive) { return; } if (Mode == ActorMode.Posed) { Ch.data.fallSeconds = 0f; Ch.data.passedOut = false; SyncLook(PoseRot); if (Object.op_Implicit((Object)(object)Clip)) { float num = Mathf.Max(0.0001f, Clip.length); if (ClipPlaying) { ClipTime += Time.deltaTime * ClipSpeed; } if (ClipTime > num) { ClipTime %= num; } if (ClipTime < 0f) { ClipTime = num + ClipTime % num; } } if (AnimatorMode) { DriveAnimatorState(); } } if (!Object.op_Implicit((Object)(object)Zombie) || ((Behaviour)Zombie).enabled) { return; } foreach (GameObject mushroomVisual in Zombie.mushroomVisuals) { if (Object.op_Implicit((Object)(object)mushroomVisual)) { if (mushroomVisual.activeSelf != Mushrooms) { mushroomVisual.SetActive(Mushrooms); } if (Mushrooms && mushroomVisual.transform.localScale.x < 1f) { mushroomVisual.transform.localScale = Vector3.one; } } } } private void DriveAnimatorState() { Animator animator = Ch.refs.animator; if (!Object.op_Implicit((Object)(object)Clip) || !Object.op_Implicit((Object)(object)animator)) { return; } int num = Animator.StringToHash(((Object)Clip).name); float num2 = ((Clip.length > 0f) ? (ClipTime / Clip.length) : 0f); if (_animatorStatePlayed != ((Object)Clip).name || !ClipPlaying) { if (animator.HasState(0, num)) { animator.Play(num, 0, num2); } _animatorStatePlayed = ((Object)Clip).name; } Ch.refs.animations.ForceSpeed(ClipPlaying ? ClipSpeed : 0f); } public void ApplyAnimationOverride() { //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: 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_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00da: 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_0171: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Unknown result type (might be due to invalid IL or missing references) //IL_0177: Unknown result type (might be due to invalid IL or missing references) //IL_017c: 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_0188: Unknown result type (might be due to invalid IL or missing references) //IL_018d: 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_019c: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_01ae: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0106: 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_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_011a: 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_0128: Unknown result type (might be due to invalid IL or missing references) if (Mode != ActorMode.Posed || !Alive) { return; } Animator animator = Ch.refs.animator; if (!AnimatorMode && Object.op_Implicit((Object)(object)Clip) && Object.op_Implicit((Object)(object)animator)) { try { Clip.SampleAnimation(((Component)animator).gameObject, ClipTime); } catch (Exception ex) { Plugin.Log.LogWarning((object)("SampleAnimation failed, switching to animator mode: " + ex.Message)); AnimatorMode = true; } } Quaternion val = (Object.op_Implicit((Object)(object)Ch.refs.rigCreator) ? ((Component)Ch.refs.rigCreator).transform.rotation : PoseRot); BodypartType[] posableParts = PosableParts; foreach (BodypartType val2 in posableParts) { if (LimbOffsets.TryGetValue(val2, out var value) && !(value == Vector3.zero)) { Bodypart val3 = Part(val2); if (Object.op_Implicit((Object)(object)val3)) { Quaternion val4 = val * Quaternion.Euler(value) * Quaternion.Inverse(val); val3.transform.rotation = val4 * val3.transform.rotation; } } } if (HeadTilt != 0f || HeadTurn != 0f) { Bodypart val5 = Part((BodypartType)4); if (Object.op_Implicit((Object)(object)val5)) { Quaternion val6 = Quaternion.AngleAxis(HeadTurn, val * Vector3.up) * Quaternion.AngleAxis(HeadTilt, val * Vector3.right); val5.transform.rotation = val6 * val5.transform.rotation; } } CapturePose(); } public override void LateUpdate() { if (Alive) { ApplyExpressions(); if (base.Hidden && !Ch.refs.customization._allRenderersHidden) { Ch.refs.customization.HideAllRenderers(); } } } public override void SetHidden(bool hidden) { if (Alive) { if (hidden) { Ch.refs.customization.HideAllRenderers(); } else { Ch.refs.customization.ShowAllRenderers(); } base.Hidden = hidden; } } public static List<KeyValuePair<string, Texture>> EyeOptions(CharacterActor a) { List<KeyValuePair<string, Texture>> list = new List<KeyValuePair<string, Texture>>(); Customization instance = Singleton<Customization>.Instance; if ((Object)(object)instance != (Object)null && instance.eyes != null) { for (int i = 0; i < instance.eyes.Length; i++) { if ((Object)(object)instance.eyes[i] != (Object)null && Object.op_Implicit((Object)(object)instance.eyes[i].texture)) { list.Add(new KeyValuePair<string, Texture>("Eyes " + (i + 1), instance.eyes[i].texture)); } } } if (a != null && a.Alive) { CharacterCustomization customization = a.Ch.refs.customization; if (Object.op_Implicit((Object)(object)customization.passedOutEyes)) { list.Add(new KeyValuePair<string, Texture>("Passed out", customization.passedOutEyes)); } if (Object.op_Implicit((Object)(object)customization.deadEyes)) { list.Add(new KeyValuePair<string, Texture>("Dead", customization.deadEyes)); } } Texture zombieEyeTexture = Catalog.ZombieEyeTexture; if (Object.op_Implicit((Object)(object)zombieEyeTexture)) { list.Add(new KeyValuePair<string, Texture>("Zombie", zombieEyeTexture)); } return list; } private void ApplyExpressions() { CustomizationRefs refs = Ch.refs.customization.refs; if (Eyes >= 0 && refs?.EyeRenderers != null) { List<KeyValuePair<string, Texture>> list = EyeOptions(this); if (Eyes < list.Count) { if (_origEyes == null) { _origEyes = refs.EyeRenderers.Select((Renderer r) => (!Object.op_Implicit((Object)(object)r)) ? null : r.material.GetTexture(CharacterCustomization.MainTex)).ToArray(); } Renderer[] eyeRenderers = refs.EyeRenderers; foreach (Renderer val in eyeRenderers) { if (Object.op_Implicit((Object)(object)val)) { val.material.SetTexture(CharacterCustomization.MainTex, list[Eyes].Value); } } } } else if (_origEyes != null && refs?.EyeRenderers != null) { for (int num2 = 0; num2 < refs.EyeRenderers.Length && num2 < _origEyes.Length; num2++) { if (Object.op_Implicit((Object)(object)refs.EyeRenderers[num2]) && Object.op_Implicit((Object)(object)_origEyes[num2])) { refs.EyeRenderers[num2].material.SetTexture(CharacterCustomization.MainTex, _origEyes[num2]); } } _origEyes = null; } if (Object.op_Implicit((Object)(object)_mouth) && Object.op_Implicit((Object)(object)_mouth.mouthRenderer) && Mouth >= 0 && Mouth < MouthCount) { _mouth.mouthRenderer.material.SetInt("_UseTalkSprites", 1); _mouth.mouthRenderer.material.SetTexture("_TalkSprite", (Texture)(object)_mouth.mouthTextures[Mouth]); } } public void ResetMouth() { Mouth = -1; if (Object.op_Implicit((Object)(object)_mouth) && Object.op_Implicit((Object)(object)_mouth.mouthRenderer)) { _mouth.mouthRenderer.material.SetInt("_UseTalkSprites", 0); } } public void Ragdoll(float seconds) { SetMode(ActorMode.Physics); try { Ch.Fall(seconds, 0f); } catch (Exception ex) { Plugin.Log.LogWarning((object)("Fall failed: " + ex.Message)); } } public void Launch(Vector3 velocity, float ragdollSeconds) { //IL_005b: Unknown result type (might be due to invalid IL or missing references) SetMode(ActorMode.Physics); if (ragdollSeconds > 0f) { try { Ch.Fall(ragdollSeconds, 0f); } catch { } } foreach (Rigidbody rigidbody in Ch.refs.ragdoll.rigidbodies) { if (Object.op_Implicit((Object)(object)rigidbody) && !rigidbody.isKinematic) { rigidbody.linearVelocity = velocity; } } } public void WakeZombie() { if (!Object.op_Implicit((Object)(object)Zombie)) { return; } SetMode(ActorMode.AI); try { Zombie.WakeUpFromSleep(); } catch (Exception ex) { Plugin.Log.LogWarning((object)ex.Message); } } public PropObject SpawnSkeletonCopy() { GameObject val = Resources.Load<GameObject>("Skeleton"); if (!Object.op_Implicit((Object)(object)val)) { Studio.Toast("Skeleton prefab not found"); return null; } GameObject obj = Object.Instantiate<GameObject>(val); Skelleton component = obj.GetComponent<Skelleton>(); if (Object.op_Implicit((Object)(object)component)) { component.SpawnSkelly(Ch); } PropObject propObject = new PropObject(obj, ObjKind.Prop, "Skeleton", Name + " skeleton"); propObject.SpawnType = SpawnType.LocalProp; propObject.SetFrozen(frozen: true); return propObject; } public override void OnDeleted() { if (Object.op_Implicit((Object)(object)Ch)) { ByCharacter.Remove(Ch); } } public void Release() { LimbOffsets.Clear(); HeadTilt = (HeadTurn = 0f); Eyes = -1; ResetMouth(); SetMode(IsPlayer ? ActorMode.Physics : (HasAI ? ActorMode.AI : ActorMode.Physics)); } public override ObjData Save() { //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: 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_010c: Unknown result type (might be due to invalid IL or missing references) ObjData objData = base.Save(); objData.mode = Mode.ToString(); objData.clip = (Object.op_Implicit((Object)(object)Clip) ? ((Object)Clip).name : null); objData.clipTime = ClipTime; objData.clipPlaying = ClipPlaying; objData.clipSpeed = ClipSpeed; objData.animatorMode = AnimatorMode; objData.headTilt = HeadTilt; objData.headTurn = HeadTurn; objData.eyes = Eyes; objData.mouth = Mouth; objData.mushrooms = Mushrooms; objData.lookPlayer = LookPlayer; List<float> list = new List<float>(); foreach (KeyValuePair<BodypartType, Vector3> limbOffset in LimbOffsets) { list.Add((float)limbOffset.Key); list.Add(limbOffset.Value.x); list.Add(limbOffset.Value.y); list.Add(limbOffset.Value.z); } objData.limbs = list.ToArray(); return objData; } public override void Load(ObjData d) { //IL_01a7: Unknown result type (might be due to invalid IL or missing references) //IL_01b7: 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) if (!string.IsNullOrEmpty(d.name)) { Name = d.name; } AnimatorMode = d.animatorMode; Clip = (string.IsNullOrEmpty(d.clip) ? null : ((IEnumerable<AnimationClip>)Clips).FirstOrDefault((Func<AnimationClip, bool>)((AnimationClip c) => ((Object)c).name == d.clip))); ClipTime = d.clipTime; ClipPlaying = d.clipPlaying; ClipSpeed = d.clipSpeed; HeadTilt = d.headTilt; HeadTurn = d.headTurn; Eyes = d.eyes; Mouth = d.mouth; Mushrooms = d.mushrooms; LimbOffsets.Clear(); if (d.limbs != null) { for (int num = 0; num + 3 < d.limbs.Length; num += 4) { LimbOffsets[(BodypartType)(int)d.limbs[num]] = new Vector3(d.limbs[num + 1], d.limbs[num + 2], d.limbs[num + 3]); } } if (!Enum.TryParse<ActorMode>(d.mode, out var result)) { result = ActorMode.Posed; } if (result == ActorMode.Frozen) { result = ActorMode.Posed; } SetMode(result); MoveTo(Util.V(d.pos), Util.Q(d.rot)); SetHidden(d.hidden); } static CharacterActor() { BodypartType[] array = new BodypartType[17]; RuntimeHelpers.InitializeArray(array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/); PosableParts = (BodypartType[])(object)array; } } public static class Capture { public static bool Capturing; public static string LastFile; public static bool Guides; public static bool Thirds = true; public static bool Center = true; public static bool SafeArea; public static bool YouTubeBadge = true; public static int Aspect; public static readonly string[] AspectNames = new string[6] { "Screen", "16:9", "1:1", "4:5", "9:16", "2.39:1" }; private static readonly float[] AspectValues = new float[6] { 0f, 1.7777778f, 1f, 0.8f, 0.5625f, 2.39f }; public static bool CropToAspect = true; public static bool Letterbox; public static float LetterboxRatio = 2.39f; private static readonly List<Canvas> _hiddenCanvases = new List<Canvas>(); public static bool HudHidden { get; private set; } public static void SetHudHidden(bool hide) { if (hide == HudHidden) { return; } HudHidden = hide; if (hide) { _hiddenCanvases.Clear(); Canvas[] array = Object.FindObjectsByType<Canvas>((FindObjectsSortMode)0); foreach (Canvas val in array) { if (Object.op_Implicit((Object)(object)val) && ((Behaviour)val).enabled && val.isRootCanvas) { ((Behaviour)val).enabled = false; _hiddenCanvases.Add(val); } } return; } foreach (Canvas hiddenCanvase in _hiddenCanvases) { if (Object.op_Implicit((Object)(object)hiddenCanvase)) { ((Behaviour)hiddenCanvase).enabled = true; } } _hiddenCanvases.Clear(); } public static void KeepHudHidden() { if (!HudHidden) { return; } Canvas[] array = Object.FindObjectsByType<Canvas>((FindObjectsSortMode)0); foreach (Canvas val in array) { if (Object.op_Implicit((Object)(object)val) && ((Behaviour)val).enabled && val.isRootCanvas) { ((Behaviour)val).enabled = false; if (!_hiddenCanvases.Contains(val)) { _hiddenCanvases.Add(val); } } } } public static Rect CropRect(float w, float h) { //IL_002f: 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_004f: Unknown result type (might be due to invalid IL or missing references) float num = AspectValues[Mathf.Clamp(Aspect, 0, AspectValues.Length - 1)]; if (num <= 0f) { return new Rect(0f, 0f, w, h); } if (w / h > num) { float num2 = h * num; return new Rect((w - num2) * 0.5f, 0f, num2, h); } float num3 = w / num; return new Rect(0f, (h - num3) * 0.5f, w, num3); } public static IEnumerator TakeScreenshot() { if (Capturing) { yield break; } Capturing = true; bool hudWasHidden = HudHidden; if (Settings.HideHudInCapture.Value) { SetHudHidden(hide: true); } yield return null; yield return (object)new WaitForEndOfFrame(); string path = Settings.ResolveScreenshotFolder(); string file = Path.Combine(path, "PEAK_" + DateTime.Now.ToString("yyyy-MM-dd_HH-mm-ss-fff") + ".png"); int num = Mathf.Clamp(Settings.SuperSize.Value, 1, 4); try { if (!CropToAspect || Aspect == 0) { ScreenCapture.CaptureScreenshot(file, num); } else { Texture2D val = ScreenCapture.CaptureScreenshotAsTexture(num); Rect val2 = CropRect(((Texture)val).width, ((Texture)val).height); int num2 = Mathf.RoundToInt(((Rect)(ref val2)).x); int num3 = Mathf.RoundToInt(((Rect)(ref val2)).y); int num4 = Mathf.RoundToInt(((Rect)(ref val2)).width); int num5 = Mathf.RoundToInt(((Rect)(ref val2)).height); Texture2D val3 = new Texture2D(num4, num5, (TextureFormat)3, false); val3.SetPixels(val.GetPixels(num2, num3, num4, num5)); val3.Apply(); File.WriteAllBytes(file, ImageConversion.EncodeToPNG(val3)); Object.Destroy((Object)(object)val); Object.Destroy((Object)(object)val3); } LastFile = file; } catch (Exception ex) { Plugin.Log.LogError((object)("Screenshot failed: " + ex)); Studio.Toast("Screenshot failed: " + ex.Message); } yield return null; yield return null; if (!hudWasHidden) { SetHudHidden(hide: false); } Capturing = false; if (LastFile == file) { Studio.Toast("Saved " + Path.GetFileName(file)); } } public static void OpenFolder() { try { Application.OpenURL("file:///" + Settings.ResolveScreenshotFolder().Replace("\\", "/")); } catch (Exception ex) { Studio.Toast(ex.Message); } } public static void DrawOverlays(bool showGuides) { //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_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005d: 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_0072: 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_00af: 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_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_011e: 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_01d9: Unknown result type (might be due to invalid IL or missing references) //IL_01e6: Unknown result type (might be due to invalid IL or missing references) //IL_01f7: Unknown result type (might be due to invalid IL or missing references) //IL_01fc: Unknown result type (might be due to invalid IL or missing references) //IL_0203: 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_0221: Unknown result type (might be due to invalid IL or missing references) //IL_0226: Unknown result type (might be due to invalid IL or missing references) //IL_02b7: Unknown result type (might be due to invalid IL or missing references) //IL_02bc: Unknown result type (might be due to invalid IL or missing references) //IL_02dd: Unknown result type (might be due to invalid IL or missing references) //IL_02e2: Unknown result type (might be due to invalid IL or missing references) //IL_0303: Unknown result type (might be due to invalid IL or missing references) //IL_0308: Unknown result type (might be due to invalid IL or missing references) //IL_0329: Unknown result type (might be due to invalid IL or missing references) //IL_032e: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Unknown result type (might be due to invalid IL or missing references) //IL_017f: 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_01b7: Unknown result type (might be due to invalid IL or missing references) //IL_0391: Unknown result type (might be due to invalid IL or missing references) //IL_0396: Unknown result type (might be due to invalid IL or missing references) //IL_03ab: Unknown result type (might be due to invalid IL or missing references) float num = Screen.width; float num2 = Screen.height; if (Letterbox) { float num3 = Mathf.Max(0f, (num2 - num / LetterboxRatio) * 0.5f); Draw.GuiRect(new Rect(0f, 0f, num, num3), Color.black); Draw.GuiRect(new Rect(0f, num2 - num3, num, num3), Color.black); } if (!showGuides) { return; } Rect val = CropRect(num, num2); Color c = default(Color); ((Color)(ref c))..ctor(0f, 0f, 0f, 0.55f); if (Aspect != 0) { Draw.GuiRect(new Rect(0f, 0f, num, ((Rect)(ref val)).y), c); Draw.GuiRect(new Rect(0f, ((Rect)(ref val)).yMax, num, num2 - ((Rect)(ref val)).yMax), c); Draw.GuiRect(new Rect(0f, ((Rect)(ref val)).y, ((Rect)(ref val)).x, ((Rect)(ref val)).height), c); Draw.GuiRect(new Rect(((Rect)(ref val)).xMax, ((Rect)(ref val)).y, num - ((Rect)(ref val)).xMax, ((Rect)(ref val)).height), c); } Color c2 = default(Color); ((Color)(ref c2))..ctor(1f, 1f, 1f, 0.35f); if (Thirds) { for (int i = 1; i <= 2; i++) { Draw.GuiRect(new Rect(((Rect)(ref val)).x + ((Rect)(ref val)).width * (float)i / 3f, ((Rect)(ref val)).y, 1f, ((Rect)(ref val)).height), c2); Draw.GuiRect(new Rect(((Rect)(ref val)).x, ((Rect)(ref val)).y + ((Rect)(ref val)).height * (float)i / 3f, ((Rect)(ref val)).width, 1f), c2); } } if (Center) { Vector2 center = ((Rect)(ref val)).center; Draw.GuiRect(new Rect(center.x - 10f, center.y, 21f, 1f), c2); Draw.GuiRect(new Rect(center.x, center.y - 10f, 1f, 21f), c2); } if (SafeArea) { Rect val2 = default(Rect); ((Rect)(ref val2))..ctor(((Rect)(ref val)).x + ((Rect)(ref val)).width * 0.05f, ((Rect)(ref val)).y + ((Rect)(ref val)).height * 0.05f, ((Rect)(ref val)).width * 0.9f, ((Rect)(ref val)).height * 0.9f); Color c3 = default(Color); ((Color)(ref c3))..ctor(0.3f, 0.9f, 1f, 0.5f); Draw.GuiRect(new Rect(((Rect)(ref val2)).x, ((Rect)(ref val2)).y, ((Rect)(ref val2)).width, 1f), c3); Draw.GuiRect(new Rect(((Rect)(ref val2)).x, ((Rect)(ref val2)).yMax, ((Rect)(ref val2)).width, 1f), c3); Draw.GuiRect(new Rect(((Rect)(ref val2)).x, ((Rect)(ref val2)).y, 1f, ((Rect)(ref val2)).height), c3); Draw.GuiRect(new Rect(((Rect)(ref val2)).xMax, ((Rect)(ref val2)).y, 1f, ((Rect)(ref val2)).height), c3); } if (YouTubeBadge) { float num4 = ((Rect)(ref val)).width * 0.085f; float num5 = ((Rect)(ref val)).height * 0.075f; Rect val3 = new Rect(((Rect)(ref val)).xMax - num4 - ((Rect)(ref val)).width * 0.012f, ((Rect)(ref val)).yMax - num5 - ((Rect)(ref val)).height * 0.02f, num4, num5); Draw.GuiRect(val3, new Color(0f, 0f, 0f, 0.6f)); GUI.Label(val3, " 12:34", Studio.Instance.Ui.SmallLabel); } } } public enum SpawnType { Character, ScoutDouble, ZombieScout, NetProp, Item, LocalProp, Light, Backdrop } public class SpawnDef { public string Name; public string Prefab; public string Category; public string Note; public SpawnType Type; public LightType LightType; public Color Color = Color.white; public float Intensity = 3f; public float Range = 10f; public float Angle = 50f; public Vector3 Size = new Vector3(10f, 6f, 0.1f); private bool? _available; public bool Available { get { if (Type == SpawnType.Light || Type == SpawnType.Backdrop) { return true; } if (!_available.HasValue) { _available = (Object)(object)Resources.Load<GameObject>(Prefab) != (Object)null; } return _available.Value; } } } public static class Catalog { public static readonly string[] Categories; public static readonly List<SpawnDef> All; private static bool _itemsLoaded; public static bool Scanned; private static Texture _zombieEyes; public static Texture ZombieEyeTexture { get { if (Object.op_Implicit((Object)(object)_zombieEyes)) { return _zombieEyes; } GameObject val = Resources.Load<GameObject>("MushroomZombie"); if (Object.op_Implicit((Object)(object)val)) { MushroomZombie component = val.GetComponent<MushroomZombie>(); if (Object.op_Implicit((Object)(object)component)) { _zombieEyes = component.zombieEyeTexture; } } return _zombieEyes; } } static Catalog() { //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Unknown result type (might be due to invalid IL or missing references) //IL_0174: 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_01dd: Unknown result type (might be due to invalid IL or missing references) //IL_01e2: 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_024b: Unknown result type (might be due to invalid IL or missing references) //IL_0250: Unknown result type (might be due to invalid IL or missing references) //IL_0299: Unknown result type (might be due to invalid IL or missing references) //IL_02ae: Unknown result type (might be due to invalid IL or missing references) //IL_02b3: Unknown result type (might be due to invalid IL or missing references) //IL_02fc: Unknown result type (might be due to invalid IL or missing references) //IL_0311: Unknown result type (might be due to invalid IL or missing references) //IL_0316: Unknown result type (might be due to invalid IL or missing references) //IL_035f: Unknown result type (might be due to invalid IL or missing references) //IL_0365: Unknown result type (might be due to invalid IL or missing references) //IL_036a: Unknown result type (might be due to invalid IL or missing references) //IL_03c1: Unknown result type (might be due to invalid IL or missing references) //IL_03c6: Unknown result type (might be due to invalid IL or missing references) //IL_03db: Unknown result type (might be due to invalid IL or missing references) //IL_03e0: Unknown result type (might be due to invalid IL or missing references) //IL_0421: Unknown result type (might be due to invalid IL or missing references) //IL_0426: Unknown result type (might be due to invalid IL or missing references) //IL_043b: Unknown result type (might be due to invalid IL or missing references) //IL_0440: Unknown result type (might be due to invalid IL or missing references) //IL_0481: Unknown result type (might be due to invalid IL or missing references) //IL_0486: Unknown result type (might be due to invalid IL or missing references) //IL_049b: Unknown result type (might be due to invalid IL or missing references) //IL_04a0: Unknown result type (might be due to invalid IL or missing references) //IL_04d2: Unknown result type (might be due to invalid IL or missing references) //IL_04d7: Unknown result type (might be due to invalid IL or missing references) //IL_04ec: Unknown result type (might be due to invalid IL or missing references) //IL_04f1: Unknown result type (might be due to invalid IL or missing references) //IL_0523: Unknown result type (might be due to invalid IL or missing references) //IL_0528: Unknown result type (might be due to invalid IL or missing references) //IL_053d: Unknown result type (might be due to invalid IL or missing references) //IL_0542: Unknown result type (might be due to invalid IL or missing references) Categories = new string[6] { "Actors", "Creatures", "Items", "Lights", "Backdrops", "Scanned" }; All = new List<SpawnDef>(); Add("Actors", "Mushroom Zombie", "MushroomZombie", SpawnType.Character, "The zombie that sleeps in the jungle. Posable."); Add("Actors", "Zombified Scout", "MushroomZombie_Player", SpawnType.ZombieScout, "A scout turned zombie, wearing a player's cosmetics."); Add("Actors", "Scout Double", "MushroomZombie_Player", SpawnType.ScoutDouble, "A clean posable copy of a player (no mushrooms, normal eyes)."); Add("Actors", "Scoutmaster", "Character_Scoutmaster", SpawnType.Character, "The Scoutmaster. Posable."); Add("Creatures", "Beetle", "0_Items/Beetle", SpawnType.NetProp); Add("Creatures", "Scorpion", "0_Items/Scorpion", SpawnType.NetProp); Add("Creatures", "Frog", "0_Items/Frog", SpawnType.NetProp); Add("Creatures", "Bee Swarm", "BeeSwarm", SpawnType.NetProp); Add("Creatures", "Gloom Ghost", "GhostBall", SpawnType.NetProp); Add("Creatures", "Tornado", "Tornado", SpawnType.NetProp); All.Add(new SpawnDef { Category = "Lights", Name = "Key Light (spot)", Type = SpawnType.Light, LightType = (LightType)0, Color = new Color(1f, 0.95f, 0.88f), Intensity = 8f, Range = 15f, Angle = 45f }); All.Add(new SpawnDef { Category = "Lights", Name = "Rim Light (cool)", Type = SpawnType.Light, LightType = (LightType)0, Color = new Color(0.55f, 0.75f, 1f), Intensity = 12f, Range = 12f, Angle = 35f }); All.Add(new SpawnDef { Category = "Lights", Name = "Warm Fill (point)", Type = SpawnType.Light, LightType = (LightType)2, Color = new Color(1f, 0.65f, 0.35f), Intensity = 4f, Range = 8f }); All.Add(new SpawnDef { Category = "Lights", Name = "Spooky Green (point)", Type = SpawnType.Light, LightType = (LightType)2, Color = new Color(0.4f, 1f, 0.45f), Intensity = 5f, Range = 8f }); All.Add(new SpawnDef { Category = "Lights", Name = "Danger Red (point)", Type = SpawnType.Light, LightType = (LightType)2, Color = new Color(1f, 0.15f, 0.1f), Intensity = 6f, Range = 8f }); All.Add(new SpawnDef { Category = "Lights", Name = "White Point", Type = SpawnType.Light, LightType = (LightType)2, Color = Color.white, Intensity = 4f, Range = 10f }); All.Add(new SpawnDef { Category = "Backdrops", Name = "Green Screen", Type = SpawnType.Backdrop, Color = new Color(0f, 0.85f, 0.2f), Size = new Vector3(12f, 7f, 0.05f) }); All.Add(new SpawnDef { Category = "Backdrops", Name = "Blue Screen", Type = SpawnType.Backdrop, Color = new Color(0f, 0.3f, 1f), Size = new Vector3(12f, 7f, 0.05f) }); All.Add(new SpawnDef { Category = "Backdrops", Name = "Green Floor", Type = SpawnType.Backdrop, Color = new Color(0f, 0.85f, 0.2f), Size = new Vector3(12f, 0.05f, 12f) }); All.Add(new SpawnDef { Category = "Backdrops", Name = "Black Wall", Type = SpawnType.Backdrop, Color = Color.black, Size = new Vector3(12f, 7f, 0.05f) }); All.Add(new SpawnDef { Category = "Backdrops", Name = "White Wall", Type = SpawnType.Backdrop, Color = Color.white, Size = new Vector3(12f, 7f, 0.05f) }); } private static void Add(string cat, string name, string prefab, SpawnType type, string note = null) { All.Add(new SpawnDef { Category = cat, Name = name, Prefab = prefab, Type = type, Note = note }); } public static IEnumerable<SpawnDef> In(string category) { if (category == "Items") { EnsureItems(); } return All.Where((SpawnDef d) => d.Category == category); } public static void EnsureItems() { if (_itemsLoaded) { return; } try { ItemDatabase instance = SingletonAsset<ItemDatabase>.Instance; if ((Object)(object)instance == (Object)null || ((DatabaseAsset<ItemDatabase, Item>)(object)instance).Objects == null) { return; } _itemsLoaded = true; HashSet<string> hashSet = new HashSet<string>(All.Select((SpawnDef a) => a.Prefab)); foreach (Item item in from i in ((DatabaseAsset<ItemDatabase, Item>)(object)instance).Objects where (Object)(object)i != (Object)null orderby DisplayName(i) select i) { string text = "0_Items/" + ((Object)((Component)item).gameObject).name; if (!hashSet.Contains(text)) { hashSet.Add(text); All.Add(new SpawnDef { Category = "Items", Name = DisplayName(item), Prefab = text, Type = SpawnType.Item }); } } } catch (Exception ex) { Plugin.Log.LogWarning((object)("Item database not ready: " + ex.Message)); } } private static string DisplayName(Item i) { string text = null; try { text = i.UIData?.itemName; } catch { } if (string.IsNullOrWhiteSpace(text)) { text = ((Object)((Component)i).gameObject).name; } if (!(text == ((Object)((Component)i).gameObject).name)) { return text + " (" + ((Object)((Component)i).gameObject).name + ")"; } return text; } public static int ScanResources() { int num = 0; HashSet<string> hashSet = new HashSet<string>(All.Select((SpawnDef a) => a.Prefab)); GameObject[] array = Resources.LoadAll<GameObject>(""); foreach (GameObject val in array) { if (Object.op_Implicit((Object)(object)val) && Object.op_Implicit((Object)(object)val.GetComponent<PhotonView>()) && Spawner.IsSafePrefab(val)) { string text = null; if ((Object)(object)Resources.Load<GameObject>(((Object)val).name) == (Object)(object)val) { text = ((Object)val).name; } else if ((Object)(object)Resources.Load<GameObject>("0_Items/" + ((Object)val).name) == (Object)(object)val) { text = "0_Items/" + ((Object)val).name; } if (text != null && !hashSet.Contains(text)) { hashSet.Add(text); SpawnType spawnType = ((!Object.op_Implicit((Object)(object)val.GetComponent<Character>())) ? (Object.op_Implicit((Object)(object)val.GetComponent<Item>()) ? SpawnType.Item : SpawnType.NetProp) : SpawnType.Character); All.Add(new SpawnDef { Category = "Scanned", Name = ((Object)val).name, Prefab = text, Type = spawnType, Note = ((spawnType == SpawnType.Character) ? "Character prefab" : null) }); num++; } } } Scanned = true; return num; } } public static class Spawner { public static Player LookPlayer; private static GameObject NetSpawn(string prefab, Vector3 pos, Quaternion rot) { //IL_0015: 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) if (!PhotonNetwork.InRoom) { Studio.Toast("Start or join a run first (objects are network-spawned)."); return null; } try { return PhotonNetwork.Instantiate(prefab, pos, rot, (byte)0, (object[])null); } catch (Exception ex) { Studio.Toast("Could not spawn " + prefab + ": " + ex.Message); Plugin.Log.LogError((object)ex); return null; } } public static StudioObject Spawn(SpawnDef def, Vector3 groundPos, Quaternion rot) { //IL_00e3: 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_0039: 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_005c: Unknown result type (might be due to invalid IL or missing references) //IL_005d: 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_006c: 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_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_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: 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_00c0: 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_0128: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) switch (def.Type) { case SpawnType.Light: { LightObject lightObject = new LightObject(def.Name, def.LightType, def.Color, def.Intensity, def.Range, def.Angle); lightObject.MoveTo(groundPos + Vector3.up * 1.6f, rot * Quaternion.Euler(20f, 0f, 0f)); return lightObject; } case SpawnType.Backdrop: { BackdropObject backdropObject = new BackdropObject(def.Name, def.Color, def.Size); backdropObject.MoveTo(groundPos + Vector3.up * (def.Size.y * 0.5f), rot); return backdropObject; } case SpawnType.Character: case SpawnType.ScoutDouble: case SpawnType.ZombieScout: return SpawnCharacter(def.Prefab, def.Type, def.Name, groundPos, rot, LookPlayer ?? PhotonNetwork.LocalPlayer); default: { if (!IsSafePrefab(Resources.Load<GameObject>(def.Prefab))) { Studio.Toast(def.Name + " can't be spawned safely."); return null; } GameObject val = NetSpawn(def.Prefab, groundPos + Vector3.up * 0.3f, rot); if (!Object.op_Implicit((Object)(object)val)) { return null; } ObjKind kind = ((def.Category == "Creatures") ? ObjKind.Creature : ((def.Type == SpawnType.Item) ? ObjKind.Item : ObjKind.Prop)); PropObject propObject = new PropObject(val, kind, def.Prefab, def.Name.Split(new string[1] { " (" }, StringSplitOptions.None)[0]) { SpawnType = def.Type }; propObject.SetFrozen(frozen: true); ((MonoBehaviour)Studio.Instance).StartCoroutine(DropNextFrame(propObject)); return propObject; } } } private static IEnumerator DropNextFrame(StudioObject o) { yield return null; if (o.Alive) { o.DropToGround(); } } public static bool IsSafePrefab(GameObject prefab) { if (!Object.op_Implicit((Object)(object)prefab)) { return false; } Character component = prefab.GetComponent<Character>(); if (Object.op_Implicit((Object)(object)component) && !component.isBot) { return false; } if (Object.op_Implicit((Object)(object)prefab.GetComponent<Player>()) || Object.op_Implicit((Object)(object)prefab.GetComponent<PlayerGhost>())) { return false; } return true; } public static CharacterActor SpawnCharacter(string prefab, SpawnType type, string name, Vector3 groundPos, Quaternion rot, Player look) { //IL_0020: 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_002b: 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_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) if (!IsSafePrefab(Resources.Load<GameObject>(prefab))) { Studio.Toast(prefab + " is a player body and can't be spawned (use Scout Double instead)."); return null; } GameObject val = NetSpawn(prefab, groundPos + Vector3.up * 1.2f, rot); if (!Object.op_Implicit((Object)(object)val)) { return null; } Character component = val.GetComponent<Character>(); if (!Object.op_Implicit((Object)(object)component)) { Studio.Toast(prefab + " is not a character; placed as a prop."); return null; } Behaviour[] components = val.GetComponents<Behaviour>(); foreach (Behaviour val2 in components) { if (val2 is MushroomZombie || val2 is Scoutmaster || val2 is Bot) { val2.enabled = false; } } if ((type == SpawnType.ScoutDouble || type == SpawnType.ZombieScout) && look != null) { component.refs.customization.overridePhotonPlayer = look; } CharacterActor characterActor = new CharacterActor(component, isPlayer: false, type, prefab, name); if (look != null && (type == SpawnType.ScoutDouble || type == SpawnType.ZombieScout)) { characterActor.LookPlayer = look.NickName; characterActor.Name = ((type == SpawnType.ScoutDouble) ? (look.NickName + " (double)") : ("Zombie " + look.NickName)); } if (type == SpawnType.ScoutDouble) { characterActor.Mushrooms = false; } if (Object.op_Implicit((Object)(object)characterActor.Zombie)) { component.isZombie = type != SpawnType.ScoutDouble; } characterActor.SetMode(ActorMode.Posed); characterActor.PoseRot = rot; ((MonoBehaviour)Studio.Instance).StartCoroutine(FinishActor(characterActor, type, look)); return characterActor; } private static IEnumerator FinishActor(CharacterActor a, SpawnType type, Player look) { for (int i = 0; i < 3; i++) { yield return null; } yield return (object)new WaitForFixedUpdate(); yield return (object)new WaitForFixedUpdate(); if (!a.Alive) { yield break; } if (type == SpawnType.ScoutDouble && look != null) { try { PersistentPlayerDataService service = GameHandler.GetService<PersistentPlayerDataService>(); a.Ch.refs.customization.OnPlayerDataChange(service.GetPlayerData(look)); } catch (Exception ex) { Plugin.Log.LogWarning((object)("Could not restore cosmetics: " + ex.Message)); } a.Ch.isZombie = false; } a.RefreshClips(); if (!Object.op_Implicit((Object)(object)a.Clip) && !a.AnimatorMode) { a.Clip = a.DefaultIdleClip(); } yield return (object)new WaitForFixedUpdate(); if (a.Alive) { a.DropToGround(); } } } public class ZoneCtl { public WindChillZone Zone; public string Label; public int Force; public float Progress = 0.6f; public bool Everywhere = true; public Bounds OrigBounds; public bool Expanded; } public static class Env { public static bool LockTime; public static float LockedTime = 12f; public static float TimeSpeed = 1f; public static float SunYaw; public static float SunIntensity = 1f; public static float MoonIntensity = 1f; public static bool OverrideSunColor; public static Color SunColor = new Color(1f, 0.85f, 0.65f); public static float ShadowStrength = -1f; public static bool OverrideFog; public static float ExtraFog; public static bool HideRisingFog; private static readonly List<GameObject> _hiddenFog = new List<GameObject>(); public static readonly List<ZoneCtl> Zones = new List<ZoneCtl>(); public static bool NoStormEffects = true; public static bool StormFollowsCamera = true; public static float WorldTimeScale = 1f; public static bool WorldPaused; private static float _baseFixedDelta = -1f; public static bool GodMode = true; public static readonly KeyValuePair<string, float>[] TimePresets = new KeyValuePair<string, float>[8] { new KeyValuePair<string, float>("Dawn", 5.6f), new KeyValuePair<string, float>("Morning", 8f), new KeyValuePair<string, float>("Noon", 12f), new KeyValuePair<string, float>("Afternoon", 15.5f), new KeyValuePair<string, float>("Golden", 18.6f), new KeyValuePair<string, float>("Sunset", 19.8f), new KeyValuePair<string, float>("Dusk", 20.6f), new KeyValuePair<string, float>("Night", 0.5f) }; public static DayNightManager DN => DayNightManager.instance; public static float CurrentTime { get { if (!Object.op_Implicit((Object)(object)DN)) { return 0f; } return DN.timeOfDay % 24f; } } public static void SetTime(float t, bool lockIt) { LockedTime = Mathf.Repeat(t, 24f); if (lockIt) { LockTime = true; } if (Object.op_Implicit((Object)(object)DN)) { DN.setTimeOfDay(LockedTime); DN.UpdateCycle(); } } public static List<DayNightProfile> Profiles() { return (from p in Resources.FindObjectsOfTypeAll<DayNightProfile>() where Object.op_Implicit((Object)(object)p) orderby ((Object)p).name select p).ToList(); } public static void SetProfile(DayNightProfile p) { if (Object.op_Implicit((Object)(object)DN) && Object.op_Implicit((Object)(object)p)) { DN.BlendProfiles(p); } } public static void ApplyFogVisibility() { foreach (GameObject item in _hiddenFog) { if (Object.op_Implicit((Object)(object)item)) { item.SetActive(true); } } _hiddenFog.Clear(); if (!HideRisingFog) { return; } Fog[] array = Object.FindObjectsByType<Fog>((FindObjectsSortMode)0); foreach (Fog val in array) { if (Object.op_Implicit((Object)(object)val) && ((Component)val).gameObject.activeSelf) { ((Component)val).gameObject.SetActive(false); _hiddenFog.Add(((Component)val).gameObject); } } FogSphere[] array2 = Object.FindObjectsByType<FogSphere>((FindObjectsSortMode)0); foreach (FogSphere val2 in array2) { if (Object.op_Implicit((Object)(object)val2) && ((Component)val2).gameObject.activeSelf) { ((Component)val2).gameObject.SetActive(false); _hiddenFog.Add(((Component)val2).gameObject); } } } public static void RefreshZones() { //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) Dictionary<WindChillZone, ZoneCtl> dictionary = Zones.Where((ZoneCtl z) => Object.op_Implicit((Object)(object)z.Zone)).ToDictionary((ZoneCtl z) => z.Zone); Zones.Clear(); WindChillZone[] array = Object.FindObjectsByType<WindChillZone>((FindObjectsInactive)1, (FindObjectsSortMode)0); foreach (WindChillZone val in array) { if (!Object.op_Implicit((Object)(object)val)) { continue; } if (dictionary.TryGetValue(val, out var value)) { Zones.Add(value); continue; } string[] array2 = (from s in ((Component)val).GetComponentsInChildren<StormVisual>(true) select ((object)Unsafe.As<StormType, StormType>(ref s.stormType)/*cast due to .constrained prefix*/).ToString()).Distinct().ToArray(); string text = (Object.op_Implicit((Object)(object)((Component)val).transform.parent) ? ((Object)((Component)val).transform.parent).name : ""); Zones.Add(new ZoneCtl { Zone = val, Label = ((array2.Length != 0) ? string.Join("+", array2) : "Wind") + " - " + ((Object)val).name + ((text.Length > 0) ? (" (" + text + ")") : ""), OrigBounds = val.windZoneBounds }); } } public static ZoneCtl Ctl(WindChillZone z) { for (int i = 0; i < Zones.Count; i++) { if ((Object)(object)Zones[i].Zone == (Object)(object)z) { return Zones[i]; } } return null; } public static void Tick() { //IL_004d: 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_0063: 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_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_009c: 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) foreach (ZoneCtl zone in Zones) { if (Object.op_Implicit((Object)(object)zone.Zone)) { bool flag = zone.Force == 1 && zone.Everywhere; if (flag && !zone.Expanded) { zone.OrigBounds = zone.Zone.windZoneBounds; zone.Zone.windZoneBounds = new Bounds(((Bounds)(ref zone.OrigBounds)).center, Vector3.one * 200000f); zone.Expanded = true; } else if (!flag && zone.Expanded) { zone.Zone.windZoneBounds = zone.OrigBounds; zone.Expanded = false; } } } } public static void ApplyTimeScale() { if (_baseFixedDelta < 0f) { _baseFixedDelta = Time.fixedDeltaTime; } float num = (Time.timeScale = (WorldPaused ? 0f : Mathf.Clamp(WorldTimeScale, 0.01f, 4f))); Time.fixedDeltaTime = ((num > 0f) ? Mathf.Max(0.0005f, _baseFixedDelta * Mathf.Min(1f, num)) : _baseFixedDelta); } public static void ResetTimeScale() { WorldPaused = false; WorldTimeScale = 1f; if (_baseFixedDelta > 0f) { Time.fixedDeltaTime = _baseFixedDelta; } Time.timeScale = 1f; } public static void BringZoneHere(ZoneCtl z) { if (Object.op_Implicit((Object)(object)z.Zone)) { ((Component)z.Zone).transform.SetParent((Transform)null, true); ((Component)z.Zone).gameObject.SetActive(true); Transform[] componentsInChildren = ((Component)z.Zone).GetComponentsInChildren<Transform>(true); for (int i = 0; i < componentsInChildren.Length; i++) { ((Component)componentsInChildren[i]).gameObject.SetActive(true); } z.Everywhere = true; z.Force = 1; } } public static void ResetAll() { LockTime = false; TimeSpeed = 1f; SunYaw = 0f; SunIntensity = (MoonIntensity = 1f); OverrideSunColor = false; ShadowStrength = -1f; OverrideFog = false; HideRisingFog = false; ApplyFogVisibility(); foreach (ZoneCtl zone in Zones) { zone.Force = 0; } Tick(); ResetTimeScale(); } } public class CamShot { public string name = "Shot"; public float[] pos; public float yaw; public float pitch; public float roll; public float fov = 60f; public float duration = 3f; [JsonIgnore] public Vector3 Pos => Util.V(pos); } public class FreeCam { public bool Active; public Vector3 Pos; public float Yaw; public float Pitch; public float Roll; public float Fov = 60f; public float Smoothing = 0.35f; public bool Looking; private Vector3 _sPos; private float _sYaw; private float _sPitch; private float _sRoll; private float _sFov; public readonly List<CamShot> Bookmarks = new List<CamShot>(); public readonly List<CamShot> Path = new List<CamShot>(); public bool PathPlaying; public bool PathLoop; public bool PathEase = true; public bool ShowPath = true; public float PathTime; public bool Orbiting; public float OrbitSpeed = 15f; private float _orbitAngle; private float _orbitRadius; private float _orbitHeight; private Vector3 _orbitCenter; public float SpeedMul = 1f; public float PathLength { get { float num = 0f; for (int i = 0; i < Path.Count - 1; i++) { num += Mathf.Max(0.05f, Path[i].duration); } return num; } } public void Enable(Transform from, Camera cam) { //IL_001a: 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) //IL_002a: 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_0032: 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_0040: Unknown result type (might be due to invalid IL or missing references) if (!Active) { Active = true; if (Object.op_Implicit((Object)(object)from)) { Pos = from.position; Quaternion rotation = from.rotation; Vector3 eulerAngles = ((Quaternion)(ref rotation)).eulerAngles; Yaw = eulerAngles.y; Pitch = Util.WrapAngle(eulerAngles.x); Roll = 0f; } if (Object.op_Implicit((Object)(object)cam)) { Fov = cam.fieldOfView; } Snap(); } } public void Disable() { Active = false; PathPlaying = false; Orbiting = false; Looking = false; } public void Snap() { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) _sPos = Pos; _sYaw = Yaw; _sPitch = Pitch; _sRoll = Roll; _sFov = Fov; } public void Update(bool editorOpen, bool mouseOverUi, bool typing) { //IL_00ae: 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_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00be: 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_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_0319: Unknown result type (might be due to invalid IL or missing references) //IL_031e: Unknown result type (might be due to invalid IL or missing references) //IL_034c: Unknown result type (might be due to invalid IL or missing references) //IL_0362: Unknown result type (might be due to invalid IL or missing references) //IL_0367: 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_0370: Unknown result type (might be due to invalid IL or missing references) //IL_0375: Unknown result type (might be due to invalid IL or missing references) //IL_0377: Unknown result type (might be due to invalid IL or missing references) //IL_037c: Unknown result type (might be due to invalid IL or missing references) //IL_0387: Unknown result type (might be due to invalid IL or missing references) //IL_038c: Unknown result type (might be due to invalid IL or missing references) //IL_0391: Unknown result type (might be due to invalid IL or missing references) //IL_0398: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0102: 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_0182: 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_018b: Unknown result type (might be due to invalid IL or missing references) //IL_0190: Unknown result type (might be due to invalid IL or missing references) //IL_0194: Unknown result type (might be due to invalid IL or missing references) //IL_0199: Unknown result type (might be due to invalid IL or missing references) //IL_01a0: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: 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_01b9: 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_01c5: Unknown result type (might be due to invalid IL or missing references) //IL_01cb: Unknown result type (might be due to invalid IL or missing references) //IL_01d0: Unknown result type (might be due to invalid IL or missing references) //IL_01d5: Unknown result type (might be due to invalid IL or missing references) //IL_01df: Unknown result type (might be due to invalid IL or missing references) //IL_01e4: Unknown result type (might be due to invalid IL or missing references) //IL_01eb: Unknown result type (might be due to invalid IL or missing references) //IL_01f1: Unknown result type (might be due to invalid IL or missing references) //IL_01f6: Unknown result type (might be due to invalid IL or missing references) //IL_01fb: Unknown result type (might be due to invalid IL or missing references) //IL_024e: Unknown result type (might be due to invalid IL or missing references) if (!Active) { return; } float unscaledDeltaTime = Time.unscaledDeltaTime; Looking = !editorOpen || (Input.GetMouseButton(1) && (Looking || !mouseOverUi)); if (Looking && !PathPlaying) { float value = Settings.LookSensitivity.Value; Yaw += Input.GetAxisRaw("Mouse X") * value; Pitch -= Input.GetAxisRaw("Mouse Y") * value; Pitch = Mathf.Clamp(Pitch, -89.5f, 89.5f); } if (!typing && !PathPlaying) { Vector3 val = Vector3.zero; if (Input.GetKey((KeyCode)119)) { val += Vector3.forward; } if (Input.GetKey((KeyCode)115)) { val += Vector3.back; } if (Input.GetKey((KeyCode)100)) { val += Vector3.right; } if (Input.GetKey((KeyCode)97)) { val += Vector3.left; } bool num = Input.GetKey((KeyCode)101) || Input.GetKey((KeyCode)32); bool flag = Input.GetKey((KeyCode)113) || Input.GetKey((KeyCode)306); float num2 = Settings.CamSpeed.Value * SpeedMul; if (Input.GetKey((KeyCode)304)) { num2 *= 4f; } if (Input.GetKey((KeyCode)308)) { num2 *= 0.2f; } Quaternion val2 = Quaternion.Euler(Pitch, Yaw, 0f); Pos += val2 * ((Vector3)(ref val)).normalized * num2 * unscaledDeltaTime; if (num) { Pos += Vector3.up * num2 * unscaledDeltaTime; } if (flag) { Pos -= Vector3.up * num2 * unscaledDeltaTime; } if (Input.GetKey((KeyCode)122)) { Roll += 30f * unscaledDeltaTime; } if (Input.GetKey((KeyCode)99)) { Roll -= 30f * unscaledDeltaTime; } if (Input.GetKeyDown((KeyCode)120)) { Roll = 0f; } float y = Input.mouseScrollDelta.y; if (!mouseOverUi && Mathf.Abs(y) > 0.01f) { if (Looking) { SpeedMul = Mathf.Clamp(SpeedMul * ((y > 0f) ? 1.15f : 0.86956525f), 0.05f, 20f); } else { Fov = Mathf.Clamp(Fov - y * 2f, 5f, 120f); } } if (Input.GetMouseButtonDown(2) && !mouseOverUi) { Fov = 60f; } } if (Orbiting && Studio.Instance.Selected != null && Studio.Instance.Selected.Alive) { _orbitCenter = Studio.Instance.Selected.Position; _orbitAngle += OrbitSpeed * Time.unscaledDeltaTime; Vector3 val3 = Quaternion.Euler(0f, _orbitAngle, 0f) * new Vector3(0f, 0f, 0f - _orbitRadius); Pos = _orbitCenter + val3 + Vector3.up * _orbitHeight; LookAt(_orbitCenter); } else if (Orbiting) { Orbiting = false; } if (PathPlaying) { EvaluatePath(unscaledDeltaTime); } } public void StartOrbit() { //IL_001a: 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_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_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_002e: Unknown result type (might be due to invalid IL or missing references) //IL_005d: 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) StudioObject selected = Studio.Instance.Selected; if (selected == null) { Studio.Toast("Select something to orbit around."); return; } Vector3 position = selected.Position; Vector3 val = Pos - position; _orbitHeight = val.y; val.y = 0f; _orbitRadius = Mathf.Max(1f, ((Vector3)(ref val)).magnitude); _orbitAngle = Mathf.Atan2(0f - val.x, 0f - val.z) * 57.29578f; Orbiting = true; } public void LookAt(Vector3 target) { //IL_0000: 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_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0023: 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) Vector3 val = target - Pos; if (!(((Vector3)(ref val)).sqrMagnitude < 0.0001f)) { Yaw = Mathf.Atan2(val.x, val.z) * 57.29578f; Pitch = (0f - Mathf.Asin(Mathf.Clamp(((Vector3)(ref val)).normalized.y, -1f, 1f))) * 57.29578f; } } public void Focus(StudioObject o) { //IL_000d: 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_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: 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_0029: 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_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_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_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_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_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) if (o == null || !o.Alive) { return; } Vector3 position = o.Position; float num = Vector3.Distance(Pos, position); Bounds bounds = o.GetBounds(); Vector3 val = ((Bounds)(ref bounds)).extents; float num2 = Mathf.Clamp(((Vector3)(ref val)).magnitude * 3f, 2.5f, 20f); if (num > num2 * 2.5f || num < 0.5f) { val = Pos - position; Vector3 val2 = ((Vector3)(ref val)).normalized; if (((Vector3)(ref val2)).sqrMagnitude < 0.01f) { val2 = -(Quaternion.Euler(0f, Yaw, 0f) * Vector3.forward); } Pos = position + val2 * num2; } LookAt(position); } public CamShot Capture(string name) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) return new CamShot { name = name, pos = Util.F(Pos), yaw = Yaw, pitch = Pitch, roll = Roll, fov = Fov }; } public void GoTo(CamShot s, bool instant) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) Pos = s.Pos; Yaw = s.yaw; Pitch = s.pitch; Roll = s.roll; Fov = s.fov; if (instant) { Snap(); } } public void PlayPath() { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) if (Path.Count < 2) { Studio.Toast("Add at least 2 path keyframes (key " + ((object)Settings.KeyAddPathKey.Value/*cast due to .constrained prefix*/).ToString() + ")."); return; } Orbiting = false; PathTime = 0f; PathPlaying = true; } private void EvaluatePath(float dt) { //IL_0053: 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) float pathLength = PathLength; PathTime += dt; if (PathTime >= pathLength) { if (PathLoop) { PathTime %= pathLength; } else { PathTime = pathLength; PathPlaying = false; } } CamShot camShot = SampleShot(PathTime); Pos = camShot.Pos; Yaw = camShot.yaw; Pitch = camShot.pitch; Roll = camShot.roll; Fov = camShot.fov; Snap(); } public CamShot SampleShot(float time) { //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0127: 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_0135: 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) float pathLength = PathLength; float num = ((pathLength <= 0f) ? 0f : Mathf.Clamp(time, 0f, pathLength)); if (PathEase && pathLength > 0f) { num = Mathf.SmoothStep(0f, pathLength, num / pathLength); } int i = 0; float num2 = 0f; for (; i < Path.Count - 1; i++) { float num3 = Mathf.Max(0.05f, Path[i].duration); if (num <= num2 + num3 || i == Path.Count - 2) { num = Mathf.Clamp01((num - num2) / num3); break; } num2 += num3; } CamShot camShot = K(i - 1); CamShot camShot2 = K(i); CamShot camShot3 = K(i + 1); CamShot camShot4 = K(i + 2); float yaw = camShot2.yaw; float p = yaw + Mathf.DeltaAngle(yaw, camShot.yaw); float num4 = yaw + Mathf.DeltaAngle(yaw, camShot3.yaw); float p2 = num4 + Mathf.DeltaAngle(camShot3.yaw, camShot4.yaw); return new CamShot { pos = Util.F(Util.CatmullRom(camShot.Pos, camShot2.Pos, camShot3.Pos, camShot4.Pos, num)), yaw = Util.CatmullRom(p, yaw, num4, p2, num), pitch = Util.CatmullRom(camShot.pitch, camShot2.pitch, camShot3.pitch, camShot4.pitch, num), roll = Util.CatmullRom(camShot.roll, camShot2.roll, camShot3.roll, camShot4.roll, num), fov = Util.CatmullRom(camShot.fov, camShot2.fov, camShot3.fov, camShot4.fov, num) }; CamShot K(int num5) { return Path[Mathf.Clamp(num5, 0, Path.Count - 1)]; } } public void Apply(Transform t, Camera cam) { //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) //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_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) float unscaledDeltaTime = Time.unscaledDeltaTime; float num = Mathf.Lerp(40f, 1.5f, Mathf.Clamp01(Smoothing)); float num2 = 1f - Mathf.Exp((0f - num) * unscaledDeltaTime); if (PathPlaying || Orbiting) { num2 = 1f; } _sPos = Vector3.Lerp(_sPos, Pos, num2); _sYaw = Mathf.LerpAngle(_sYaw, Yaw, num2); _sPitch = Mathf.Lerp(_sPitch, Pitch, num2); _sRoll = Mathf.Lerp(_sRoll, Roll, num2); _sFov = Mathf.Lerp(_sFov, Fov, num2); t.SetPositionAndRotation(_sPos, Quaternion.Euler(_sPitch, _sYaw, _sRoll)); if (Object.op_Implicit((Object)(object)cam)) { cam.fieldOfView = _sFov; } } public void RenderPath(Camera cam) { //IL_0050: 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_0068: 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) //IL_009c: 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_00a6: 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_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_0122: 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_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_0198: 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_0172: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Unknown result type (might be due to invalid IL or missing references) if (!ShowPath || Path.Count == 0 || (Object)(object)cam == (Object)null) { return; } Color c = default(Color); ((Color)(ref c))..ctor(1f, 0.6f, 0.15f, 0.9f); for (int i = 0; i < Path.Count; i++) { if (Draw.ToScreen(cam, Path[i].Pos, out var screen)) { Draw.Rect(screen, 5f, c); Vector3 val = Quaternion.Euler(Path[i].pitch, Path[i].yaw, 0f) * Vector3.forward; if (Draw.ToScreen(cam, Path[i].Pos + val * 0.8f, out var screen2)) { Draw.Line(screen, screen2, 2f, c); } } } if (Path.Count < 2) { return; } float pathLength = PathLength; bool pathEase = PathEase; PathEase = false; Vector2 a = default(Vector2); bool flag = false; int num = Mathf.Clamp(Path.Count * 16, 16, 300); for (int j = 0; j <= num; j++