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 SimpleVikingsDoSwim v1.1.1
SimpleVikingsDoSwim.dll
Decompiled 2 months 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 Microsoft.CodeAnalysis; using UnityEngine; using UnityEngine.Rendering; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyCompany("SimpleVikingsDoSwim")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.1.1.0")] [assembly: AssemblyInformationalVersion("1.1.1")] [assembly: AssemblyProduct("Simple Vikings Do Swim")] [assembly: AssemblyTitle("SimpleVikingsDoSwim")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.1.1.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 SimpleVikingsDoSwim { [BepInPlugin("SimpleVikingsDoSwim", "Simple Vikings Do Swim", "1.1.1")] public class Plugin : BaseUnityPlugin { [HarmonyPatch(typeof(Character), "Awake")] public class CharacterAwakePatch { public static void Prefix(Character __instance) { if (__instance.IsPlayer()) { __instance.m_swimDepth = _minSwimDepth; _swimDepth = __instance.m_swimDepth; } } } [HarmonyPatch(typeof(Character), "CustomFixedUpdate")] public class CharacterFixedUpdatePatch { public static void Prefix(Character __instance, ref Vector3 ___m_lookDir, float dt) { //IL_0209: Unknown result type (might be due to invalid IL or missing references) //IL_01bd: Unknown result type (might be due to invalid IL or missing references) if (!__instance.IsPlayer() || (Object)(object)__instance == (Object)null) { return; } if (!__instance.InWater()) { __instance.m_swimDepth = _minSwimDepth; } if (ZInput.GetKeyDown((KeyCode)306, true) && __instance.IsSwimming() && !_isDiving) { _isDiving = true; __instance.m_swimDepth = _minSwimDepth + 1f; } if (ZInput.GetKey((KeyCode)306, true) && __instance.InWater() && !__instance.IsOnGround() && __instance.IsSwimming()) { _swimDepth = __instance.m_swimDepth; float num = ___m_lookDir.y * ___m_lookDir.y * 2f * dt; if (num > 0.5f) { num = 0.5f; } float y = ___m_lookDir.y; if (y > -0.25f && y < 0.15f) { num = 0f; } if ((double)___m_lookDir.y > 0.15) { __instance.m_swimDepth -= num; if (__instance.m_swimDepth < _minSwimDepth - 0.4f) { __instance.m_swimDepth = _minSwimDepth; } } else if ((double)___m_lookDir.y < -0.25) { __instance.m_swimDepth += num; if (__instance.m_swimDepth > _maxSwimDepth) { __instance.m_swimDepth = _maxSwimDepth; } } if (__instance.m_swimDepth > _minSwimDepth + 0.1f) { __instance.SetMoveDir(___m_lookDir); } } if (ZInput.GetKey((KeyCode)32, true) && _isDiving) { Vector3 moveDir = default(Vector3); ((Vector3)(ref moveDir))..ctor(___m_lookDir.x, ___m_lookDir.y, ___m_lookDir.z); moveDir.y = 1f; __instance.SetMoveDir(moveDir); __instance.m_swimDepth -= 2f * dt; if ((double)__instance.m_swimDepth < (double)_minSwimDepth - 0.4) { __instance.m_swimDepth = _minSwimDepth; } } } } [HarmonyPatch(typeof(Character), "UpdateMotion")] public class CharacterUpdateMotionPatch { public static void Prefix(Character __instance, ref float ___m_lastGroundTouch, ref float ___m_swimTimer) { //IL_0058: Unknown result type (might be due to invalid IL or missing references) if (__instance.IsPlayer()) { if (__instance.m_swimDepth > _minSwimDepth + 0.1f) { _isDiving = true; ___m_lastGroundTouch = 0.3f; ___m_swimTimer = 0f; } else { _isDiving = false; } _swimDepth = __instance.m_swimDepth; if (((Component)__instance).transform.position.y > __instance.GetLiquidLevel() && _isDiving && !ZInput.GetKey((KeyCode)306, true)) { _isDiving = false; } } } } [HarmonyPatch(typeof(Character), "UpdateSwimming")] public class CharacterUpdateSwimmingPatch { public static bool Prefix(float dt, ref Character __instance) { //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_006d: 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_008f: 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_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_013f: 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_014c: Unknown result type (might be due to invalid IL or missing references) //IL_019f: Unknown result type (might be due to invalid IL or missing references) //IL_01a4: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_01af: Unknown result type (might be due to invalid IL or missing references) //IL_018d: Unknown result type (might be due to invalid IL or missing references) //IL_0194: Unknown result type (might be due to invalid IL or missing references) //IL_0199: Unknown result type (might be due to invalid IL or missing references) //IL_01ee: Unknown result type (might be due to invalid IL or missing references) //IL_01fa: Unknown result type (might be due to invalid IL or missing references) //IL_01ff: Unknown result type (might be due to invalid IL or missing references) //IL_0204: Unknown result type (might be due to invalid IL or missing references) //IL_0240: Unknown result type (might be due to invalid IL or missing references) //IL_0228: Unknown result type (might be due to invalid IL or missing references) //IL_0232: Unknown result type (might be due to invalid IL or missing references) //IL_0237: 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_034a: Unknown result type (might be due to invalid IL or missing references) //IL_037d: Unknown result type (might be due to invalid IL or missing references) //IL_0382: Unknown result type (might be due to invalid IL or missing references) //IL_0386: Unknown result type (might be due to invalid IL or missing references) //IL_03ad: Unknown result type (might be due to invalid IL or missing references) //IL_02d4: Unknown result type (might be due to invalid IL or missing references) //IL_0306: Unknown result type (might be due to invalid IL or missing references) //IL_030b: Unknown result type (might be due to invalid IL or missing references) //IL_030f: Unknown result type (might be due to invalid IL or missing references) //IL_0330: Unknown result type (might be due to invalid IL or missing references) //IL_0415: 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_0469: Unknown result type (might be due to invalid IL or missing references) //IL_0475: Unknown result type (might be due to invalid IL or missing references) //IL_0483: Unknown result type (might be due to invalid IL or missing references) //IL_048f: Unknown result type (might be due to invalid IL or missing references) //IL_044f: Unknown result type (might be due to invalid IL or missing references) //IL_045b: Unknown result type (might be due to invalid IL or missing references) //IL_055e: Unknown result type (might be due to invalid IL or missing references) if (!__instance.IsPlayer()) { return true; } bool flag = __instance.IsOnGround(); if (Mathf.Max(0f, __instance.m_maxAirAltitude - ((Component)__instance).transform.position.y) > 0.5f && __instance.m_onLand != null) { __instance.m_onLand(new Vector3(((Component)__instance).transform.position.x, __instance.GetLiquidLevel(), ((Component)__instance).transform.position.z)); } __instance.m_maxAirAltitude = ((Component)__instance).transform.position.y; float num = __instance.m_swimSpeed * __instance.GetAttackSpeedFactorMovement(); if (__instance.IsPlayer() && ZInput.GetKey((KeyCode)304, true)) { num *= _swimSprintSpeed.Value; } if (__instance.InMinorActionSlowdown()) { num = 0f; } __instance.m_seman.ApplyStatusEffectSpeedMods(ref num, __instance.m_moveDir); Vector3 val = __instance.m_moveDir * num; if (__instance.IsPlayer()) { __instance.m_currentVel = Vector3.Lerp(__instance.m_currentVel, val, __instance.m_swimAcceleration); } else { float magnitude = ((Vector3)(ref val)).magnitude; float magnitude2 = ((Vector3)(ref __instance.m_currentVel)).magnitude; if (magnitude > magnitude2) { magnitude = Mathf.MoveTowards(magnitude2, magnitude, __instance.m_swimAcceleration); val = ((Vector3)(ref val)).normalized * magnitude; } __instance.m_currentVel = Vector3.Lerp(__instance.m_currentVel, val, 0.5f); } if (((Vector3)(ref __instance.m_currentVel)).magnitude > 0.1f) { __instance.AddNoise(15f); } __instance.AddPushbackForce(ref __instance.m_currentVel); Vector3 val2 = __instance.m_currentVel - __instance.m_body.linearVelocity; val2.y = 0f; if (((Vector3)(ref val2)).magnitude > 20f) { val2 = ((Vector3)(ref val2)).normalized * 20f; } __instance.m_body.AddForce(val2, (ForceMode)2); float num2 = __instance.GetLiquidLevel() - __instance.m_swimDepth; if (__instance.IsPlayer()) { if (_isDiving && (double)__instance.m_swimDepth > (double)_minSwimDepth + 2.5) { num2 = _waterSurface - __instance.m_swimDepth; } else { _waterSurface = __instance.GetLiquidLevel(); } } if (((Component)__instance).transform.position.y < num2) { float num3 = Mathf.Clamp01((num2 - ((Component)__instance).transform.position.y) / 2f); float num4 = Mathf.Lerp(0f, 10f, num3); Vector3 linearVelocity = __instance.m_body.linearVelocity; linearVelocity.y = Mathf.MoveTowards(linearVelocity.y, num4, 50f * dt); __instance.m_body.linearVelocity = linearVelocity; } else { float num5 = Mathf.Clamp01((0f - (num2 - ((Component)__instance).transform.position.y)) / 1f); float num6 = Mathf.Lerp(0f, 10f, num5); Vector3 linearVelocity2 = __instance.m_body.linearVelocity; linearVelocity2.y = Mathf.MoveTowards(linearVelocity2.y, 0f - num6, 30f * dt); __instance.m_body.linearVelocity = linearVelocity2; } float num7 = 0f; if (((Vector3)(ref __instance.m_moveDir)).magnitude > 0.1f || __instance.AlwaysRotateCamera()) { float swimTurnSpeed = __instance.m_swimTurnSpeed; __instance.m_seman.ApplyStatusEffectSpeedMods(ref swimTurnSpeed, __instance.m_currentVel); num7 = __instance.UpdateRotation(swimTurnSpeed, dt, false); } __instance.m_body.angularVelocity = Vector3.zero; __instance.UpdateEyeRotation(); __instance.m_body.useGravity = true; float num8 = ((__instance.IsPlayer() || __instance.HaveRider()) ? Vector3.Dot(__instance.m_currentVel, ((Component)__instance).transform.forward) : Vector3.Dot(__instance.m_body.linearVelocity, ((Component)__instance).transform.forward)); float num9 = Vector3.Dot(__instance.m_currentVel, ((Component)__instance).transform.right); __instance.m_currentTurnVel = Mathf.SmoothDamp(__instance.m_currentTurnVel, num7, ref __instance.m_currentTurnVelChange, 0.5f, 99f); __instance.m_zanim.SetFloat(_forwardSpeed, num8); __instance.m_zanim.SetFloat(_sidewaySpeed, num9); __instance.m_zanim.SetFloat(_turnSpeed, __instance.m_currentTurnVel); __instance.m_zanim.SetBool(_inWater, !flag); __instance.m_zanim.SetBool(_onGround, false); __instance.m_zanim.SetBool(_encumbered, false); __instance.m_zanim.SetBool(_flying, false); if (!flag) { __instance.OnSwimming(val, dt); } return false; } } [HarmonyPatch(typeof(Player), "OnSwimming")] public class PlayerOnSwimmingPatch { public static bool Prefix(ref Vector3 targetVel, float dt, Player __instance) { //IL_01cd: Unknown result type (might be due to invalid IL or missing references) //IL_01d4: Expected O, but got Unknown //IL_01e5: Unknown result type (might be due to invalid IL or missing references) //IL_01ea: Unknown result type (might be due to invalid IL or missing references) //IL_01f1: Unknown result type (might be due to invalid IL or missing references) //IL_01f6: Unknown result type (might be due to invalid IL or missing references) //IL_020a: Unknown result type (might be due to invalid IL or missing references) //IL_021e: Unknown result type (might be due to invalid IL or missing references) //IL_0223: 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_0240: Unknown result type (might be due to invalid IL or missing references) //IL_024e: Unknown result type (might be due to invalid IL or missing references) //IL_0254: Unknown result type (might be due to invalid IL or missing references) bool flag = (Object)(object)__instance == (Object)(object)Player.m_localPlayer; float skillFactor = __instance.m_skills.GetSkillFactor((SkillType)103); float num = Mathf.Lerp(__instance.m_swimStaminaDrainMinSkill, __instance.m_swimStaminaDrainMaxSkill, skillFactor); if (flag && ZInput.GetKey((KeyCode)304, true)) { num *= _swimStaminaDrain.Value; } num += num * ((Character)__instance).GetEquipmentSwimStaminaModifier(); ((Character)__instance).m_seman.ModifySwimStaminaUsage(num, ref num, true); if (((Vector3)(ref targetVel)).magnitude <= 0.1f && _isDiving && ((Character)__instance).m_swimDepth > _minSwimDepth + 0.1f) { if (((Character)__instance).IsEncumbered()) { ((Character)__instance).UseStamina(dt * num * Game.m_moveStaminaRate); } else { ((Character)__instance).UseStamina(dt * num * Game.m_moveStaminaRate * 0.1f); } __instance.m_swimSkillImproveTimer += dt; if (__instance.m_swimSkillImproveTimer > 1f) { __instance.m_swimSkillImproveTimer = 0f; ((Character)__instance).RaiseSkill((SkillType)103, 0.2f); } } if (((Vector3)(ref targetVel)).magnitude > 0.1f) { ((Character)__instance).UseStamina(dt * num * Game.m_moveStaminaRate); __instance.m_swimSkillImproveTimer += dt; if (__instance.m_swimSkillImproveTimer > 1f) { __instance.m_swimSkillImproveTimer = 0f; ((Character)__instance).RaiseSkill((SkillType)103, 1f); } } if (!((Character)__instance).HaveStamina(0f)) { __instance.m_drownDamageTimer += dt; if (__instance.m_drownDamageTimer > 1f) { __instance.m_drownDamageTimer = 0f; float damage = Mathf.Ceil(((Character)__instance).GetMaxHealth() / 25f); HitData val = new HitData(); val.m_damage.m_damage = damage; val.m_point = ((Character)__instance).GetCenterPoint(); val.m_dir = Vector3.down; val.m_pushForce = 10f; val.m_hitType = (HitType)4; ((Character)__instance).Damage(val); Vector3 position = ((Component)__instance).transform.position; position.y = ((Character)__instance).GetLiquidLevel(); __instance.m_drownEffects.Create(position, ((Component)__instance).transform.rotation, (Transform)null, 1f, -1, default(ZDOID)); } } return false; } } [HarmonyPatch(typeof(GameCamera), "UpdateCamera")] public class GameCameraUpdateCameraPatch { public static void Prefix(GameCamera __instance) { //IL_0061: 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_013a: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)Player.m_localPlayer == (Object)null) { return; } __instance.m_minWaterDistance = ((!_isDiving) ? 0.3f : (-5000f)); if (__instance.m_maxDistance != 4f && _maxDistance == 0f) { _maxDistance = __instance.m_maxDistance; } camera_positionY = ((Component)__instance).transform.position.y; if (((Component)__instance).transform.position.y < camera_waterSurface && _isDiving) { __instance.m_maxDistance = 4f; EnvSetup currentEnvironment = EnvMan.instance.GetCurrentEnvironment(); if (_environment != currentEnvironment.m_name) { _environment = currentEnvironment.m_name + "_Underwater"; if (!_environments.Contains(_environment)) { EnvMan.instance.AppendEnvironment(CreateUnderwaterEnv(currentEnvironment)); Logger.LogInfo((object)("Created Underwater Environment: " + _environment)); } EnvMan.instance.SetForceEnvironment(_environment); } return; } if ((((Component)__instance).transform.position.y > camera_waterSurface || !_isDiving) && _environment != "") { _environment = ""; if (_maxDistance != 0f) { __instance.m_maxDistance = _maxDistance; } EnvMan.instance.SetForceEnvironment(""); } if (!_isDiving && _maxDistance != 0f) { __instance.m_maxDistance = _maxDistance; } } } [HarmonyPatch(typeof(WaterVolume), "UpdateMaterials")] public class WaterVolumeUpdatePatch { private static ShadowCastingMode mode; public static void Postfix(WaterVolume __instance) { //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Invalid comparison between Unknown and I4 //IL_0031: 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_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_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_008b: 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_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_0145: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)__instance.m_waterSurface == (Object)null) { return; } if ((Object)(object)GameCamera.instance != (Object)null) { camera_waterSurface = __instance.GetWaterSurface(((Component)GameCamera.instance).transform.position, 1f); } if ((int)mode == 0) { mode = ((Renderer)__instance.m_waterSurface).shadowCastingMode; } Quaternion rotation; if (camera_positionY < camera_waterSurface && _isDiving) { rotation = ((Component)((Component)__instance.m_waterSurface).GetComponent<MeshRenderer>()).transform.rotation; if (!((Quaternion)(ref rotation)).eulerAngles.y.Equals(180f)) { ((Component)__instance.m_waterSurface).transform.Rotate(180f, 0f, 0f); ((Renderer)__instance.m_waterSurface).shadowCastingMode = (ShadowCastingMode)2; } } else { rotation = ((Component)((Component)__instance.m_waterSurface).GetComponent<MeshRenderer>()).transform.rotation; if (((Quaternion)(ref rotation)).eulerAngles.y.Equals(180f)) { ((Component)__instance.m_waterSurface).transform.Rotate(-180f, 0f, 0f); ((Renderer)__instance.m_waterSurface).shadowCastingMode = mode; } } } } internal static Plugin Instance; internal static ManualLogSource Logger; internal static Harmony Harmony = new Harmony("SimpleVikingsDoSwim"); internal static float _swimDepth = 0f; internal static float _minSwimDepth = 1.5f; internal static float _maxSwimDepth = 30f; public static float _maxDistance = 0f; public static float _waterSurface = 30f; public static float camera_positionY; public static float camera_waterSurface = 30f; internal static bool _isDiving = false; public static int _forwardSpeed; public static int _sidewaySpeed; public static int _turnSpeed; public static int _inWater; public static int _onGround; public static int _encumbered; public static int _flying; public static PluginConfig _swimSprintSpeed; public static PluginConfig _swimStaminaDrain; public static string _environment = ""; public static List<string> _environments = new List<string>(); private void Awake() { Instance = this; Logger = ((BaseUnityPlugin)this).Logger; _swimSprintSpeed = new PluginConfig("General", "Sprint Swim Speed Multiplier").AddValue("Set Swim Sprint Speed Multiplier", 1.7f, 1f, 3f); _swimStaminaDrain = new PluginConfig("General", "Sprint Swim Stamina Drain Multiplier").AddValue("Set Sprint Swim Stamina Drain Multiplier", 2.5f, 1f, 3f); _forwardSpeed = ZSyncAnimation.GetHash("forward_speed"); _sidewaySpeed = ZSyncAnimation.GetHash("sideway_speed"); _turnSpeed = ZSyncAnimation.GetHash("turn_speed"); _inWater = ZSyncAnimation.GetHash("inWater"); _onGround = ZSyncAnimation.GetHash("onGround"); _encumbered = ZSyncAnimation.GetHash("encumbered"); _flying = ZSyncAnimation.GetHash("flying"); Harmony.PatchAll(); Logger.LogInfo((object)"Plugin is loaded!"); } private void OnDestroy() { ((BaseUnityPlugin)this).Config.Save(); Harmony.UnpatchSelf(); Logger.LogInfo((object)"Plugin is unloaded!"); } private static EnvSetup CreateUnderwaterEnv(EnvSetup original) { //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0094: 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_00a5: 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_00b6: 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_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: 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_0103: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Unknown result type (might be due to invalid IL or missing references) EnvSetup val = original.Clone(); val.m_name = original.m_name + "_Underwater"; _environments.Add(val.m_name); val.m_default = false; val.m_isWet = true; val.m_ambColorDay = new Color(0f, 0.25f, 0.27f); val.m_ambColorNight = new Color(0f, 0.12f, 0.14f); Color val2 = default(Color); ((Color)(ref val2))..ctor(0f, 0.3188f, 0.3667f, 1f); val.m_fogColorDay = val2; val.m_fogColorMorning = val2 * 0.6f; val.m_fogColorEvening = val2 * 0.6f; val.m_fogColorNight = val2 * 0.4f; val.m_fogColorSunDay = original.m_fogColorSunDay * 0.8f; val.m_fogColorSunMorning = original.m_fogColorSunMorning * 0.8f; val.m_fogColorSunEvening = original.m_fogColorSunEvening * 0.8f; val.m_fogDensityDay = 0.035f; val.m_fogDensityMorning = 0.04f; val.m_fogDensityEvening = 0.04f; val.m_fogDensityNight = 0.05f; val.m_lightIntensityDay = 0.35f; val.m_lightIntensityNight = 0.05f; val.m_ambientOcclusionColor = new Color(0f, 0.08f, 0.1f); val.m_aoIntensityDay = 0.8f; val.m_aoIntensityMorning = 0.65f; val.m_aoIntensityEvening = 0.65f; val.m_aoIntensityNight = 0.5f; return val; } } public class PluginConfig { private ConfigEntry<bool> statusCE = null; private ConfigEntry<float> valueCE = null; private ConfigEntry<KeyboardShortcut> shortcutCE = null; private bool LastStatus = false; private Action onAction = null; private bool Startup = false; private bool OffOrOn = false; public string Section { get; private set; } public string Name { get; private set; } public bool IsTrigger { get; private set; } = false; public bool Status { get { if (statusCE != null) { return statusCE.Value; } return false; } set { if (statusCE != null && statusCE.Value != value) { statusCE.Value = value; } } } public float Value { get { if (valueCE != null) { return valueCE.Value; } return 0f; } set { if (valueCE != null) { valueCE.Value = value; } } } public PluginConfig(string section, string name) { Section = section; Name = name; } public PluginConfig AddStatus(string description, bool defaultValue = false) { statusCE = ((BaseUnityPlugin)Plugin.Instance).Config.Bind<bool>(Section, "Status of " + Name, defaultValue, description); return this; } public PluginConfig AddTrigger(string description, bool defaultValue = false) { IsTrigger = true; statusCE = ((BaseUnityPlugin)Plugin.Instance).Config.Bind<bool>(Section, "Trigger of " + Name, defaultValue, description); return this; } public PluginConfig AddValue(string description, float defaultValue, float minValue, float maxValue) { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Expected O, but got Unknown valueCE = ((BaseUnityPlugin)Plugin.Instance).Config.Bind<float>(Section, "Value of " + Name, defaultValue, new ConfigDescription(description, (AcceptableValueBase)(object)new AcceptableValueRange<float>(minValue, maxValue), Array.Empty<object>())); return this; } public PluginConfig AddShortcut(KeyCode key = (KeyCode)0, KeyCode[] modifiers = null) { //IL_0022: 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) shortcutCE = ((BaseUnityPlugin)Plugin.Instance).Config.Bind<KeyboardShortcut>(Section, "Shortcut of " + Name, new KeyboardShortcut(key, modifiers ?? Array.Empty<KeyCode>()), "Hotkey for on and off. Examples: Mouse 0, Mouse 1, Q, C, Shift + Q, Shift + C"); return this; } public PluginConfig AddAction(Action action) { onAction = action; if (valueCE != null) { valueCE.SettingChanged += delegate { action(); }; } return this; } public PluginConfig AddOffOrOn(bool offOrOn = false) { Startup = true; OffOrOn = offOrOn; return this; } public virtual void Update() { if (statusCE == null) { return; } if (Startup) { Status = OffOrOn; Startup = false; } if (shortcutCE != null && IskeyUp()) { Status = !Status; } if (Status != LastStatus) { string text = Section + " " + Name + " " + (IsTrigger ? "<color=green>Triggered</color>" : (Status ? "<color=green>Enabled</color>" : "<color=red>Disabled</color>")); if ((Object)(object)MessageHud.instance != (Object)null) { MessageHud.instance.ShowMessage((MessageType)1, text, 0, (Sprite)null, false, true); } if (onAction != null) { onAction(); } if (IsTrigger) { Status = false; } else { LastStatus = Status; } } } private bool IskeyUp() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_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_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0062: 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) KeyboardShortcut value = shortcutCE.Value; List<KeyCode> list = ((KeyboardShortcut)(ref value)).Modifiers.ToList(); foreach (KeyCode item in list) { if (!Input.GetKey(item)) { return false; } } value = shortcutCE.Value; if (Input.GetKeyUp(((KeyboardShortcut)(ref value)).MainKey)) { return true; } return false; } } public static class MyPluginInfo { public const string PLUGIN_GUID = "SimpleVikingsDoSwim"; public const string PLUGIN_NAME = "Simple Vikings Do Swim"; public const string PLUGIN_VERSION = "1.1.1"; } }