using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using Photon.Pun; using REPOLib.Modules; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("Empress")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+5f1b735e473ca4ccf3b383128fbebd889cb564da")] [assembly: AssemblyProduct("SuperBattleGolfValuables")] [assembly: AssemblyTitle("SuperBattleGolfValuables")] [assembly: AssemblyVersion("1.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace Empress.REPO.SuperBattleGolfValuables { internal static class RepoValuableAccess { private delegate void PlayerHealthHurtOtherDelegate(PlayerHealth instance, int damage, Vector3 hurtPosition, bool savingGrace, int enemyIndex, bool hurtByHeal); private delegate void PlayerTumbleRequestDelegate(PlayerTumble instance, bool isTumbling, bool playerInput); private delegate void PlayerTumbleOverrideTimeDelegate(PlayerTumble instance, float time); private delegate void EnemyHealthHurtDelegate(EnemyHealth instance, int damage, Vector3 hurtDirection); private delegate void ImpactDestroyObjectDelegate(PhysGrabObjectImpactDetector instance, bool effects); private static readonly FieldRef RunManagerInstanceRef = AccessTools.StaticFieldRefAccess(RequiredField(typeof(RunManager), "instance")); private static readonly FieldRef> TinyRef = AccessTools.FieldRefAccess>("tiny"); private static readonly FieldRef> SmallRef = AccessTools.FieldRefAccess>("small"); private static readonly FieldRef> MediumRef = AccessTools.FieldRefAccess>("medium"); private static readonly FieldRef> BigRef = AccessTools.FieldRefAccess>("big"); private static readonly FieldRef> WideRef = AccessTools.FieldRefAccess>("wide"); private static readonly FieldRef> TallRef = AccessTools.FieldRefAccess>("tall"); private static readonly FieldRef> VeryTallRef = AccessTools.FieldRefAccess>("veryTall"); private static readonly FieldRef ValuePresetRef = AccessTools.FieldRefAccess("valuePreset"); private static readonly FieldRef DurabilityPresetRef = AccessTools.FieldRefAccess("durabilityPreset"); private static readonly FieldRef PhysAttributePresetRef = AccessTools.FieldRefAccess("physAttributePreset"); private static readonly FieldRef VolumeTypeRef = AccessTools.FieldRefAccess("volumeType"); private static readonly FieldRef DollarValueOverrideRef = AccessTools.FieldRefAccess("dollarValueOverride"); private static readonly FieldRef DebugVolumeRef = AccessTools.FieldRefAccess("debugVolume"); private static readonly FieldRef ParticleColorsRef = AccessTools.FieldRefAccess("particleColors"); private static readonly FieldRef ValueMinRef = AccessTools.FieldRefAccess("valueMin"); private static readonly FieldRef ValueMaxRef = AccessTools.FieldRefAccess("valueMax"); private static readonly FieldRef FragilityRef = AccessTools.FieldRefAccess("fragility"); private static readonly FieldRef DurabilityRef = AccessTools.FieldRefAccess("durability"); private static readonly FieldRef MassRef = AccessTools.FieldRefAccess("mass"); private static readonly FieldRef GrabbedRef = AccessTools.FieldRefAccess("grabbed"); private static readonly FieldRef GrabbedLocalRef = AccessTools.FieldRefAccess("grabbedLocal"); private static readonly FieldRef HeldByLocalPlayerRef = AccessTools.FieldRefAccess("heldByLocalPlayer"); private static readonly FieldRef> PlayerGrabbingRef = AccessTools.FieldRefAccess>("playerGrabbing"); private static readonly FieldRef BreakLevelHeavyRef = AccessTools.FieldRefAccess("breakLevelHeavy"); private static readonly FieldRef BreakLevelMediumRef = AccessTools.FieldRefAccess("breakLevelMedium"); private static readonly FieldRef BreakLevelLightRef = AccessTools.FieldRefAccess("breakLevelLight"); private static readonly FieldRef PlayerIsDisabledRef = AccessTools.FieldRefAccess("isDisabled"); private static readonly FieldRef PlayerDeadSetRef = AccessTools.FieldRefAccess("deadSet"); private static readonly FieldRef PlayerHealthRef = AccessTools.FieldRefAccess("playerHealth"); private static readonly FieldRef PlayerTumbleRef = AccessTools.FieldRefAccess("tumble"); private static readonly FieldRef BoxColliderDrawGizmosRef = AccessTools.FieldRefAccess("drawGizmos"); private static readonly FieldRef MeshColliderShowGizmoRef = AccessTools.FieldRefAccess("showGizmo"); private static readonly PlayerHealthHurtOtherDelegate PlayerHealthHurtOtherRef = AccessTools.MethodDelegate(RequiredMethod(typeof(PlayerHealth), "HurtOther", typeof(int), typeof(Vector3), typeof(bool), typeof(int), typeof(bool)), (object)null, true); private static readonly PlayerTumbleRequestDelegate PlayerTumbleRequestRef = AccessTools.MethodDelegate(RequiredMethod(typeof(PlayerTumble), "TumbleRequest", typeof(bool), typeof(bool)), (object)null, true); private static readonly PlayerTumbleOverrideTimeDelegate PlayerTumbleOverrideTimeRef = AccessTools.MethodDelegate(RequiredMethod(typeof(PlayerTumble), "TumbleOverrideTime", typeof(float)), (object)null, true); private static readonly EnemyHealthHurtDelegate EnemyHealthHurtRef = AccessTools.MethodDelegate(RequiredMethod(typeof(EnemyHealth), "Hurt", typeof(int), typeof(Vector3)), (object)null, true); private static readonly ImpactDestroyObjectDelegate ImpactDestroyObjectRef = AccessTools.MethodDelegate(RequiredMethod(typeof(PhysGrabObjectImpactDetector), "DestroyObject", typeof(bool)), (object)null, true); public static RunManager? GetRunManagerInstance() { return RunManagerInstanceRef.Invoke(); } public static List GetList(LevelValuables preset, Type type) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected I4, but got Unknown return (int)type switch { 0 => TinyRef.Invoke(preset), 1 => SmallRef.Invoke(preset), 2 => MediumRef.Invoke(preset), 3 => BigRef.Invoke(preset), 4 => WideRef.Invoke(preset), 5 => TallRef.Invoke(preset), 6 => VeryTallRef.Invoke(preset), _ => MediumRef.Invoke(preset), }; } public static void ConfigureValuable(ValuableObject valuable, SuperBattleGolfValuableDefinition definition) { //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Expected I4, but got Unknown ValuePresetRef.Invoke(valuable) = CreateValuePreset(definition); DurabilityPresetRef.Invoke(valuable) = CreateDurabilityPreset(definition); PhysAttributePresetRef.Invoke(valuable) = CreatePhysAttributePreset(definition); VolumeTypeRef.Invoke(valuable) = (Type)(int)definition.VolumeType; DollarValueOverrideRef.Invoke(valuable) = 0; DebugVolumeRef.Invoke(valuable) = false; ParticleColorsRef.Invoke(valuable) = CreateParticleGradient(definition); } public static bool IsGrabbed(PhysGrabObject physGrabObject) { return GrabbedRef.Invoke(physGrabObject); } public static bool IsGrabbedForVoice(PhysGrabObject physGrabObject) { List list = PlayerGrabbingRef.Invoke(physGrabObject); if (!GrabbedRef.Invoke(physGrabObject) && !GrabbedLocalRef.Invoke(physGrabObject) && !HeldByLocalPlayerRef.Invoke(physGrabObject)) { if (list != null) { return list.Count > 0; } return false; } return true; } public static ImpactState GetBreakState(PhysGrabObjectImpactDetector detector, int breakLevel) { if (breakLevel != BreakLevelHeavyRef.Invoke(detector)) { if (breakLevel != BreakLevelMediumRef.Invoke(detector)) { if (breakLevel != BreakLevelLightRef.Invoke(detector)) { return (ImpactState)0; } return (ImpactState)1; } return (ImpactState)2; } return (ImpactState)3; } public static bool CanAffectPlayer(PlayerAvatar player) { if ((Object)(object)player != (Object)null && !PlayerIsDisabledRef.Invoke(player) && !PlayerDeadSetRef.Invoke(player)) { return (Object)(object)PlayerHealthRef.Invoke(player) != (Object)null; } return false; } public static void HurtPlayer(PlayerAvatar player, int damage) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) PlayerHealth val = PlayerHealthRef.Invoke(player); if ((Object)(object)val != (Object)null) { PlayerHealthHurtOtherRef(val, damage, Vector3.zero, savingGrace: false, -1, hurtByHeal: false); } } public static void TumblePlayer(PlayerAvatar player, float time) { PlayerTumble val = PlayerTumbleRef.Invoke(player); if (!((Object)(object)val == (Object)null)) { PlayerTumbleRequestRef(val, isTumbling: true, playerInput: false); PlayerTumbleOverrideTimeRef(val, time); } } public static void HurtEnemy(EnemyHealth enemyHealth, int damage, Vector3 hurtDirection) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)enemyHealth != (Object)null) { EnemyHealthHurtRef(enemyHealth, damage, hurtDirection); } } public static void DestroyImpactObject(PhysGrabObjectImpactDetector detector, bool effects) { if ((Object)(object)detector != (Object)null) { ImpactDestroyObjectRef(detector, effects); } } public static void HideGrabMeshColliderGizmo(PhysGrabObjectMeshCollider meshHelper) { if ((Object)(object)meshHelper != (Object)null) { MeshColliderShowGizmoRef.Invoke(meshHelper) = false; } } public static void HideGrabBoxColliderGizmo(PhysGrabObjectBoxCollider boxHelper) { if ((Object)(object)boxHelper != (Object)null) { BoxColliderDrawGizmosRef.Invoke(boxHelper) = false; } } private static Value CreateValuePreset(SuperBattleGolfValuableDefinition definition) { Value val = ScriptableObject.CreateInstance(); ((Object)val).hideFlags = (HideFlags)61; ((Object)val).name = "Value - " + definition.DisplayName; ValueMinRef.Invoke(val) = definition.ValueMin; ValueMaxRef.Invoke(val) = definition.ValueMax; return val; } private static Durability CreateDurabilityPreset(SuperBattleGolfValuableDefinition definition) { Durability val = ScriptableObject.CreateInstance(); ((Object)val).hideFlags = (HideFlags)61; ((Object)val).name = "Durability - " + definition.DisplayName; FragilityRef.Invoke(val) = Mathf.Clamp(definition.Fragility + StableJitter(definition.PrefabName, "fragility", 5.5f), 5f, 95f); DurabilityRef.Invoke(val) = Mathf.Clamp(definition.Durability + StableJitter(definition.PrefabName, "durability", 5.5f), 5f, 100f); return val; } private static PhysAttribute CreatePhysAttributePreset(SuperBattleGolfValuableDefinition definition) { PhysAttribute val = ScriptableObject.CreateInstance(); ((Object)val).hideFlags = (HideFlags)61; ((Object)val).name = "PhysAttribute - " + definition.DisplayName; MassRef.Invoke(val) = definition.Mass; return val; } private static float StableJitter(string name, string salt, float radius) { uint num = 2166136261u; string text = name + ":" + salt; for (int i = 0; i < text.Length; i++) { num ^= text[i]; num *= 16777619; } return ((float)(num & 0xFFFFu) / 65535f * 2f - 1f) * radius; } private static Gradient CreateParticleGradient(SuperBattleGolfValuableDefinition definition) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Expected O, but got Unknown //IL_0010: 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_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002d: 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_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_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_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008f: 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_00a5: Unknown result type (might be due to invalid IL or missing references) Gradient val = new Gradient(); val.SetKeys((GradientColorKey[])(object)new GradientColorKey[3] { new GradientColorKey(definition.Accent, 0f), new GradientColorKey(Color.Lerp(definition.Primary, definition.Secondary, 0.6f), 0.55f), new GradientColorKey(definition.Secondary, 1f) }, (GradientAlphaKey[])(object)new GradientAlphaKey[3] { new GradientAlphaKey(1f, 0f), new GradientAlphaKey(0.8f, 0.75f), new GradientAlphaKey(0f, 1f) }); return val; } private static FieldInfo RequiredField(Type type, string fieldName) { FieldInfo fieldInfo = AccessTools.Field(type, fieldName); if (fieldInfo == null) { throw new MissingFieldException(type.FullName, fieldName); } return fieldInfo; } private static MethodInfo RequiredMethod(Type type, string methodName, params Type[] parameters) { MethodInfo methodInfo = AccessTools.Method(type, methodName, parameters, (Type[])null); if (methodInfo == null) { throw new MissingMethodException(type.FullName, methodName); } return methodInfo; } } [HarmonyPatch] internal static class SuperBattleGolfPhysGrabObjectStartPatches { private static readonly string[] GrabMethodNames = new string[4] { "GrabStarted", "GrabStartedRPC", "GrabPlayerAddRPC", "GrabLinkRPC" }; private static IEnumerable TargetMethods() { string[] grabMethodNames = GrabMethodNames; foreach (string text in grabMethodNames) { MethodInfo methodInfo = AccessTools.Method(typeof(PhysGrabObject), text, (Type[])null, (Type[])null); if (methodInfo != null) { yield return methodInfo; } } } private static void Postfix(PhysGrabObject __instance, MethodBase __originalMethod) { if (!((Object)(object)__instance == (Object)null)) { SuperBattleGolfValuableGrabFeedback.TriggerFrom(__instance, __originalMethod.Name); } } } [HarmonyPatch] internal static class SuperBattleGolfPhysGrabObjectReleasePatches { private static readonly string[] ReleaseMethodNames = new string[3] { "GrabEnded", "GrabEndedRPC", "GrabPlayerRemoveRPC" }; private static IEnumerable TargetMethods() { string[] releaseMethodNames = ReleaseMethodNames; foreach (string text in releaseMethodNames) { MethodInfo methodInfo = AccessTools.Method(typeof(PhysGrabObject), text, (Type[])null, (Type[])null); if (methodInfo != null) { yield return methodInfo; } } } private static void Postfix(PhysGrabObject __instance) { if (!((Object)(object)__instance == (Object)null)) { SuperBattleGolfValuableGrabFeedback.ReleaseFrom(__instance); } } } [HarmonyPatch(typeof(PhysGrabObjectImpactDetector), "BreakRPC")] internal static class SuperBattleGolfImpactBreakPatch { private static void Postfix(PhysGrabObjectImpactDetector __instance, Vector3 _contactPoint, int breakLevel) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) SuperBattleGolfValuableBreakFeedback.TriggerFrom(__instance, _contactPoint, breakLevel, destroyed: false); } } [HarmonyPatch(typeof(PhysGrabObjectImpactDetector), "DestroyObjectRPC")] internal static class SuperBattleGolfImpactDestroyPatch { private static void Postfix(PhysGrabObjectImpactDetector __instance, bool effects) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) if (effects) { SuperBattleGolfValuableBreakFeedback.TriggerFrom(__instance, ((Component)__instance).transform.position, 0, destroyed: true); } } } internal sealed class SuperBattleGolfValuableActiveLogic : MonoBehaviour { private const float LandmineArmDelay = 0.85f; private const float LandmineTriggerRadius = 0.95f; private const float LandmineBeepInterval = 1.35f; private const float MagnetDuration = 2.6f; private const float MagnetTickInterval = 0.08f; private const float RocketArmDelay = 0.35f; private const float FreezeArmDelay = 0.35f; private static readonly Collider[] NearbyColliders = (Collider[])(object)new Collider[64]; private SuperBattleGolfValuableDefinition? _definition; private PhysGrabObject? _physGrabObject; private PhysGrabObjectImpactDetector? _impactDetector; private Rigidbody? _rigidbody; private bool _runtimeReady; private bool _landmineArming; private bool _landmineArmed; private bool _landmineDetonated; private bool _rocketArmed; private bool _freezeArmed; private float _landmineArmTime; private float _nextLandmineBeepTime; private float _rocketArmTime; private float _freezeArmTime; private float _magnetEndTime; private float _nextMagnetTickTime; public void Configure(SuperBattleGolfValuableDefinition definition) { _definition = definition; } private void Start() { EnsureRuntimeReady(); } private void Update() { EnsureRuntimeReady(); if (_definition != null) { UpdateLandmine(); UpdateMagnet(); } } private void OnCollisionEnter(Collision collision) { HandleCollision(collision); } private void OnCollisionStay(Collision collision) { HandleCollision(collision); } internal static void TriggerFrom(PhysGrabObject physGrabObject, string source) { if (!((Object)(object)physGrabObject == (Object)null)) { SuperBattleGolfValuableActiveLogic superBattleGolfValuableActiveLogic = ((Component)physGrabObject).GetComponent(); if ((Object)(object)superBattleGolfValuableActiveLogic == (Object)null) { superBattleGolfValuableActiveLogic = ((Component)physGrabObject).GetComponentInChildren(true); } superBattleGolfValuableActiveLogic?.OnGrab(source); } } private void EnsureRuntimeReady() { _physGrabObject = ((Component)this).GetComponent(); _impactDetector = ((Component)this).GetComponent(); _rigidbody = ((Component)this).GetComponent(); if (_definition == null) { string prefabName = ((Object)((Component)this).gameObject).name.Replace("(Clone)", string.Empty).Trim(); _definition = SuperBattleGolfValuableDefinitions.FindByPrefabName(prefabName); } _runtimeReady = true; } private void OnGrab(string source) { EnsureRuntimeReady(); if (_definition != null) { switch (_definition.PrefabName) { case "SuperBattleGolfValuable_Landmine": ArmLandmine(); break; case "SuperBattleGolfValuable_Electromagnet": ActivateMagnet(); break; case "SuperBattleGolfValuable_FreezeBomb": case "SuperBattleGolfValuable_FreezeBombIceBlock": ArmFreezeBomb(); break; case "SuperBattleGolfValuable_Rocket": ArmRocket(); break; } } } private void ArmLandmine() { //IL_0043: 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) if (!_landmineArmed && !_landmineArming && !_landmineDetonated) { _landmineArming = true; _landmineArmTime = Time.time + 0.85f; _nextLandmineBeepTime = _landmineArmTime; SpawnPulse(((Component)this).transform.position, 1.2f, new Color(1f, 0.48f, 0.16f), 1.9f, 0.32f); } } private void UpdateLandmine() { //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0083: 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_00de: 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_0121: Unknown result type (might be due to invalid IL or missing references) if (_definition?.PrefabName != "SuperBattleGolfValuable_Landmine" || _landmineDetonated) { return; } if (_landmineArming && Time.time >= _landmineArmTime) { _landmineArming = false; _landmineArmed = true; PlayClip("SBG_LandmineArmedBeep", ((Component)this).transform.position, 0.9f); SpawnPulse(((Component)this).transform.position, 1.45f, new Color(1f, 0.2f, 0.1f), 2.3f, 0.3f); } if (!_landmineArmed) { return; } if (Time.time >= _nextLandmineBeepTime) { _nextLandmineBeepTime = Time.time + 1.35f; PlayClip("SBG_LandmineArmedBeep", ((Component)this).transform.position, 0.55f); SpawnPulse(((Component)this).transform.position, 0.95f, new Color(1f, 0.12f, 0.05f), 1.4f, 0.2f); } if (IsGrabbed() || !IsAuthoritative()) { return; } int num = Physics.OverlapSphereNonAlloc(((Component)this).transform.position, 0.95f, NearbyColliders, -1, (QueryTriggerInteraction)2); for (int i = 0; i < num; i++) { Collider collider = NearbyColliders[i]; if (IsMeaningfulTrigger(collider)) { Detonate(); break; } } } private void ActivateMagnet() { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) _magnetEndTime = Mathf.Max(_magnetEndTime, Time.time + 2.6f); _nextMagnetTickTime = 0f; SpawnPulse(((Component)this).transform.position, 2.35f, new Color(0.48f, 0.62f, 1f), 2.1f, 0.38f); } private void UpdateMagnet() { //IL_0058: Unknown result type (might be due to invalid IL or missing references) if (!(_definition?.PrefabName != "SuperBattleGolfValuable_Electromagnet") && !(Time.time > _magnetEndTime) && !(Time.time < _nextMagnetTickTime) && IsAuthoritative()) { _nextMagnetTickTime = Time.time + 0.08f; PullNearby(((Component)this).transform.position, 5.2f, 0.34f); } } private void ArmFreezeBomb() { //IL_001e: 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) _freezeArmed = true; _freezeArmTime = Time.time + 0.35f; SpawnPulse(((Component)this).transform.position, 1.7f, new Color(0.45f, 0.95f, 1f), 2f, 0.36f); } private void ArmRocket() { //IL_001e: 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_006c: 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) _rocketArmed = true; _rocketArmTime = Time.time + 0.35f; SpawnPulse(((Component)this).transform.position, 1.6f, new Color(1f, 0.42f, 0.16f), 2f, 0.32f); if ((Object)(object)_rigidbody != (Object)null && IsAuthoritative()) { _rigidbody.AddForce(((Component)this).transform.forward * 0.9f, (ForceMode)1); } } private void HandleCollision(Collision collision) { if (_runtimeReady && _definition != null && IsAuthoritative()) { if (_definition.PrefabName == "SuperBattleGolfValuable_Landmine" && _landmineArmed && !_landmineDetonated && !IsGrabbed() && (Object)(object)collision.collider != (Object)null && IsMeaningfulTrigger(collision.collider)) { Detonate(); } else if ((_definition.PrefabName == "SuperBattleGolfValuable_FreezeBomb" || _definition.PrefabName == "SuperBattleGolfValuable_FreezeBombIceBlock") && _freezeArmed && Time.time >= _freezeArmTime && !IsGrabbed() && IsMeaningfulCollision(collision, 0.7f)) { Detonate(); } else if (_definition.PrefabName == "SuperBattleGolfValuable_Rocket" && _rocketArmed && Time.time >= _rocketArmTime && !IsGrabbed() && IsMeaningfulCollision(collision, 1.2f)) { Detonate(); } } } private bool IsMeaningfulCollision(Collision collision, float minimumVelocity) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) if (collision == null || (Object)(object)collision.collider == (Object)null) { return false; } Vector3 relativeVelocity = collision.relativeVelocity; if (((Vector3)(ref relativeVelocity)).magnitude >= minimumVelocity) { return true; } return IsMeaningfulTrigger(collision.collider); } private bool IsMeaningfulTrigger(Collider collider) { if ((Object)(object)collider == (Object)null || (Object)(object)((Component)collider).transform == (Object)null || ((Component)collider).transform.IsChildOf(((Component)this).transform)) { return false; } PhysGrabObject componentInParent = ((Component)collider).GetComponentInParent(); if ((Object)(object)componentInParent != (Object)null && (Object)(object)componentInParent == (Object)(object)_physGrabObject) { return false; } if ((Object)(object)((Component)collider).GetComponentInParent() != (Object)null || (Object)(object)((Component)collider).GetComponentInParent() != (Object)null) { return true; } Rigidbody attachedRigidbody = collider.attachedRigidbody; if ((Object)(object)attachedRigidbody != (Object)null && !attachedRigidbody.isKinematic) { return (Object)(object)attachedRigidbody != (Object)(object)_rigidbody; } return false; } private void Detonate() { if (!_landmineDetonated) { _landmineDetonated = true; if ((Object)(object)_impactDetector != (Object)null) { RepoValuableAccess.DestroyImpactObject(_impactDetector, effects: true); } } } private bool IsGrabbed() { if ((Object)(object)_physGrabObject != (Object)null) { return RepoValuableAccess.IsGrabbedForVoice(_physGrabObject); } return false; } private void PullNearby(Vector3 origin, float radius, float force) { //IL_0000: 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_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0065: 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_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) int num = Physics.OverlapSphereNonAlloc(origin, radius, NearbyColliders, -1, (QueryTriggerInteraction)1); for (int i = 0; i < num; i++) { Rigidbody val = (((Object)(object)NearbyColliders[i] != (Object)null) ? NearbyColliders[i].attachedRigidbody : null); if (!((Object)(object)val == (Object)null) && !val.isKinematic && !((Component)val).transform.IsChildOf(((Component)this).transform)) { Vector3 val2 = origin - val.worldCenterOfMass; float num2 = Mathf.Max(0.1f, ((Vector3)(ref val2)).magnitude); val.AddForce(val2 / num2 * (force * Mathf.Clamp01(1f - num2 / radius)), (ForceMode)1); } } } private static bool IsAuthoritative() { if (!PhotonNetwork.OfflineMode && PhotonNetwork.InRoom) { return PhotonNetwork.IsMasterClient; } return true; } private static void PlayClip(string clipName, Vector3 origin, float volume) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Invalid comparison between Unknown and I4 //IL_002a: Unknown result type (might be due to invalid IL or missing references) AudioClip val = SuperBattleGolfValuableBundleVisuals.LoadAudioClip(clipName); if (!((Object)(object)val == (Object)null)) { if ((int)val.loadState == 0) { val.LoadAudioData(); } if ((int)val.loadState != 3) { AudioSource.PlayClipAtPoint(val, origin, volume); } } } private static void SpawnPulse(Vector3 origin, float radius, Color color, float intensity, float duration) { //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_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("Super Battle Golf Active Pulse") { hideFlags = (HideFlags)52 }; val.transform.position = origin; Light val2 = val.AddComponent(); val2.type = (LightType)2; val2.color = color; val2.intensity = intensity; val2.range = radius; val.AddComponent().Configure(val2, duration); } } internal sealed class SuperBattleGolfValuableBreakFeedback : MonoBehaviour { private const float LogicCooldown = 0.5f; private static readonly Collider[] NearbyColliders = (Collider[])(object)new Collider[64]; private SuperBattleGolfValuableDefinition? _definition; private PhysGrabObject? _physGrabObject; private float _lastLogicTime = -999f; public void Configure(SuperBattleGolfValuableDefinition definition) { _definition = definition; } private void Start() { EnsureRuntimeReady(); } private void EnsureRuntimeReady() { _physGrabObject = ((Component)this).GetComponent(); if (_definition == null) { string prefabName = ((Object)((Component)this).gameObject).name.Replace("(Clone)", string.Empty).Trim(); _definition = SuperBattleGolfValuableDefinitions.FindByPrefabName(prefabName); } } internal static void TriggerFrom(PhysGrabObjectImpactDetector detector, Vector3 contactPoint, int breakLevel, bool destroyed) { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)detector == (Object)null)) { SuperBattleGolfValuableBreakFeedback superBattleGolfValuableBreakFeedback = ((Component)detector).GetComponent(); if ((Object)(object)superBattleGolfValuableBreakFeedback == (Object)null) { superBattleGolfValuableBreakFeedback = ((Component)detector).GetComponentInChildren(true); } ImpactState state = (ImpactState)(destroyed ? 3 : ((int)RepoValuableAccess.GetBreakState(detector, breakLevel))); superBattleGolfValuableBreakFeedback?.TriggerBreak(contactPoint, state, destroyed); } } private void TriggerBreak(Vector3 contactPoint, ImpactState state, bool destroyed) { //IL_000e: 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_0036: Invalid comparison between Unknown and I4 //IL_016f: Unknown result type (might be due to invalid IL or missing references) //IL_01ae: Unknown result type (might be due to invalid IL or missing references) //IL_026d: Unknown result type (might be due to invalid IL or missing references) //IL_01d4: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Unknown result type (might be due to invalid IL or missing references) //IL_015e: 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_025c: Unknown result type (might be due to invalid IL or missing references) //IL_0200: Unknown result type (might be due to invalid IL or missing references) //IL_0201: Unknown result type (might be due to invalid IL or missing references) //IL_020b: Unknown result type (might be due to invalid IL or missing references) //IL_0210: Unknown result type (might be due to invalid IL or missing references) //IL_022e: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Unknown result type (might be due to invalid IL or missing references) EnsureRuntimeReady(); if (_definition == null || (int)state == 0 || Time.time - _lastLogicTime < 0.5f) { return; } _lastLogicTime = Time.time; bool flag = destroyed || (int)state == 3; string prefabName = _definition.PrefabName; if (prefabName == null) { return; } switch (prefabName.Length) { case 42: switch (prefabName[24]) { default: return; case 'F': break; case 'O': if (prefabName == "SuperBattleGolfValuable_OrbitalLaserRemote" && flag) { Explode(contactPoint + Vector3.up * 0.35f, 4.6f, 5.4f, new Color(0.45f, 0.95f, 1f), "SBG_OrbitalLaserExplosion"); } return; } if (!(prefabName == "SuperBattleGolfValuable_FreezeBombIceBlock")) { break; } goto IL_01ad; case 30: if (!(prefabName == "SuperBattleGolfValuable_Rocket")) { break; } goto IL_013d; case 38: if (!(prefabName == "SuperBattleGolfValuable_RocketLauncher")) { break; } goto IL_013d; case 32: if (prefabName == "SuperBattleGolfValuable_Landmine") { Explode(contactPoint, flag ? 5.6f : 4.2f, flag ? 7.5f : 4.8f, new Color(1f, 0.45f, 0.16f), "SBG_LandmineExplosion"); } break; case 34: if (!(prefabName == "SuperBattleGolfValuable_FreezeBomb")) { break; } goto IL_01ad; case 37: if (prefabName == "SuperBattleGolfValuable_Electromagnet") { MagnetPulse(contactPoint, flag ? 5.4f : 4f, flag ? 4.5f : 2.6f); } break; case 31: if (prefabName == "SuperBattleGolfValuable_Airhorn" && flag) { Explode(contactPoint, 3.6f, 3.4f, new Color(1f, 0.92f, 0.48f), "SBG_Airhorn"); } break; case 35: if (prefabName == "SuperBattleGolfValuable_SpringBoots") { SpringPulse(contactPoint, flag ? 3.8f : 2.6f, flag ? 5.6f : 3.4f); } break; case 33: case 36: case 39: case 40: case 41: break; IL_013d: if (flag) { Explode(contactPoint, 5.2f, 6.2f, Color.Lerp(Color.red, Color.yellow, 0.45f), "SBG_RocketExplosion"); } break; IL_01ad: FreezePulse(contactPoint, flag ? 4.8f : 3.6f, flag ? 0.12f : 0.32f); break; } } private void Explode(Vector3 origin, float radius, float force, Color color, string clipName) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) SpawnPulse(origin, radius, color, 3.8f, 0.55f); PlayClip(clipName, origin); if (IsAuthoritative()) { PushNearby(origin, radius, force, 0.45f); DamageNearby(origin, radius, Mathf.RoundToInt(force * 8f)); } } private void FreezePulse(Vector3 origin, float radius, float velocityMultiplier) { //IL_0000: 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_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_00be: 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_0084: 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_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) SpawnPulse(origin, radius, new Color(0.45f, 0.95f, 1f), 3.2f, 0.7f); PlayClip("SBG_FreezeBombExplosion", origin); if (!IsAuthoritative()) { return; } int num = Physics.OverlapSphereNonAlloc(origin, radius, NearbyColliders, -1, (QueryTriggerInteraction)1); for (int i = 0; i < num; i++) { Rigidbody val = (((Object)(object)NearbyColliders[i] != (Object)null) ? NearbyColliders[i].attachedRigidbody : null); if (!((Object)(object)val == (Object)null) && !ShouldSkip(val)) { val.velocity *= velocityMultiplier; val.angularVelocity *= velocityMultiplier; val.AddForce(Vector3.up * 0.35f, (ForceMode)1); } } DamageNearby(origin, radius * 0.75f, 8); } private void MagnetPulse(Vector3 origin, float radius, float force) { //IL_0000: 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_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0088: 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_00a0: 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) SpawnPulse(origin, radius, new Color(0.58f, 0.65f, 1f), 3f, 0.5f); PlayClip("SBG_ElectromagnetActivation", origin); if (!IsAuthoritative()) { return; } int num = Physics.OverlapSphereNonAlloc(origin, radius, NearbyColliders, -1, (QueryTriggerInteraction)1); for (int i = 0; i < num; i++) { Rigidbody val = (((Object)(object)NearbyColliders[i] != (Object)null) ? NearbyColliders[i].attachedRigidbody : null); if (!((Object)(object)val == (Object)null) && !ShouldSkip(val)) { Vector3 val2 = origin - val.worldCenterOfMass; float num2 = Mathf.Max(0.1f, ((Vector3)(ref val2)).magnitude); val.AddForce(val2 / num2 * (force * Mathf.Clamp01(1f - num2 / radius)), (ForceMode)1); } } } private void SpringPulse(Vector3 origin, float radius, float force) { //IL_0000: 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_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) SpawnPulse(origin, radius, new Color(0.55f, 1f, 0.35f), 2.8f, 0.45f); PlayClip("SBG_SpringBootsActivation", origin); if (IsAuthoritative()) { PushNearby(origin, radius, force, 1.15f); } } private void PushNearby(Vector3 origin, float radius, float force, float upwardBias) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0084: 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_009f: 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_00ab: 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) int num = Physics.OverlapSphereNonAlloc(origin, radius, NearbyColliders, -1, (QueryTriggerInteraction)1); for (int i = 0; i < num; i++) { Rigidbody val = (((Object)(object)NearbyColliders[i] != (Object)null) ? NearbyColliders[i].attachedRigidbody : null); if (!((Object)(object)val == (Object)null) && !ShouldSkip(val)) { Vector3 val2 = val.worldCenterOfMass - origin; float num2 = Mathf.Max(0.1f, ((Vector3)(ref val2)).magnitude); Vector3 val3 = val2 / num2 + Vector3.up * upwardBias; Vector3 val4 = ((Vector3)(ref val3)).normalized * (force * Mathf.Clamp01(1f - num2 / radius)); val.AddForce(val4, (ForceMode)1); val.AddTorque(Random.insideUnitSphere * force, (ForceMode)1); } } } private bool ShouldSkip(Rigidbody target) { if (!target.isKinematic) { return ((Component)target).transform.IsChildOf(((Component)this).transform); } return true; } private static void DamageNearby(Vector3 origin, float radius, int maxDamage) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) PlayerAvatar[] array = Object.FindObjectsOfType(); foreach (PlayerAvatar val in array) { if (RepoValuableAccess.CanAffectPlayer(val)) { float num = Vector3.Distance(((Component)val).transform.position, origin); if (!(num > radius)) { int damage = Mathf.Max(1, Mathf.RoundToInt((float)maxDamage * Mathf.Lerp(1f, 0.35f, num / radius))); RepoValuableAccess.HurtPlayer(val, damage); RepoValuableAccess.TumblePlayer(val, 1.1f); } } } EnemyHealth[] array2 = Object.FindObjectsOfType(); foreach (EnemyHealth val2 in array2) { if (!((Object)(object)val2 == (Object)null)) { float num2 = Vector3.Distance(((Component)val2).transform.position, origin); if (!(num2 > radius)) { Vector3 val3 = ((Component)val2).transform.position - origin; RepoValuableAccess.HurtEnemy(val2, Mathf.Max(1, Mathf.RoundToInt((float)maxDamage * Mathf.Lerp(1f, 0.35f, num2 / radius))), ((Vector3)(ref val3)).normalized); } } } } private static bool IsAuthoritative() { if (!PhotonNetwork.OfflineMode && PhotonNetwork.InRoom) { return PhotonNetwork.IsMasterClient; } return true; } private static void PlayClip(string clipName, Vector3 origin) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Invalid comparison between Unknown and I4 //IL_002a: Unknown result type (might be due to invalid IL or missing references) AudioClip val = SuperBattleGolfValuableBundleVisuals.LoadAudioClip(clipName); if (!((Object)(object)val == (Object)null)) { if ((int)val.loadState == 0) { val.LoadAudioData(); } if ((int)val.loadState != 3) { AudioSource.PlayClipAtPoint(val, origin, 1f); } } } private static void SpawnPulse(Vector3 origin, float radius, Color color, float intensity, float duration) { //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_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_006d: 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_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Expected O, but got Unknown //IL_00b9: 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_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("Super Battle Golf Break Pulse") { hideFlags = (HideFlags)52 }; val.transform.position = origin; Light val2 = val.AddComponent(); val2.type = (LightType)2; val2.color = color; val2.intensity = intensity; val2.range = radius; val.AddComponent().Configure(val2, duration); GameObject obj = GameObject.CreatePrimitive((PrimitiveType)0); ((Object)obj).name = "Super Battle Golf Visible Pulse"; ((Object)obj).hideFlags = (HideFlags)52; obj.transform.position = origin; obj.transform.localScale = Vector3.one * radius * 2f; Collider component = obj.GetComponent(); if ((Object)(object)component != (Object)null) { Object.Destroy((Object)(object)component); } Material val3 = new Material(Shader.Find("Standard")); Color color2 = color; color2.a = 0.26f; val3.color = color2; val3.SetFloat("_Mode", 3f); val3.SetInt("_SrcBlend", 5); val3.SetInt("_DstBlend", 10); val3.SetInt("_ZWrite", 0); val3.DisableKeyword("_ALPHATEST_ON"); val3.EnableKeyword("_ALPHABLEND_ON"); val3.DisableKeyword("_ALPHAPREMULTIPLY_ON"); val3.renderQueue = 3000; Renderer component2 = obj.GetComponent(); component2.sharedMaterial = val3; obj.AddComponent().Configure(component2, val3, color2, duration); } } internal static class SuperBattleGolfValuableBundleVisuals { private const string BundleFileName = "superbattlegolfvaluablesassets"; private static readonly Dictionary VisualPrefabs = new Dictionary(); private static readonly Dictionary AudioClipsByName = new Dictionary(StringComparer.OrdinalIgnoreCase); private static readonly List AudioClips = new List(); private static ManualLogSource? _log; private static AssetBundle? _bundle; private static bool _loadAttempted; private static bool _audioLoaded; public static void Initialize(string pluginDirectory, ManualLogSource log) { _log = log; if (_loadAttempted) { return; } _loadAttempted = true; string text = Path.Combine(pluginDirectory, "superbattlegolfvaluablesassets"); if (!File.Exists(text)) { log.LogWarning((object)("Generated valuable asset bundle was not found at " + text + ". Falling back to procedural visuals.")); return; } try { foreach (AssetBundle allLoadedAssetBundle in AssetBundle.GetAllLoadedAssetBundles()) { if (string.Equals(((Object)allLoadedAssetBundle).name, "superbattlegolfvaluablesassets", StringComparison.OrdinalIgnoreCase)) { _bundle = allLoadedAssetBundle; log.LogInfo((object)"Using already-loaded generated valuable asset bundle: superbattlegolfvaluablesassets"); return; } } _bundle = AssetBundle.LoadFromFile(text); if ((Object)(object)_bundle == (Object)null) { log.LogWarning((object)("Unity returned null when loading " + text + ". Falling back to procedural visuals.")); } else { log.LogInfo((object)("Loaded generated valuable asset bundle: " + text)); } } catch (Exception arg) { log.LogWarning((object)$"Failed to load generated valuable asset bundle {text}: {arg}"); _bundle = null; } } public static bool TryAttach(Transform parent, SuperBattleGolfValuableDefinition definition) { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) GameObject val = LoadVisualPrefab(definition.PrefabName); if ((Object)(object)val == (Object)null) { return false; } GameObject val2 = Object.Instantiate(val, parent, false); ((Object)val2).name = "SuperBattleGolfValuableVisual"; val2.transform.localPosition = Vector3.zero; val2.transform.localRotation = Quaternion.identity; val2.transform.localScale = Vector3.one; ((Object)val2).hideFlags = (HideFlags)52; SetLayerRecursively(val2.transform, ((Component)parent).gameObject.layer); Collider[] componentsInChildren = val2.GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren.Length; i++) { Object.Destroy((Object)(object)componentsInChildren[i]); } StripParticleEffects(val2); return true; } public static AudioClip[] LoadAllAudioClips() { //IL_0049: Unknown result type (might be due to invalid IL or missing references) if (_audioLoaded) { return AudioClips.ToArray(); } _audioLoaded = true; if ((Object)(object)_bundle == (Object)null) { return Array.Empty(); } try { AudioClip[] array = _bundle.LoadAllAssets(); foreach (AudioClip val in array) { if ((Object)(object)val != (Object)null) { if ((int)val.loadState == 0) { val.LoadAudioData(); } AudioClips.Add(val); AudioClipsByName[((Object)val).name] = val; } } } catch (Exception arg) { ManualLogSource? log = _log; if (log != null) { log.LogWarning((object)$"Failed to load grab audio clips from generated bundle: {arg}"); } } return AudioClips.ToArray(); } public static AudioClip? LoadAudioClip(string name) { LoadAllAudioClips(); if (!AudioClipsByName.TryGetValue(name, out AudioClip value)) { return null; } return value; } public static AudioClip[] LoadAudioClipsFor(SuperBattleGolfValuableDefinition definition) { LoadAllAudioClips(); object obj = definition.PrefabName switch { "SuperBattleGolfValuable_MiniGolfCart" => new string[5] { "SBG_GolfCartHonk", "SBG_GolfCartSpecialHonk", "SBG_GolfCartEngine", "SBG_GolfCartJump", "SBG_GolfCartCollision" }, "SuperBattleGolfValuable_SpectatorCamera" => new string[3] { "SBG_ItemBoxCollected", "SBG_BallInHole", "SBG_GolfCartSpecialHonk" }, "SuperBattleGolfValuable_BattleGolfBall" => new string[3] { "SBG_BallInHole", "SBG_NormalClubSwing", "SBG_ItemBoxCollected" }, "SuperBattleGolfValuable_GolfClub" => new string[2] { "SBG_NormalClubSwing", "SBG_BallInHole" }, "SuperBattleGolfValuable_GolfTee" => new string[2] { "SBG_NormalClubSwing", "SBG_ItemBoxCollected" }, "SuperBattleGolfValuable_CoffeeCup" => new string[2] { "SBG_CoffeeDrink", "SBG_GolfCartBriefcaseOpenEnd" }, "SuperBattleGolfValuable_CoffeePlate" => new string[2] { "SBG_CoffeeDrink", "SBG_GolfCartBriefcaseOpenStart" }, "SuperBattleGolfValuable_HotCoffee" => new string[2] { "SBG_CoffeeDrink", "SBG_SpringBootFlip" }, "SuperBattleGolfValuable_Airhorn" => new string[1] { "SBG_Airhorn" }, "SuperBattleGolfValuable_DuelingPistol" => new string[2] { "SBG_GunAim", "SBG_PistolShot" }, "SuperBattleGolfValuable_ElephantGun" => new string[2] { "SBG_GunAim", "SBG_ElephantGunShot" }, "SuperBattleGolfValuable_Electromagnet" => new string[3] { "SBG_ElectromagnetActivation", "SBG_ElectromagnetReflect", "SBG_ElectromagnetShieldActivation" }, "SuperBattleGolfValuable_FreezeBomb" => new string[3] { "SBG_FreezeBombShot", "SBG_FreezeBombExplosion", "SBG_FreezeBombProjectileLoop" }, "SuperBattleGolfValuable_FreezeBombIceBlock" => new string[3] { "SBG_FreezeBombUnfreeze", "SBG_FreezeBombPlatformBreak", "SBG_FreezeBombExplosion" }, "SuperBattleGolfValuable_OrbitalLaserRemote" => new string[3] { "SBG_OrbitalLaserActivation", "SBG_OrbitalLaserCharge", "SBG_OrbitalLaserExplosion" }, "SuperBattleGolfValuable_RocketLauncher" => new string[2] { "SBG_RocketLauncherShot", "SBG_RocketExplosion" }, "SuperBattleGolfValuable_Rocket" => new string[2] { "SBG_RocketEngine", "SBG_RocketExplosion" }, "SuperBattleGolfValuable_SpringBoots" => new string[2] { "SBG_SpringBootsActivation", "SBG_SpringBootFlip" }, "SuperBattleGolfValuable_Landmine" => new string[3] { "SBG_LandmineArm", "SBG_LandmineArmedBeep", "SBG_LandmineExplosion" }, "SuperBattleGolfValuable_GolfCartBriefcase" => new string[3] { "SBG_GolfCartBriefcaseOpenStart", "SBG_GolfCartBriefcaseOpenEnd", "SBG_GolfCartEngineOff" }, _ => Array.Empty(), }; List list = new List(((Array)obj).Length); string[] array = (string[])obj; foreach (string key in array) { if (AudioClipsByName.TryGetValue(key, out AudioClip value) && (Object)(object)value != (Object)null) { list.Add(value); } } return list.ToArray(); } private static GameObject? LoadVisualPrefab(string prefabName) { if (VisualPrefabs.TryGetValue(prefabName, out GameObject value)) { return value; } if ((Object)(object)_bundle == (Object)null) { VisualPrefabs[prefabName] = null; return null; } try { GameObject val = _bundle.LoadAsset(prefabName); if ((Object)(object)val == (Object)null) { val = _bundle.LoadAsset("Assets/SuperBattleGolfValuables/Prefabs/" + prefabName + ".prefab"); } if ((Object)(object)val == (Object)null) { ManualLogSource? log = _log; if (log != null) { log.LogWarning((object)("Generated bundle is missing valuable visual prefab '" + prefabName + "'.")); } } VisualPrefabs[prefabName] = val; return val; } catch (Exception arg) { ManualLogSource? log2 = _log; if (log2 != null) { log2.LogWarning((object)$"Failed to load visual prefab '{prefabName}' from generated bundle: {arg}"); } VisualPrefabs[prefabName] = null; return null; } } private static void SetLayerRecursively(Transform root, int layer) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Expected O, but got Unknown ((Component)root).gameObject.layer = layer; foreach (Transform item in root) { SetLayerRecursively(item, layer); } } private static void StripParticleEffects(GameObject root) { ParticleSystem[] componentsInChildren = root.GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren.Length; i++) { Object.Destroy((Object)(object)componentsInChildren[i]); } ParticleSystemRenderer[] componentsInChildren2 = root.GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren2.Length; i++) { Object.Destroy((Object)(object)componentsInChildren2[i]); } TrailRenderer[] componentsInChildren3 = root.GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren3.Length; i++) { Object.Destroy((Object)(object)componentsInChildren3[i]); } LineRenderer[] componentsInChildren4 = root.GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren4.Length; i++) { Object.Destroy((Object)(object)componentsInChildren4[i]); } } } internal sealed class SuperBattleGolfValuableDefinition { public string PrefabName { get; } public string DisplayName { get; } public string SourceReference { get; } public Type VolumeType { get; } public int ValueMin { get; } public int ValueMax { get; } public float Fragility { get; } public float Durability { get; } public float Mass { get; } public Color Primary { get; } public Color Secondary { get; } public Color Accent { get; } public Vector3 GrabBoundsCenter { get; } public Vector3 GrabBoundsSize { get; } public bool GrabGlow { get; } public bool PlayAnimationsOnGrab { get; } public bool PlaySoundsOnGrab { get; } public SuperBattleGolfValuableDefinition(string prefabName, string displayName, string sourceReference, Type volumeType, int valueMin, int valueMax, float fragility, float durability, float mass, Color primary, Color secondary, Color accent, Vector3 grabBoundsCenter, Vector3 grabBoundsSize, bool playAnimationsOnGrab, bool playSoundsOnGrab) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_004c: 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_0054: 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_005c: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006c: 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) PrefabName = prefabName; DisplayName = displayName; SourceReference = sourceReference; VolumeType = volumeType; ValueMin = valueMin; ValueMax = valueMax; Fragility = fragility; Durability = durability; Mass = mass; Primary = primary; Secondary = secondary; Accent = accent; GrabBoundsCenter = grabBoundsCenter; GrabBoundsSize = grabBoundsSize; GrabGlow = true; PlayAnimationsOnGrab = playAnimationsOnGrab; PlaySoundsOnGrab = playSoundsOnGrab; } } internal static class SuperBattleGolfValuableDefinitions { public static readonly SuperBattleGolfValuableDefinition[] All = new SuperBattleGolfValuableDefinition[20] { new SuperBattleGolfValuableDefinition("SuperBattleGolfValuable_MiniGolfCart", "Mini Golf Cart", "GameObject/Golf Cart.prefab", (Type)4, 5600, 9400, 10f, 117f, 3f, new Color(0.188f, 0.428f, 0.403f), new Color(0.443f, 0.654f, 0.618f), new Color(0.567f, 0.205f, 0.615f), new Vector3(0f, 0.14f, 0f), new Vector3(0.36f, 0.28f, 0.28f), playAnimationsOnGrab: true, playSoundsOnGrab: true), new SuperBattleGolfValuableDefinition("SuperBattleGolfValuable_SpectatorCamera", "Spectator Camera", "GameObject/Spectator Camera.prefab", (Type)2, 3900, 7600, 24f, 112f, 1.9f, new Color(0.279f, 0.383f, 0.471f), new Color(0.352f, 0.711f, 0.544f), new Color(0.838f, 0.838f, 0.793f), new Vector3(0f, 0.38f, 0f), new Vector3(0.82f, 0.78f, 0.66f), playAnimationsOnGrab: true, playSoundsOnGrab: true), new SuperBattleGolfValuableDefinition("SuperBattleGolfValuable_BattleGolfBall", "Battle Golf Ball", "GameObject/Ball.prefab", (Type)0, 2500, 7400, 15f, 100f, 0.65f, new Color(0.428f, 0.812f, 0.386f), new Color(0.654f, 0.299f, 0.863f), new Color(0.203f, 0.759f, 0.759f), new Vector3(0f, 0.24f, 0f), new Vector3(0.5f, 0.5f, 0.46f), playAnimationsOnGrab: true, playSoundsOnGrab: true), new SuperBattleGolfValuableDefinition("SuperBattleGolfValuable_GolfClub", "Golf Club", "GameObject/Golf club.prefab", (Type)2, 3900, 8900, 23f, 87f, 1.9f, new Color(0.804f, 0.683f, 0.572f), new Color(0.731f, 0.654f, 0.841f), new Color(0.245f, 0.561f, 0.53f), new Vector3(0f, 0.38f, 0f), new Vector3(0.82f, 0.78f, 0.66f), playAnimationsOnGrab: true, playSoundsOnGrab: true), new SuperBattleGolfValuableDefinition("SuperBattleGolfValuable_GolfTee", "Golf Tee", "GameObject/Tee.prefab", (Type)2, 4800, 7400, 10f, 117f, 1.9f, new Color(0.211f, 0.572f, 0.496f), new Color(0.42f, 0.784f, 0.632f), new Color(0.635f, 0.287f, 0.606f), new Vector3(0f, 0.38f, 0f), new Vector3(0.82f, 0.78f, 0.66f), playAnimationsOnGrab: true, playSoundsOnGrab: true), new SuperBattleGolfValuableDefinition("SuperBattleGolfValuable_CoffeeCup", "Coffee Cup", "GameObject/Coffee mug.prefab", (Type)0, 2400, 6900, 17f, 93f, 0.65f, new Color(0.355f, 0.313f, 0.491f), new Color(0.547f, 0.7f, 0.426f), new Color(0.705f, 0.304f, 0.457f), new Vector3(0f, 0.24f, 0f), new Vector3(0.5f, 0.5f, 0.46f), playAnimationsOnGrab: true, playSoundsOnGrab: true), new SuperBattleGolfValuableDefinition("SuperBattleGolfValuable_CoffeePlate", "Coffee Plate", "GameObject/Coffee plate.prefab", (Type)2, 1400, 6300, 24f, 102f, 1.9f, new Color(0.55f, 0.773f, 0.604f), new Color(0.804f, 0.533f, 0.369f), new Color(0.205f, 0.702f, 0.307f), new Vector3(0f, 0.38f, 0f), new Vector3(0.82f, 0.78f, 0.66f), playAnimationsOnGrab: true, playSoundsOnGrab: true), new SuperBattleGolfValuableDefinition("SuperBattleGolfValuable_HotCoffee", "Hot Coffee", "GameObject/Coffee.prefab", (Type)2, 2400, 5100, 14f, 87f, 1.9f, new Color(0.403f, 0.33f, 0.423f), new Color(0.589f, 0.508f, 0.496f), new Color(0.488f, 0.38f, 0.262f), new Vector3(0f, 0.38f, 0f), new Vector3(0.82f, 0.78f, 0.66f), playAnimationsOnGrab: true, playSoundsOnGrab: true), new SuperBattleGolfValuableDefinition("SuperBattleGolfValuable_Airhorn", "Airhorn", "GameObject/Airhorn.prefab", (Type)2, 1900, 6400, 27f, 89f, 1.9f, new Color(0.265f, 0.547f, 0.866f), new Color(0.637f, 0.725f, 0.53f), new Color(0.434f, 0.601f, 0.618f), new Vector3(0f, 0.38f, 0f), new Vector3(0.82f, 0.78f, 0.66f), playAnimationsOnGrab: true, playSoundsOnGrab: true), new SuperBattleGolfValuableDefinition("SuperBattleGolfValuable_DuelingPistol", "Dueling Pistol", "GameObject/Dueling pistol.prefab", (Type)2, 3600, 7400, 18f, 102f, 1.9f, new Color(0.462f, 0.564f, 0.361f), new Color(0.259f, 0.553f, 0.767f), new Color(0.304f, 0.753f, 0.194f), new Vector3(0f, 0.38f, 0f), new Vector3(0.82f, 0.78f, 0.66f), playAnimationsOnGrab: true, playSoundsOnGrab: true), new SuperBattleGolfValuableDefinition("SuperBattleGolfValuable_ElephantGun", "Elephant Gun", "GameObject/Elephant gun.prefab", (Type)2, 1400, 6300, 24f, 91f, 1.9f, new Color(0.378f, 0.615f, 0.378f), new Color(0.524f, 0.671f, 0.575f), new Color(0.773f, 0.86f, 0.27f), new Vector3(0f, 0.38f, 0f), new Vector3(0.82f, 0.78f, 0.66f), playAnimationsOnGrab: true, playSoundsOnGrab: true), new SuperBattleGolfValuableDefinition("SuperBattleGolfValuable_Electromagnet", "Electromagnet", "GameObject/Electromagnet.prefab", (Type)2, 1300, 6400, 21f, 105f, 1.9f, new Color(0.245f, 0.688f, 0.428f), new Color(0.748f, 0.762f, 0.714f), new Color(0.736f, 0.29f, 0.462f), new Vector3(0f, 0.38f, 0f), new Vector3(0.82f, 0.78f, 0.66f), playAnimationsOnGrab: true, playSoundsOnGrab: true), new SuperBattleGolfValuableDefinition("SuperBattleGolfValuable_FreezeBomb", "Freeze Bomb", "GameObject/Freeze bomb.prefab", (Type)2, 5300, 10600, 10f, 115f, 1.9f, new Color(0.366f, 0.547f, 0.64f), new Color(0.897f, 0.736f, 0.756f), new Color(0.739f, 0.652f, 0.663f), new Vector3(0f, 0.38f, 0f), new Vector3(0.82f, 0.78f, 0.66f), playAnimationsOnGrab: true, playSoundsOnGrab: true), new SuperBattleGolfValuableDefinition("SuperBattleGolfValuable_FreezeBombIceBlock", "Freeze Bomb Ice Block", "GameObject/Freeze bomb ice block.prefab", (Type)2, 4400, 7400, 23f, 103f, 1.9f, new Color(0.688f, 0.635f, 0.239f), new Color(0.756f, 0.598f, 0.626f), new Color(0.259f, 0.719f, 0.228f), new Vector3(0f, 0.38f, 0f), new Vector3(0.82f, 0.78f, 0.66f), playAnimationsOnGrab: true, playSoundsOnGrab: true), new SuperBattleGolfValuableDefinition("SuperBattleGolfValuable_OrbitalLaserRemote", "Orbital Laser Remote", "GameObject/Orbital laser.prefab", (Type)2, 5200, 9100, 24f, 88f, 1.9f, new Color(0.55f, 0.228f, 0.615f), new Color(0.804f, 0.265f, 0.654f), new Color(0.205f, 0.875f, 0.784f), new Vector3(0f, 0.38f, 0f), new Vector3(0.82f, 0.78f, 0.66f), playAnimationsOnGrab: true, playSoundsOnGrab: true), new SuperBattleGolfValuableDefinition("SuperBattleGolfValuable_RocketLauncher", "Rocket Launcher", "GameObject/Rocket launcher.prefab", (Type)2, 3900, 9100, 18f, 116f, 1.9f, new Color(0.454f, 0.657f, 0.239f), new Color(0.719f, 0.547f, 0.629f), new Color(0.64f, 0.666f, 0.239f), new Vector3(0f, 0.38f, 0f), new Vector3(0.82f, 0.78f, 0.66f), playAnimationsOnGrab: true, playSoundsOnGrab: true), new SuperBattleGolfValuableDefinition("SuperBattleGolfValuable_Rocket", "Rocket", "GameObject/Rocket.prefab", (Type)2, 3000, 7200, 27f, 105f, 1.9f, new Color(0.505f, 0.623f, 0.242f), new Color(0.849f, 0.225f, 0.714f), new Color(0.793f, 0.589f, 0.592f), new Vector3(0f, 0.38f, 0f), new Vector3(0.82f, 0.78f, 0.66f), playAnimationsOnGrab: true, playSoundsOnGrab: true), new SuperBattleGolfValuableDefinition("SuperBattleGolfValuable_SpringBoots", "Spring Boots", "GameObject/Spring boots.prefab", (Type)2, 4400, 8500, 27f, 102f, 1.9f, new Color(0.776f, 0.666f, 0.203f), new Color(0.578f, 0.849f, 0.214f), new Color(0.883f, 0.493f, 0.496f), new Vector3(0f, 0.38f, 0f), new Vector3(0.82f, 0.78f, 0.66f), playAnimationsOnGrab: true, playSoundsOnGrab: true), new SuperBattleGolfValuableDefinition("SuperBattleGolfValuable_Landmine", "Landmine", "GameObject/Landmine.prefab", (Type)2, 3900, 9100, 22f, 100f, 1.9f, new Color(0.205f, 0.502f, 0.335f), new Color(0.245f, 0.764f, 0.694f), new Color(0.618f, 0.434f, 0.448f), new Vector3(0f, 0.38f, 0f), new Vector3(0.82f, 0.78f, 0.66f), playAnimationsOnGrab: true, playSoundsOnGrab: true), new SuperBattleGolfValuableDefinition("SuperBattleGolfValuable_GolfCartBriefcase", "Golf Cart Briefcase", "GameObject/Golf cart equipment whole.prefab", (Type)4, 6000, 10800, 11f, 92f, 3f, new Color(0.875f, 0.666f, 0.572f), new Color(0.75f, 0.86f, 0.838f), new Color(0.818f, 0.544f, 0.522f), new Vector3(0f, 0.35f, 0f), new Vector3(1.18f, 0.72f, 0.78f), playAnimationsOnGrab: true, playSoundsOnGrab: true) }; public static SuperBattleGolfValuableDefinition? FindByPrefabName(string prefabName) { SuperBattleGolfValuableDefinition[] all = All; foreach (SuperBattleGolfValuableDefinition superBattleGolfValuableDefinition in all) { if (string.Equals(superBattleGolfValuableDefinition.PrefabName, prefabName, StringComparison.OrdinalIgnoreCase)) { return superBattleGolfValuableDefinition; } } return null; } } internal static class SuperBattleGolfValuableGrabBounds { private const int MaxColliderTriangles = 40; private const float MinColliderExtent = 0.015f; public static void Add(Transform root, SuperBattleGolfValuableDefinition definition) { RemoveTemplateColliders(root); if (AddMeshColliders(root) == 0) { AddFallbackBox(root, definition); SuperBattleGolfValuablesPlugin.Log.LogWarning((object)(definition.DisplayName + " had no usable renderer meshes for grab colliders; using fitted fallback bounds.")); } } private static int AddMeshColliders(Transform root) { int num = 0; Renderer[] componentsInChildren = ((Component)root).GetComponentsInChildren(true); foreach (Renderer val in componentsInChildren) { if (val.enabled && !(val is ParticleSystemRenderer)) { Mesh val2 = CreateCollisionMesh(val); if ((Object)(object)val2 == (Object)null || !HasValidCollisionShape(val2)) { DestroyMesh(val2); continue; } MeshCollider obj = ((Component)val).gameObject.AddComponent(); obj.cookingOptions = (MeshColliderCookingOptions)14; obj.convex = true; ((Collider)obj).isTrigger = false; obj.sharedMesh = val2; ConfigureColliderObject(((Component)val).gameObject); ((Component)val).gameObject.AddComponent(); RepoValuableAccess.HideGrabMeshColliderGizmo(((Component)val).gameObject.AddComponent()); num++; } } return num; } private static Mesh? CreateCollisionMesh(Renderer renderer) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Expected O, but got Unknown //IL_00a8: Unknown result type (might be due to invalid IL or missing references) Mesh val = null; Mesh val2 = null; SkinnedMeshRenderer val3 = (SkinnedMeshRenderer)(object)((renderer is SkinnedMeshRenderer) ? renderer : null); if (val3 != null && (Object)(object)val3.sharedMesh != (Object)null) { val2 = new Mesh { name = ((Object)renderer).name + "_SuperBattleGolfGrabCollider", hideFlags = (HideFlags)61 }; try { val3.BakeMesh(val2); val = val2; } catch { val = val3.sharedMesh; } } else { MeshFilter component = ((Component)renderer).GetComponent(); if ((Object)(object)component != (Object)null && (Object)(object)component.sharedMesh != (Object)null) { val = component.sharedMesh; } } Mesh val4 = CreateReducedMesh(val, ((Object)renderer).name + "_SuperBattleGolfGrabCollider"); if ((Object)(object)val4 == (Object)null && (Object)(object)val != (Object)null) { val4 = CreateBoxMesh(val.bounds, ((Object)renderer).name + "_SuperBattleGolfGrabCollider"); } DestroyMesh(val2); return val4; } private static Mesh? CreateReducedMesh(Mesh? sourceMesh, string name) { //IL_0025: 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_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Expected O, but got Unknown //IL_0098: 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_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)sourceMesh == (Object)null) { return null; } if (!sourceMesh.isReadable) { return null; } Vector3[] vertices = sourceMesh.vertices; int[] triangles = sourceMesh.triangles; if (!HasValidVertexSet(vertices, sourceMesh.bounds) || triangles.Length < 3) { return null; } int num = triangles.Length / 3; int num2 = Mathf.Min(num, 40); Vector3[] array = (Vector3[])(object)new Vector3[num2 * 3]; int[] array2 = new int[num2 * 3]; for (int i = 0; i < num2; i++) { int num3 = ((num2 > 1) ? Mathf.RoundToInt((float)i * ((float)num - 1f) / ((float)num2 - 1f)) : 0) * 3; int num4 = i * 3; array[num4] = vertices[triangles[num3]]; array[num4 + 1] = vertices[triangles[num3 + 1]]; array[num4 + 2] = vertices[triangles[num3 + 2]]; array2[num4] = num4; array2[num4 + 1] = num4 + 1; array2[num4 + 2] = num4 + 2; } Mesh val = new Mesh { name = name, hideFlags = (HideFlags)61 }; val.vertices = array; val.triangles = array2; val.RecalculateBounds(); if (!HasValidCollisionShape(val)) { DestroyMesh(val); return null; } return val; } private static Mesh? CreateBoxMesh(Bounds bounds, string name) { //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_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0084: 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_0091: 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_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_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: 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_00cd: 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_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_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_00f1: 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_00fc: 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_0109: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0115: 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_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_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_015e: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Unknown result type (might be due to invalid IL or missing references) //IL_017c: Expected O, but got Unknown Vector3 size = ((Bounds)(ref bounds)).size; if (Mathf.Max(new float[3] { size.x, size.y, size.z }) < 0.015f) { return null; } Vector3 min = ((Bounds)(ref bounds)).min; Vector3 max = ((Bounds)(ref bounds)).max; Vector3[] vertices = (Vector3[])(object)new Vector3[8] { new Vector3(min.x, min.y, min.z), new Vector3(max.x, min.y, min.z), new Vector3(max.x, max.y, min.z), new Vector3(min.x, max.y, min.z), new Vector3(min.x, min.y, max.z), new Vector3(max.x, min.y, max.z), new Vector3(max.x, max.y, max.z), new Vector3(min.x, max.y, max.z) }; int[] triangles = new int[36] { 0, 2, 1, 0, 3, 2, 4, 5, 6, 4, 6, 7, 0, 1, 5, 0, 5, 4, 2, 3, 7, 2, 7, 6, 1, 2, 6, 1, 6, 5, 3, 0, 4, 3, 4, 7 }; Mesh val = new Mesh { name = name, hideFlags = (HideFlags)61, vertices = vertices, triangles = triangles }; val.RecalculateBounds(); return val; } private static bool HasValidCollisionShape(Mesh mesh) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) if (mesh.isReadable && mesh.vertexCount >= 3) { return HasValidVertexSet(mesh.vertices, mesh.bounds); } return false; } private static bool HasValidVertexSet(IReadOnlyList vertices, Bounds bounds) { //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_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0022: 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_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) Vector3 size = ((Bounds)(ref bounds)).size; if (Mathf.Max(new float[3] { size.x, size.y, size.z }) < 0.015f) { return false; } HashSet hashSet = new HashSet(); for (int i = 0; i < vertices.Count; i++) { Vector3 val = vertices[i]; hashSet.Add(new Vector3Int(Mathf.RoundToInt(val.x * 10000f), Mathf.RoundToInt(val.y * 10000f), Mathf.RoundToInt(val.z * 10000f))); if (hashSet.Count >= 3) { return true; } } return false; } private static void AddFallbackBox(Transform root, SuperBattleGolfValuableDefinition definition) { //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_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_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) //IL_0046: 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_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_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_0074: 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_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_0110: 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_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Expected O, but got Unknown //IL_0136: Unknown result type (might be due to invalid IL or missing references) Bounds val = CalculateVisualBounds(root); GameObject val2 = new GameObject("SuperBattleGolfValuableFallbackGrabBounds"); val2.transform.SetParent(root, false); val2.transform.localPosition = root.InverseTransformPoint(((Bounds)(ref val)).center); val2.transform.localRotation = Quaternion.identity; val2.transform.localScale = Vector3.one; Vector3 size = ((Bounds)(ref val)).size; Vector3 lossyScale = root.lossyScale; size.x = ((lossyScale.x == 0f) ? definition.GrabBoundsSize.x : (size.x / Mathf.Abs(lossyScale.x))); size.y = ((lossyScale.y == 0f) ? definition.GrabBoundsSize.y : (size.y / Mathf.Abs(lossyScale.y))); size.z = ((lossyScale.z == 0f) ? definition.GrabBoundsSize.z : (size.z / Mathf.Abs(lossyScale.z))); BoxCollider obj = val2.AddComponent(); obj.center = Vector3.zero; obj.size = Vector3.Max(size, Vector3.one * 0.12f); ((Collider)obj).isTrigger = false; ConfigureColliderObject(val2); val2.AddComponent(); RepoValuableAccess.HideGrabBoxColliderGizmo(val2.AddComponent()); } private static void ConfigureColliderObject(GameObject gameObject) { gameObject.tag = "Phys Grab Object"; int num = LayerMask.NameToLayer("PhysGrabObject"); if (num >= 0) { gameObject.layer = num; } } private static Bounds CalculateVisualBounds(Transform root) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0019: 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_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) Renderer[] componentsInChildren = ((Component)root).GetComponentsInChildren(true); Bounds bounds = default(Bounds); ((Bounds)(ref bounds))..ctor(root.position, Vector3.one * 0.3f); bool flag = false; Renderer[] array = componentsInChildren; foreach (Renderer val in array) { if (val.enabled && !(val is ParticleSystemRenderer)) { if (flag) { ((Bounds)(ref bounds)).Encapsulate(val.bounds); continue; } bounds = val.bounds; flag = true; } } return bounds; } private static void RemoveTemplateColliders(Transform root) { PhysGrabObjectCollider[] componentsInChildren = ((Component)root).GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren.Length; i++) { DestroyComponent((Component)(object)componentsInChildren[i]); } PhysGrabObjectBoxCollider[] componentsInChildren2 = ((Component)root).GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren2.Length; i++) { DestroyComponent((Component)(object)componentsInChildren2[i]); } PhysGrabObjectMeshCollider[] componentsInChildren3 = ((Component)root).GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren3.Length; i++) { DestroyComponent((Component)(object)componentsInChildren3[i]); } Collider[] componentsInChildren4 = ((Component)root).GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren4.Length; i++) { DestroyComponent((Component)(object)componentsInChildren4[i]); } } private static void DestroyComponent(Component component) { if ((Object)(object)component != (Object)null) { Object.DestroyImmediate((Object)(object)component); } } private static void DestroyMesh(Mesh? mesh) { //IL_000a: 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) if ((Object)(object)mesh != (Object)null && (((Object)mesh).hideFlags & 0x3D) != 0) { Object.DestroyImmediate((Object)(object)mesh); } } } internal sealed class SuperBattleGolfValuableGrabFeedback : MonoBehaviour { private const float TriggerCooldown = 1.45f; private readonly List _animators = new List(); private readonly List _legacyAnimations = new List(); private AudioClip[] _audioClips = Array.Empty(); private SuperBattleGolfValuableDefinition? _definition; private AudioSource? _audioSource; private PhysGrabObject? _physGrabObject; private bool _playAnimations; private bool _playSounds; private bool _runtimeReady; private bool _grabActive; private bool _wasGrabbed; private int _grabCount; private float _lastTriggerTime = -999f; public void Configure(SuperBattleGolfValuableDefinition definition, AudioClip[] audioClips, bool playAnimations, bool playSounds) { _definition = definition; _audioClips = audioClips ?? Array.Empty(); _playAnimations = playAnimations; _playSounds = playSounds; } private void Start() { EnsureRuntimeReady(); } private void EnsureRuntimeReady() { _physGrabObject = ((Component)this).GetComponent(); RecoverConfigurationFromSpawnedName(); if (_runtimeReady) { CollectAnimationsIfNeeded(); CreateAudioSourceIfNeeded(); } else { _runtimeReady = true; CollectAnimationsIfNeeded(); CreateAudioSourceIfNeeded(); } } private void CollectAnimationsIfNeeded() { if (_playAnimations && _animators.Count == 0 && _legacyAnimations.Count == 0) { _animators.AddRange(((Component)this).GetComponentsInChildren(true)); _legacyAnimations.AddRange(((Component)this).GetComponentsInChildren(true)); } } private void RecoverConfigurationFromSpawnedName() { if (_definition != null) { return; } string b = ((Object)((Component)this).gameObject).name.Replace("(Clone)", string.Empty).Trim(); SuperBattleGolfValuableDefinition[] all = SuperBattleGolfValuableDefinitions.All; foreach (SuperBattleGolfValuableDefinition superBattleGolfValuableDefinition in all) { if (string.Equals(superBattleGolfValuableDefinition.PrefabName, b, StringComparison.OrdinalIgnoreCase)) { Configure(superBattleGolfValuableDefinition, SuperBattleGolfValuableBundleVisuals.LoadAudioClipsFor(superBattleGolfValuableDefinition), superBattleGolfValuableDefinition.PlayAnimationsOnGrab, superBattleGolfValuableDefinition.PlaySoundsOnGrab); break; } } } private void CreateAudioSourceIfNeeded() { if (_playSounds && _audioClips.Length != 0 && !((Object)(object)_audioSource != (Object)null)) { _audioSource = ((Component)this).gameObject.AddComponent(); _audioSource.playOnAwake = false; _audioSource.spatialBlend = 1f; _audioSource.rolloffMode = (AudioRolloffMode)1; _audioSource.minDistance = 1.5f; _audioSource.maxDistance = 28f; _audioSource.volume = 1f; } } private void Update() { EnsureRuntimeReady(); if (!((Object)(object)_physGrabObject == (Object)null)) { bool flag = RepoValuableAccess.IsGrabbedForVoice(_physGrabObject); if (!flag || flag == _wasGrabbed) { _wasGrabbed = flag; return; } _wasGrabbed = flag; TriggerGrab("poll"); } } internal static void TriggerFrom(PhysGrabObject physGrabObject, string source) { SuperBattleGolfValuableGrabFeedback superBattleGolfValuableGrabFeedback = ((Component)physGrabObject).GetComponent(); if ((Object)(object)superBattleGolfValuableGrabFeedback == (Object)null) { superBattleGolfValuableGrabFeedback = ((Component)physGrabObject).GetComponentInChildren(true); } superBattleGolfValuableGrabFeedback?.TriggerGrab(source); } internal static void ReleaseFrom(PhysGrabObject physGrabObject) { SuperBattleGolfValuableGrabFeedback superBattleGolfValuableGrabFeedback = ((Component)physGrabObject).GetComponent(); if ((Object)(object)superBattleGolfValuableGrabFeedback == (Object)null) { superBattleGolfValuableGrabFeedback = ((Component)physGrabObject).GetComponentInChildren(true); } superBattleGolfValuableGrabFeedback?.ReleaseGrab(); } internal void TriggerGrab(string source) { if (!_grabActive && !(Time.time - _lastTriggerTime < 1.45f)) { _lastTriggerTime = Time.time; _grabActive = true; _wasGrabbed = true; _grabCount++; EnsureRuntimeReady(); PlayGrabAnimation(); PlayGrabSound(); if (_definition != null && (Object)(object)_physGrabObject != (Object)null) { SuperBattleGolfValuableActiveLogic.TriggerFrom(_physGrabObject, source); SuperBattleGolfValuableGrabLogic.Play(_definition, ((Component)this).transform, _physGrabObject, _grabCount); } } } private void ReleaseGrab() { _grabActive = false; _wasGrabbed = false; } private void PlayGrabAnimation() { //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Expected O, but got Unknown if (!_playAnimations) { return; } foreach (Animator animator in _animators) { if (!((Object)(object)animator == (Object)null) && !((Object)(object)animator.runtimeAnimatorController == (Object)null)) { AnimationClip[] animationClips = animator.runtimeAnimatorController.animationClips; if (animationClips.Length != 0) { AnimationClip val = animationClips[_grabCount % animationClips.Length]; animator.Play(((Object)val).name, 0, 0f); animator.Update(0f); } } } foreach (Animation legacyAnimation in _legacyAnimations) { if ((Object)(object)legacyAnimation == (Object)null || legacyAnimation.GetClipCount() == 0) { continue; } { IEnumerator enumerator3 = legacyAnimation.GetEnumerator(); try { if (enumerator3.MoveNext()) { AnimationState val2 = (AnimationState)enumerator3.Current; legacyAnimation.Play(val2.name); } } finally { IDisposable disposable = enumerator3 as IDisposable; if (disposable != null) { disposable.Dispose(); } } } } } private void PlayGrabSound() { //IL_003d: 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_0052: Invalid comparison between Unknown and I4 if (_playSounds && !((Object)(object)_audioSource == (Object)null) && _audioClips.Length != 0) { AudioClip val = _audioClips[Mathf.Abs(_grabCount) % _audioClips.Length]; if ((int)val.loadState == 0) { val.LoadAudioData(); } if ((int)val.loadState == 3) { SuperBattleGolfValuablesPlugin.Log.LogWarning((object)("Grab audio '" + ((Object)val).name + "' failed to load.")); } else { _audioSource.PlayOneShot(val, 1f); } } } } internal sealed class SuperBattleGolfValuableGrabGlow : MonoBehaviour { private readonly List _materials = new List(); private PhysGrabObject? _physGrabObject; [SerializeField] private Color _glowColor = Color.cyan; private bool _wasGrabbed; public void Configure(Color glowColor) { //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) _glowColor = glowColor; } private void Start() { _physGrabObject = ((Component)this).GetComponent(); Renderer[] componentsInChildren = ((Component)this).GetComponentsInChildren(true); foreach (Renderer val in componentsInChildren) { if (!val.enabled) { continue; } Material[] materials = val.materials; foreach (Material val2 in materials) { if ((Object)(object)val2 != (Object)null && val2.HasProperty("_EmissionColor")) { val2.EnableKeyword("_EMISSION"); _materials.Add(val2); } } } } private void Update() { //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_physGrabObject == (Object)null) { return; } bool flag = RepoValuableAccess.IsGrabbed(_physGrabObject); if (flag == _wasGrabbed) { return; } _wasGrabbed = flag; Color val = (flag ? (_glowColor * 1.35f) : Color.black); foreach (Material material in _materials) { if ((Object)(object)material != (Object)null) { material.SetColor("_EmissionColor", val); } } } } internal static class SuperBattleGolfValuableGrabLogic { private static readonly Collider[] NearbyColliders = (Collider[])(object)new Collider[40]; public static void Play(SuperBattleGolfValuableDefinition definition, Transform root, PhysGrabObject physGrabObject, int grabCount) { //IL_0560: Unknown result type (might be due to invalid IL or missing references) //IL_056a: Unknown result type (might be due to invalid IL or missing references) //IL_056f: Unknown result type (might be due to invalid IL or missing references) //IL_0579: Unknown result type (might be due to invalid IL or missing references) //IL_057e: Unknown result type (might be due to invalid IL or missing references) //IL_0584: Unknown result type (might be due to invalid IL or missing references) //IL_058e: Unknown result type (might be due to invalid IL or missing references) //IL_0453: Unknown result type (might be due to invalid IL or missing references) //IL_045d: Unknown result type (might be due to invalid IL or missing references) //IL_0469: Unknown result type (might be due to invalid IL or missing references) //IL_0473: Unknown result type (might be due to invalid IL or missing references) //IL_047f: Unknown result type (might be due to invalid IL or missing references) //IL_027c: Unknown result type (might be due to invalid IL or missing references) //IL_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_0295: Unknown result type (might be due to invalid IL or missing references) //IL_029a: Unknown result type (might be due to invalid IL or missing references) //IL_02a0: Unknown result type (might be due to invalid IL or missing references) //IL_02aa: Unknown result type (might be due to invalid IL or missing references) //IL_061a: Unknown result type (might be due to invalid IL or missing references) //IL_0624: Unknown result type (might be due to invalid IL or missing references) //IL_062a: Unknown result type (might be due to invalid IL or missing references) //IL_0634: Unknown result type (might be due to invalid IL or missing references) //IL_033c: Unknown result type (might be due to invalid IL or missing references) //IL_0357: Unknown result type (might be due to invalid IL or missing references) //IL_035c: Unknown result type (might be due to invalid IL or missing references) //IL_0366: Unknown result type (might be due to invalid IL or missing references) //IL_036b: Unknown result type (might be due to invalid IL or missing references) //IL_0375: Unknown result type (might be due to invalid IL or missing references) //IL_037a: Unknown result type (might be due to invalid IL or missing references) //IL_0380: Unknown result type (might be due to invalid IL or missing references) //IL_038a: Unknown result type (might be due to invalid IL or missing references) //IL_02dc: Unknown result type (might be due to invalid IL or missing references) //IL_02e6: Unknown result type (might be due to invalid IL or missing references) //IL_02eb: Unknown result type (might be due to invalid IL or missing references) //IL_02f5: Unknown result type (might be due to invalid IL or missing references) //IL_02fa: Unknown result type (might be due to invalid IL or missing references) //IL_0300: Unknown result type (might be due to invalid IL or missing references) //IL_030a: Unknown result type (might be due to invalid IL or missing references) //IL_0316: Unknown result type (might be due to invalid IL or missing references) //IL_0320: Unknown result type (might be due to invalid IL or missing references) //IL_0325: Unknown result type (might be due to invalid IL or missing references) //IL_032f: Unknown result type (might be due to invalid IL or missing references) //IL_0397: Unknown result type (might be due to invalid IL or missing references) //IL_039c: Unknown result type (might be due to invalid IL or missing references) //IL_03a6: Unknown result type (might be due to invalid IL or missing references) //IL_03ab: Unknown result type (might be due to invalid IL or missing references) //IL_03b5: Unknown result type (might be due to invalid IL or missing references) //IL_03ba: Unknown result type (might be due to invalid IL or missing references) //IL_03c0: Unknown result type (might be due to invalid IL or missing references) //IL_03ca: 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_02c0: 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_02cf: Unknown result type (might be due to invalid IL or missing references) //IL_05d5: Unknown result type (might be due to invalid IL or missing references) //IL_05df: Unknown result type (might be due to invalid IL or missing references) //IL_05e4: Unknown result type (might be due to invalid IL or missing references) //IL_05ee: Unknown result type (might be due to invalid IL or missing references) //IL_03d7: Unknown result type (might be due to invalid IL or missing references) //IL_03dc: Unknown result type (might be due to invalid IL or missing references) //IL_03e6: Unknown result type (might be due to invalid IL or missing references) //IL_03eb: Unknown result type (might be due to invalid IL or missing references) //IL_03f5: Unknown result type (might be due to invalid IL or missing references) //IL_03fa: Unknown result type (might be due to invalid IL or missing references) //IL_0400: Unknown result type (might be due to invalid IL or missing references) //IL_040a: Unknown result type (might be due to invalid IL or missing references) //IL_0417: Unknown result type (might be due to invalid IL or missing references) //IL_042c: Unknown result type (might be due to invalid IL or missing references) //IL_0436: Unknown result type (might be due to invalid IL or missing references) //IL_043c: Unknown result type (might be due to invalid IL or missing references) //IL_0446: Unknown result type (might be due to invalid IL or missing references) //IL_04f0: Unknown result type (might be due to invalid IL or missing references) //IL_04f5: Unknown result type (might be due to invalid IL or missing references) //IL_04ff: Unknown result type (might be due to invalid IL or missing references) //IL_0504: Unknown result type (might be due to invalid IL or missing references) //IL_050e: Unknown result type (might be due to invalid IL or missing references) //IL_0513: Unknown result type (might be due to invalid IL or missing references) //IL_0519: Unknown result type (might be due to invalid IL or missing references) //IL_0523: Unknown result type (might be due to invalid IL or missing references) //IL_052f: Unknown result type (might be due to invalid IL or missing references) //IL_0535: Unknown result type (might be due to invalid IL or missing references) //IL_053f: Unknown result type (might be due to invalid IL or missing references) //IL_0544: Unknown result type (might be due to invalid IL or missing references) //IL_049b: Unknown result type (might be due to invalid IL or missing references) //IL_04a0: Unknown result type (might be due to invalid IL or missing references) //IL_04aa: Unknown result type (might be due to invalid IL or missing references) //IL_04af: Unknown result type (might be due to invalid IL or missing references) //IL_04c9: Unknown result type (might be due to invalid IL or missing references) //IL_04d3: Unknown result type (might be due to invalid IL or missing references) //IL_04d9: Unknown result type (might be due to invalid IL or missing references) //IL_04e3: Unknown result type (might be due to invalid IL or missing references) //IL_05ff: Unknown result type (might be due to invalid IL or missing references) //IL_059a: Unknown result type (might be due to invalid IL or missing references) //IL_05a4: Unknown result type (might be due to invalid IL or missing references) //IL_05aa: Unknown result type (might be due to invalid IL or missing references) //IL_05b4: Unknown result type (might be due to invalid IL or missing references) //IL_05b9: Unknown result type (might be due to invalid IL or missing references) //IL_05bf: Unknown result type (might be due to invalid IL or missing references) //IL_05c9: Unknown result type (might be due to invalid IL or missing references) SpawnPulseLight(root, definition); Rigidbody component = ((Component)physGrabObject).GetComponent(); if ((Object)(object)component == (Object)null || component.isKinematic || !IsAuthoritative()) { return; } string prefabName = definition.PrefabName; if (prefabName == null) { return; } switch (prefabName.Length) { case 38: switch (prefabName[24]) { default: return; case 'B': break; case 'R': if (prefabName == "SuperBattleGolfValuable_RocketLauncher") { Kick(component, -root.forward * 1.4f + Vector3.up * 0.4f, root.right * 5f); PushNearby(root, root.position - root.forward * 0.35f, 2.6f, 1.4f, 0.2f); } return; } if (!(prefabName == "SuperBattleGolfValuable_BattleGolfBall")) { break; } goto IL_02b5; case 31: switch (prefabName[24]) { default: return; case 'G': break; case 'A': if (prefabName == "SuperBattleGolfValuable_Airhorn") { PushNearby(root, root.position, 3.6f, 2.4f, 0.35f); Kick(component, -root.forward * 0.8f + Vector3.up * 0.3f, root.up * 3.5f); } return; } if (!(prefabName == "SuperBattleGolfValuable_GolfTee")) { break; } goto IL_02b5; case 32: switch (prefabName[24]) { case 'G': if (prefabName == "SuperBattleGolfValuable_GolfClub") { Kick(component, root.right * 0.9f + Vector3.up * 0.35f, root.forward * 5f); } break; case 'L': if (prefabName == "SuperBattleGolfValuable_Landmine") { Kick(component, Vector3.up * 0.9f, Random.insideUnitSphere * 3.5f); if (grabCount % 3 == 0) { PushNearby(root, root.position, 2.2f, 1.2f, 0.25f); } } break; } break; case 33: switch (prefabName[24]) { default: return; case 'C': if (!(prefabName == "SuperBattleGolfValuable_CoffeeCup")) { return; } break; case 'H': if (!(prefabName == "SuperBattleGolfValuable_HotCoffee")) { return; } break; } goto IL_0315; case 35: switch (prefabName[24]) { default: return; case 'C': break; case 'E': if (prefabName == "SuperBattleGolfValuable_ElephantGun") { Kick(component, -root.forward * 1.7f + Vector3.up * 0.35f, root.right * 6f); } return; case 'S': if (prefabName == "SuperBattleGolfValuable_SpringBoots") { Kick(component, Vector3.up * 2.3f + root.forward * 0.35f, root.right * 4.2f); } return; } if (!(prefabName == "SuperBattleGolfValuable_CoffeePlate")) { break; } goto IL_0315; case 37: switch (prefabName[24]) { case 'D': if (prefabName == "SuperBattleGolfValuable_DuelingPistol") { Kick(component, -root.forward * 1.1f + Vector3.up * 0.25f, root.right * 4f); } break; case 'E': if (prefabName == "SuperBattleGolfValuable_Electromagnet") { PullNearby(root, root.position, 4.2f, 2.1f); Kick(component, Vector3.up * 0.25f, root.up * 5f); } break; } break; case 42: switch (prefabName[24]) { default: return; case 'F': break; case 'O': if (prefabName == "SuperBattleGolfValuable_OrbitalLaserRemote") { PushNearby(root, root.position + Vector3.up * 0.6f, 3.1f, 1.6f, -0.15f); Kick(component, Vector3.up * 0.55f, root.up * 4f); } return; } if (!(prefabName == "SuperBattleGolfValuable_FreezeBombIceBlock")) { break; } goto IL_0451; case 36: if (prefabName == "SuperBattleGolfValuable_MiniGolfCart") { Kick(component, root.forward * 1.15f + Vector3.up * 0.9f, root.right * 4.5f); } break; case 34: if (!(prefabName == "SuperBattleGolfValuable_FreezeBomb")) { break; } goto IL_0451; case 30: if (prefabName == "SuperBattleGolfValuable_Rocket") { Kick(component, root.forward * 1.65f + Vector3.up * 0.3f, root.forward * 6f); } break; case 41: if (prefabName == "SuperBattleGolfValuable_GolfCartBriefcase") { Kick(component, Vector3.up * 0.75f, root.right * 3.5f); } break; case 39: case 40: break; IL_0315: Kick(component, Vector3.up * 0.45f, Random.insideUnitSphere * 2.5f); break; IL_02b5: Kick(component, Vector3.up * 1.25f, Random.insideUnitSphere * 6f); break; IL_0451: component.velocity *= 0.45f; component.angularVelocity *= 0.35f; PushNearby(root, root.position, 2.8f, 0.85f, 0.15f); break; } } private static bool IsAuthoritative() { if (!PhotonNetwork.OfflineMode && PhotonNetwork.InRoom) { return PhotonNetwork.IsMasterClient; } return true; } private static void Kick(Rigidbody rigidbody, Vector3 impulse, Vector3 torque) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) rigidbody.AddForce(impulse, (ForceMode)1); rigidbody.AddTorque(torque, (ForceMode)1); } private static void PushNearby(Transform ownerRoot, Vector3 origin, float radius, float force, float upwardBias) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_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_00af: Unknown result type (might be due to invalid IL or missing references) int num = Physics.OverlapSphereNonAlloc(origin, radius, NearbyColliders, -1, (QueryTriggerInteraction)1); for (int i = 0; i < num; i++) { Rigidbody val = (((Object)(object)NearbyColliders[i] != (Object)null) ? NearbyColliders[i].attachedRigidbody : null); if (!((Object)(object)val == (Object)null) && !val.isKinematic && !((Component)val).transform.IsChildOf(ownerRoot)) { Vector3 val2 = val.worldCenterOfMass - origin; float num2 = Mathf.Max(0.1f, ((Vector3)(ref val2)).magnitude); Vector3 val3 = val2 / num2 + Vector3.up * upwardBias; Vector3 val4 = ((Vector3)(ref val3)).normalized * (force * Mathf.Clamp01(1f - num2 / radius)); val.AddForce(val4, (ForceMode)1); } } } private static void PullNearby(Transform ownerRoot, Vector3 origin, float radius, float force) { //IL_0000: 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_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) int num = Physics.OverlapSphereNonAlloc(origin, radius, NearbyColliders, -1, (QueryTriggerInteraction)1); for (int i = 0; i < num; i++) { Rigidbody val = (((Object)(object)NearbyColliders[i] != (Object)null) ? NearbyColliders[i].attachedRigidbody : null); if (!((Object)(object)val == (Object)null) && !val.isKinematic && !((Component)val).transform.IsChildOf(ownerRoot)) { Vector3 val2 = origin - val.worldCenterOfMass; float num2 = Mathf.Max(0.1f, ((Vector3)(ref val2)).magnitude); val.AddForce(val2 / num2 * (force * Mathf.Clamp01(1f - num2 / radius)), (ForceMode)1); } } } private static void SpawnPulseLight(Transform root, SuperBattleGolfValuableDefinition definition) { //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_0012: 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_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0036: 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_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("Super Battle Golf Grab Pulse") { hideFlags = (HideFlags)52 }; val.transform.SetParent(root, false); val.transform.localPosition = definition.GrabBoundsCenter; val.transform.localRotation = Quaternion.identity; Light val2 = val.AddComponent(); val2.type = (LightType)2; val2.color = definition.Accent; val2.intensity = 1.6f; Vector3 grabBoundsSize = definition.GrabBoundsSize; val2.range = Mathf.Max(((Vector3)(ref grabBoundsSize)).magnitude * 1.15f, 1.4f); val.AddComponent().Configure(val2, 0.38f); } } internal sealed class SuperBattleGolfValuableLightFade : MonoBehaviour { private Light? _light; private float _startIntensity; private float _startRange; private float _duration = 0.35f; private float _startTime; public void Configure(Light lightSource, float duration) { _light = lightSource; _startIntensity = lightSource.intensity; _startRange = lightSource.range; _duration = Mathf.Max(0.05f, duration); _startTime = Time.time; } private void Update() { if ((Object)(object)_light == (Object)null) { Object.Destroy((Object)(object)((Component)this).gameObject); return; } float num = Mathf.Clamp01((Time.time - _startTime) / _duration); float num2 = 1f - num; _light.intensity = _startIntensity * num2; _light.range = _startRange * Mathf.Lerp(0.45f, 1f, num2); if (num >= 1f) { Object.Destroy((Object)(object)((Component)this).gameObject); } } } internal sealed class SuperBattleGolfValuablePrefabFactory { private static readonly List GenericPreset = new List { "Valuables - Generic" }; private readonly ManualLogSource _log; private readonly Dictionary _templates = new Dictionary(); private GameObject? _prefabBank; public SuperBattleGolfValuablePrefabFactory(ManualLogSource log) { _log = log; } public bool TryRegisterAll() { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) ResolveTemplates(); if (_templates.Count == 0) { return false; } int num = 0; SuperBattleGolfValuableDefinition[] all = SuperBattleGolfValuableDefinitions.All; foreach (SuperBattleGolfValuableDefinition superBattleGolfValuableDefinition in all) { GameObject template = GetTemplate(superBattleGolfValuableDefinition.VolumeType); if ((Object)(object)template == (Object)null) { _log.LogWarning((object)$"Skipping {superBattleGolfValuableDefinition.DisplayName}: no template valuable exists for {superBattleGolfValuableDefinition.VolumeType}."); } else if (Valuables.RegisterValuable(CreatePrefab(superBattleGolfValuableDefinition, template), GenericPreset) == null) { _log.LogWarning((object)("REPOLib rejected " + superBattleGolfValuableDefinition.DisplayName + ".")); } else { num++; } } return num > 0; } private void ResolveTemplates() { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) _templates.Clear(); foreach (LevelValuables value in ValuablePresets.AllValuablePresets.Values) { Type[] volumeTypes = SuperBattleGolfValuableVisuals.VolumeTypes; foreach (Type val in volumeTypes) { if (!_templates.ContainsKey(val)) { GameObject val2 = FindTemplateInList(RepoValuableAccess.GetList(value, val)); if ((Object)(object)val2 != (Object)null) { _templates.Add(val, val2); } } } } } private static GameObject? FindTemplateInList(List? prefabRefs) { if (prefabRefs == null) { return null; } foreach (PrefabRef prefabRef in prefabRefs) { if (prefabRef != null && prefabRef.IsValid()) { GameObject prefab = prefabRef.Prefab; if ((Object)(object)prefab != (Object)null && (Object)(object)prefab.GetComponent() != (Object)null) { return prefab; } } } return null; } private GameObject? GetTemplate(Type type) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) if (_templates.TryGetValue(type, out GameObject value) && (Object)(object)value != (Object)null) { return value; } if (_templates.TryGetValue((Type)2, out value) && (Object)(object)value != (Object)null) { return value; } foreach (GameObject value2 in _templates.Values) { if ((Object)(object)value2 != (Object)null) { return value2; } } return null; } private GameObject CreatePrefab(SuperBattleGolfValuableDefinition definition, GameObject template) { //IL_0081: Unknown result type (might be due to invalid IL or missing references) GameObject val = EnsurePrefabBank(); GameObject val2 = Object.Instantiate(template, val.transform, false); ((Object)val2).name = definition.PrefabName; ((Object)val2).hideFlags = (HideFlags)61; val2.SetActive(true); RepoValuableAccess.ConfigureValuable(val2.GetComponent(), definition); DisableTemplateRenderers(val2); if (!SuperBattleGolfValuableBundleVisuals.TryAttach(val2.transform, definition)) { SuperBattleGolfValuableVisuals.Build(val2.transform, definition); } SuperBattleGolfValuableGrabBounds.Add(val2.transform, definition); if (definition.GrabGlow) { (val2.GetComponent() ?? val2.AddComponent()).Configure(definition.Accent); } if (definition.PlayAnimationsOnGrab || definition.PlaySoundsOnGrab) { (val2.GetComponent() ?? val2.AddComponent()).Configure(definition, SuperBattleGolfValuableBundleVisuals.LoadAudioClipsFor(definition), definition.PlayAnimationsOnGrab, definition.PlaySoundsOnGrab); } (val2.GetComponent() ?? val2.AddComponent()).Configure(definition); (val2.GetComponent() ?? val2.AddComponent()).Configure(definition); return val2; } private GameObject EnsurePrefabBank() { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Expected O, but got Unknown if ((Object)(object)_prefabBank != (Object)null) { return _prefabBank; } _prefabBank = new GameObject("SuperBattleGolfValuables Prefab Bank") { hideFlags = (HideFlags)61 }; _prefabBank.SetActive(false); Object.DontDestroyOnLoad((Object)(object)_prefabBank); return _prefabBank; } private static void DisableTemplateRenderers(GameObject prefab) { Renderer[] componentsInChildren = prefab.GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren.Length; i++) { componentsInChildren[i].enabled = false; } } } internal sealed class SuperBattleGolfValuablePulseFade : MonoBehaviour { private Renderer? _renderer; private Material? _material; private Color _startColor; private Vector3 _startScale; private float _duration = 0.45f; private float _startTime; public void Configure(Renderer renderer, Material material, Color color, float duration) { //IL_000f: 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_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) _renderer = renderer; _material = material; _startColor = color; _startScale = ((Component)this).transform.localScale; _duration = Mathf.Max(0.05f, duration); _startTime = Time.time; } private void Update() { //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_renderer == (Object)null || (Object)(object)_material == (Object)null) { Object.Destroy((Object)(object)((Component)this).gameObject); return; } float num = Mathf.Clamp01((Time.time - _startTime) / _duration); float num2 = 1f - num; ((Component)this).transform.localScale = Vector3.Lerp(_startScale * 0.18f, _startScale, Mathf.SmoothStep(0f, 1f, num)); Color startColor = _startColor; startColor.a *= num2; _material.color = startColor; if (num >= 1f) { Object.Destroy((Object)(object)((Component)this).gameObject); } } } [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInPlugin("Empress.REPO.SuperBattleGolfValuables", "Super Battle Golf Valuables", "1.0.0")] public sealed class SuperBattleGolfValuablesPlugin : BaseUnityPlugin { internal const string PluginGuid = "Empress.REPO.SuperBattleGolfValuables"; internal const string PluginName = "Super Battle Golf Valuables"; internal const string PluginVersion = "1.0.0"; private static readonly Harmony Harmony = new Harmony("Empress.REPO.SuperBattleGolfValuables"); private bool _registrationStarted; private bool _registered; internal static ManualLogSource Log { get; private set; } = null; private void Awake() { Log = ((BaseUnityPlugin)this).Logger; ((Component)this).gameObject.transform.parent = null; ((Object)((Component)this).gameObject).hideFlags = (HideFlags)61; Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject); Harmony.PatchAll(typeof(SuperBattleGolfValuablesPlugin).Assembly); ((MonoBehaviour)this).StartCoroutine(RegisterWhenREPOLibIsReady()); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Super Battle Golf Valuables v1.0.0 loaded."); } private IEnumerator RegisterWhenREPOLibIsReady() { if (!_registrationStarted) { _registrationStarted = true; while ((Object)(object)RepoValuableAccess.GetRunManagerInstance() == (Object)null || ValuablePresets.AllValuablePresets.Count == 0) { yield return null; } yield return null; SuperBattleGolfValuableBundleVisuals.Initialize(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location) ?? string.Empty, ((BaseUnityPlugin)this).Logger); SuperBattleGolfValuablePrefabFactory superBattleGolfValuablePrefabFactory = new SuperBattleGolfValuablePrefabFactory(((BaseUnityPlugin)this).Logger); _registered = superBattleGolfValuablePrefabFactory.TryRegisterAll(); ((BaseUnityPlugin)this).Logger.LogInfo((object)(_registered ? ("Registered " + SuperBattleGolfValuableDefinitions.All.Length + " generated valuables with REPOLib.") : "Generated valuables could not be registered because no vanilla valuable templates were available.")); } } } internal static class SuperBattleGolfValuableVisuals { public static readonly Type[] VolumeTypes; public static void Build(Transform root, SuperBattleGolfValuableDefinition definition) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("SuperBattleGolfValuableProceduralVisual"); val.transform.SetParent(root, false); val.transform.localPosition = Vector3.zero; val.transform.localRotation = Quaternion.identity; val.transform.localScale = Vector3.one; string text = definition.PrefabName.ToLowerInvariant(); if (text.Contains("dog")) { BuildDog(val.transform, definition); } else if (text.Contains("van")) { BuildVan(val.transform, definition); } else { BuildProp(val.transform, definition); } } private static void BuildDog(Transform root, SuperBattleGolfValuableDefinition definition) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_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_0107: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) Material material = MaterialFor(definition.PrefabName + " Body", definition.Primary); Material material2 = MaterialFor(definition.PrefabName + " Accent", definition.Accent, emission: true); AddSphere(root, "Body", new Vector3(0f, 0.34f, 0f), new Vector3(0.34f, 0.2f, 0.2f), material); AddSphere(root, "Head", new Vector3(0f, 0.5f, -0.24f), new Vector3(0.18f, 0.16f, 0.16f), material); AddCube(root, "Ears", new Vector3(0f, 0.62f, -0.24f), new Vector3(0.34f, 0.06f, 0.08f), material2); AddCylinder(root, "Stand", new Vector3(0f, 0.035f, 0f), Quaternion.identity, new Vector3(0.56f, 0.035f, 0.56f), MaterialFor(definition.PrefabName + " Stand", definition.Secondary)); } private static void BuildVan(Transform root, SuperBattleGolfValuableDefinition definition) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_017c: Unknown result type (might be due to invalid IL or missing references) Material material = MaterialFor(definition.PrefabName + " Body", definition.Primary); Material material2 = MaterialFor(definition.PrefabName + " Trim", definition.Secondary); Material material3 = MaterialFor(definition.PrefabName + " Lights", definition.Accent, emission: true); AddCube(root, "Body", new Vector3(0f, 0.35f, 0f), new Vector3(0.78f, 0.36f, 0.42f), material); AddCube(root, "Cabin", new Vector3(0.16f, 0.58f, 0f), new Vector3(0.4f, 0.22f, 0.38f), material2); AddCube(root, "Lights", new Vector3(0.4f, 0.36f, -0.22f), new Vector3(0.22f, 0.06f, 0.025f), material3); AddCylinder(root, "Front Wheel", new Vector3(0.26f, 0.14f, -0.25f), Quaternion.Euler(90f, 0f, 0f), new Vector3(0.13f, 0.08f, 0.13f), material2); AddCylinder(root, "Rear Wheel", new Vector3(-0.26f, 0.14f, -0.25f), Quaternion.Euler(90f, 0f, 0f), new Vector3(0.13f, 0.08f, 0.13f), material2); } private static void BuildProp(Transform root, SuperBattleGolfValuableDefinition definition) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) Material material = MaterialFor(definition.PrefabName + " Primary", definition.Primary); Material material2 = MaterialFor(definition.PrefabName + " Secondary", definition.Secondary); Material material3 = MaterialFor(definition.PrefabName + " Accent", definition.Accent, emission: true); AddCube(root, "Core", new Vector3(0f, 0.36f, 0f), new Vector3(0.5f, 0.52f, 0.38f), material); AddCube(root, "Face", new Vector3(0f, 0.42f, -0.2f), new Vector3(0.42f, 0.2f, 0.025f), material3); AddCylinder(root, "Base", new Vector3(0f, 0.035f, 0f), Quaternion.identity, new Vector3(0.58f, 0.035f, 0.58f), material2); } private static GameObject AddCube(Transform parent, string name, Vector3 localPosition, Vector3 localScale, Material material) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) return AddPrimitive(parent, name, (PrimitiveType)3, localPosition, Quaternion.identity, localScale, material); } private static GameObject AddSphere(Transform parent, string name, Vector3 localPosition, Vector3 localScale, Material material) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) return AddPrimitive(parent, name, (PrimitiveType)0, localPosition, Quaternion.identity, localScale, material); } private static GameObject AddCylinder(Transform parent, string name, Vector3 localPosition, Quaternion localRotation, Vector3 localScale, Material material) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) return AddPrimitive(parent, name, (PrimitiveType)2, localPosition, localRotation, localScale, material); } private static GameObject AddPrimitive(Transform parent, string name, PrimitiveType primitiveType, Vector3 localPosition, Quaternion localRotation, Vector3 localScale, Material material) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) GameObject obj = GameObject.CreatePrimitive(primitiveType); ((Object)obj).name = name; obj.transform.SetParent(parent, false); obj.transform.localPosition = localPosition; obj.transform.localRotation = localRotation; obj.transform.localScale = localScale; Collider component = obj.GetComponent(); if ((Object)(object)component != (Object)null) { Object.Destroy((Object)(object)component); } obj.GetComponent().sharedMaterial = material; return obj; } private static Material MaterialFor(string name, Color color, bool emission = false) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0016: 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_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Expected O, but got Unknown //IL_003a: 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) Material val = new Material(Shader.Find("Standard")) { name = name, color = color, hideFlags = (HideFlags)61 }; if (emission) { val.EnableKeyword("_EMISSION"); val.SetColor("_EmissionColor", color * 0.85f); } return val; } static SuperBattleGolfValuableVisuals() { Type[] array = new Type[7]; RuntimeHelpers.InitializeArray(array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/); VolumeTypes = (Type[])(object)array; } } }