Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of SCPItems v0.9.1
plugins/SCPItems.dll
Decompiled 8 minutes ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using ExitGames.Client.Photon; using HarmonyLib; using Microsoft.CodeAnalysis; using Photon.Pun; using Photon.Realtime; using REPOLib.Modules; using Strobotnik.Klattersynth; using UnityEngine; using UnityEngine.AI; using UnityEngine.Audio; using UnityEngine.Events; using UnityEngine.Rendering; using UnityEngine.SceneManagement; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: IgnoresAccessChecksTo("Assembly-CSharp")] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("SCPItems")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+bd7f42bbadba45eb5b35ae796757bf4fe27350e1")] [assembly: AssemblyProduct("SCPItems")] [assembly: AssemblyTitle("SCPItems")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace SCPItems { internal static class BallBuilder { private const string BaseResourcePath = "Items/Item Orb Zero Gravity"; public const string PrefabName = "Item SCP 018"; public const string ModelName = "SCP-018 Model"; private static Mesh mesh; internal static readonly AudioClip[][] Bounces = new AudioClip[3][]; internal static Mesh Mesh { get { if (!Object.op_Implicit((Object)(object)mesh)) { return mesh = SlAssets.LoadMesh("scp018"); } return mesh; } } public static void BuildAndRegister() { //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Expected O, but got Unknown //IL_023d: Unknown result type (might be due to invalid IL or missing references) //IL_0242: Unknown result type (might be due to invalid IL or missing references) //IL_0246: Unknown result type (might be due to invalid IL or missing references) //IL_026c: Unknown result type (might be due to invalid IL or missing references) //IL_027d: Unknown result type (might be due to invalid IL or missing references) //IL_0284: Unknown result type (might be due to invalid IL or missing references) //IL_0296: Unknown result type (might be due to invalid IL or missing references) //IL_02b6: Unknown result type (might be due to invalid IL or missing references) //IL_02bb: Unknown result type (might be due to invalid IL or missing references) //IL_02c3: Unknown result type (might be due to invalid IL or missing references) //IL_02d6: Unknown result type (might be due to invalid IL or missing references) //IL_0405: Unknown result type (might be due to invalid IL or missing references) //IL_040d: Unknown result type (might be due to invalid IL or missing references) GameObject val = Resources.Load<GameObject>("Items/Item Orb Zero Gravity"); if (!Object.op_Implicit((Object)(object)val)) { throw new Exception("Base item \"Items/Item Orb Zero Gravity\" not found. The game may have been updated."); } Item val2 = val.GetComponent<ItemAttributes>()?.item; if (!Object.op_Implicit((Object)(object)val2)) { throw new Exception("The anti-gravity orb has no Item asset."); } string[] array = new string[3] { "low", "med", "high" }; for (int i = 0; i < 3; i++) { Bounces[i] = (AudioClip[])(object)new AudioClip[5]; for (int j = 0; j < 5; j++) { Bounces[i][j] = SlAssets.LoadSound($"scp018_{array[i]}{j + 1}"); } } GameObject val3 = new GameObject("SCPItems Prefabs 018"); val3.SetActive(false); ((Object)val3).hideFlags = (HideFlags)61; Object.DontDestroyOnLoad((Object)(object)val3); GameObject val4 = Object.Instantiate<GameObject>(val, val3.transform); ((Object)val4).name = "Item SCP 018"; int layer = val4.layer; ItemOrbZeroGravity[] components = val4.GetComponents<ItemOrbZeroGravity>(); for (int k = 0; k < components.Length; k++) { Object.DestroyImmediate((Object)(object)components[k]); } ItemOrb[] components2 = val4.GetComponents<ItemOrb>(); for (int k = 0; k < components2.Length; k++) { Object.DestroyImmediate((Object)(object)components2[k]); } Material val5 = null; Renderer[] componentsInChildren = val4.GetComponentsInChildren<Renderer>(true); foreach (Renderer val6 in componentsInChildren) { if (!Object.op_Implicit((Object)(object)val5) && val6 is MeshRenderer && Object.op_Implicit((Object)(object)((Component)val6).transform.parent) && ((Object)((Component)val6).transform.parent).name == "Top") { val5 = val6.sharedMaterial; } val6.enabled = false; } string[] array2 = new string[1] { "sphere effect" }; foreach (string text in array2) { Transform val7 = val4.transform.Find(text); if (Object.op_Implicit((Object)(object)val7)) { Object.DestroyImmediate((Object)(object)((Component)val7).gameObject); } } Light[] componentsInChildren2 = val4.GetComponentsInChildren<Light>(true); for (int k = 0; k < componentsInChildren2.Length; k++) { ((Behaviour)componentsInChildren2[k]).enabled = false; } Bounds bounds = Mesh.bounds; float x = ((Bounds)(ref bounds)).size.x; SphereCollider componentInChildren = val4.GetComponentInChildren<SphereCollider>(true); if (Object.op_Implicit((Object)(object)componentInChildren)) { ((Component)componentInChildren).transform.localPosition = Vector3.zero; ((Component)componentInChildren).transform.localScale = Vector3.one * x / (componentInChildren.radius * 2f); } else { Plugin.Log.LogWarning((object)"The orb has no sphere collider; SCP-018 keeps the orb's shape."); } GameObject val8 = new GameObject("SCP-018 Model") { layer = layer }; val8.transform.SetParent(val4.transform, false); val8.AddComponent<MeshFilter>().sharedMesh = Mesh; ((Renderer)val8.AddComponent<MeshRenderer>()).sharedMaterial = SlAssets.MakeMaterial(val5, "SCP-018", SlAssets.LoadTexture("scp018_albedo"), SlAssets.LoadTexture("scp018_normal", linear: true)); ItemBattery[] components3 = val4.GetComponents<ItemBattery>(); for (int k = 0; k < components3.Length; k++) { Object.DestroyImmediate((Object)(object)components3[k]); } BatteryVisualLogic[] componentsInChildren3 = val4.GetComponentsInChildren<BatteryVisualLogic>(true); foreach (BatteryVisualLogic val9 in componentsInChildren3) { if (Object.op_Implicit((Object)(object)val9)) { Object.DestroyImmediate((Object)(object)((Object.op_Implicit((Object)(object)((Component)val9).transform.parent) && (Object)(object)((Component)val9).transform.parent != (Object)(object)val4.transform) ? ((Component)((Component)val9).transform.parent).gameObject : ((Component)val9).gameObject)); } } val4.AddComponent<BallItem>(); val4.AddComponent<BallTrail>().width = x * 1.1f; Item val10 = Object.Instantiate<Item>(val2); ((Object)val10).name = "Item SCP 018"; val10.itemName = "SCP-018"; val10.itemNameLocalized = null; val10.description = "Super Ball. Throw it hard and every bounce is faster than the last. Hurts whatever it hits, you included."; val10.itemType = (itemType)13; val10.itemVolume = (itemVolume)0; Value val11 = ScriptableObject.CreateInstance<Value>(); ((Object)val11).name = "Value - SCP-018"; val11.valueMin = (float)Plugin.BallPriceMin.Value / 4f; val11.valueMax = (float)Mathf.Max(Plugin.BallPriceMin.Value, Plugin.BallPriceMax.Value) / 4f; val10.value = val11; Object.DontDestroyOnLoad((Object)(object)val10); Object.DontDestroyOnLoad((Object)(object)val11); val4.GetComponent<ItemAttributes>().item = val10; if (Items.RegisterItem(val4.GetComponent<ItemAttributes>()) == null) { throw new Exception("REPOLib refused to register SCP-018 (see REPOLib errors above)."); } Plugin.Log.LogInfo((object)"Registered SCP-018."); } } internal class BallItem : MonoBehaviour { private const float Gain = 1.25f; private const float MinBounceSpeed = 2f; private const float HitCooldown = 0.3f; private const float PlayerHurtSpeed = 8f; private PhotonView photonView; private ItemToggle itemToggle; private PhysGrabObject physGrabObject; private ItemEquippable equippable; private Collider[] colliders; private PhysicsMaterial bouncy; private PhysicsMaterial[] originalMaterials; private bool active; private bool wasGrabbed; private float releaseWindow; private float activeLeft; private float pendingSpeed; private Vector3 pendingNormal; private bool pendingBoost; private float soundBudget; private readonly Dictionary<Object, float> lastHit = new Dictionary<Object, float>(); private bool IsHost => SemiFunc.IsMasterClientOrSingleplayer(); private void Awake() { //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_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: 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_00d0: Expected O, but got Unknown photonView = ((Component)this).GetComponent<PhotonView>(); itemToggle = ((Component)this).GetComponent<ItemToggle>(); if (Object.op_Implicit((Object)(object)itemToggle)) { itemToggle.disabled = true; } physGrabObject = ((Component)this).GetComponent<PhysGrabObject>(); equippable = ((Component)this).GetComponent<ItemEquippable>(); colliders = ((Component)this).GetComponentsInChildren<Collider>(true); originalMaterials = (PhysicsMaterial[])(object)new PhysicsMaterial[colliders.Length]; for (int i = 0; i < colliders.Length; i++) { originalMaterials[i] = colliders[i].sharedMaterial; } bouncy = new PhysicsMaterial("SCP-018") { bounciness = 0.95f, bounceCombine = (PhysicsMaterialCombine)3, dynamicFriction = 0.1f, staticFriction = 0.1f, frictionCombine = (PhysicsMaterialCombine)2 }; } private void Start() { NotValuableObject component = ((Component)this).GetComponent<NotValuableObject>(); if (Object.op_Implicit((Object)(object)component)) { component.hasHealth = false; } } private void Update() { //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) if (!IsHost) { return; } soundBudget = Mathf.Min(soundBudget + Time.deltaTime * 8f, 3f); if (Object.op_Implicit((Object)(object)itemToggle) && itemToggle.toggleState) { itemToggle.ToggleItem(false, -1); } bool grabbed = physGrabObject.grabbed; if (wasGrabbed && !grabbed) { releaseWindow = 0.5f; } wasGrabbed = grabbed; if (releaseWindow > 0f) { releaseWindow -= Time.deltaTime; bool flag = SemiFunc.RunIsShop() || RunManager.instance.levelIsShop; if (!active && !grabbed && !flag && (!Object.op_Implicit((Object)(object)equippable) || !equippable.isEquipped)) { Vector3 linearVelocity = physGrabObject.rb.linearVelocity; if (((Vector3)(ref linearVelocity)).magnitude >= Plugin.BallWakeSpeed.Value) { releaseWindow = 0f; GoLive(); } } } if (active) { activeLeft -= Time.deltaTime; if (activeLeft <= 0f || (Object.op_Implicit((Object)(object)equippable) && equippable.isEquipped)) { Calm(); } } } private void FixedUpdate() { //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: 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_0126: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_0159: Unknown result type (might be due to invalid IL or missing references) //IL_015c: 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) if (!IsHost || !active) { return; } Rigidbody rb = physGrabObject.rb; rb.linearDamping = 0f; rb.angularDamping = 0.05f; rb.collisionDetectionMode = (CollisionDetectionMode)2; Collider[] array = colliders; foreach (Collider val in array) { if (Object.op_Implicit((Object)(object)val) && (Object)(object)val.sharedMaterial != (Object)(object)bouncy) { val.sharedMaterial = bouncy; } } if (pendingBoost && !physGrabObject.grabbed) { pendingBoost = false; Vector3 linearVelocity = rb.linearVelocity; float num = Mathf.Min(Mathf.Max(((Vector3)(ref linearVelocity)).magnitude, pendingSpeed * 0.9f) * 1.25f, Plugin.BallMaxSpeed.Value); if (((Vector3)(ref linearVelocity)).sqrMagnitude > 0.01f) { Vector3 dir = Vector3.zero; Vector3 val2 = (((Random.value < Plugin.BallTargetChance.Value && PickTarget(rb.position, pendingNormal, num, players: false, out dir)) || (Random.value < Plugin.BallPlayerChance.Value && PickTarget(rb.position, pendingNormal, num, players: true, out dir))) ? dir : Scatter(((Vector3)(ref linearVelocity)).normalized, pendingNormal)); rb.linearVelocity = val2 * num; } } } private static Vector3 Scatter(Vector3 dir, Vector3 normal) { //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_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_001a: 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_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0034: 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) //IL_005f: 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_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) Vector3 val = dir + Random.onUnitSphere * Plugin.BallScatter.Value; Vector3 normalized = ((Vector3)(ref val)).normalized; if (((Vector3)(ref normal)).sqrMagnitude < 0.01f) { return normalized; } float num = Vector3.Dot(normalized, normal); if (num < 0.25f) { val = normalized + normal * (0.25f - num); normalized = ((Vector3)(ref val)).normalized; } return normalized; } private static bool PickTarget(Vector3 from, Vector3 normal, float speed, bool players, out Vector3 dir) { //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_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) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Unknown result type (might be due to invalid IL or missing references) //IL_018a: 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_01a1: 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_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_01af: Unknown result type (might be due to invalid IL or missing references) //IL_01ce: Unknown result type (might be due to invalid IL or missing references) //IL_01cf: 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_01d7: Unknown result type (might be due to invalid IL or missing references) //IL_01dc: Unknown result type (might be due to invalid IL or missing references) //IL_01bf: 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_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_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_01ec: Unknown result type (might be due to invalid IL or missing references) //IL_01ee: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) dir = Vector3.zero; List<Vector3> list = new List<Vector3>(); if (players) { foreach (PlayerAvatar item in SemiFunc.PlayerGetList()) { if (Object.op_Implicit((Object)(object)item) && !item.isDisabled && !item.deadSet) { list.Add(((Component)item).transform.position + Vector3.up * 1f); } } } else if (Object.op_Implicit((Object)(object)EnemyDirector.instance)) { foreach (EnemyParent item2 in EnemyDirector.instance.enemiesSpawned) { if (Object.op_Implicit((Object)(object)item2) && Object.op_Implicit((Object)(object)item2.Enemy) && item2.Spawned && Object.op_Implicit((Object)(object)item2.Enemy.CenterTransform)) { list.Add(item2.Enemy.CenterTransform.position); } } } int mask = LayerMask.GetMask(new string[1] { "Default" }); while (list.Count > 0) { int index = Random.Range(0, list.Count); Vector3 val = list[index] - from; list.RemoveAt(index); float magnitude = ((Vector3)(ref val)).magnitude; if (!(magnitude < 1f) && !(magnitude > 25f)) { float num = magnitude / Mathf.Max(speed, 1f); Vector3 val2 = val + Vector3.up * (0.5f * (0f - Physics.gravity.y) * num * num); Vector3 normalized = ((Vector3)(ref val2)).normalized; if ((!(((Vector3)(ref normal)).sqrMagnitude > 0.01f) || !(Vector3.Dot(normalized, normal) < 0.1f)) && !Physics.Linecast(from, from + val * 0.95f, mask, (QueryTriggerInteraction)1)) { dir = normalized; return true; } } } return false; } private void GoLive() { //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) active = true; activeLeft = Plugin.BallSeconds.Value; lastHit.Clear(); if (SemiFunc.IsMultiplayer()) { photonView.RPC("WakeRPC", (RpcTarget)0, Array.Empty<object>()); } else { WakeRPC(); } } private void Calm() { //IL_005a: 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) active = false; pendingBoost = false; Rigidbody rb = physGrabObject.rb; rb.collisionDetectionMode = (CollisionDetectionMode)1; for (int i = 0; i < colliders.Length; i++) { if (Object.op_Implicit((Object)(object)colliders[i])) { colliders[i].sharedMaterial = originalMaterials[i]; } } rb.linearVelocity *= 0.3f; } private void OnCollisionEnter(Collision c) { //IL_001f: 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_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0092: 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_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_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_00a6: 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_00c9: 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_013d: 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_0146: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) if (!IsHost || !active || physGrabObject.grabbed) { return; } Vector3 relativeVelocity = c.relativeVelocity; float magnitude = ((Vector3)(ref relativeVelocity)).magnitude; if (magnitude < 2f) { return; } pendingBoost = true; pendingSpeed = magnitude; Vector3 val; ContactPoint contact; if (c.contactCount <= 0) { val = Vector3.zero; } else { contact = c.GetContact(0); val = ((ContactPoint)(ref contact)).normal; } pendingNormal = val; Vector3 val2; if (c.contactCount <= 0) { val2 = ((Component)this).transform.position; } else { contact = c.GetContact(0); val2 = ((ContactPoint)(ref contact)).point; } Vector3 val3 = val2; relativeVelocity = c.relativeVelocity; Vector3 val4; if (!(((Vector3)(ref relativeVelocity)).sqrMagnitude > 0.01f)) { val4 = Vector3.zero; } else { relativeVelocity = c.relativeVelocity; val4 = -((Vector3)(ref relativeVelocity)).normalized; } Vector3 dir = val4; HitWhatever(c.collider, magnitude, val3, dir); if (soundBudget >= 1f) { soundBudget -= 1f; int num = ((!(magnitude < 8f)) ? ((magnitude < 18f) ? 1 : 2) : 0); if (SemiFunc.IsMultiplayer()) { photonView.RPC("BounceRPC", (RpcTarget)0, new object[2] { num, val3 }); } else { BounceRPC(num, val3); } } } private void HitWhatever(Collider other, float speed, Vector3 point, Vector3 dir) { //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)other)) { return; } EnemyRigidbody componentInParent = ((Component)other).GetComponentInParent<EnemyRigidbody>(); if (Object.op_Implicit((Object)(object)componentInParent) && Object.op_Implicit((Object)(object)componentInParent.enemy)) { Enemy enemy = componentInParent.enemy; if (Ready((Object)(object)enemy)) { if (enemy.HasHealth && Object.op_Implicit((Object)(object)enemy.Health)) { enemy.Health.Hurt(Mathf.RoundToInt(speed * Plugin.BallEnemyDamage.Value), dir); } if (speed > 15f && enemy.HasStateStunned && Object.op_Implicit((Object)(object)enemy.StateStunned)) { enemy.StateStunned.Set(1.5f); } } } else { if (!Plugin.BallHurtsPlayers.Value || speed < 8f) { return; } PlayerAvatar val = null; if (((Component)other).CompareTag("Player")) { PlayerController componentInParent2 = ((Component)other).GetComponentInParent<PlayerController>(); val = (Object.op_Implicit((Object)(object)componentInParent2) ? componentInParent2.playerAvatarScript : ((Component)other).GetComponentInParent<PlayerAvatar>()); } else { PlayerTumble componentInParent3 = ((Component)other).GetComponentInParent<PlayerTumble>(); if (Object.op_Implicit((Object)(object)componentInParent3)) { val = componentInParent3.playerAvatar; } } if (Object.op_Implicit((Object)(object)val) && !val.isDisabled && Object.op_Implicit((Object)(object)val.playerHealth) && Ready((Object)(object)val)) { val.playerHealth.HurtOther(Mathf.RoundToInt(speed * Plugin.BallPlayerDamage.Value), point, false, -1, false); } } } private bool Ready(Object target) { if (lastHit.TryGetValue(target, out var value) && Time.time - value < 0.3f) { return false; } lastHit[target] = Time.time; return true; } [PunRPC] private void WakeRPC(PhotonMessageInfo info = default(PhotonMessageInfo)) { //IL_0000: 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 (SemiFunc.MasterOnlyRPC(info)) { Play(BallBuilder.Bounces[2], ((Component)this).transform.position, 0.8f); } } [PunRPC] private void BounceRPC(int level, Vector3 point, PhotonMessageInfo info = default(PhotonMessageInfo)) { //IL_0000: 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) if (SemiFunc.MasterOnlyRPC(info)) { Play(BallBuilder.Bounces[Mathf.Clamp(level, 0, 2)], point, 0.6f + 0.2f * (float)level); } } private static void Play(AudioClip[] set, Vector3 at, float volume) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) if (set != null && set.Length != 0) { SlAssets.Play(set[Random.Range(0, set.Length)], at, null, volume, 25f); } } } internal static class BatteryGraft { internal static ItemBattery Add(GameObject cap, float capHeight, string label, int bars = 0, bool chargeable = true) { GameObject val = Resources.Load<GameObject>("Items/Item Rubber Duck"); ItemBattery val2 = (Object.op_Implicit((Object)(object)val) ? val.GetComponent<ItemBattery>() : null); Transform val3 = (Object.op_Implicit((Object)(object)val) ? val.transform.Find("Item Battery (1)") : null); if (!Object.op_Implicit((Object)(object)val2) || !Object.op_Implicit((Object)(object)val3)) { Plugin.Log.LogWarning((object)("Couldn't borrow the Rubber Duck's battery; " + label + " will have no battery.")); return null; } GameObject val4 = Object.Instantiate<GameObject>(((Component)val3).gameObject, cap.transform, false); ((Object)val4).name = ((Object)val3).name; ItemBattery val5 = cap.AddComponent<ItemBattery>(); FieldInfo[] fields = typeof(ItemBattery).GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); foreach (FieldInfo fieldInfo in fields) { if (fieldInfo.IsLiteral || fieldInfo.IsInitOnly) { continue; } object value = fieldInfo.GetValue(val2); Object val6 = (Object)((value is Object) ? value : null); if (val6 != null && Object.op_Implicit(val6)) { Component val7 = (Component)(object)((val6 is Component) ? val6 : null); object obj2; if (val7 == null) { Object obj = ((val6 is GameObject) ? val6 : null); obj2 = ((obj != null) ? ((GameObject)obj).transform : null); } else { obj2 = val7.transform; } Transform val8 = (Transform)obj2; if (!Object.op_Implicit((Object)(object)val8)) { fieldInfo.SetValue(val5, value); continue; } string text = PathUnder(val8, val3); if (text == null) { fieldInfo.SetValue(val5, null); continue; } Transform val9 = ((text.Length == 0) ? val4.transform : val4.transform.Find(text)); object value2 = null; if (Object.op_Implicit((Object)(object)val9)) { value2 = ((val6 is GameObject) ? ((Component)val9).gameObject : ((val6 is Transform) ? ((object)val9) : ((object)((Component)val9).GetComponent(((object)val6).GetType())))); } fieldInfo.SetValue(val5, value2); } else if (fieldInfo.FieldType.IsValueType || fieldInfo.FieldType == typeof(string)) { fieldInfo.SetValue(val5, value); } } val5.autoDrain = false; val5.batteryActive = false; val5.onlyShowWhenItemToggleIsOn = false; val5.isUnchargable = !chargeable; if (bars > 0) { val5.batteryBars = bars; } val5.batteryLife = 100f; val5.upOffset = Mathf.Max(val5.upOffset, capHeight + 0.15f); if (!Object.op_Implicit((Object)(object)val5.batteryTransform)) { val5.batteryTransform = val4.transform; } return val5; } private static string PathUnder(Transform t, Transform root) { List<string> list = new List<string>(); Transform val = t; while (Object.op_Implicit((Object)(object)val)) { if ((Object)(object)val == (Object)(object)root) { list.Reverse(); return string.Join("/", list); } list.Add(((Object)val).name); val = val.parent; } return null; } } internal static class Build { private static class Machines { internal static bool Contains(string n) { string[] machineNames = MachineNames; foreach (string value in machineNames) { if (n.Contains(value)) { return true; } } return false; } } private static readonly Dictionary<string, Mesh> meshes = new Dictionary<string, Mesh>(); internal static Material ItemMaterial; internal static readonly List<PrefabRef> TestLoot = new List<PrefabRef>(); private static readonly string[] MachineNames = new string[3] { "SCP-914", "SCP-294", "SCP-1162" }; internal static readonly string[] SmallLoot = new string[2] { "Valuables/02 Small/Valuable Wizard Love Potion", "Valuables/02 Small/Valuable Museum Car" }; internal static readonly string[] MediumLoot = new string[2] { "Valuables/03 Medium/Valuable Manor Trophy", "Valuables/03 Medium/Valuable Manor Kettle" }; internal static readonly string[] BigLoot = new string[2] { "Valuables/04 Big/Valuable Manor Television", "Valuables/04 Big/Valuable Museum Boombox" }; private static Dictionary<string, Object> presets; internal static BoxCollider LastBox; internal static bool MenuOpen { get { if (Object.op_Implicit((Object)(object)MenuManager.instance)) { return Object.op_Implicit((Object)(object)MenuManager.instance.currentMenuPage); } return false; } } internal static Mesh Mesh(string part) { if (!meshes.TryGetValue(part, out var value) || !Object.op_Implicit((Object)(object)value)) { value = (meshes[part] = SlAssets.LoadMesh(part)); } return value; } internal static Bounds Bounds(string[] parts) { //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_001c: 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) Bounds bounds = Mesh(parts[0]).bounds; for (int i = 1; i < parts.Length; i++) { ((Bounds)(ref bounds)).Encapsulate(Mesh(parts[i]).bounds); } return bounds; } internal static string UseTag(string name) { return name + " <color=#FFFFFF>[" + SemiFunc.InputDisplayReplaceTags("[interact]", "<u><b>", "</b></u>") + "]</color>"; } private static bool Has(string asset) { return typeof(Build).Assembly.GetManifestResourceInfo("SCPItems." + asset) != null; } internal static Material Material(Material baseMat, string part) { bool num = !Has(part + "_normal.png"); Texture2D albedo = (num ? SlAssets.LoadPalette(part + "_albedo") : SlAssets.LoadTexture(part + "_albedo")); Texture2D normal = (num ? null : SlAssets.LoadTexture(part + "_normal", linear: true)); return SlAssets.MakeMaterial(baseMat, part, albedo, normal); } internal static void Matte(GameObject go, float smoothness = 0.08f) { MeshRenderer[] componentsInChildren = go.GetComponentsInChildren<MeshRenderer>(true); for (int i = 0; i < componentsInChildren.Length; i++) { Material sharedMaterial = ((Renderer)componentsInChildren[i]).sharedMaterial; if (!Object.op_Implicit((Object)(object)sharedMaterial)) { continue; } string[] array = new string[2] { "_Smoothness", "_Glossiness" }; foreach (string text in array) { if (sharedMaterial.HasProperty(text)) { sharedMaterial.SetFloat(text, smoothness); } } array = new string[2] { "_GlossyReflections", "_SpecularHighlights" }; foreach (string text2 in array) { if (sharedMaterial.HasProperty(text2)) { sharedMaterial.SetFloat(text2, 0f); } } sharedMaterial.EnableKeyword("_GLOSSYREFLECTIONS_OFF"); sharedMaterial.EnableKeyword("_SPECULARHIGHLIGHTS_OFF"); } } internal static void FrameIcon(GameObject root, Bounds local, float pitch = 0f, float margin = 1.15f) { //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_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: 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_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_0116: Unknown result type (might be due to invalid IL or missing references) //IL_0130: 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_01fa: Unknown result type (might be due to invalid IL or missing references) //IL_01ff: Unknown result type (might be due to invalid IL or missing references) //IL_0204: Unknown result type (might be due to invalid IL or missing references) //IL_0209: Unknown result type (might be due to invalid IL or missing references) //IL_020d: Unknown result type (might be due to invalid IL or missing references) //IL_0212: Unknown result type (might be due to invalid IL or missing references) //IL_0215: Unknown result type (might be due to invalid IL or missing references) //IL_021a: Unknown result type (might be due to invalid IL or missing references) //IL_021f: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Unknown result type (might be due to invalid IL or missing references) //IL_015b: 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_0161: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Unknown result type (might be due to invalid IL or missing references) //IL_016b: 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) Transform val = root.transform.Find("SemiIcon Maker"); if (Object.op_Implicit((Object)(object)val)) { SemiIconMaker component = ((Component)val).GetComponent<SemiIconMaker>(); Camera val2 = ((Object.op_Implicit((Object)(object)component) && Object.op_Implicit((Object)(object)component.iconCamera)) ? component.iconCamera : ((Component)val).GetComponentInChildren<Camera>(true)); Transform val3 = (Object.op_Implicit((Object)(object)val2) ? ((Component)val2).transform : val); if (pitch != 0f) { val.rotation = Quaternion.AngleAxis(pitch, val3.right) * val.rotation; } float num = Mathf.Tan((Object.op_Implicit((Object)(object)val2) ? val2.fieldOfView : 30f) * 0.5f * (MathF.PI / 180f)); float num2 = ((Object.op_Implicit((Object)(object)component) && Object.op_Implicit((Object)(object)component.renderTexture)) ? ((float)((Texture)component.renderTexture).width / (float)((Texture)component.renderTexture).height) : 1f); float num3 = num * num2; Transform transform = root.transform; Vector3 val4 = transform.InverseTransformDirection(val3.forward); Vector3 val5 = transform.InverseTransformDirection(val3.right); Vector3 val6 = transform.InverseTransformDirection(val3.up); float num4 = 0f; float num5 = 0f; for (int i = 0; i < 8; i++) { Vector3 val7 = Vector3.Scale(((Bounds)(ref local)).extents, new Vector3((float)(((i & 1) != 0) ? 1 : (-1)), (float)(((i & 2) != 0) ? 1 : (-1)), (float)(((i & 4) != 0) ? 1 : (-1)))); float num6 = Vector3.Dot(val7, val5); float num7 = Vector3.Dot(val7, val6); float num8 = Vector3.Dot(val7, val4); num4 = Mathf.Max(new float[3] { num4, margin * Mathf.Abs(num6) / num3 - num8, margin * Mathf.Abs(num7) / num - num8 }); num5 = Mathf.Max(num5, 0f - num8); } if (Object.op_Implicit((Object)(object)val2)) { num4 = Mathf.Max(num4, num5 + val2.nearClipPlane + 0.02f); } Vector3 val8 = transform.TransformPoint(((Bounds)(ref local)).center - val4 * num4); val.position += val8 - val3.position; } } internal static GameObject Model(Transform parent, Material baseMat, string[] parts, bool centred = false, float scale = 1f) { //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_000c: 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_0023: Expected O, but got Unknown //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) Bounds val = Bounds(parts); GameObject val2 = new GameObject("SL Model") { layer = ((Component)parent).gameObject.layer }; val2.transform.SetParent(parent, false); val2.transform.localScale = Vector3.one * scale; val2.transform.localPosition = new Vector3(0f - ((Bounds)(ref val)).center.x, centred ? (0f - ((Bounds)(ref val)).center.y) : (0f - ((Bounds)(ref val)).min.y), 0f - ((Bounds)(ref val)).center.z) * scale; foreach (string text in parts) { GameObject val3 = new GameObject(text) { layer = ((Component)parent).gameObject.layer }; val3.transform.SetParent(val2.transform, false); val3.AddComponent<MeshFilter>().sharedMesh = Mesh(text); ((Renderer)val3.AddComponent<MeshRenderer>()).sharedMaterial = Material(baseMat, text); } return val2; } internal static GameObject Holder(string name) { //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_0017: 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: Expected O, but got Unknown //IL_0026: Expected O, but got Unknown GameObject val = new GameObject("SCPItems Prefabs " + name); val.SetActive(false); ((Object)val).hideFlags = (HideFlags)61; Object.DontDestroyOnLoad((Object)val); return val; } internal static GameObject ShopItem(string prefabName, string displayName, string description, itemType type, int priceMin, int priceMax, string[] parts, string basePath = "Items/Item Health Pack Small", float scale = 1f, params string[] strip) { //IL_02c4: Unknown result type (might be due to invalid IL or missing references) //IL_02c5: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_01af: Unknown result type (might be due to invalid IL or missing references) //IL_01ef: Unknown result type (might be due to invalid IL or missing references) //IL_01f4: Unknown result type (might be due to invalid IL or missing references) //IL_01f8: Unknown result type (might be due to invalid IL or missing references) //IL_01ff: Unknown result type (might be due to invalid IL or missing references) //IL_0204: Unknown result type (might be due to invalid IL or missing references) //IL_0273: Unknown result type (might be due to invalid IL or missing references) //IL_0285: Unknown result type (might be due to invalid IL or missing references) //IL_028a: Unknown result type (might be due to invalid IL or missing references) //IL_028c: Unknown result type (might be due to invalid IL or missing references) //IL_0228: Unknown result type (might be due to invalid IL or missing references) //IL_023a: Unknown result type (might be due to invalid IL or missing references) //IL_0246: Unknown result type (might be due to invalid IL or missing references) //IL_0252: Unknown result type (might be due to invalid IL or missing references) //IL_0254: Unknown result type (might be due to invalid IL or missing references) //IL_025e: Unknown result type (might be due to invalid IL or missing references) //IL_0263: Unknown result type (might be due to invalid IL or missing references) GameObject obj = Resources.Load<GameObject>(basePath); if (!Object.op_Implicit((Object)(object)obj)) { throw new Exception("Base item \"" + basePath + "\" not found. The game may have been updated."); } Item val = obj.GetComponent<ItemAttributes>()?.item; if (!Object.op_Implicit((Object)(object)val)) { throw new Exception("\"" + basePath + "\" has no Item asset."); } GameObject val2 = Object.Instantiate<GameObject>(obj, Holder(prefabName).transform); ((Object)val2).name = prefabName; if (parts != null) { Material val3 = null; ItemHealthPack component = val2.GetComponent<ItemHealthPack>(); if (Object.op_Implicit((Object)(object)component)) { if (Object.op_Implicit((Object)(object)component.mesh)) { val3 = ((Renderer)component.mesh).sharedMaterial; } if (Object.op_Implicit((Object)(object)component.propLight) && Object.op_Implicit((Object)(object)component.propLight.lightComponent)) { ((Behaviour)component.propLight.lightComponent).enabled = false; } Object.DestroyImmediate((Object)(object)component); } MonoBehaviour[] componentsInChildren = val2.GetComponentsInChildren<MonoBehaviour>(true); foreach (MonoBehaviour val4 in componentsInChildren) { if (Object.op_Implicit((Object)(object)val4) && Array.IndexOf(strip, ((object)val4).GetType().Name) >= 0) { Object.DestroyImmediate((Object)(object)val4); } } Renderer[] componentsInChildren2 = val2.GetComponentsInChildren<Renderer>(true); foreach (Renderer val5 in componentsInChildren2) { if (!Object.op_Implicit((Object)(object)val3) && val5 is MeshRenderer) { val3 = val5.sharedMaterial; } val5.enabled = false; } Light[] componentsInChildren3 = val2.GetComponentsInChildren<Light>(true); for (int i = 0; i < componentsInChildren3.Length; i++) { ((Behaviour)componentsInChildren3[i]).enabled = false; } ParticleSystem[] componentsInChildren4 = val2.GetComponentsInChildren<ParticleSystem>(true); for (int i = 0; i < componentsInChildren4.Length; i++) { MainModule main = componentsInChildren4[i].main; ((MainModule)(ref main)).playOnAwake = false; } if (!Object.op_Implicit((Object)(object)ItemMaterial)) { ItemMaterial = val3; } Model(val2.transform, val3, parts, centred: false, scale); Bounds val6 = Bounds(parts); Vector3 val7 = ((Bounds)(ref val6)).size * scale; Transform val8 = val2.transform.Find("Semi Box Collider"); if (Object.op_Implicit((Object)(object)val8)) { val8.localPosition = new Vector3(0f, val7.y * 0.5f, 0f); val8.localRotation = Quaternion.identity; val8.localScale = Vector3.Max(val7, Vector3.one * 0.05f); } FrameIcon(val2, new Bounds(new Vector3(0f, val7.y * 0.5f, 0f), val7)); } Item val9 = Object.Instantiate<Item>(val); ((Object)val9).name = prefabName; val9.itemName = displayName; val9.itemNameLocalized = null; val9.description = description; val9.itemType = type; Value val10 = ScriptableObject.CreateInstance<Value>(); ((Object)val10).name = "Value - " + displayName; val10.valueMin = (float)priceMin / 4f; val10.valueMax = (float)Mathf.Max(priceMin, priceMax) / 4f; val9.value = val10; Object.DontDestroyOnLoad((Object)(object)val9); Object.DontDestroyOnLoad((Object)(object)val10); val2.GetComponent<ItemAttributes>().item = val9; return val2; } internal static void Register(GameObject shopItem, string label) { if (Items.RegisterItem(shopItem.GetComponent<ItemAttributes>()) == null) { throw new Exception("REPOLib refused to register " + label + " (see REPOLib errors above)."); } Plugin.Log.LogInfo((object)("Registered " + label + ".")); } internal static void Feel(GameObject go, string mass, string durability, string sound) { ValuableObject component = go.GetComponent<ValuableObject>(); if (!Object.op_Implicit((Object)(object)component)) { return; } if (presets == null) { presets = new Dictionary<string, Object>(); Resources.LoadAll<GameObject>("Valuables"); PhysAttribute[] array = Resources.FindObjectsOfTypeAll<PhysAttribute>(); foreach (PhysAttribute val in array) { presets["PhysAttribute " + ((Object)val).name.Replace("PhysAttribute ", "")] = (Object)(object)val; } Durability[] array2 = Resources.FindObjectsOfTypeAll<Durability>(); foreach (Durability val2 in array2) { presets["Durability " + ((Object)val2).name.Replace("Durability ", "").Trim()] = (Object)(object)val2; } PhysAudio[] array3 = Resources.FindObjectsOfTypeAll<PhysAudio>(); foreach (PhysAudio val3 in array3) { presets["PhysAudio " + ((Object)val3).name.Replace("PhysAudio - ", "")] = (Object)(object)val3; } } if (mass != null) { PhysAttribute val4 = Find<PhysAttribute>("PhysAttribute " + mass); if (Object.op_Implicit((Object)(object)val4)) { component.physAttributePreset = val4; } } if (durability != null) { Durability val5 = Find<Durability>("Durability " + durability); if (Object.op_Implicit((Object)(object)val5)) { component.durabilityPreset = val5; } } if (sound != null) { PhysAudio val6 = Find<PhysAudio>("PhysAudio " + sound); if (Object.op_Implicit((Object)(object)val6)) { component.audioPreset = val6; } } T Find<T>(string key) where T : Object { if (presets.TryGetValue(key, out var value)) { T val7 = (T)(object)((value is T) ? value : null); if (val7 != null) { return val7; } } Plugin.Log.LogWarning((object)(((Object)go).name + ": no vanilla preset \"" + key + "\" (kept the base valuable's).")); return default(T); } } internal static GameObject Loot(string name, string[] bases, string[] parts, Type volume, int valueMin, int valueMax, float boxGrow = 1.1f, float scale = 1f) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_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_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: 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_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_00c6: 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_0045: Unknown result type (might be due to invalid IL or missing references) Material baseMat; BoxCollider box; GameObject val = CandyValuables.CloneValuable(bases, name, Holder(name).transform, out baseMat, out box); LastBox = box; if (val.transform.localScale != Vector3.one) { Plugin.Log.LogWarning((object)$"{name}: its base valuable is scaled {val.transform.localScale} (the model will be too)."); } Model(val.transform, baseMat, parts, centred: false, scale); Bounds val2 = Bounds(parts); Bounds b = default(Bounds); ((Bounds)(ref b))..ctor(new Vector3(0f, ((Bounds)(ref val2)).size.y * scale * 0.5f, 0f), Vector3.Max(((Bounds)(ref val2)).size * scale * boxGrow, Vector3.one * 0.06f)); CandyValuables.FitBox(box, b, 1f); CandyValuables.SetValue(val, volume, valueMin, valueMax, name); return val; } internal static PrefabRef RegisterLoot(GameObject loot, bool inLevels) { PrefabRef val = (inLevels ? Valuables.RegisterValuable(loot) : NetworkPrefabs.RegisterNetworkPrefab("Valuables/" + ((Object)loot).name, loot)); if (val == null) { throw new Exception("REPOLib refused to register " + ((Object)loot).name + "."); } if (!((Object)loot).name.Contains("Slice") && !Machines.Contains(((Object)loot).name)) { TestLoot.Add(val); } Plugin.Log.LogInfo((object)("Registered " + ((Object)loot).name + (inLevels ? " (level loot)." : " (spawned only)."))); return val; } internal static GameObject Spawn(PrefabRef prefab, Vector3 at, Quaternion rot) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) return Valuables.SpawnValuable(prefab, at, rot); } } internal enum Candy { Red, Green, Yellow, Blue, Rainbow, Pink } internal class CandyEffects : MonoBehaviour { private static CandyEffects instance; private static readonly Dictionary<PlayerAvatar, int> taken = new Dictionary<PlayerAvatar, int>(); private static readonly HashSet<PlayerAvatar> handless = new HashSet<PlayerAvatar>(); private static LevelGenerator level; private static readonly Dictionary<PlayerAvatar, List<Renderer>> arms = new Dictionary<PlayerAvatar, List<Renderer>>(); private static readonly string[] ArmRoots = new string[2] { "Player Spring Impulse - Arm Left", "Player Spring Impulse - Arm Right" }; private float speedLeft; private float invincibleLeft; private static readonly HashSet<PlayerAvatar> dead = new HashSet<PlayerAvatar>(); private ParticleScriptExplosion boom; internal static bool LocalHandless { get { if (handless.Count == 0) { return false; } return IsHandless(Object.op_Implicit((Object)(object)PlayerController.instance) ? PlayerController.instance.playerAvatarScript : null); } } private static CandyEffects Get() { //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_001c: Expected O, but got Unknown if (!Object.op_Implicit((Object)(object)instance)) { GameObject val = new GameObject("SCPItems SCP-330 Effects"); Object.DontDestroyOnLoad((Object)val); instance = val.AddComponent<CandyEffects>(); } return instance; } private static void NewLevelCheck() { if ((Object)(object)level == (Object)(object)LevelGenerator.Instance) { return; } level = LevelGenerator.Instance; taken.Clear(); foreach (PlayerAvatar item in handless) { if (Object.op_Implicit((Object)(object)item) && Object.op_Implicit((Object)(object)item.flashlightController)) { item.flashlightController.hideFlashlight = false; } } foreach (KeyValuePair<PlayerAvatar, List<Renderer>> arm in arms) { foreach (Renderer item2 in arm.Value) { if (Object.op_Implicit((Object)(object)item2)) { item2.enabled = true; } } } arms.Clear(); handless.Clear(); dead.Clear(); if (Object.op_Implicit((Object)(object)instance)) { instance.speedLeft = 0f; instance.invincibleLeft = 0f; } } internal static int HostTake(PlayerAvatar p) { Get(); NewLevelCheck(); taken.TryGetValue(p, out var value); return taken[p] = value + 1; } internal static bool IsHandless(PlayerAvatar p) { NewLevelCheck(); if (Object.op_Implicit((Object)(object)p)) { return handless.Contains(p); } return false; } private static void Died(PlayerAvatar p) { handless.Remove(p); taken.Remove(p); dead.Add(p); if (Object.op_Implicit((Object)(object)p.flashlightController)) { p.flashlightController.hideFlashlight = false; } Plugin.Log.LogInfo((object)("SCP-330: " + p.playerName + " died; their arms come back when they're revived.")); } private static void Revived(PlayerAvatar p) { dead.Remove(p); if (arms.TryGetValue(p, out var value)) { foreach (Renderer item in value) { if (Object.op_Implicit((Object)(object)item)) { item.enabled = true; } } } arms.Remove(p); } internal static void Sever(PlayerAvatar p) { Get(); NewLevelCheck(); handless.Add(p); if (p.isLocal && Object.op_Implicit((Object)(object)p.physGrabber) && Object.op_Implicit((Object)(object)p.physGrabber.grabbedPhysGrabObject)) { p.physGrabber.ReleaseObject(p.physGrabber.grabbedPhysGrabObject.photonView.ViewID, 1f); } PopArms(p); } internal static MeshRenderer ArmRenderer(PlayerAvatar p, int side) { if (!Object.op_Implicit((Object)(object)p) || !Object.op_Implicit((Object)(object)p.playerAvatarVisuals)) { return null; } Transform[] componentsInChildren = ((Component)p.playerAvatarVisuals).GetComponentsInChildren<Transform>(true); foreach (Transform val in componentsInChildren) { if (((Object)val).name != ArmRoots[side]) { continue; } MeshRenderer[] componentsInChildren2 = ((Component)val).GetComponentsInChildren<MeshRenderer>(true); foreach (MeshRenderer val2 in componentsInChildren2) { if (((Object)val2).name.StartsWith("mesh_arm")) { return val2; } } } return null; } private static void PopArms(PlayerAvatar p) { //IL_00b0: 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_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: 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_00be: 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_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_0179: 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_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_01b7: 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) if (!Object.op_Implicit((Object)(object)p) || !Object.op_Implicit((Object)(object)p.playerAvatarVisuals) || arms.ContainsKey(p)) { return; } List<Renderer> list = new List<Renderer>(); Transform[] componentsInChildren = ((Component)p.playerAvatarVisuals).GetComponentsInChildren<Transform>(true); foreach (Transform val in componentsInChildren) { if (Array.IndexOf(ArmRoots, ((Object)val).name) >= 0) { list.AddRange(((Component)val).GetComponentsInChildren<Renderer>(true)); } } if (SemiFunc.IsMasterClientOrSingleplayer() && CandyValuables.ArmPrefab != null) { for (int j = 0; j < 2; j++) { MeshRenderer val2 = ArmRenderer(p, j); Vector3 val3; if (!Object.op_Implicit((Object)(object)val2)) { val3 = ((Component)p).transform.position + Vector3.up; } else { Bounds bounds = ((Renderer)val2).bounds; val3 = ((Bounds)(ref bounds)).center; } Vector3 val4 = val3; Quaternion val5 = (Object.op_Implicit((Object)(object)val2) ? ((Component)val2).transform.rotation : ((Component)p).transform.rotation); GameObject val6 = NetworkPrefabs.SpawnNetworkPrefab(CandyValuables.ArmPrefab, val4, val5, (byte)0, new object[2] { p.photonView.ViewID, j }); if (Object.op_Implicit((Object)(object)val6)) { SeveredArm component = val6.GetComponent<SeveredArm>(); if (Object.op_Implicit((Object)(object)component)) { component.Dress(p.photonView.ViewID, j); } Rigidbody component2 = val6.GetComponent<Rigidbody>(); if (Object.op_Implicit((Object)(object)component2)) { component2.linearVelocity = ((Component)p).transform.right * ((j == 0) ? (-1f) : 1f) * Random.Range(2.5f, 4f) + Vector3.up * Random.Range(2.5f, 4f); component2.angularVelocity = Random.insideUnitSphere * 12f; } } } } arms[p] = list; foreach (Renderer item in list) { if (Object.op_Implicit((Object)(object)item)) { item.enabled = false; } } } internal static void HostApply(PlayerAvatar p, Candy c) { if (Object.op_Implicit((Object)(object)p) && Object.op_Implicit((Object)(object)p.playerHealth)) { if (c == Candy.Red || c == Candy.Rainbow) { p.playerHealth.HealOther(Plugin.BowlRedHeal.Value, true); } if (c == Candy.Green || c == Candy.Rainbow) { ((MonoBehaviour)Get()).StartCoroutine(Regen(p)); } } } private static IEnumerator Regen(PlayerAvatar p) { for (int i = 0; i < 8; i++) { yield return (object)new WaitForSeconds(2.5f); if (!Object.op_Implicit((Object)(object)p) || p.isDisabled || !Object.op_Implicit((Object)(object)p.playerHealth)) { break; } p.playerHealth.HealOther(Mathf.Max(1, Mathf.RoundToInt((float)Plugin.BowlGreenHeal.Value / 8f)), true); } } internal static void PinkBoom(PlayerAvatar p) { ((MonoBehaviour)Get()).StartCoroutine(Get().Pink(p)); } private IEnumerator Pink(PlayerAvatar player) { if (player.isLocal && Object.op_Implicit((Object)(object)ItemInfoUI.instance)) { ItemInfoUI.instance.ItemInfoText((ItemAttributes)null, "...that candy was pink.", false); } yield return (object)new WaitForSeconds(1.2f); if (!Object.op_Implicit((Object)(object)player)) { yield break; } if (!Object.op_Implicit((Object)(object)boom)) { GameObject val = Resources.Load<GameObject>("Items/Item Rubber Duck"); ParticleScriptExplosion val2 = (Object.op_Implicit((Object)(object)val) ? val.GetComponentInChildren<ParticleScriptExplosion>(true) : null); if (Object.op_Implicit((Object)(object)val2)) { boom = ((Component)this).gameObject.AddComponent<ParticleScriptExplosion>(); FieldCopy.Values<ParticleScriptExplosion>(val2, boom); } } Vector3 val3 = (Object.op_Implicit((Object)(object)player.PlayerVisionTarget) ? player.PlayerVisionTarget.VisionTransform.position : ((Component)player).transform.position); if (Object.op_Implicit((Object)(object)boom)) { boom.playerCausingHurtOverride = player; ParticlePrefabExplosion val4 = boom.Spawn(val3, 0.8f, Plugin.BowlPinkDamage.Value, Plugin.BowlPinkDamage.Value * 3, 1.5f, false, false, 1f, 0f); if (Object.op_Implicit((Object)(object)val4) && Object.op_Implicit((Object)(object)val4.HurtCollider)) { val4.HurtCollider.playerKill = true; } } if (SemiFunc.IsMasterClientOrSingleplayer() && Object.op_Implicit((Object)(object)player.playerHealth) && !player.isDisabled) { player.playerHealth.HurtOther(9999, val3, false, -1, false); } } internal static void LocalApply(Candy c) { CandyEffects candyEffects = Get(); if (c == Candy.Yellow || c == Candy.Rainbow) { candyEffects.speedLeft = 12f; } if (c == Candy.Blue || c == Candy.Rainbow) { candyEffects.invincibleLeft = 6f; PlayerAvatar val = (Object.op_Implicit((Object)(object)PlayerController.instance) ? PlayerController.instance.playerAvatarScript : null); if (Object.op_Implicit((Object)(object)val) && Object.op_Implicit((Object)(object)val.playerHealth)) { val.playerHealth.InvincibleSet(6f); } } if (Object.op_Implicit((Object)(object)ItemInfoUI.instance)) { ItemInfoUI.instance.ItemInfoText((ItemAttributes)null, "SCP-330 " + c switch { Candy.Blue => "blue: untouchable for a moment", Candy.Yellow => "yellow: sugar rush", Candy.Green => "green: healing slowly", Candy.Red => "red: patched up", _ => "rainbow: a bit of everything", }, false); } } private void Update() { NewLevelCheck(); PlayerController val = PlayerController.instance; PlayerAvatar val2 = (Object.op_Implicit((Object)(object)val) ? val.playerAvatarScript : null); if (Object.op_Implicit((Object)(object)val) && speedLeft > 0f) { speedLeft -= Time.deltaTime; val.OverrideSpeed(1.4f, 0.2f, -1f); val.EnergyCurrent = val.EnergyStart; } if (invincibleLeft > 0f) { invincibleLeft -= Time.deltaTime; } if (dead.Count > 0) { dead.RemoveWhere((PlayerAvatar p) => !Object.op_Implicit((Object)(object)p)); List<PlayerAvatar> list = null; foreach (PlayerAvatar item in dead) { if (!item.deadSet && !item.isDisabled) { (list ?? (list = new List<PlayerAvatar>())).Add(item); } } if (list != null) { foreach (PlayerAvatar item2 in list) { Revived(item2); } } } if (handless.Count == 0) { return; } handless.RemoveWhere((PlayerAvatar p) => !Object.op_Implicit((Object)(object)p)); List<PlayerAvatar> list2 = null; foreach (PlayerAvatar item3 in handless) { if (item3.deadSet || item3.isDisabled) { (list2 ?? (list2 = new List<PlayerAvatar>())).Add(item3); } } if (list2 != null) { foreach (PlayerAvatar item4 in list2) { Died(item4); } } foreach (PlayerAvatar item5 in handless) { if (arms.TryGetValue(item5, out var value)) { foreach (Renderer item6 in value) { if (Object.op_Implicit((Object)(object)item6) && item6.enabled) { item6.enabled = false; } } } if (Object.op_Implicit((Object)(object)item5.flashlightController)) { item5.flashlightController.hideFlashlight = true; } if ((Object)(object)item5 == (Object)(object)val2 && Object.op_Implicit((Object)(object)item5.physGrabber)) { item5.physGrabber.OverrideGrabDisable(0.5f); } } } } internal static class CandyValuables { public const string BowlName = "Valuable SCP-330 Bowl"; private static readonly string[] BowlBases = new string[3] { "Valuables/03 Medium/Valuable Manor Trophy", "Valuables/03 Medium/Valuable Manor Bottle", "Valuables/03 Medium/Valuable Arctic Fan" }; private static readonly string[] CandyBases = new string[3] { "Valuables/02 Small/Valuable Wizard Love Potion", "Valuables/02 Small/Valuable Museum Car", "Valuables/02 Small/Valuable Golden Pumpkin Small" }; internal static PrefabRef BowlPrefab; internal static PrefabRef ArmPrefab; internal static readonly Dictionary<Candy, PrefabRef> CandyPrefabs = new Dictionary<Candy, PrefabRef>(); internal static AudioClip Eat; internal static AudioClip Crunch; internal static AudioClip Grab; internal static AudioClip Red; internal static AudioClip Green; internal static AudioClip Rainbow; internal static AudioClip Evil; public static void BuildAndRegister() { //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Expected O, but got Unknown //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_017b: 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_0286: Unknown result type (might be due to invalid IL or missing references) //IL_028b: Unknown result type (might be due to invalid IL or missing references) //IL_0297: Unknown result type (might be due to invalid IL or missing references) //IL_02a9: Unknown result type (might be due to invalid IL or missing references) //IL_036f: Unknown result type (might be due to invalid IL or missing references) Eat = SlAssets.LoadSound("scp330_eat"); Crunch = SlAssets.LoadSound("scp330_crunch"); Grab = SlAssets.LoadSound("scp330_grab"); Red = SlAssets.LoadSound("scp330_red"); Green = SlAssets.LoadSound("scp330_green"); Rainbow = SlAssets.LoadSound("scp330_rainbow"); Evil = SlAssets.LoadSound("scp330_evil"); GameObject val = new GameObject("SCPItems Prefabs 330"); val.SetActive(false); ((Object)val).hideFlags = (HideFlags)61; Object.DontDestroyOnLoad((Object)(object)val); Texture2D albedo = SlAssets.LoadTexture("scp330_candy_albedo"); Texture2D normal = SlAssets.LoadTexture("scp330_candy_normal", linear: true); foreach (Candy value in Enum.GetValues(typeof(Candy))) { string text = value.ToString().ToLowerInvariant(); Material baseMat; BoxCollider box; GameObject val2 = CloneValuable(CandyBases, "Valuable SCP-330 Candy " + value, val.transform, out baseMat, out box); Build.Feel(val2, "Light", "Strong+", "Pill bottle"); Mesh val3 = SlAssets.LoadMesh("scp330_" + text); AddModel(val2.transform, val3, SlAssets.MakeMaterial(baseMat, "SCP-330 Candy", albedo, normal)); Bounds bounds = val3.bounds; ((Bounds)(ref bounds)).size = Vector3.Max(((Bounds)(ref bounds)).size * 1.3f, Vector3.one * 0.09f); FitBox(box, bounds, 1f); SetValue(val2, (Type)0, Plugin.CandyValueMin.Value, Plugin.CandyValueMax.Value, "SCP-330 Candy"); PhysGrabObjectImpactDetector component = val2.GetComponent<PhysGrabObjectImpactDetector>(); if (Object.op_Implicit((Object)(object)component)) { component.isIndestructible = true; component.destroyDisable = true; component.indestructibleBreakEffects = false; } val2.AddComponent<CandyValuable>().kind = value; PrefabRef val4 = NetworkPrefabs.RegisterNetworkPrefab("Valuables/" + ((Object)val2).name, val2); if (val4 == null) { throw new Exception($"REPOLib refused to register the {value} candy."); } CandyPrefabs[value] = val4; } Material baseMat2; BoxCollider box2; GameObject val5 = CloneValuable(CandyBases, "Valuable Severed Arm", val.transform, out baseMat2, out box2); Build.Feel(val5, "Light++", "Strong", "Flesh Small"); GameObject val6 = new GameObject("SL Model") { layer = val5.layer }; val6.transform.SetParent(val5.transform, false); val6.AddComponent<MeshFilter>(); val6.AddComponent<MeshRenderer>(); SetValue(val5, (Type)1, Plugin.ArmValueMin.Value, Plugin.ArmValueMax.Value, "Severed Arm"); val5.AddComponent<SeveredArm>().box = box2; ArmPrefab = NetworkPrefabs.RegisterNetworkPrefab("Valuables/" + ((Object)val5).name, val5); Material baseMat3; BoxCollider box3; GameObject val7 = CloneValuable(BowlBases, "Valuable SCP-330 Bowl", val.transform, out baseMat3, out box3); Build.Feel(val7, "Medium", "Default", "Ceramic Medium"); Mesh val8 = SlAssets.LoadMesh("scp330_bowl"); AddModel(val7.transform, val8, SlAssets.MakeMaterial(baseMat3, "SCP-330 Bowl", SlAssets.LoadTexture("scp330_bowl_albedo"), SlAssets.LoadTexture("scp330_bowl_normal", linear: true))); BuildBowlColliders(box3, val8.bounds); SetValue(val7, (Type)2, Plugin.BowlValueMin.Value, Plugin.BowlValueMax.Value, "SCP-330 Bowl"); val7.AddComponent<BowlValuable>(); if (Plugin.BowlSpawns.Value) { BowlPrefab = Valuables.RegisterValuable(val7); if (BowlPrefab == null) { throw new Exception("REPOLib refused to register the SCP-330 bowl."); } } else { BowlPrefab = NetworkPrefabs.RegisterNetworkPrefab("Valuables/" + ((Object)val7).name, val7); } Plugin.Log.LogInfo((object)"Registered SCP-330 (bowl and candies)."); } internal static GameObject CloneValuable(string[] bases, string name, Transform holder, out Material baseMat, out BoxCollider box) { //IL_019e: Unknown result type (might be due to invalid IL or missing references) //IL_01a3: Unknown result type (might be due to invalid IL or missing references) //IL_01af: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: Unknown result type (might be due to invalid IL or missing references) GameObject val = null; for (int i = 0; i < bases.Length; i++) { val = Resources.Load<GameObject>(bases[i]); if (Object.op_Implicit((Object)(object)val) && Object.op_Implicit((Object)(object)val.GetComponent<ValuableObject>())) { break; } } if (!Object.op_Implicit((Object)(object)val)) { throw new Exception("No vanilla valuable to build on (looked for " + string.Join(", ", bases) + ")."); } GameObject val2 = Object.Instantiate<GameObject>(val, holder); ((Object)val2).name = name; MonoBehaviour[] componentsInChildren = val2.GetComponentsInChildren<MonoBehaviour>(true); foreach (MonoBehaviour val3 in componentsInChildren) { if (Object.op_Implicit((Object)(object)val3) && !(val3 is ValuableObject) && ((object)val3).GetType().Name.StartsWith("Valuable")) { Object.DestroyImmediate((Object)(object)val3); } } baseMat = null; Renderer[] componentsInChildren2 = val2.GetComponentsInChildren<Renderer>(true); foreach (Renderer val4 in componentsInChildren2) { if (!Object.op_Implicit((Object)(object)baseMat) && val4 is MeshRenderer) { baseMat = val4.sharedMaterial; } val4.enabled = false; } Light[] componentsInChildren3 = val2.GetComponentsInChildren<Light>(true); for (int i = 0; i < componentsInChildren3.Length; i++) { ((Behaviour)componentsInChildren3[i]).enabled = false; } box = null; Collider[] componentsInChildren4 = val2.GetComponentsInChildren<Collider>(true); foreach (Collider val5 in componentsInChildren4) { if (!Object.op_Implicit((Object)(object)box)) { BoxCollider val6 = (BoxCollider)(object)((val5 is BoxCollider) ? val5 : null); if (val6 != null) { box = val6; continue; } } val5.enabled = false; } if (!Object.op_Implicit((Object)(object)box)) { throw new Exception("\"" + ((Object)val).name + "\" has no box collider to reuse."); } if ((Object)(object)((Component)box).gameObject == (Object)(object)val2) { GameObject val7 = new GameObject("Valuable Box Collider") { layer = val2.layer, tag = val2.tag }; val7.transform.SetParent(val2.transform, false); BoxCollider val8 = val7.AddComponent<BoxCollider>(); ((Collider)val8).sharedMaterial = ((Collider)box).sharedMaterial; ((Collider)box).enabled = false; box = val8; } else { ((Component)box).transform.SetParent(val2.transform, false); } return val2; } private static void AddModel(Transform parent, Mesh mesh, Material mat) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("SL Model") { layer = ((Component)parent).gameObject.layer }; val.transform.SetParent(parent, false); val.AddComponent<MeshFilter>().sharedMesh = mesh; ((Renderer)val.AddComponent<MeshRenderer>()).sharedMaterial = mat; } internal static void FitBox(BoxCollider box, Bounds b, float shrink) { //IL_0007: 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_001c: 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_0036: 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) Transform transform = ((Component)box).transform; transform.localPosition = Vector3.zero; transform.localRotation = Quaternion.identity; transform.localScale = Vector3.one; box.center = ((Bounds)(ref b)).center; box.size = ((Bounds)(ref b)).size * shrink; } private static void BuildBowlColliders(BoxCollider template, Bounds b) { //IL_0002: 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_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_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_00b5: 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_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: 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_0122: 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_013e: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_018a: Unknown result type (might be due to invalid IL or missing references) float x = ((Bounds)(ref b)).size.x; float y = ((Bounds)(ref b)).size.y; float z = ((Bounds)(ref b)).size.z; FitBox(template, new Bounds(new Vector3(0f, 0.015f, 0f), new Vector3(x * 0.55f, 0.03f, z * 0.55f)), 1f); Bounds[] array = (Bounds[])(object)new Bounds[4] { new Bounds(new Vector3(x * 0.42f, y * 0.5f, 0f), new Vector3(0.03f, y, z * 0.75f)), new Bounds(new Vector3((0f - x) * 0.42f, y * 0.5f, 0f), new Vector3(0.03f, y, z * 0.75f)), new Bounds(new Vector3(0f, y * 0.5f, z * 0.42f), new Vector3(x * 0.75f, y, 0.03f)), new Bounds(new Vector3(0f, y * 0.5f, (0f - z) * 0.42f), new Vector3(x * 0.75f, y, 0.03f)) }; foreach (Bounds b2 in array) { GameObject obj = Object.Instantiate<GameObject>(((Component)template).gameObject, ((Component)template).transform.parent, false); ((Object)obj).name = ((Object)((Component)template).gameObject).name + " (wall)"; FitBox(obj.GetComponent<BoxCollider>(), b2, 1f); } } internal static void SetValue(GameObject go, Type volume, int min, int max, string label) { //IL_0007: 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) ValuableObject component = go.GetComponent<ValuableObject>(); component.volumeType = volume; Value val = ScriptableObject.CreateInstance<Value>(); ((Object)val).name = "Value - " + label; val.valueMin = min; val.valueMax = Mathf.Max(min, max); Object.DontDestroyOnLoad((Object)(object)val); component.valuePreset = val; } } internal class BowlTestSpawner : MonoBehaviour { private LevelGenerator done; private void Update() { LevelGenerator instance = LevelGenerator.Instance; if ((Plugin.SpawnBowlAtStart.Value || Plugin.SpawnLootAtStart.Value) && Object.op_Implicit((Object)(object)instance) && instance.Generated && !((Object)(object)instance == (Object)(object)done)) { done = instance; if (SemiFunc.IsMasterClientOrSingleplayer() && SemiFunc.RunIsLevel()) { ((MonoBehaviour)this).StartCoroutine(Spawn()); } } } private IEnumerator Spawn() { yield return (object)new WaitForSeconds(3f); PlayerController me = PlayerController.instance; if (!Object.op_Implicit((Object)(object)me)) { yield break; } Vector3 val = ((Component)me).transform.position + ((Component)me).transform.forward * 1.2f + Vector3.up * 0.3f; if (Plugin.SpawnBowlAtStart.Value && CandyValuables.BowlPrefab != null) { Valuables.SpawnValuable(CandyValuables.BowlPrefab, val, Quaternion.Euler(0f, ((Component)me).transform.eulerAngles.y, 0f)); } if (Plugin.SpawnLootAtStart.Value) { for (int i = 0; i < Build.TestLoot.Count; i++) { float num = (float)(i + 1) * MathF.PI * 2f / (float)(Build.TestLoot.Count + 1); Vector3 val2 = Quaternion.Euler(0f, num * 57.29578f, 0f) * ((Component)me).transform.forward; Vector3 val3 = ((Component)me).transform.position + val2 * 2.5f + Vector3.up * 0.4f; Valuables.SpawnValuable(Build.TestLoot[i], val3, Quaternion.LookRotation(-val2)); yield return (object)new WaitForSeconds(0.1f); } } } } internal class BowlValuable : MonoBehaviour { private struct Seat { public PhysGrabObject candy; public Vector3 pos; public Quaternion rot; } private readonly List<Seat> seats = new List<Seat>(); private void Start() { if (SemiFunc.IsMasterClientOrSingleplayer() && SemiFunc.RunIsLevel()) { ((MonoBehaviour)this).StartCoroutine(Fill()); } } private void FixedUpdate() { //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: 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_00d7: Unknown result type (might be due to invalid IL or missing references) if (seats.Count == 0 || !SemiFunc.IsMasterClientOrSingleplayer()) { return; } for (int num = seats.Count - 1; num >= 0; num--) { Seat seat = seats[num]; if (!Object.op_Implicit((Object)(object)seat.candy) || seat.candy.dead || seat.candy.grabbed || seat.candy.playerGrabbing.Count > 0) { Release(seat.candy); seats.RemoveAt(num); } else { seat.candy.rb.isKinematic = true; seat.candy.rb.MovePosition(((Component)this).transform.TransformPoint(seat.pos)); seat.candy.rb.MoveRotation(((Component)this).transform.rotation * seat.rot); } } } private void OnDestroy() { foreach (Seat seat in seats) { Release(seat.candy); } seats.Clear(); } private void IgnoreBowl(PhysGrabObject candy, bool ignore) { if (!Object.op_Implicit((Object)(object)candy)) { return; } Collider[] componentsInChildren = ((Component)this).GetComponentsInChildren<Collider>(); Collider[] componentsInChildren2 = ((Component)candy).GetComponentsInChildren<Collider>(); foreach (Collider val in componentsInChildren2) { Collider[] array = componentsInChildren; foreach (Collider val2 in array) { if (Object.op_Implicit((Object)(object)val) && Object.op_Implicit((Object)(object)val2)) { Physics.IgnoreCollision(val, val2, ignore); } } } } private void Release(PhysGrabObject candy) { if (Object.op_Implicit((Object)(object)candy)) { IgnoreBowl(candy, ignore: false); if (Object.op_Implicit((Object)(object)candy.rb)) { candy.rb.isKinematic = false; candy.rb.detectCollisions = true; } } } private IEnumerator Fill() { while (!Object.op_Implicit((Object)(object)LevelGenerator.Instance) || !LevelGenerator.Instance.Generated) { yield return (object)new WaitForSeconds(0.25f); } yield return (object)new WaitForSeconds(0.5f); int count = Random.Range(Plugin.BowlCandiesMin.Value, Mathf.Max(Plugin.BowlCandiesMin.Value, Plugin.BowlCandiesMax.Value) + 1); Vector3 val = default(Vector3); for (int i = 0; i < count; i++) { float num = (float)i * 2.4f; float num2 = 0.05f + 0.07f * ((float)(i % 3) / 2f); ((Vector3)(ref val))..ctor(Mathf.Cos(num) * num2, 0.05f + (float)(i / 3) * 0.04f, Mathf.Sin(num) * num2); Quaternion val2 = Quaternion.Euler(Random.Range(-25f, 25f), Random.Range(0f, 360f), Random.Range(-25f, 25f)); Candy key = Roll(); if (CandyValuables.CandyPrefabs.TryGetValue(key, out var value)) { GameObject val3 = Valuables.SpawnValuable(value, ((Component)this).transform.TransformPoint(val), ((Component)this).transform.rotation * val2); PhysGrabObject val4 = (Object.op_Implicit((Object)(object)val3) ? val3.GetComponent<PhysGrabObject>() : null); if (Object.op_Implicit((Object)(object)val4)) { IgnoreBowl(val4, ignore: true); seats.Add(new Seat { candy = val4, pos = val, rot = val2 }); } yield return (object)new WaitForSeconds(0.05f); } } } private static Candy Roll() { if (Random.value < Plugin.BowlPinkChance.Value) { return Candy.Pink; } float value = Random.value; if (!(value < 0.24f)) { if (!(value < 0.48f)) { if (!(value < 0.72f)) { if (!(value < 0.92f)) { return Candy.Rainbow; } return Candy.Blue; } return Candy.Yellow; } return Candy.Green; } return Candy.Red; } } internal class CandyValuable : MonoBehaviour { public Candy kind; private PhotonView photonView; private PhysGrabObject physGrabObject; private PhysGrabObjectImpactDetector impact; private float heldTime; private float requestCooldown; private bool eaten; private static readonly List<CandyValuable> all = new List<CandyValuable>(); private Collider[] cols; internal static string Name(Candy c) { if (c != Candy.Rainbow) { return c.ToString() + " Candy"; } return "Rainbow Candy"; } private void Awake() { photonView = ((Component)this).GetComponent<PhotonView>(); physGrabObject = ((Component)this).GetComponent<PhysGrabObject>(); impact = ((Component)this).GetComponent<PhysGrabObjectImpactDetector>(); if (Object.op_Implicit((Object)(object)impact)) { impact.isIndestructible = true; impact.destroyDisable = true; impact.indestructibleBreakEffects = false; } } private void Start() { cols = ((Component)this).GetComponentsInChildren<Collider>(true); all.RemoveAll((CandyValuable c) => !Object.op_Implicit((Object)(object)c)); foreach (CandyValuable item in all) { Collider[] array = cols; foreach (Collider val in array) { Collider[] array2 = item.cols; foreach (Collider val2 in array2) { if (Object.op_Implicit((Object)(object)val) && Object.op_Implicit((Object)(object)val2)) { Physics.IgnoreCollision(val, val2, true); } } } } all.Add(this); } private void OnDestroy() { all.Remove(this); } private void Update() { //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) if (requestCooldown > 0f) { requestCooldown -= Time.deltaTime; } if (eaten || !Object.op_Implicit((Object)(object)physGrabObject) || !physGrabObject.grabbedLocal) { heldTime = 0f; return; } heldTime += Time.deltaTime; if (Object.op_Implicit((Object)(object)ItemInfoUI.instance)) { ItemInfoUI.instance.ItemInfoText((ItemAttributes)null, Build.UseTag(Name(kind)), false); } PlayerController instance = PlayerController.instance; if (!(requestCooldown > 0f) && Object.op_Implicit((Object)(object)instance) && !(instance.InputDisableTimer > 0f) && SemiFunc.InputDown((InputKey)2)) { requestCooldown = 1f; int viewID = instance.playerAvatarScript.photonView.ViewID; if (SemiFunc.IsMultiplayer()) { photonView.RPC("EatRequestRPC", (RpcTarget)2, new object[1] { viewID }); } else { EatRequestRPC(viewID); } } } [PunRPC] private void EatRequestRPC(int playerViewID, PhotonMessageInfo info = default(PhotonMessageInfo)) { //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) if (!SemiFunc.IsMasterClientOrSingleplayer() || eaten) { return; } PlayerAvatar val = SemiFunc.PlayerAvatarGetFromPhotonID(playerViewID); if (!Object.op_Implicit((Object)(object)val) || val.isDisabled || CandyEffects.IsHandless(val)) { return; } eaten = true; if (CandyEffects.HostTake(val) > Plugin.BowlSafeCandies.Value) { if (SemiFunc.IsMultiplayer()) { photonView.RPC("HandsRPC", (RpcTarget)0, new object[1] { playerViewID }); } else { HandsRPC(playerViewID); } if (Object.op_Implicit((Object)(object)val.playerHealth)) { val.playerHealth.HurtOther(Plugin.BowlGreedDamage.Value, ((Component)val).transform.position, false, -1, false); } } else { if (SemiFunc.IsMultiplayer()) { photonView.RPC("EatRPC", (RpcTarget)0, new object[2] { playerViewID, (int)kind }); } else { EatRPC(playerViewID, (int)kind); } CandyEffects.HostApply(val, kind); } if (Object.op_Implicit((Object)(object)impact)) { impact.DestroyObject(false, true); } else { physGrabObject.DestroyPhysGrabObject(); } } [PunRPC] private void EatRPC(int playerViewID, int candy, PhotonMessageInfo info = default(PhotonMessageInfo)) { //IL_0000: 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_0096: Unknown result type (might be due to invalid IL or missing references) if (!SemiFunc.MasterOnlyRPC(info)) { return; } eaten = true; PlayerAvatar val = SemiFunc.PlayerAvatarGetFromPhotonID(playerViewID); if (Object.op_Implicit((Object)(object)val)) { SlAssets.Play((Random.value < 0.5f) ? CandyValuables.Eat : CandyValuables.Crunch, ((Component)val).transform.position, ((Component)val).transform, 0.9f); AudioClip val2 = (AudioClip)(candy switch { 5 => CandyValuables.Evil, 4 => CandyValuables.Rainbow, 1 => CandyValuables.Green, 0 => CandyValuables.Red, _ => null, }); if (Object.op_Implicit((Object)(object)val2)) { SlAssets.Play(val2, ((Component)val).transform.position, ((Component)val).transform, 0.7f); } if (candy == 5) { CandyEffects.PinkBoom(val); } else if (val.isLocal) { CandyEffects.LocalApply((Candy)candy); } } } [PunRPC] private void HandsRPC(int playerViewID, PhotonMessageInfo info = default(PhotonMessageInfo)) { //IL_0000: 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) if (!SemiFunc.MasterOnlyRPC(info)) { return; } eaten = true; PlayerAvatar val = SemiFunc.PlayerAvatarGetFromPhotonID(playerViewID); if (Object.op_Implicit((Object)(object)val)) { SlAssets.Play(CandyValuables.Crunch, ((Component)val).transform.position, ((Component)val).transform); if (val.isLocal && Object.op_Implicit((Object)(object)ItemInfoUI.instance)) { ItemInfoUI.instance.ItemInfoText((ItemAttributes)null, "You took more than two.", false); } CandyEffects.Sever(val); } } } internal static class FieldCopy { internal static void Values<T>(T from, T to) where T : Component { FieldInfo[] fields = typeof(T).GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); foreach (FieldInfo fieldInfo in fields) { if (fieldInfo.IsLiteral || fieldInfo.IsInitOnly) { continue; } object value = fieldInfo.GetValue(from); Object val = (Object)((value is Object) ? value : null); if (val != null) { if (Object.op_Implicit(val) && !(val is Component) && !(val is GameObject)) { fieldInfo.SetValue(to, value); } } else if (fieldInfo.FieldType.IsValueType || fieldInfo.FieldType == typeof(string)) { fieldInfo.SetValue(to, value); } } } } internal class SeveredArm : MonoBehaviour { public BoxCollider box; private bool dressed; private static readonly int HurtAmount = Shader.PropertyToID("_ColorOverlayAmount"); private Material[] ownMats; private void Start() { PhotonView component = ((Component)this).GetComponent<PhotonView>(); object[] array = ((component != null) ? component.InstantiationData : null); if (array != null && array.Length >= 2) { Dress((int)array[0], (int)array[1]); } } internal void Dress(int playerViewID, int side) { //IL_00bd: 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_0073: Expected O, but got Unknown //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: 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_0110: 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_011f: 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_013e: Unknown result type (might be due to invalid IL or missing references) if (dressed) { return; } MeshRenderer val = CandyEffects.ArmRenderer(SemiFunc.PlayerAvatarGetFromPhotonID(playerViewID), side); if (!Object.op_Implicit((Object)(object)val)) { return; } dressed = true; Transform val2 = ((Component)this).transform.Find("SL Model"); MeshFilter component = ((Component)val).GetComponent<MeshFilter>(); ((Component)val2).GetComponent<MeshFilter>().sharedMesh = component.sharedMesh; Material[] sharedMaterials = ((Renderer)val).sharedMaterials; for (int i = 0; i < sharedMaterials.Length; i++) { if (Object.op_Implicit((Object)(object)sharedMaterials[i])) { sharedMaterials[i] = new Material(sharedMaterials[i]); if (sharedMaterials[i].HasProperty(HurtAmount)) { sharedMaterials[i].SetFloat(HurtAmount, 0f); } } } ((Renderer)((Component)val2).GetComponent<MeshRenderer>()).sharedMaterials = sharedMaterials; ownMats = sharedMaterials; val2.localScale = ((Component)val).transform.lossyScale; if (Object.op_Implicit((Object)(object)box)) { Bounds bounds = component.sharedMesh.bounds; Bounds b = default(Bounds); ((Bounds)(ref b))..ctor(Vector3.Scale(((Bounds)(ref bounds)).center, val2.localScale), Vector3.Scale(((Bounds)(ref bounds)).size, val2.localScale)); ((Bounds)(ref b)).size = Vector3.Max(((Bounds)(ref b)).size * 1.2f, Vector3.one * 0.08f); CandyValuables.FitBox(box, b, 1f); } } private void OnDestroy() { if (ownMats == null) { return; } Material[] array = ownMats; foreach (Material val in array) { if (Object.op_Implicit((Object)(object)val)) { Object.Destroy((Object)(object)val); } } } } internal static class CapBuilder { private const string BaseResourcePath = "Items/Item Health Pack Small"; public const string PrefabName = "Item SCP 268"; public const string ModelName = "SCP-268 Model"; public const float Width = 0.55f; internal static float Scale { get { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) Bounds bounds = CapModel.Mesh.bounds; return 0.55f / Mathf.Max(0.01f, ((Bounds)(ref bounds)).size.x); } } public static void BuildAndRegister() { //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Expected O, but got Unknown //IL_016b: Unknown result type (might be due to invalid IL or missing references) //IL_0170: Unknown result type (might be due to invalid IL or missing references) //IL_01a4: Unknown result type (might be due to invalid IL or missing references) //IL_01a9: Unknown result type (might be due to invalid IL or missing references) //IL_01b0: Unknown result type (might be due to invalid IL or missing references) //IL_01b5: Unknown result type (might be due to invalid IL or missing references) //IL_01bc: Unknown result type (might be due to invalid IL or missing references) //IL_01ce: Unknown result type (might be due to invalid IL or missing references) //IL_01d6: 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_01f6: Unknown result type (might be due to invalid IL or missing references) //IL_0204: Unknown result type (might be due to invalid IL or missing references) //IL_020e: Unknown result type (might be due to invalid IL or missing references) //IL_0214: Unknown result type (might be due to invalid IL or missing references) //IL_021b: Unknown result type (might be due to invalid IL or missing re