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 TogetherWeRow v1.0.0
TogetherWeRow.dll
Decompiled a week agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Jotunn.Entities; using Jotunn.Managers; using Jotunn.Utils; using Microsoft.CodeAnalysis; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: IgnoresAccessChecksTo("Assembly-CSharp")] [assembly: IgnoresAccessChecksTo("assembly_googleanalytics")] [assembly: IgnoresAccessChecksTo("assembly_guiutils")] [assembly: IgnoresAccessChecksTo("assembly_lux")] [assembly: IgnoresAccessChecksTo("assembly_postprocessing")] [assembly: IgnoresAccessChecksTo("assembly_simplemeshcombine")] [assembly: IgnoresAccessChecksTo("assembly_sunshafts")] [assembly: IgnoresAccessChecksTo("assembly_utils")] [assembly: IgnoresAccessChecksTo("assembly_valheim")] [assembly: IgnoresAccessChecksTo("gui_framework")] [assembly: IgnoresAccessChecksTo("SoftReferenceableAssets")] [assembly: IgnoresAccessChecksTo("Splatform")] [assembly: TargetFramework(".NETFramework,Version=v4.6.2", FrameworkDisplayName = ".NET Framework 4.6.2")] [assembly: AssemblyCompany("GitMCP")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyDescription("Passenger seats on boats get oars. Sit down to help the captain go faster.")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+b08e1ea171d7ea91b48db7b13878182ae3c43bdf")] [assembly: AssemblyProduct("TogetherWeRow")] [assembly: AssemblyTitle("TogetherWeRow")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace TogetherWeRow { internal static class Localizations { internal static void Register() { CustomLocalization localization = LocalizationManager.Instance.GetLocalization(); string text = "English"; localization.AddTranslation(ref text, new Dictionary<string, string> { { "togetherwerow_use", "Row" } }); } } internal static class TogetherWeRowCrew { private const float MastRadius = 0.9f; private const float Centerline = 0.5f; internal static int Count(Ship ship) { if ((Object)(object)ship == (Object)null) { return 0; } int num = 0; foreach (Player allPlayer in Player.GetAllPlayers()) { if (!((Object)(object)allPlayer == (Object)null) && ((Character)allPlayer).IsAttachedToShip() && CanRow(ship, allPlayer.GetAttachPoint())) { num++; } } return num; } internal static bool Occupied(Transform attachPoint) { if ((Object)(object)attachPoint == (Object)null) { return false; } foreach (Player allPlayer in Player.GetAllPlayers()) { if ((Object)(object)allPlayer != (Object)null && (Object)(object)allPlayer.GetAttachPoint() == (Object)(object)attachPoint) { return true; } } return false; } internal static bool CanRow(Ship ship, Transform attach) { //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_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)ship == (Object)null || (Object)(object)attach == (Object)null) { return false; } if ((Object)(object)((Component)attach).GetComponentInParent<Ship>() != (Object)(object)ship) { return false; } if ((Object)(object)ship.m_shipControlls != (Object)null && (Object)(object)attach == (Object)(object)ship.m_shipControlls.m_attachPoint) { return false; } if (Mathf.Abs(((Component)ship).transform.InverseTransformPoint(attach.position).x) < 0.5f) { return false; } GameObject mastObject = ship.m_mastObject; if ((Object)(object)mastObject != (Object)null) { if (attach.IsChildOf(mastObject.transform)) { return false; } Vector3 val = attach.position - mastObject.transform.position; val.y = 0f; if (((Vector3)(ref val)).sqrMagnitude < 0.80999994f) { return false; } } return true; } } internal static class TogetherWeRowOars { private const string WoodSource = "wood_pole"; private const string WoodPath = "New"; private const float Dip = 48f; private const float Stroke = 16f; internal static Transform Build(Transform ship, Transform attach, float side) { //IL_0005: 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_0024: 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_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0085: 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_00ba: Unknown result type (might be due to invalid IL or missing references) Transform transform = new GameObject("TogetherWeRowOar").transform; transform.SetParent(ship, false); Vector3 localPosition = ship.InverseTransformPoint(attach.position); localPosition.x += side * 0.55f; localPosition.y += 0.2f; transform.localPosition = localPosition; transform.localRotation = Rest(side); Fit("Shaft", transform, new Vector3(side * 0.85f, 0f, 0f), new Vector3(1.7f, 0.07f, 0.07f)); Fit("Blade", transform, new Vector3(side * 1.75f, 0f, 0f), new Vector3(0.4f, 0.04f, 0.28f)); return transform; } internal static Quaternion Rest(float side) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) return Quaternion.Euler(0f, 0f, (0f - side) * 48f); } internal static Quaternion StrokeAt(float side, float time) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) return Quaternion.Euler(0f, 0f, (0f - side) * (48f + Mathf.Sin(time * 3.2f) * 16f)); } private static void Fit(string name, Transform parent, Vector3 target, Vector3 scale) { //IL_008c: 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_00a8: 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_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) GameObject prefab = PrefabManager.Instance.GetPrefab("wood_pole"); Transform val = (((Object)(object)prefab == (Object)null) ? null : prefab.transform.Find("New")); MeshFilter val2 = (((Object)(object)val == (Object)null) ? null : ((Component)val).GetComponent<MeshFilter>()); if ((Object)(object)val2 == (Object)null || (Object)(object)val2.sharedMesh == (Object)null) { TogetherWeRowPlugin.Log.LogWarning((object)("'wood_pole/New' is gone; the oar is missing its " + name + ".")); return; } GameObject val3 = Object.Instantiate<GameObject>(((Component)val).gameObject, parent); ((Object)val3).name = name; val3.transform.localRotation = Quaternion.identity; val3.transform.localScale = scale; Transform transform = val3.transform; Bounds bounds = val2.sharedMesh.bounds; transform.localPosition = target - Vector3.Scale(((Bounds)(ref bounds)).center, scale); LODGroup[] componentsInChildren = val3.GetComponentsInChildren<LODGroup>(true); for (int i = 0; i < componentsInChildren.Length; i++) { Object.DestroyImmediate((Object)(object)componentsInChildren[i]); } Collider[] componentsInChildren2 = val3.GetComponentsInChildren<Collider>(true); for (int i = 0; i < componentsInChildren2.Length; i++) { Object.DestroyImmediate((Object)(object)componentsInChildren2[i]); } Renderer[] componentsInChildren3 = val3.GetComponentsInChildren<Renderer>(true); for (int i = 0; i < componentsInChildren3.Length; i++) { componentsInChildren3[i].enabled = true; } } } [BepInPlugin("com.gitmcp.togetherwerow", "Together We Row", "1.0.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] [NetworkCompatibility(/*Could not decode attribute arguments.*/)] public class TogetherWeRowPlugin : BaseUnityPlugin { public const string PluginGuid = "com.gitmcp.togetherwerow"; public const string PluginName = "Together We Row"; public const string PluginVersion = "1.0.0"; internal static ManualLogSource Log; internal static ConfigEntry<float> Speed; private Harmony _harmony; private void Awake() { //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Expected O, but got Unknown //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Expected O, but got Unknown //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Expected O, but got Unknown Log = ((BaseUnityPlugin)this).Logger; Speed = ((BaseUnityPlugin)this).Config.Bind<float>("TogetherWeRow", "Speed", 1f, new ConfigDescription("How much one helper adds, as a multiple of the helm's paddle. 1 means the helm plus one rower goes twice as fast from paddling, and that same extra still applies with the sail up.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 4f), new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true } })); Localizations.Register(); _harmony = new Harmony("com.gitmcp.togetherwerow"); _harmony.PatchAll(typeof(TogetherWeRowPlugin).Assembly); int num = _harmony.GetPatchedMethods().Count(); Log.LogInfo((object)string.Format("{0} {1} loaded, {2} method(s) patched.", "Together We Row", "1.0.0", num)); } private void OnDestroy() { Harmony harmony = _harmony; if (harmony != null) { harmony.UnpatchSelf(); } } } internal class TogetherWeRowRig : MonoBehaviour { private struct Bench { public Transform Attach; public Transform Pivot; public float Side; } private readonly List<Bench> _benches = new List<Bench>(); private Ship _ship; private bool _built; private void Awake() { _ship = ((Component)this).GetComponent<Ship>(); } private void Start() { Build(); } private void Update() { //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Invalid comparison between Unknown and I4 //IL_00b0: 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) if (!_built) { Build(); } else { if ((Object)(object)_ship == (Object)null) { return; } bool flag = (Object)(object)_ship.m_shipControlls != (Object)null && _ship.m_shipControlls.HaveValidUser() && (int)_ship.GetSpeedSetting() > 0; float time = Time.time; foreach (Bench bench in _benches) { if (!((Object)(object)bench.Pivot == (Object)null)) { bool flag2 = flag && TogetherWeRowCrew.Occupied(bench.Attach); bench.Pivot.localRotation = (flag2 ? TogetherWeRowOars.StrokeAt(bench.Side, time) : TogetherWeRowOars.Rest(bench.Side)); } } } } private void Build() { //IL_0084: 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) if (_built || (Object)(object)_ship == (Object)null || PrefabManager.Instance == null || (Object)(object)PrefabManager.Instance.GetPrefab("wood_pole") == (Object)null) { return; } Chair[] componentsInChildren = ((Component)this).GetComponentsInChildren<Chair>(true); foreach (Chair val in componentsInChildren) { if (val.m_inShip && !((Object)(object)val.m_attachPoint == (Object)null) && TogetherWeRowCrew.CanRow(_ship, val.m_attachPoint)) { float side = ((((Component)this).transform.InverseTransformPoint(val.m_attachPoint.position).x >= 0f) ? 1f : (-1f)); Transform pivot = TogetherWeRowOars.Build(((Component)this).transform, val.m_attachPoint, side); _benches.Add(new Bench { Attach = val.m_attachPoint, Pivot = pivot, Side = side }); } } _built = true; if (_benches.Count > 0) { TogetherWeRowPlugin.Log.LogInfo((object)$"{((Object)_ship).name} gained {_benches.Count} oar(s)."); } } } public static class MyPluginInfo { public const string PLUGIN_GUID = "TogetherWeRow"; public const string PLUGIN_NAME = "TogetherWeRow"; public const string PLUGIN_VERSION = "1.0.0"; } } namespace TogetherWeRow.Patches { [HarmonyPatch(typeof(Chair), "GetHoverText")] internal static class ChairPatch { private static void Postfix(Chair __instance, ref string __result) { if (__instance.m_inShip && !string.IsNullOrEmpty(__result)) { Ship componentInParent = ((Component)__instance).GetComponentInParent<Ship>(); if (!((Object)(object)componentInParent == (Object)null) && TogetherWeRowCrew.CanRow(componentInParent, __instance.m_attachPoint) && __result.IndexOf("888888", StringComparison.Ordinal) < 0) { __result = Localization.instance.Localize(__instance.m_name + "\n[<color=yellow><b>$KEY_Use</b></color>] $togetherwerow_use"); } } } } [HarmonyPatch(typeof(Ship))] internal static class ShipPatch { [HarmonyPostfix] [HarmonyPatch("Start")] private static void HangOars(Ship __instance) { if ((Object)(object)((Component)__instance).GetComponent<TogetherWeRowRig>() == (Object)null) { ((Component)__instance).gameObject.AddComponent<TogetherWeRowRig>(); } } [HarmonyPostfix] [HarmonyPatch("CustomFixedUpdate")] private static void Pull(Ship __instance, float fixedDeltaTime) { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Invalid comparison between Unknown and I4 //IL_0069: 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_0097: 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_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) if (!__instance.IsOwner() || (Object)(object)__instance.m_shipControlls == (Object)null || !__instance.m_shipControlls.HaveValidUser()) { return; } Speed speedSetting = __instance.GetSpeedSetting(); if ((int)speedSetting == 0) { return; } int num = TogetherWeRowCrew.Count(__instance); if (num != 0) { float num2 = (float)num * TogetherWeRowPlugin.Speed.Value; if (!(num2 <= 0f)) { float num3 = (((int)speedSetting == 1) ? (-1f) : 1f); Vector3 val = ((Component)__instance).transform.forward * (num3 * __instance.m_backwardForce * num2 * (1f - Mathf.Abs(__instance.GetRudderValue()))); Vector3 val2 = ((Component)__instance).transform.position + ((Component)__instance).transform.forward * __instance.m_stearForceOffset; __instance.m_body.AddForceAtPosition(val * (__instance.m_body.mass * fixedDeltaTime), val2, (ForceMode)1); } } } } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public IgnoresAccessChecksToAttribute(string assemblyName) { } } }