Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of RIDING BEARS v0.4.2
RidingBears.dll
Decompiled 2 days agousing System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using HarmonyLib; using Jotunn; using Jotunn.Configs; using Jotunn.Entities; using Jotunn.Managers; using Jotunn.Utils; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("RIDING BEARS!")] [assembly: AssemblyDescription("Tame, ride and share a bear in Valheim.")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("RIDING BEARS!")] [assembly: AssemblyCopyright("Based on MyBearFriend by MysteriousMilk, WTFPL")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("e3243d22-4307-4008-ba36-9f326008cde5")] [assembly: AssemblyFileVersion("0.4.2.0")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.4.2.0")] namespace RidingBears { internal static class LocalizationHelper { private static readonly List<string> languages = new List<string> { "English", "Swedish", "French", "Italian", "German", "Spanish", "Russian", "Romanian", "Bulgarian", "Macedonian", "Finnish", "Danish", "Norwegian", "Icelandic", "Turkish", "Lithuanian", "Czech", "Hungarian", "Slovak", "Polish", "Dutch", "Portuguese_European", "Portuguese_Brazilian", "Chinese", "Chinese_Trad", "Japanese", "Korean", "Hindi", "Thai", "Abenaki", "Croatian", "Georgian", "Greek", "Serbian", "Ukrainian", "Latvian" }; public static bool IsLanguageSupported(string language) { return languages.Contains(language); } } internal class BearPassengerSeat : MonoBehaviour, Hoverable, Interactable { private const float OccupiedRadius = 0.1f; public Transform AttachPoint; public GameObject ColliderRoot; public string AttachAnimation; public Vector3 DetachOffset; public float UseDistance = 2f; public string GetHoverName() { return Localization.instance.Localize("$rb_saddle_passenger"); } public string GetHoverText() { if (!InUseDistance((Humanoid)(object)Player.m_localPlayer)) { return Localization.instance.Localize("<color=#888888>$piece_toofar</color>"); } return Localization.instance.Localize("$rb_saddle_passenger\n[<color=yellow><b>$KEY_Use</b></color>] $rb_saddle_passenger_use"); } public bool Interact(Humanoid human, bool hold, bool alt) { //IL_0074: Unknown result type (might be due to invalid IL or missing references) if (hold || alt) { return false; } Player val = (Player)(object)((human is Player) ? human : null); if (val == null || !InUseDistance(human)) { return false; } if (IsSeated(val)) { ((Character)val).AttachStop(); return false; } if (IsOccupied()) { ((Character)val).Message((MessageType)2, "$msg_blocked", 0, (Sprite)null); return false; } if (((Character)val).IsEncumbered()) { ((Character)val).Message((MessageType)2, "$rb_saddle_passenger_encumbered", 0, (Sprite)null); return false; } ((Character)val).AttachStart(AttachPoint, ColliderRoot, false, false, false, AttachAnimation, DetachOffset, (Transform)null); return false; } public bool UseItem(Humanoid user, ItemData item) { return false; } internal bool IsSeated(Player player) { if ((Object)(object)player != (Object)null && ((Character)player).IsAttached()) { return (Object)(object)player.GetAttachPoint() == (Object)(object)AttachPoint; } return false; } private bool IsOccupied() { //IL_0016: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)AttachPoint == (Object)null) { return false; } Player closestPlayer = Player.GetClosestPlayer(AttachPoint.position, 0.1f); if ((Object)(object)closestPlayer != (Object)null) { return (Object)(object)closestPlayer != (Object)(object)Player.m_localPlayer; } return false; } private bool InUseDistance(Humanoid human) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)human != (Object)null && (Object)(object)AttachPoint != (Object)null) { return Vector3.Distance(((Component)human).transform.position, AttachPoint.position) < UseDistance; } return false; } private void OnDisable() { Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer != (Object)null && ((Character)localPlayer).IsAttached() && (Object)(object)localPlayer.GetAttachPoint() == (Object)(object)AttachPoint) { ((Character)localPlayer).AttachStop(); } } } internal static class BearRiderAttack { private static bool s_loggedAttacks; internal static void Trigger(Sadle saddle, bool strong) { Character character = saddle.GetCharacter(); Humanoid val = (Humanoid)(object)((character is Humanoid) ? character : null); if (val == null || (Object)(object)((Character)val).m_nview == (Object)null || !((Character)val).m_nview.IsOwner()) { return; } List<ItemData> attackItems = GetAttackItems(val); if (attackItems.Count == 0) { return; } bool flag = false; ItemData val2 = attackItems[0]; if (strong) { if (attackItems.Count > 1) { val2 = attackItems[attackItems.Count - 1]; } else if (CanAttack(attackItems[0].m_shared.m_secondaryAttack)) { flag = true; } } if (val.GetCurrentWeapon() == val2 || val.EquipItem(val2, false)) { ((Character)val).StartAttack((Character)null, flag); } } private static List<ItemData> GetAttackItems(Humanoid creature) { Inventory inventory = creature.GetInventory(); if (inventory == null) { return new List<ItemData>(); } List<ItemData> list = (from item in inventory.GetAllItems() where CanAttack(item.m_shared.m_attack) group item by item.m_shared.m_name into @group select @group.First() into item orderby ((DamageTypes)(ref item.m_shared.m_damages)).GetTotalDamage() select item).ToList(); if (!s_loggedAttacks) { s_loggedAttacks = true; Logger.LogInfo((object)("'" + ((Object)creature).name + "' can attack with: " + ((list.Count > 0) ? string.Join(", ", list.Select((ItemData a) => $"{a.m_shared.m_name} ({((DamageTypes)(ref a.m_shared.m_damages)).GetTotalDamage():0.#} dmg" + (CanAttack(a.m_shared.m_secondaryAttack) ? ", +secondary" : string.Empty) + ")")) : "nothing") + " - light attack first, heavy attack last.")); } return list; } private static bool CanAttack(Attack attack) { if (attack != null) { return !string.IsNullOrEmpty(attack.m_attackAnimation); } return false; } } internal static class BearRiderJump { private static bool s_logged; internal static void Trigger(Sadle saddle) { //IL_00e4: 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) Character character = saddle.GetCharacter(); if ((Object)(object)character == (Object)null || (Object)(object)character.m_nview == (Object)null || !character.m_nview.IsOwner() || !character.IsOnGround()) { return; } float value = RidingBears.BearRideJumpStamina.Value; if (!(value > 0f) || saddle.HaveStamina(value)) { if (!s_logged) { s_logged = true; Logger.LogInfo((object)($"'{((Object)character).name}' jump force: {character.m_jumpForce:0.###} " + $"(forward {character.m_jumpForceForward:0.###}). " + ((character.m_jumpForce > 0f) ? "Using the creature's own jump." : $"Creature cannot jump on its own, forcing {RidingBears.BearRideJumpForce.Value:0.###}."))); } if (character.m_jumpForce > 0f) { character.Jump(true); } else { character.ForceJump(((Component)character).transform.up * RidingBears.BearRideJumpForce.Value, true); } if (value > 0f) { saddle.UseStamina(value); } } } } internal static class BearSaddle { private const string LoxPrefabName = "Lox"; private const string SaddleObjectName = "RB_BearSaddle"; private const string SaddleVisualName = "RB_BearSaddleVisual"; private const string AttachPointName = "RB_BearSaddleAttachPoint"; private const string PassengerSeatName = "RB_BearPassengerSeat"; private const string PassengerAttachPointName = "RB_BearPassengerAttachPoint"; private const float SaddleLengthFactor = 0.8f; private const float BackHeightFactor = 0.25f; private static bool s_loggedGraft; internal static bool TryPrepare(GameObject bearPrefab, Tameable bearTameable) { //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)bearPrefab.GetComponent<BearSaddleMarker>() != (Object)null) { Logger.LogDebug((object)"Bear prefab is already prepared for riding, skipping."); return true; } GameObject loxPrefab = GetLoxPrefab(); if ((Object)(object)loxPrefab == (Object)null) { return false; } Tameable component = loxPrefab.GetComponent<Tameable>(); if ((Object)(object)component == (Object)null) { Logger.LogWarning((object)"Expected the Lox prefab to have a Tameable component."); return false; } Sadle saddle = component.m_saddle; if ((Object)(object)saddle == (Object)null) { Logger.LogWarning((object)"Lox prefab has no Sadle component to copy from."); return false; } if ((Object)(object)component.m_saddleItem == (Object)null) { Logger.LogWarning((object)"Lox prefab has no saddle item to reuse."); return false; } bearTameable.m_saddleItem = component.m_saddleItem; bearTameable.m_dropSaddleOnDeath = component.m_dropSaddleOnDeath; bearTameable.m_dropSaddleOffset = component.m_dropSaddleOffset; bearTameable.m_dropItemVel = component.m_dropItemVel; BearSaddleMarker bearSaddleMarker = bearPrefab.AddComponent<BearSaddleMarker>(); bearSaddleMarker.SaddleSource = ((Component)saddle).gameObject; bearSaddleMarker.BoneName = RidingBears.BearSaddleBone.Value?.Trim(); bearSaddleMarker.MountIcon = FindMountIcon(); Logger.LogInfo((object)("Bear prepared for riding with '" + ((Object)component.m_saddleItem).name + "': bone '" + bearSaddleMarker.BoneName + "'. Saddle size and height are measured on each spawned Bear.")); return true; } internal static void Graft(Tameable tameable, BearSaddleMarker marker) { if ((Object)(object)marker.SaddleSource == (Object)null) { Logger.LogWarning((object)"Saddle source is gone, this Bear cannot be ridden."); return; } Transform transform = ((Component)tameable).transform; GameObject val = CopySaddleSource(marker.SaddleSource); ((Object)val).name = "RB_BearSaddle"; Sadle componentInChildren = val.GetComponentInChildren<Sadle>(true); if ((Object)(object)componentInChildren == (Object)null) { Logger.LogWarning((object)("Copy of '" + ((Object)marker.SaddleSource).name + "' has no Sadle component.")); Object.Destroy((Object)(object)val); return; } string text = RidingBears.BearSaddleItemName.Value?.Trim(); if (!string.IsNullOrEmpty(text)) { componentInChildren.m_hoverText = text; } if ((Object)(object)marker.MountIcon != (Object)null) { componentInChildren.m_mountIcon = marker.MountIcon; } StripLoxVisuals(val); BuildVisual(val.transform, tameable.m_saddleItem, marker); val.AddComponent<BoxCollider>(); BuildAttachPoint(componentInChildren); if (RidingBears.BearRidePassengerEnabled.Value) { BuildPassengerSeat(componentInChildren, tameable); } Transform val2 = FindBone(transform, marker.BoneName); val.transform.SetParent(val2, false); componentInChildren.m_attachPoint = val.transform.Find("RB_BearSaddleAttachPoint"); tameable.m_saddle = componentInChildren; Apply(tameable, marker); val.SetActive(true); if (!s_loggedGraft) { LogGraftResult(tameable, val, componentInChildren, val2); s_loggedGraft = true; } ((Component)componentInChildren).gameObject.SetActive(false); } internal static void Apply(Tameable tameable, BearSaddleMarker marker) { //IL_003d: 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_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_0142: 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_015c: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_0174: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_01d2: Unknown result type (might be due to invalid IL or missing references) //IL_01e0: Unknown result type (might be due to invalid IL or missing references) //IL_01ec: Unknown result type (might be due to invalid IL or missing references) //IL_020f: Unknown result type (might be due to invalid IL or missing references) //IL_0214: Unknown result type (might be due to invalid IL or missing references) //IL_0220: Unknown result type (might be due to invalid IL or missing references) //IL_0226: Unknown result type (might be due to invalid IL or missing references) //IL_0233: Unknown result type (might be due to invalid IL or missing references) //IL_0238: Unknown result type (might be due to invalid IL or missing references) //IL_025c: Unknown result type (might be due to invalid IL or missing references) //IL_0261: Unknown result type (might be due to invalid IL or missing references) //IL_0266: Unknown result type (might be due to invalid IL or missing references) //IL_01ba: Unknown result type (might be due to invalid IL or missing references) //IL_01c6: Unknown result type (might be due to invalid IL or missing references) Sadle saddle = tameable.m_saddle; if (!((Object)(object)saddle == (Object)null)) { Transform transform = ((Component)saddle).transform; Transform transform2 = ((Component)tameable).transform; Transform val = (((Object)(object)transform.parent != (Object)null) ? transform.parent : transform2); float num = Mathf.Max(0.1f, val.position.y - transform2.position.y); float num2 = Mathf.Max(marker.MeshSize.x, Mathf.Max(marker.MeshSize.y, marker.MeshSize.z)); float num3 = ((num2 > 0f) ? (num * 0.8f / num2 * RidingBears.BearSaddleScaleMultiplier.Value) : RidingBears.BearSaddleScaleMultiplier.Value); Vector3 val2 = default(Vector3); ((Vector3)(ref val2))..ctor(num3, num3, num3 * RidingBears.BearSaddleLengthStretch.Value); Bounds scaled = default(Bounds); ((Bounds)(ref scaled))..ctor(Vector3.Scale(marker.MeshCentre, val2), Vector3.Scale(marker.MeshSize, val2)); Transform val3 = transform.Find("RB_BearSaddleVisual"); if ((Object)(object)val3 != (Object)null) { val3.localRotation = Quaternion.Euler(RidingBears.BearSaddleMeshRotationX.Value, RidingBears.BearSaddleMeshRotationY.Value, RidingBears.BearSaddleMeshRotationZ.Value); val3.localScale = val2; val3.localPosition = val3.localRotation * new Vector3(0f - ((Bounds)(ref scaled)).center.x, 0f - ((Bounds)(ref scaled)).center.y + ((Bounds)(ref scaled)).extents.y, 0f - ((Bounds)(ref scaled)).center.z); } Transform val4 = transform.Find("RB_BearSaddleAttachPoint"); if ((Object)(object)val4 != (Object)null) { val4.localPosition = new Vector3(RidingBears.BearSaddleRiderOffsetX.Value, RidingBears.BearSaddleRiderOffsetY.Value, RidingBears.BearSaddleRiderOffsetZ.Value); val4.localRotation = Quaternion.identity; } ApplySeatColliders(saddle, transform, scaled); transform.localScale = WorldToLocalScale(val, 1f); transform.rotation = transform2.rotation * Quaternion.Euler(RidingBears.BearSaddleTuneRotationX.Value, RidingBears.BearSaddleTuneRotationY.Value, RidingBears.BearSaddleTuneRotationZ.Value); transform.position = val.position + transform2.up * (num * 0.25f) + transform2.TransformVector(new Vector3(RidingBears.BearSaddleTuneX.Value, RidingBears.BearSaddleTuneY.Value, RidingBears.BearSaddleTuneZ.Value)); } } private static void ApplySeatColliders(Sadle saddle, Transform root, Bounds scaled) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0044: 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_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) BearPassengerSeat componentInChildren = ((Component)root).GetComponentInChildren<BearPassengerSeat>(true); float num = (((Object)(object)componentInChildren != (Object)null) ? (((Bounds)(ref scaled)).size.z * 0.5f) : ((Bounds)(ref scaled)).size.z); float num2 = (((Object)(object)componentInChildren != (Object)null) ? (((Bounds)(ref scaled)).size.z * 0.25f) : 0f); BoxCollider component = ((Component)saddle).GetComponent<BoxCollider>(); if ((Object)(object)component != (Object)null) { component.center = new Vector3(0f, ((Bounds)(ref scaled)).extents.y, num2); component.size = new Vector3(((Bounds)(ref scaled)).size.x, ((Bounds)(ref scaled)).size.y, num); ((Collider)component).isTrigger = false; } if (!((Object)(object)componentInChildren == (Object)null)) { BoxCollider component2 = ((Component)componentInChildren).GetComponent<BoxCollider>(); if ((Object)(object)component2 != (Object)null) { component2.center = new Vector3(0f, ((Bounds)(ref scaled)).extents.y, 0f - num2); component2.size = new Vector3(((Bounds)(ref scaled)).size.x, ((Bounds)(ref scaled)).size.y, num); ((Collider)component2).isTrigger = false; } if ((Object)(object)componentInChildren.AttachPoint != (Object)null) { componentInChildren.AttachPoint.localPosition = new Vector3(RidingBears.BearSaddlePassengerOffsetX.Value, RidingBears.BearSaddlePassengerOffsetY.Value, RidingBears.BearSaddlePassengerOffsetZ.Value); componentInChildren.AttachPoint.localRotation = Quaternion.identity; } } } private static void BuildPassengerSeat(Sadle saddle, Tameable tameable) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown //IL_003a: 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_007e: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("RB_BearPassengerSeat"); val.transform.SetParent(((Component)saddle).transform, false); val.layer = ((Component)saddle).gameObject.layer; val.AddComponent<BoxCollider>(); Transform transform = new GameObject("RB_BearPassengerAttachPoint").transform; transform.SetParent(val.transform, false); BearPassengerSeat bearPassengerSeat = val.AddComponent<BearPassengerSeat>(); bearPassengerSeat.AttachPoint = transform; bearPassengerSeat.ColliderRoot = ((Component)tameable).gameObject; bearPassengerSeat.AttachAnimation = saddle.m_attachAnimation; bearPassengerSeat.DetachOffset = saddle.m_detachOffset; bearPassengerSeat.UseDistance = saddle.m_maxUseRange; } internal static void ApplyToLiveSaddles() { BearSaddleMarker[] array = Object.FindObjectsByType<BearSaddleMarker>((FindObjectsSortMode)0); foreach (BearSaddleMarker bearSaddleMarker in array) { Tameable component = ((Component)bearSaddleMarker).GetComponent<Tameable>(); if ((Object)(object)component != (Object)null && (Object)(object)component.m_saddle != (Object)null) { Apply(component, bearSaddleMarker); } } } private static void StripLoxVisuals(GameObject saddleObject) { Renderer[] componentsInChildren = saddleObject.GetComponentsInChildren<Renderer>(true); for (int i = 0; i < componentsInChildren.Length; i++) { componentsInChildren[i].enabled = false; } Collider[] componentsInChildren2 = saddleObject.GetComponentsInChildren<Collider>(true); for (int i = 0; i < componentsInChildren2.Length; i++) { componentsInChildren2[i].enabled = false; } } private static void BuildVisual(Transform saddleRoot, ItemDrop saddleItem, BearSaddleMarker marker) { //IL_000c: 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_0168: 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_017a: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Expected O, but got Unknown //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: 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_011c: 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_0193: Unknown result type (might be due to invalid IL or missing references) //IL_01a9: Unknown result type (might be due to invalid IL or missing references) //IL_0131: 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_0128: Unknown result type (might be due to invalid IL or missing references) Transform transform = ((Component)saddleItem).transform; Transform transform2 = new GameObject("RB_BearSaddleVisual").transform; transform2.SetParent(saddleRoot, false); Bounds val = default(Bounds); bool flag = false; MeshFilter[] componentsInChildren = ((Component)transform).GetComponentsInChildren<MeshFilter>(true); foreach (MeshFilter val2 in componentsInChildren) { MeshRenderer component = ((Component)val2).GetComponent<MeshRenderer>(); if (!((Object)(object)component == (Object)null) && !((Object)(object)val2.sharedMesh == (Object)null)) { GameObject val3 = new GameObject(((Object)val2).name); val3.transform.SetParent(transform2, false); val3.transform.localPosition = transform.InverseTransformPoint(((Component)val2).transform.position); val3.transform.localRotation = Quaternion.Inverse(transform.rotation) * ((Component)val2).transform.rotation; val3.transform.localScale = ((Component)val2).transform.lossyScale; val3.AddComponent<MeshFilter>().sharedMesh = val2.sharedMesh; ((Renderer)val3.AddComponent<MeshRenderer>()).sharedMaterials = ((Renderer)component).sharedMaterials; Bounds val4 = TransformBounds(val2.sharedMesh.bounds, val3.transform); if (flag) { ((Bounds)(ref val)).Encapsulate(val4); continue; } val = val4; flag = true; } } if (!flag) { Logger.LogWarning((object)("'" + ((Object)saddleItem).name + "' has no static mesh to use as the saddle's looks.")); return; } marker.MeshCentre = ((Bounds)(ref val)).center; marker.MeshSize = ((Bounds)(ref val)).size; if (!s_loggedGraft) { Logger.LogInfo((object)($"Saddle looks taken from '{((Object)saddleItem).name}': mesh bounds {((Bounds)(ref val)).size} " + $"centre {((Bounds)(ref val)).center}.")); } } private static void BuildAttachPoint(Sadle saddle) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) new GameObject("RB_BearSaddleAttachPoint").transform.SetParent(((Component)saddle).transform, false); } private static GameObject CopySaddleSource(GameObject source) { bool activeSelf = source.activeSelf; try { source.SetActive(false); return Object.Instantiate<GameObject>(source); } finally { source.SetActive(activeSelf); } } private static Transform FindBone(Transform creatureRoot, string boneName) { if (string.IsNullOrEmpty(boneName)) { return creatureRoot; } List<Transform> list = (from t in ((Component)creatureRoot).GetComponentsInChildren<Transform>(true) where ((Object)t).name.IndexOf(boneName, StringComparison.OrdinalIgnoreCase) >= 0 select t).ToList(); if (list.Count == 0) { Logger.LogWarning((object)("No bone matching '" + boneName + "' on '" + ((Object)creatureRoot).name + "', attaching the saddle to the creature root instead. Available: " + string.Join(", ", (from t in ((Component)creatureRoot).GetComponentsInChildren<Transform>(true) select ((Object)t).name).Distinct()))); return creatureRoot; } Transform bone = list[list.Count / 2]; if (!s_loggedGraft) { Logger.LogInfo((object)($"'{boneName}' matched {list.Count} bone(s): " + string.Join(", ", list.Select((Transform t) => ((Object)t).name + (((Object)(object)t == (Object)(object)bone) ? " <- using this one" : string.Empty))))); } return bone; } private static Bounds TransformBounds(Bounds bounds, Transform transform) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001e: 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_0029: 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_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0068: 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_007e: Unknown result type (might be due to invalid IL or missing references) Vector3 val = transform.localRotation * Vector3.Scale(((Bounds)(ref bounds)).center, transform.localScale) + transform.localPosition; Vector3 val2 = transform.localRotation * Vector3.Scale(((Bounds)(ref bounds)).extents, transform.localScale); return new Bounds(val, new Vector3(Mathf.Abs(val2.x) * 2f, Mathf.Abs(val2.y) * 2f, Mathf.Abs(val2.z) * 2f)); } private static Vector3 WorldToLocalScale(Transform parent, float worldScale) { //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_0007: 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_001f: 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_0037: 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_004f: Unknown result type (might be due to invalid IL or missing references) Vector3 lossyScale = parent.lossyScale; return new Vector3((lossyScale.x != 0f) ? (worldScale / lossyScale.x) : worldScale, (lossyScale.y != 0f) ? (worldScale / lossyScale.y) : worldScale, (lossyScale.z != 0f) ? (worldScale / lossyScale.z) : worldScale); } private static Sprite FindMountIcon() { string value = RidingBears.BearSaddleMountIcon.Value; if (string.IsNullOrEmpty(value)) { return null; } string[] array = value.Split(new char[1] { ';' }, StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < array.Length; i++) { string text = array[i].Trim(); if (text.Length != 0) { GameObject prefab = PrefabManager.Instance.GetPrefab(text); Sprite val = ((!((Object)(object)prefab != (Object)null)) ? null : prefab.GetComponent<ItemDrop>()?.m_itemData?.m_shared)?.m_icons?.FirstOrDefault((Func<Sprite, bool>)((Sprite sprite) => (Object)(object)sprite != (Object)null)); if ((Object)(object)val != (Object)null) { Logger.LogInfo((object)("Mount icon taken from '" + text + "'.")); return val; } } } Logger.LogWarning((object)("No icon found among '" + value + "', the mount panel will keep showing the Lox. These are prefab names, not the names shown in game.")); return null; } private static GameObject GetLoxPrefab() { GameObject val = CreatureManager.Instance.GetCreaturePrefab("Lox"); if ((Object)(object)val == (Object)null) { val = PrefabManager.Instance.GetPrefab("Lox"); } if ((Object)(object)val == (Object)null) { Logger.LogWarning((object)"Could not find the Lox creature prefab."); } return val; } private static void LogGraftResult(Tameable tameable, GameObject saddleObject, Sadle saddle, Transform bone) { //IL_003f: 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_006c: 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_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_020a: Unknown result type (might be due to invalid IL or missing references) //IL_0216: Unknown result type (might be due to invalid IL or missing references) Transform transform = saddleObject.transform; string[] obj = new string[8] { "Grafted saddle onto '", ((Object)tameable).name, "': bone '", ((Object)bone).name, "', ", $"saddle at {transform.position} scale {transform.lossyScale.x:0.###}, ", $"rider at {saddle.m_attachPoint.position} ", null }; Vector3 val = saddle.m_attachPoint.position - transform.position; obj[7] = $"({((Vector3)(ref val)).magnitude:0.###}m from the saddle)."; Logger.LogInfo((object)string.Concat(obj)); Renderer[] componentsInChildren = saddleObject.GetComponentsInChildren<Renderer>(true); foreach (Renderer val2 in componentsInChildren) { if (val2.enabled) { string[] obj2 = new string[6] { " ", ((object)val2).GetType().Name, " '", ((Object)val2).name, "': ", null }; Bounds bounds = val2.bounds; object arg = ((Bounds)(ref bounds)).center; bounds = val2.bounds; obj2[5] = $"bounds centre {arg} size {((Bounds)(ref bounds)).size}."; Logger.LogInfo((object)string.Concat(obj2)); } } Collider[] componentsInChildren2 = saddleObject.GetComponentsInChildren<Collider>(true); foreach (Collider val3 in componentsInChildren2) { if (val3.enabled) { BoxCollider val4 = (BoxCollider)(object)((val3 is BoxCollider) ? val3 : null); Logger.LogInfo((object)(" " + ((object)val3).GetType().Name + " '" + ((Object)val3).name + "': layer '" + LayerMask.LayerToName(((Component)val3).gameObject.layer) + "', " + $"trigger {val3.isTrigger}" + (((Object)(object)val4 != (Object)null) ? $", local centre {val4.center} size {val4.size}" : string.Empty) + ".")); } } } } internal class BearSaddleMarker : MonoBehaviour { public GameObject SaddleSource; public string BoneName; public Vector3 MeshCentre; public Vector3 MeshSize; public Sprite MountIcon; } internal static class BearSaddleRecipe { private const string SaddlePrefabName = "SaddleLox"; private const string RecipeName = "Recipe_RB_BearSaddle"; private static bool loggedRecipe; private static bool addedRecipe; internal static void Apply(bool allowAdd) { if (!RidingBears.BearSaddleRecipeEnabled.Value) { return; } GameObject prefab = PrefabManager.Instance.GetPrefab("SaddleLox"); if ((Object)(object)prefab == (Object)null) { Logger.LogWarning((object)"Could not find 'SaddleLox', leaving its recipe alone."); } else { if ((Object)(object)ObjectDB.instance == (Object)null || ObjectDB.instance.m_recipes == null) { return; } RenameSaddle(prefab); List<Requirement> list = ParseRequirements(RidingBears.BearSaddleRecipeMaterials.Value); if (list.Count == 0) { Logger.LogWarning((object)"No usable materials in BearSaddleRecipeMaterials, leaving the saddle recipe alone."); return; } string text = RidingBears.BearSaddleRecipeStation.Value?.Trim(); int value = RidingBears.BearSaddleRecipeStationLevel.Value; List<Recipe> list2 = FindRecipes(((Object)prefab).name); foreach (Recipe item in list2) { EditRecipe(item, list, text, value); } if (list2.Count == 0) { if (!allowAdd || addedRecipe) { return; } addedRecipe = true; AddRecipe(list, text, value); } if (!loggedRecipe) { loggedRecipe = true; Logger.LogInfo((object)("'SaddleLox' recipe: " + string.Join(" + ", list.Select((Requirement r) => $"{r.m_amount}x {((Object)r.m_resItem).name}")) + $" at '{text}' level {value}" + " (" + ((list2.Count > 0) ? $"replacing {list2.Count} vanilla recipe(s)" : "added, none existed") + ").")); } } } private static void RenameSaddle(GameObject saddlePrefab) { SharedData val = saddlePrefab.GetComponent<ItemDrop>()?.m_itemData?.m_shared; if (val != null) { string text = RidingBears.BearSaddleItemName.Value?.Trim(); string text2 = RidingBears.BearSaddleItemDescription.Value?.Trim(); if (!string.IsNullOrEmpty(text) && val.m_name != text) { val.m_name = text; Logger.LogInfo((object)("Renamed '" + ((Object)saddlePrefab).name + "' to '" + text + "'.")); } if (!string.IsNullOrEmpty(text2) && val.m_description != text2) { val.m_description = text2; } } } private static List<Requirement> ParseRequirements(string materials) { //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_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Expected O, but got Unknown List<Requirement> list = new List<Requirement>(); if (string.IsNullOrEmpty(materials)) { return list; } string[] array = materials.Split(new char[1] { ';' }, StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < array.Length; i++) { string[] array2 = array[i].Split(new char[1] { ':' }, StringSplitOptions.RemoveEmptyEntries); string text = array2[0].Trim(); if (text.Length != 0) { if (array2.Length < 2 || !int.TryParse(array2[1].Trim(), out var result) || result < 1) { result = 1; } GameObject prefab = PrefabManager.Instance.GetPrefab(text); ItemDrop val = (((Object)(object)prefab != (Object)null) ? prefab.GetComponent<ItemDrop>() : null); if ((Object)(object)val == (Object)null) { Logger.LogWarning((object)("Saddle recipe: no item called '" + text + "', skipping it. Prefab names are case sensitive and are not the names shown in game.")); continue; } list.Add(new Requirement { m_resItem = val, m_amount = result, m_recover = true }); } } return list; } private static List<Recipe> FindRecipes(string itemPrefabName) { if ((Object)(object)ObjectDB.instance == (Object)null || ObjectDB.instance.m_recipes == null) { return new List<Recipe>(); } return ObjectDB.instance.m_recipes.Where((Recipe recipe) => (Object)(object)recipe != (Object)null && (Object)(object)recipe.m_item != (Object)null && ((Object)((Component)recipe.m_item).gameObject).name == itemPrefabName).ToList(); } private static void EditRecipe(Recipe recipe, List<Requirement> requirements, string stationName, int stationLevel) { recipe.m_resources = requirements.ToArray(); recipe.m_minStationLevel = stationLevel; recipe.m_enabled = true; CraftingStation station = GetStation(stationName); if ((Object)(object)station != (Object)null) { recipe.m_craftingStation = station; recipe.m_repairStation = station; } } private static void AddRecipe(List<Requirement> requirements, string stationName, int stationLevel) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Expected O, but got Unknown //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Expected O, but got Unknown RecipeConfig val = new RecipeConfig { Name = "Recipe_RB_BearSaddle", Item = "SaddleLox", CraftingStation = stationName, RepairStation = stationName, MinStationLevel = stationLevel, Requirements = ((IEnumerable<Requirement>)requirements).Select((Func<Requirement, RequirementConfig>)((Requirement r) => new RequirementConfig { Item = ((Object)r.m_resItem).name, Amount = r.m_amount, Recover = true })).ToArray() }; ItemManager.Instance.AddRecipe(new CustomRecipe(val)); } private static CraftingStation GetStation(string stationName) { if (string.IsNullOrEmpty(stationName)) { return null; } GameObject prefab = PrefabManager.Instance.GetPrefab(stationName); CraftingStation obj = (((Object)(object)prefab != (Object)null) ? prefab.GetComponent<CraftingStation>() : null); if ((Object)(object)obj == (Object)null) { Logger.LogWarning((object)("No crafting station called '" + stationName + "', keeping the recipe's current station.")); } return obj; } } [BepInPlugin("com.nikolag.ridingbears", "RIDING BEARS!", "0.4.2")] [BepInDependency(/*Could not decode attribute arguments.*/)] [NetworkCompatibility(/*Could not decode attribute arguments.*/)] public class RidingBears : BaseUnityPlugin { public const string PluginGUID = "com.nikolag.ridingbears"; public const string PluginName = "RIDING BEARS!"; public const string PluginVersion = "0.4.2"; public static CustomLocalization Localization = LocalizationManager.Instance.GetLocalization(); private const string bearNameLocalizedFormat = "name_randBearName"; private Harmony harmony; private FileSystemWatcher configWatcher; private volatile bool configFileChanged; private int randomNameCount; private bool creaturesAvailable; private bool prefabsAvailable; private bool isConfigured; public static ConfigEntry<string> BearConsumableItems; public static ConfigEntry<float> BearTameTime; public static ConfigEntry<float> BearFedDuration; public static ConfigEntry<bool> BearRideEnabled; public static ConfigEntry<string> BearSaddleBone; public static ConfigEntry<string> BearSaddleMountIcon; public static ConfigEntry<float> BearSaddleTuneX; public static ConfigEntry<float> BearSaddleTuneY; public static ConfigEntry<float> BearSaddleTuneZ; public static ConfigEntry<float> BearSaddleTuneRotationX; public static ConfigEntry<float> BearSaddleTuneRotationY; public static ConfigEntry<float> BearSaddleTuneRotationZ; public static ConfigEntry<float> BearSaddleScaleMultiplier; public static ConfigEntry<float> BearSaddleMeshRotationX; public static ConfigEntry<float> BearSaddleMeshRotationY; public static ConfigEntry<float> BearSaddleMeshRotationZ; public static ConfigEntry<float> BearSaddleRiderOffsetX; public static ConfigEntry<float> BearSaddleRiderOffsetY; public static ConfigEntry<float> BearSaddleRiderOffsetZ; public static ConfigEntry<bool> BearRidePassengerEnabled; public static ConfigEntry<float> BearSaddleLengthStretch; public static ConfigEntry<float> BearSaddlePassengerOffsetX; public static ConfigEntry<float> BearSaddlePassengerOffsetY; public static ConfigEntry<float> BearSaddlePassengerOffsetZ; public static ConfigEntry<bool> BearRideAttacksEnabled; public static ConfigEntry<bool> BearRideDismountOnAttack; public static ConfigEntry<bool> BearRideDismountOnJump; public static ConfigEntry<bool> BearSaddleRecipeEnabled; public static ConfigEntry<string> BearSaddleRecipeMaterials; public static ConfigEntry<string> BearSaddleItemName; public static ConfigEntry<string> BearSaddleItemDescription; public static ConfigEntry<string> BearSaddleRecipeStation; public static ConfigEntry<int> BearSaddleRecipeStationLevel; public static ConfigEntry<bool> BearRideJumpEnabled; public static ConfigEntry<float> BearRideJumpForce; public static ConfigEntry<float> BearRideJumpStamina; public RidingBears() { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Expected O, but got Unknown harmony = new Harmony("com.nikolag.ridingbears"); } public void Start() { harmony.PatchAll(Assembly.GetExecutingAssembly()); } private void Update() { if (!configFileChanged) { return; } configFileChanged = false; try { ((BaseUnityPlugin)this).Config.Reload(); } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("Could not reload the config file: " + ex.Message)); } } private void WatchConfigFile() { try { configWatcher = new FileSystemWatcher(Path.GetDirectoryName(((BaseUnityPlugin)this).Config.ConfigFilePath), Path.GetFileName(((BaseUnityPlugin)this).Config.ConfigFilePath)) { NotifyFilter = (NotifyFilters.Size | NotifyFilters.LastWrite), EnableRaisingEvents = true }; configWatcher.Changed += delegate { configFileChanged = true; }; configWatcher.Created += delegate { configFileChanged = true; }; Logger.LogInfo((object)("Watching '" + Path.GetFileName(((BaseUnityPlugin)this).Config.ConfigFilePath) + "': saddle placement settings can be edited while the game runs and apply immediately.")); } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("Could not watch the config file: " + ex.Message)); } } private void OnDestroy() { configWatcher?.Dispose(); } private void Awake() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Expected O, but got Unknown //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Expected O, but got Unknown //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Expected O, but got Unknown //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Expected O, but got Unknown //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Expected O, but got Unknown //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Expected O, but got Unknown //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Expected O, but got Unknown //IL_0190: Unknown result type (might be due to invalid IL or missing references) //IL_019a: Expected O, but got Unknown //IL_01d2: Unknown result type (might be due to invalid IL or missing references) //IL_01dc: Expected O, but got Unknown //IL_0214: Unknown result type (might be due to invalid IL or missing references) //IL_021e: Expected O, but got Unknown //IL_0256: Unknown result type (might be due to invalid IL or missing references) //IL_0260: Expected O, but got Unknown //IL_0298: Unknown result type (might be due to invalid IL or missing references) //IL_02a2: Expected O, but got Unknown //IL_02da: Unknown result type (might be due to invalid IL or missing references) //IL_02e4: Expected O, but got Unknown //IL_031c: Unknown result type (might be due to invalid IL or missing references) //IL_0326: Expected O, but got Unknown //IL_035e: Unknown result type (might be due to invalid IL or missing references) //IL_0368: Expected O, but got Unknown //IL_03a0: Unknown result type (might be due to invalid IL or missing references) //IL_03aa: Expected O, but got Unknown //IL_03e2: Unknown result type (might be due to invalid IL or missing references) //IL_03ec: Expected O, but got Unknown //IL_0424: Unknown result type (might be due to invalid IL or missing references) //IL_042e: Expected O, but got Unknown //IL_0466: Unknown result type (might be due to invalid IL or missing references) //IL_0470: Expected O, but got Unknown //IL_04a8: Unknown result type (might be due to invalid IL or missing references) //IL_04b2: Expected O, but got Unknown //IL_04d8: Unknown result type (might be due to invalid IL or missing references) //IL_04e2: Expected O, but got Unknown //IL_051a: Unknown result type (might be due to invalid IL or missing references) //IL_0524: Expected O, but got Unknown //IL_055c: Unknown result type (might be due to invalid IL or missing references) //IL_0566: Expected O, but got Unknown //IL_059e: Unknown result type (might be due to invalid IL or missing references) //IL_05a8: Expected O, but got Unknown //IL_05e0: Unknown result type (might be due to invalid IL or missing references) //IL_05ea: Expected O, but got Unknown //IL_0610: Unknown result type (might be due to invalid IL or missing references) //IL_061a: Expected O, but got Unknown //IL_0640: Unknown result type (might be due to invalid IL or missing references) //IL_064a: Expected O, but got Unknown //IL_0670: Unknown result type (might be due to invalid IL or missing references) //IL_067a: Expected O, but got Unknown //IL_06a0: Unknown result type (might be due to invalid IL or missing references) //IL_06aa: Expected O, but got Unknown //IL_06d4: Unknown result type (might be due to invalid IL or missing references) //IL_06de: Expected O, but got Unknown //IL_0708: Unknown result type (might be due to invalid IL or missing references) //IL_0712: Expected O, but got Unknown //IL_073c: Unknown result type (might be due to invalid IL or missing references) //IL_0746: Expected O, but got Unknown //IL_0770: Unknown result type (might be due to invalid IL or missing references) //IL_077a: Expected O, but got Unknown //IL_07a7: Unknown result type (might be due to invalid IL or missing references) //IL_07b1: Expected O, but got Unknown //IL_07d7: Unknown result type (might be due to invalid IL or missing references) //IL_07e1: Expected O, but got Unknown //IL_0819: Unknown result type (might be due to invalid IL or missing references) //IL_0823: Expected O, but got Unknown //IL_085b: Unknown result type (might be due to invalid IL or missing references) //IL_0865: Expected O, but got Unknown ConfigurationManagerAttributes val = new ConfigurationManagerAttributes { IsAdminOnly = true }; BearConsumableItems = ((BaseUnityPlugin)this).Config.Bind<string>("General", "BearConsumableItems", "Blueberries; Honey; RawMeat; DeerMeat", new ConfigDescription("Items that the Bear can consume/eat. Must be the name of the prefab. See Jotunn docs.", (AcceptableValueBase)null, new object[1] { val })); BearTameTime = ((BaseUnityPlugin)this).Config.Bind<float>("General", "BearTameTime", 1600f, new ConfigDescription("Amount of time (in seconds) it takes to tame a Bear (default is slightly less than wolf).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 10000f), new object[1] { val })); BearFedDuration = ((BaseUnityPlugin)this).Config.Bind<float>("General", "BearFedDuration", 400f, new ConfigDescription("Amount of time (in seconds) after feeding a Bear before it becomes hungry again (default is slightly less than wolf).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1000f), new object[1] { val })); BearRideEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Riding", "BearRideEnabled", true, new ConfigDescription("Whether a tamed Bear can be saddled (with the Lox saddle) and ridden. Applied while the game loads, so a restart is required.", (AcceptableValueBase)null, new object[1] { val })); BearSaddleBone = ((BaseUnityPlugin)this).Config.Bind<string>("Riding", "BearSaddleBone", "spine", new ConfigDescription("Name (or part of a name) of the Bear bone the saddle is attached to, so it follows the animation. Leave empty to attach it to the Bear root. Requires a restart.", (AcceptableValueBase)null, new object[1] { val })); BearSaddleMountIcon = ((BaseUnityPlugin)this).Config.Bind<string>("Riding", "BearSaddleMountIcon", "TrophyBjorn; BjornHide; TrophyBear", new ConfigDescription("Items to take the icon shown beside the mount's health and stamina from, tried in order until one exists. Prefab names, not the names shown in game. Empty keeps the Lox icon. Requires a restart.", (AcceptableValueBase)null, new object[1] { val })); BearSaddleTuneX = ((BaseUnityPlugin)this).Config.Bind<float>("Riding", "BearSaddleTuneX", 0f, new ConfigDescription("Correction to the computed saddle position, sideways, in meters. Requires a restart.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(-2f, 2f), new object[1] { val })); BearSaddleTuneY = ((BaseUnityPlugin)this).Config.Bind<float>("Riding", "BearSaddleTuneY", 0f, new ConfigDescription("Correction to the computed saddle position, height, in meters. Positive is up. Requires a restart.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(-2f, 2f), new object[1] { val })); BearSaddleTuneZ = ((BaseUnityPlugin)this).Config.Bind<float>("Riding", "BearSaddleTuneZ", 0f, new ConfigDescription("Correction to the saddle position, front to back, in meters. Positive is towards the head. Applied immediately.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(-2f, 2f), new object[1] { val })); BearSaddleTuneRotationX = ((BaseUnityPlugin)this).Config.Bind<float>("Riding", "BearSaddleTuneRotationX", 0f, new ConfigDescription("Correction to the computed saddle rotation, pitch, in degrees. Requires a restart.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(-180f, 180f), new object[1] { val })); BearSaddleTuneRotationY = ((BaseUnityPlugin)this).Config.Bind<float>("Riding", "BearSaddleTuneRotationY", 0f, new ConfigDescription("Correction to the computed saddle rotation, yaw, in degrees. Requires a restart.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(-180f, 180f), new object[1] { val })); BearSaddleTuneRotationZ = ((BaseUnityPlugin)this).Config.Bind<float>("Riding", "BearSaddleTuneRotationZ", 0f, new ConfigDescription("Correction to the computed saddle rotation, roll, in degrees. Requires a restart.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(-180f, 180f), new object[1] { val })); BearSaddleScaleMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("Riding", "BearSaddleScaleMultiplier", 1f, new ConfigDescription("Correction to the saddle size, which is scaled to the Bear's shoulder height. Requires a restart.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 3f), new object[1] { val })); BearSaddleMeshRotationX = ((BaseUnityPlugin)this).Config.Bind<float>("Riding", "BearSaddleMeshRotationX", 0f, new ConfigDescription("Rotation of the saddle model only, pitch, in degrees. Does not move the rider. Requires a restart.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(-180f, 180f), new object[1] { val })); BearSaddleMeshRotationY = ((BaseUnityPlugin)this).Config.Bind<float>("Riding", "BearSaddleMeshRotationY", 0f, new ConfigDescription("Rotation of the saddle model only, yaw, in degrees. Does not move the rider. Requires a restart.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(-180f, 180f), new object[1] { val })); BearSaddleMeshRotationZ = ((BaseUnityPlugin)this).Config.Bind<float>("Riding", "BearSaddleMeshRotationZ", 0f, new ConfigDescription("Rotation of the saddle model only, roll, in degrees. Does not move the rider. Requires a restart.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(-180f, 180f), new object[1] { val })); BearSaddleRiderOffsetX = ((BaseUnityPlugin)this).Config.Bind<float>("Riding", "BearSaddleRiderOffsetX", 0f, new ConfigDescription("Where the rider sits on the saddle, sideways, in meters. Applied immediately.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(-2f, 2f), new object[1] { val })); BearSaddleRiderOffsetY = ((BaseUnityPlugin)this).Config.Bind<float>("Riding", "BearSaddleRiderOffsetY", 0.4f, new ConfigDescription("Where the rider sits on the saddle, height, in meters. Raise it if the rider sinks into the saddle. Applied immediately.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(-2f, 2f), new object[1] { val })); BearSaddleRiderOffsetZ = ((BaseUnityPlugin)this).Config.Bind<float>("Riding", "BearSaddleRiderOffsetZ", 0.39f, new ConfigDescription("Where the rider sits on the saddle, front to back, in meters. Positive is towards the head. Applied immediately.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(-2f, 2f), new object[1] { val })); BearRidePassengerEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Riding", "BearRidePassengerEnabled", true, new ConfigDescription("Whether a second player can climb on behind the rider to be carried. The passenger does not steer, and stays seated even if the rider gets off. Requires a restart.", (AcceptableValueBase)null, new object[1] { val })); BearSaddleLengthStretch = ((BaseUnityPlugin)this).Config.Bind<float>("Riding", "BearSaddleLengthStretch", 1.5f, new ConfigDescription("How much longer the saddle is drawn so two riders fit. 1 leaves the model as it is; stretching it does distort the model somewhat. Applied immediately.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 3f), new object[1] { val })); BearSaddlePassengerOffsetX = ((BaseUnityPlugin)this).Config.Bind<float>("Riding", "BearSaddlePassengerOffsetX", 0f, new ConfigDescription("Where the passenger sits on the saddle, sideways, in meters. Applied immediately.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(-2f, 2f), new object[1] { val })); BearSaddlePassengerOffsetY = ((BaseUnityPlugin)this).Config.Bind<float>("Riding", "BearSaddlePassengerOffsetY", 0.4f, new ConfigDescription("Where the passenger sits on the saddle, height, in meters. Applied immediately.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(-2f, 2f), new object[1] { val })); BearSaddlePassengerOffsetZ = ((BaseUnityPlugin)this).Config.Bind<float>("Riding", "BearSaddlePassengerOffsetZ", 0f, new ConfigDescription("Where the passenger sits on the saddle, front to back, in meters. Negative is behind the rider. Applied immediately.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(-2f, 2f), new object[1] { val })); BearRideAttacksEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Riding", "BearRideAttacksEnabled", true, new ConfigDescription("Whether the rider's mouse buttons make the Bear attack: left click for its light attack, right click for its heavy one.", (AcceptableValueBase)null, new object[1] { val })); BearRideDismountOnAttack = ((BaseUnityPlugin)this).Config.Bind<bool>("Riding", "BearRideDismountOnAttack", false, new ConfigDescription("Whether attacking or dodging throws the rider or the passenger off the Bear, as it does in vanilla. Off means a stray mouse click no longer dismounts.", (AcceptableValueBase)null, new object[1] { val })); BearRideDismountOnJump = ((BaseUnityPlugin)this).Config.Bind<bool>("Riding", "BearRideDismountOnJump", false, new ConfigDescription("Whether jumping dismounts the Bear, for the rider and the passenger alike. Interacting dismounts either way.", (AcceptableValueBase)null, new object[1] { val })); BearSaddleRecipeEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Crafting", "BearSaddleRecipeEnabled", true, new ConfigDescription("Whether the Lox saddle's recipe is replaced so a saddle can be crafted before ever reaching the Plains. Turn off to leave the vanilla recipe alone. Requires a restart.", (AcceptableValueBase)null, new object[1] { val })); BearSaddleRecipeMaterials = ((BaseUnityPlugin)this).Config.Bind<string>("Crafting", "BearSaddleRecipeMaterials", "LeatherScraps:5; DeerHide:5; BoneFragments:3; BjornHide:3", new ConfigDescription("What the saddle costs, as prefab names with amounts, separated by semicolons. These are prefab names, not the names shown in game; anything that does not resolve is skipped with a warning in the log. Requires a restart.", (AcceptableValueBase)null, new object[1] { val })); BearSaddleItemName = ((BaseUnityPlugin)this).Config.Bind<string>("Crafting", "BearSaddleItemName", "$rb_saddle_name", new ConfigDescription("Name the saddle is shown under, both in the inventory and when looking at it on a Bear. A $token is translated, anything else is used as written. Empty leaves the vanilla name. Requires a restart.", (AcceptableValueBase)null, new object[1] { val })); BearSaddleItemDescription = ((BaseUnityPlugin)this).Config.Bind<string>("Crafting", "BearSaddleItemDescription", "$rb_saddle_description", new ConfigDescription("Description shown for the saddle, since the vanilla one tells the player to use it on a Lox. A $token is translated, anything else is used as written. Empty leaves the vanilla description. Requires a restart.", (AcceptableValueBase)null, new object[1] { val })); BearSaddleRecipeStation = ((BaseUnityPlugin)this).Config.Bind<string>("Crafting", "BearSaddleRecipeStation", "piece_workbench", new ConfigDescription("Prefab name of the crafting station the saddle is made at. Requires a restart.", (AcceptableValueBase)null, new object[1] { val })); BearSaddleRecipeStationLevel = ((BaseUnityPlugin)this).Config.Bind<int>("Crafting", "BearSaddleRecipeStationLevel", 4, new ConfigDescription("Crafting station level the saddle needs.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 10), new object[1] { val })); BearRideJumpEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Riding", "BearRideJumpEnabled", true, new ConfigDescription("Whether space makes the ridden Bear jump.", (AcceptableValueBase)null, new object[1] { val })); BearRideJumpForce = ((BaseUnityPlugin)this).Config.Bind<float>("Riding", "BearRideJumpForce", 8f, new ConfigDescription("Jump force used only for creatures that have no jump force of their own. The Bear's own value is used when it has one; check the log to see which applies.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 20f), new object[1] { val })); BearRideJumpStamina = ((BaseUnityPlugin)this).Config.Bind<float>("Riding", "BearRideJumpStamina", 10f, new ConfigDescription("Mount stamina spent per jump, taken from the saddle's stamina rather than the Bear's. Set to 0 for free jumps.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 100f), new object[1] { val })); ((BaseUnityPlugin)this).Config.SettingChanged += delegate(object sender, SettingChangedEventArgs args) { if (args.ChangedSetting.Definition.Section == "Riding") { BearSaddle.ApplyToLiveSaddles(); } }; WatchConfigFile(); CreatureManager.OnVanillaCreaturesAvailable += OnVanillaCreaturesAvailable; PrefabManager.OnVanillaPrefabsAvailable += OnVanillaPrefabsAvailable; ItemManager.OnItemsRegistered += delegate { BearSaddleRecipe.Apply(allowAdd: true); }; LocalizationManager.OnLocalizationAdded += OnLocalizationsAdded; Logger.LogInfo((object)"RidingBears v0.4.2 loaded and patched."); } private void OnLocalizationsAdded() { ResolveLocalizations(); randomNameCount = (from lang in Localization.GetLanguages() select Localization.GetTranslations(ref lang).Count((KeyValuePair<string, string> kvp) => kvp.Key.StartsWith("name_randBearName"))).DefaultIfEmpty(0).Max(); Logger.LogInfo((object)$"Random name count: {randomNameCount}"); } private void OnVanillaPrefabsAvailable() { prefabsAvailable = true; if (prefabsAvailable && creaturesAvailable && !isConfigured) { MakeBearTameable(); } BearSaddleRecipe.Apply(allowAdd: false); } private void OnVanillaCreaturesAvailable() { creaturesAvailable = true; if (prefabsAvailable && creaturesAvailable && !isConfigured) { MakeBearTameable(); } } private void MakeBearTameable() { //IL_016b: Unknown result type (might be due to invalid IL or missing references) //IL_0254: Unknown result type (might be due to invalid IL or missing references) //IL_0259: Unknown result type (might be due to invalid IL or missing references) GameObject creaturePrefab = CreatureManager.Instance.GetCreaturePrefab("Wolf"); if ((Object)(object)creaturePrefab == (Object)null) { Logger.LogWarning((object)"Could not Wolf creature prefab."); return; } Tameable component = creaturePrefab.GetComponent<Tameable>(); if ((Object)(object)component == (Object)null) { Logger.LogWarning((object)"Could not find Tameable Component for the Wolf prefab."); return; } GameObject creaturePrefab2 = CreatureManager.Instance.GetCreaturePrefab("Bjorn"); if ((Object)(object)creaturePrefab2 == (Object)null) { Logger.LogWarning((object)"Could not find Bear creature prefab."); return; } MonsterAI component2 = creaturePrefab2.GetComponent<MonsterAI>(); if ((Object)(object)component2 == (Object)null) { Logger.LogWarning((object)"Expected Bear prefab to have Monster AI."); return; } component2.m_consumeItems.Clear(); foreach (string item in EnumerateConsumables(BearConsumableItems)) { AddConsumableItem(component2, item); } Tameable component3 = creaturePrefab2.GetComponent<Tameable>(); if ((Object)(object)component3 != (Object)null) { Logger.LogWarning((object)"Expected Bear prefab to not have a Tameable component."); return; } if (component.m_tamedEffect.m_effectPrefabs.Length == 0 || component.m_petEffect.m_effectPrefabs.Length == 0 || component.m_sootheEffect.m_effectPrefabs.Length == 0) { Logger.LogWarning((object)"Could not get taming effect prefabs from Wolf prefab type."); return; } EffectData val = DuplicateEffectData(component.m_tamedEffect.m_effectPrefabs[0]); if (val == null) { return; } EffectData val2 = DuplicateEffectData(component.m_petEffect.m_effectPrefabs[0]); if (val2 == null) { return; } EffectData val3 = DuplicateEffectData(component.m_sootheEffect.m_effectPrefabs[0]); if (val3 != null) { Logger.LogDebug((object)$"m_levelUpOwnerSkill - {component.m_levelUpOwnerSkill}"); Logger.LogDebug((object)$"m_tamingTime - {component.m_tamingTime}"); Logger.LogDebug((object)$"m_fedDuration - {component.m_fedDuration}"); component3 = creaturePrefab2.AddComponent<Tameable>(); component3.m_fedDuration = BearFedDuration.Value; component3.m_tamingTime = BearTameTime.Value; component3.m_startsTamed = false; component3.m_tamedEffect.m_effectPrefabs = (EffectData[])(object)new EffectData[1] { val }; component3.m_sootheEffect.m_effectPrefabs = (EffectData[])(object)new EffectData[1] { val3 }; component3.m_petEffect.m_effectPrefabs = (EffectData[])(object)new EffectData[1] { val2 }; component3.m_commandable = component.m_commandable; component3.m_unsummonDistance = component.m_unsummonDistance; component3.m_unsummonOnOwnerLogoutSeconds = component.m_unsummonOnOwnerLogoutSeconds; component3.m_levelUpOwnerSkill = component.m_levelUpOwnerSkill; component3.m_levelUpFactor = component.m_levelUpFactor; component3.m_tamingSpeedMultiplierRange = component.m_tamingSpeedMultiplierRange; component3.m_tamingBoostMultiplier = component.m_tamingBoostMultiplier; SetRandomStartingNames(component3); if (BearRideEnabled.Value) { BearSaddle.TryPrepare(creaturePrefab2, component3); } else { Logger.LogInfo((object)"Bear riding is disabled by configuration."); } isConfigured = true; } } private static void AddConsumableItem(MonsterAI monsterAi, string itemName) { ItemDrop val = null; GameObject prefab = PrefabManager.Instance.GetPrefab(itemName); if ((Object)(object)prefab != (Object)null) { val = prefab.GetComponent<ItemDrop>(); if ((Object)(object)val != (Object)null) { monsterAi.m_consumeItems.Add(val); } } if ((Object)(object)val == (Object)null) { Logger.LogWarning((object)("Could not find item: " + itemName)); } else { Logger.LogDebug((object)("Bear can consume " + ((Object)val).name)); } } private void SetRandomStartingNames(Tameable tameable) { tameable.m_randomStartingName = new List<string>(); for (int i = 0; i < randomNameCount; i++) { tameable.m_randomStartingName.Add(string.Format("${0}{1}", "name_randBearName", i)); } } private EffectData DuplicateEffectData(EffectData fxData) { //IL_004b: 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_0057: 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_006f: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_009f: 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_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Expected O, but got Unknown if ((Object)(object)fxData.m_prefab == (Object)null) { return null; } GameObject prefab = PrefabManager.Instance.GetPrefab(((Object)fxData.m_prefab).name); if ((Object)(object)prefab == (Object)null) { Logger.LogWarning((object)("Could not get effect prefab " + ((Object)fxData.m_prefab).name)); return null; } return new EffectData { m_prefab = prefab, m_enabled = fxData.m_enabled, m_variant = fxData.m_variant, m_attach = fxData.m_attach, m_follow = fxData.m_follow, m_inheritParentRotation = fxData.m_inheritParentRotation, m_inheritParentScale = fxData.m_inheritParentScale, m_multiplyParentVisualScale = fxData.m_multiplyParentVisualScale, m_randomRotation = fxData.m_randomRotation, m_scale = fxData.m_scale, m_childTransform = fxData.m_childTransform }; } private IEnumerable<string> EnumerateConsumables(ConfigEntry<string> configConsumables) { string[] array = configConsumables.Value.Split(new char[1] { ';' }, StringSplitOptions.RemoveEmptyEntries); string[] array2 = array; foreach (string text in array2) { yield return text.Trim(); } } private void ResolveLocalizations() { try { DirectoryInfo directoryInfo = new DirectoryInfo(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)); Dictionary<string, List<FileInfo>> dictionary = new Dictionary<string, List<FileInfo>>(); foreach (FileInfo item in directoryInfo.EnumerateFiles("*.json", SearchOption.TopDirectoryOnly)) { string[] array = item.Name.Split(new char[1] { '.' }, StringSplitOptions.RemoveEmptyEntries); if (array.Length <= 2 || !(array.Last() == "json")) { continue; } string text = array[^2].Trim(); if (LocalizationHelper.IsLanguageSupported(text)) { if (!dictionary.ContainsKey(text)) { dictionary.Add(text, new List<FileInfo>()); } dictionary[text].Add(item); } } foreach (string key in dictionary.Keys) { if (Localization.GetLanguages().Contains(key)) { continue; } foreach (FileInfo item2 in dictionary[key]) { Localization.AddJsonFile(key, File.ReadAllText(item2.FullName)); ((BaseUnityPlugin)this).Logger.LogInfo((object)("Added localization file [" + item2.Name + "] from non-standard location.")); } } foreach (string language in Localization.GetLanguages()) { ((BaseUnityPlugin)this).Logger.LogInfo((object)(language + " localization loaded and available.")); } } catch (Exception) { ((BaseUnityPlugin)this).Logger.LogError((object)"Error resolving localizations."); } } } } namespace RidingBears.Patches { [HarmonyPatch] public static class PlayerSetControlsPatch { [HarmonyPrefix] [HarmonyPatch(typeof(Player), "SetControls")] public static void SetControls(Player __instance, ref bool attack, ref bool attackHold, ref bool secondaryAttack, ref bool secondaryAttackHold, ref bool jump, ref bool dodge) { Sadle riddenBearSaddle = GetRiddenBearSaddle(__instance); if ((Object)(object)riddenBearSaddle == (Object)null) { if (IsBearPassenger(__instance)) { SuppressDismount(ref attack, ref attackHold, ref secondaryAttack, ref secondaryAttackHold, ref jump, ref dodge); } return; } if (RidingBears.BearRideAttacksEnabled.Value) { if (attack | attackHold) { BearRiderAttack.Trigger(riddenBearSaddle, strong: false); } if (secondaryAttack | secondaryAttackHold) { BearRiderAttack.Trigger(riddenBearSaddle, strong: true); } } if (jump && RidingBears.BearRideJumpEnabled.Value) { BearRiderJump.Trigger(riddenBearSaddle); } SuppressDismount(ref attack, ref attackHold, ref secondaryAttack, ref secondaryAttackHold, ref jump, ref dodge); } private static void SuppressDismount(ref bool attack, ref bool attackHold, ref bool secondaryAttack, ref bool secondaryAttackHold, ref bool jump, ref bool dodge) { if (!RidingBears.BearRideDismountOnAttack.Value) { attack = false; attackHold = false; secondaryAttack = false; secondaryAttackHold = false; dodge = false; } if (!RidingBears.BearRideDismountOnJump.Value) { jump = false; } } private static bool IsBearPassenger(Player player) { if (!((Character)player).IsAttached()) { return false; } Transform attachPoint = player.GetAttachPoint(); if ((Object)(object)attachPoint != (Object)null) { return (Object)(object)((Component)attachPoint).GetComponentInParent<BearPassengerSeat>() != (Object)null; } return false; } private static Sadle GetRiddenBearSaddle(Player player) { IDoodadController doodadController = player.m_doodadController; Sadle val = (Sadle)(object)((doodadController is Sadle) ? doodadController : null); if (val == null) { return null; } Character character = val.GetCharacter(); if (!((Object)(object)character != (Object)null) || !((Object)(object)((Component)character).GetComponent<BearSaddleMarker>() != (Object)null)) { return null; } return val; } } [HarmonyPatch] public static class TameableAwakePatch { [HarmonyPrefix] [HarmonyPatch(typeof(Tameable), "Awake")] public static void Awake(Tameable __instance) { if (!((Object)(object)__instance.m_saddle != (Object)null)) { BearSaddleMarker component = ((Component)__instance).GetComponent<BearSaddleMarker>(); if (!((Object)(object)component == (Object)null)) { BearSaddle.Graft(__instance, component); } } } } }