using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using HarmonyLib;
using JetBrains.Annotations;
using Jotunn.Configs;
using Jotunn.Entities;
using Jotunn.Managers;
using Jotunn.Utils;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.UI;
using Zen;
using Zen.Lib;
using Zen.Lib.Config;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyCompany("ZenCompass")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+a38febbeeaa22d159acf0fd5d1f2d0cc3343e213")]
[assembly: AssemblyProduct("ZenCompass")]
[assembly: AssemblyTitle("ZenCompass")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
internal sealed class NullableAttribute : Attribute
{
public readonly byte[] NullableFlags;
public NullableAttribute(byte P_0)
{
NullableFlags = new byte[1] { P_0 };
}
public NullableAttribute(byte[] P_0)
{
NullableFlags = P_0;
}
}
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
internal sealed class NullableContextAttribute : Attribute
{
public readonly byte Flag;
public NullableContextAttribute(byte P_0)
{
Flag = P_0;
}
}
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace ZenCompass
{
internal class Compass
{
private CompassConstants.ViewMode _viewMode = SmallOrLarge;
private float _lastInvLookup;
private const float InvLookupFrequency = 0.5f;
private ItemData? _inventoryItem;
private readonly GameObject _root;
private readonly GameObject _needle;
private readonly GameObject _center;
private readonly GameObject _heading;
private readonly GameObject _looking;
private readonly GameObject _glass;
private readonly GameObject _mask;
private readonly GameObject _ship;
private readonly GameObject _ring;
private readonly Sprite _ringSun;
private readonly Image _lookingImage;
private readonly Image _ringImage;
private readonly Image _shipIndicatorUnder;
private readonly Image _shipIndicatorOver;
private readonly Transform _windRing;
private readonly Image _windIcon;
private readonly Transform? _originalPinRootParent;
private float _radarEmptyTimestamp;
private bool _isRadarEmptyForDuration;
private bool _isRadarExpanded;
private bool _isRadarShrunk;
private int _radarPinCount;
private bool _isDarkMode;
private const float _malfunctionCheckFrequency = 2f;
private float _lastMalfunctionCheckTime;
private bool _isMalfunction;
private Coroutine? _malfunctionDelayCoroutine;
private readonly Dictionary<Biome, EnvSetup[]?> _malfunctionConditions = new Dictionary<Biome, EnvSetup[]>();
public Vector3 North { get; private set; }
public Vector3 Looking { get; private set; }
public Vector3 Heading { get; private set; }
internal Transform transform => _root.transform;
private static Transform SmallMap => Minimap.instance.m_mapSmall.transform;
private static bool InDungeon => ((Character)Player.m_localPlayer).InInterior();
private static CompassConstants.ViewMode SmallOrLarge
{
get
{
if (!Configs.ShrinkWhenEmpty.Value)
{
return CompassConstants.ViewMode.Large;
}
return CompassConstants.ViewMode.Small;
}
}
internal Compass()
{
//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
//IL_00de: Unknown result type (might be due to invalid IL or missing references)
//IL_00f2: 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_0107: Unknown result type (might be due to invalid IL or missing references)
//IL_0111: Expected O, but got Unknown
//IL_0142: 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_0186: Unknown result type (might be due to invalid IL or missing references)
//IL_0190: Unknown result type (might be due to invalid IL or missing references)
//IL_0332: Unknown result type (might be due to invalid IL or missing references)
//IL_033c: Unknown result type (might be due to invalid IL or missing references)
Minimap instance = Minimap.instance;
((Component)instance.m_smallMarker).gameObject.SetActive(false);
((Component)instance.m_windMarker).gameObject.SetActive(false);
((Component)instance.m_biomeNameSmall).gameObject.SetActive(false);
((Behaviour)((Component)instance.m_smallShipMarker).GetComponent<Image>()).enabled = false;
((Component)instance.m_pinNameRootSmall).gameObject.SetActive(false);
((Component)instance.m_smallRoot.transform.Find("Key tip")).gameObject.SetActive(false);
((Behaviour)instance.m_mapSmall.GetComponent<RectMask2D>()).enabled = false;
((Behaviour)instance.m_smallRoot.GetComponent<Image>()).enabled = false;
((Behaviour)instance.m_mapImageSmall).enabled = false;
instance.m_mapSmall.transform.localScale = Vector2.op_Implicit(Vector2.one * 1.4f);
instance.m_mapSmall.transform.localPosition = Vector2.op_Implicit(CompassConstants.PositionInit);
_root = new GameObject("ZenCompass_Root");
_root.transform.SetParent(SmallMap, false);
_root.transform.SetAsFirstSibling();
_root.transform.localScale = Vector3.one * 2f;
_ship = Object.Instantiate<GameObject>(((Component)Minimap.instance.m_smallShipMarker).gameObject, _root.transform);
_ship.transform.localScale = Vector3.one * 2f;
_ship.SetActive(true);
_looking = LoadCompassImage("compass_looking.png", _root);
_center = LoadCompassImage("compass_center.png", _root);
_needle = LoadCompassImage("compass_needle.png", _root);
_heading = LoadCompassImage("compass_heading.png", _root);
_glass = LoadCompassImage("compass_glass.png", _root);
_mask = LoadCompassImage("compass_mask.png", _root);
_ring = LoadCompassImage("compass_ring.png", _root);
_ringSun = AssetIO.LoadSpriteFromResource((BaseUnityPlugin)(object)ZenMod<Plugin>.Instance, "compass_ring_time.png");
_ringImage = _ring.GetComponent<Image>();
_lookingImage = _looking.GetComponent<Image>();
_mask.AddComponent<Mask>().showMaskGraphic = false;
_originalPinRootParent = ((Transform)Minimap.instance.m_pinRootSmall).parent;
((Transform)Minimap.instance.m_pinRootSmall).SetParent(_mask.transform);
_shipIndicatorUnder = _ship.GetComponent<Image>();
_shipIndicatorOver = ((Component)((Transform)Hud.instance.m_shipWindIndicatorRoot).Find("Ship")).gameObject.GetComponent<Image>();
_windRing = ((Transform)Hud.instance.m_shipWindIndicatorRoot).Find("Circle");
((Component)_windRing).gameObject.SetActive(false);
_windIcon = Hud.instance.m_shipWindIcon;
((Component)_windIcon).transform.localScale = Vector3.one / 2f;
Hud.instance.m_shipHudRoot.transform.SetAsLastSibling();
Configs.MalfunctionConditions.SettingChanged += delegate
{
ParseMalfunctionConditions();
};
ParseMalfunctionConditions();
}
public void Destroy()
{
//IL_0023: 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)
Logging<Plugin>.Info((object)"Unloading", 0);
if (Object.op_Implicit((Object)(object)Minimap.instance))
{
_root.transform.localScale = Vector3.one * 2f;
((Component)Minimap.instance.m_pinRootSmall).gameObject.SetActive(true);
((Transform)Minimap.instance.m_pinRootSmall).SetParent(_originalPinRootParent);
Object.Destroy((Object)(object)_root);
}
}
internal void Update()
{
if (Object.op_Implicit((Object)(object)Player.m_localPlayer))
{
bool flag = PlayerExt.IsShipCaptain(Player.m_localPlayer);
bool flag2 = ((Character)Player.m_localPlayer).IsAttachedToShip();
bool flag3 = ((Character)Player.m_localPlayer).IsRiding();
InventoryCheck();
MalfunctionCheck();
UpdateRadar();
UpdateConfigScale();
CheckViewMode(flag || flag2 || flag3);
UpdateViewScale();
UpdateRotation(flag);
UpdateStatusEffectsPosition();
UpdateShipIndicator(flag);
UpdateWindVisibility(flag);
UpdateTimeOfDay();
}
}
private void InventoryCheck()
{
if ((Configs.CraftToUse.Value || Configs.EquipToUse.Value) && Time.time > _lastInvLookup + 0.5f)
{
_inventoryItem = CompassItem.FindInInventory();
_lastInvLookup = Time.time;
}
}
private void MalfunctionCheck()
{
//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_00a8: Unknown result type (might be due to invalid IL or missing references)
//IL_00db: Unknown result type (might be due to invalid IL or missing references)
bool flag = Player.m_localPlayer.m_teleporting || Player.m_localPlayer.m_teleportCooldown < 2f;
if (Time.time < _lastMalfunctionCheckTime + 2f && !flag)
{
return;
}
_lastMalfunctionCheckTime = Time.time;
Dictionary<Biome, EnvSetup[]?> conditions = _malfunctionConditions;
Biome currentBiome = Player.m_localPlayer.GetCurrentBiome();
EnvSetup currentEnv = EnvMan.instance.GetCurrentEnvironment();
bool flag2 = conditions.Keys.Any((Biome biome) => ((Enum)biome).HasFlag((Enum)(object)currentBiome));
bool flag3 = CheckEnv((Biome)895) || CheckEnv(currentBiome);
bool malfunction = flag2 && flag3;
Logging<Plugin>.Debug((object)$"Malfunction? {malfunction} Biome: {currentBiome} Env: {currentEnv.m_name} InBiome: {flag2} InEnv: {flag3}", 0);
if (malfunction != _isMalfunction && _malfunctionDelayCoroutine == null)
{
_malfunctionDelayCoroutine = Timing.Delay((MonoBehaviour)(object)ZenMod<Plugin>.Instance, Configs.MalfunctionTransitionDelay.Value, (Action)delegate
{
_isMalfunction = malfunction;
_malfunctionDelayCoroutine = null;
});
}
bool CheckEnv(Biome biome)
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
if (conditions.TryGetValue(biome, out EnvSetup[] value))
{
return value?.Any((EnvSetup env) => env.m_name == currentEnv?.m_name) ?? true;
}
return false;
}
}
private void ParseMalfunctionConditions()
{
//IL_006c: 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_0086: Unknown result type (might be due to invalid IL or missing references)
//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
List<EnvSetup> environments = EnvMan.instance.m_environments;
_malfunctionConditions.Clear();
foreach (var (text, text2) in IEnumerableExt.AsTuple<string, string>(Configs.MalfunctionConditions.Value.ToDictionary(':')))
{
try
{
Biome key = (Biome)Enum.Parse(typeof(Biome), text);
if (text2 == "All")
{
_malfunctionConditions[key] = null;
continue;
}
string[] weatherNames = text2.Split(new char[1] { '|' });
if (!weatherNames.All((string w) => environments.Any((EnvSetup e) => e.m_name == w)))
{
throw new Exception("Invalid weather");
}
_malfunctionConditions[key] = environments.FindAll((EnvSetup e) => weatherNames.Contains(e.m_name)).ToArray();
}
catch (Exception ex)
{
Logging<Plugin>.Error((object)("Malformed config for malfunction condition: " + text + "=" + text2 + " " + ex.Message), (ushort)0);
}
}
}
private void CheckViewMode(bool isShipOrMount)
{
if (((Character)Player.m_localPlayer).IsDead())
{
_viewMode = CompassConstants.ViewMode.None;
return;
}
if (Configs.CraftToUse.Value)
{
if (_inventoryItem == null)
{
_viewMode = CompassConstants.ViewMode.None;
return;
}
if (Configs.EquipToUse.Value && !_inventoryItem.IsEquipped())
{
_viewMode = CompassConstants.ViewMode.None;
return;
}
}
if (InDungeon)
{
_viewMode = (Configs.AllowInDungeon.Value ? SmallOrLarge : CompassConstants.ViewMode.None);
return;
}
if (Minimap.IsOpen())
{
_viewMode = CompassConstants.ViewMode.Small;
return;
}
int num = ((isShipOrMount && Plugin.IsZenMapLoaded) ? 1 : 0);
if (_radarPinCount <= num)
{
if (_isRadarEmptyForDuration)
{
if (Time.time - _radarEmptyTimestamp > 5f)
{
_viewMode = SmallOrLarge;
}
}
else
{
_isRadarEmptyForDuration = true;
_radarEmptyTimestamp = Time.time;
}
}
else
{
_isRadarEmptyForDuration = false;
_viewMode = CompassConstants.ViewMode.Large;
}
}
private void UpdateRotation(bool isShipCaptain)
{
//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_00b7: 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_00c7: Unknown result type (might be due to invalid IL or missing references)
//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
//IL_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_00ea: Unknown result type (might be due to invalid IL or missing references)
//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
//IL_0101: Unknown result type (might be due to invalid IL or missing references)
//IL_010c: Unknown result type (might be due to invalid IL or missing references)
//IL_0111: Unknown result type (might be due to invalid IL or missing references)
//IL_0118: Unknown result type (might be due to invalid IL or missing references)
//IL_0180: Unknown result type (might be due to invalid IL or missing references)
//IL_0125: Unknown result type (might be due to invalid IL or missing references)
//IL_012a: 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_0146: Unknown result type (might be due to invalid IL or missing references)
//IL_014b: Unknown result type (might be due to invalid IL or missing references)
//IL_0151: Unknown result type (might be due to invalid IL or missing references)
//IL_0158: Unknown result type (might be due to invalid IL or missing references)
//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
//IL_01cb: Unknown result type (might be due to invalid IL or missing references)
//IL_019e: Unknown result type (might be due to invalid IL or missing references)
//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
//IL_0205: Unknown result type (might be due to invalid IL or missing references)
//IL_01e9: Unknown result type (might be due to invalid IL or missing references)
//IL_021b: Unknown result type (might be due to invalid IL or missing references)
//IL_0231: Unknown result type (might be due to invalid IL or missing references)
CompassConstants.Orientation orientation = (Configs.RotatingCompass.Value ? CompassConstants.Orientation.Rotating : CompassConstants.Orientation.Fixed);
if (Configs.CraftToUse.Value)
{
orientation = ((!Configs.EquipToUse.Value) ? ((!_inventoryItem.IsCompass() || Configs.RotatingCompass.Value) ? CompassConstants.Orientation.Rotating : CompassConstants.Orientation.Fixed) : ((!_inventoryItem.IsEquipped() || !_inventoryItem.IsCompass() || Configs.RotatingCompass.Value) ? CompassConstants.Orientation.Rotating : CompassConstants.Orientation.Fixed));
}
Minimap instance = Minimap.instance;
instance.m_minZoom = 0.005f * (float)Configs.RadarRangePercent.Value / 100f;
instance.m_smallZoom = Minimap.instance.m_minZoom;
Quaternion rotation = ((Component)Camera.current).transform.rotation;
Vector3 eulerAngles = ((Quaternion)(ref rotation)).eulerAngles;
rotation = ((Component)Player.m_localPlayer).transform.rotation;
Vector3 eulerAngles2 = ((Quaternion)(ref rotation)).eulerAngles;
switch (isShipCaptain ? CompassConstants.Orientation.Rotating : orientation)
{
case CompassConstants.Orientation.Fixed:
North = Vector3.forward;
Looking = Vector3.forward * (0f - eulerAngles.y);
Heading = Vector3.forward * (0f - eulerAngles2.y);
break;
case CompassConstants.Orientation.Rotating:
North = Vector3.forward * eulerAngles.y;
Looking = Vector3.forward;
Heading = Vector3.forward * (eulerAngles.y - eulerAngles2.y);
break;
default:
throw new ArgumentOutOfRangeException("orientation", orientation, "Orientation unknown");
}
SmallMap.eulerAngles = North;
_needle.transform.eulerAngles = (_isMalfunction ? (Vector3.forward * (Mathf.Sin(Time.time / 2f) * Mathf.Sin(Time.time) * 200f)) : North);
_heading.transform.eulerAngles = (_isMalfunction ? (Vector3.forward * (Mathf.Cos(Time.time) * 400f)) : Heading);
_looking.transform.eulerAngles = Looking;
_ship.transform.eulerAngles = Heading;
_looking.SetActive(!_isMalfunction);
}
private void UpdateTimeOfDay()
{
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_003e: Unknown result type (might be due to invalid IL or missing references)
//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
//IL_0082: Unknown result type (might be due to invalid IL or missing references)
//IL_0087: Unknown result type (might be due to invalid IL or missing references)
//IL_0089: Unknown result type (might be due to invalid IL or missing references)
if (Configs.TrackTimeDay.Value && !((Character)Player.m_localPlayer).InInterior())
{
_ring.transform.eulerAngles = Vector3.forward * ((EnvMan.instance.GetDayFraction() - 0.25f) * 360f);
_ringImage.overrideSprite = _ringSun;
}
else
{
_ringImage.overrideSprite = null;
}
if (_isDarkMode && EnvMan.IsDaylight() && !((Character)Player.m_localPlayer).InInterior())
{
Color white = Color.white;
AdjustAmbiance(white);
_isDarkMode = false;
}
if ((!_isDarkMode && !EnvMan.IsDaylight()) || ((Character)Player.m_localPlayer).InInterior())
{
Color32 val = default(Color32);
((Color32)(ref val))..ctor((byte)0, (byte)127, byte.MaxValue, byte.MaxValue);
AdjustAmbiance(Color32.op_Implicit(val));
_isDarkMode = true;
}
void AdjustAmbiance(Color targetColor)
{
//IL_001c: 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)
Logging<Plugin>.Info((object)"Adjusting ambiance", 0);
float transitionDuration = EnvMan.instance.m_transitionDuration;
((Graphic)_ringImage).CrossFadeColor(targetColor, transitionDuration, false, false);
((Graphic)_lookingImage).CrossFadeColor(targetColor, transitionDuration, false, false);
}
}
private void UpdateWindVisibility(bool isShipCaptain)
{
((Behaviour)_windIcon).enabled = (_viewMode != 0 && !InDungeon && !_isMalfunction) || isShipCaptain;
((Component)_windRing).gameObject.SetActive(isShipCaptain);
_ring.gameObject.SetActive(!isShipCaptain);
}
private void UpdateStatusEffectsPosition()
{
//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_0045: 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_0064: Unknown result type (might be due to invalid IL or missing references)
if (Configs.RepositionStatusEffects.Value)
{
float num = 84f * UI.ScaleFactor;
float num2 = 70f * UI.ScaleFactor;
Transform val = _root.transform;
RectTransform statusEffectListRoot = Hud.instance.m_statusEffectListRoot;
Vector3 position = ((Transform)statusEffectListRoot).position;
position.x = val.position.x - val.localScale.x * num - num2;
((Transform)statusEffectListRoot).position = position;
}
}
private void UpdateShipIndicator(bool isShipCaptain)
{
((Behaviour)_shipIndicatorOver).enabled = isShipCaptain && _viewMode == CompassConstants.ViewMode.None;
((Behaviour)_shipIndicatorUnder).enabled = isShipCaptain && !((Behaviour)_shipIndicatorOver).enabled;
Hud.instance.m_shipControlsRoot.SetActive(isShipCaptain);
}
private void UpdateRadar()
{
//IL_0052: 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_0058: 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_006c: 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_0077: Unknown result type (might be due to invalid IL or missing references)
//IL_007c: Unknown result type (might be due to invalid IL or missing references)
//IL_0081: Unknown result type (might be due to invalid IL or missing references)
RectTransform pinRootSmall = Minimap.instance.m_pinRootSmall;
bool flag = Configs.RadarRangePercent.Value > 0 && !_isMalfunction && !InDungeon;
_radarPinCount = 0;
((Component)pinRootSmall).gameObject.SetActive(flag);
if (!flag)
{
return;
}
foreach (Transform item in (Transform)pinRootSmall)
{
item.localScale = Vector3.one * 1f;
item.rotation = Quaternion.identity;
Vector2 val2 = Vector2.op_Implicit(item.localPosition);
if (((Vector2)(ref val2)).magnitude < 84f)
{
_radarPinCount++;
}
}
}
private static void UpdateConfigScale()
{
//IL_000f: 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_0037: 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_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_006e: Unknown result type (might be due to invalid IL or missing references)
Minimap.instance.m_smallRoot.transform.localScale = Vector3.one * Configs.DisplayScale.Value;
Hud.instance.m_shipHudRoot.transform.localScale = Vector3.one * Configs.DisplayScale.Value;
Hud.instance.m_shipControlsRoot.transform.localScale = Vector3.one / Configs.DisplayScale.Value;
}
private void UpdateViewScale()
{
switch (_viewMode)
{
case CompassConstants.ViewMode.None:
SetVisible(isVisible: false);
ShrinkCompass(1f);
break;
case CompassConstants.ViewMode.Small:
SetVisible(isVisible: true);
ShrinkCompass(1f);
break;
case CompassConstants.ViewMode.Large:
SetVisible(isVisible: true);
ExpandCompass(2f);
break;
default:
throw new ArgumentOutOfRangeException("_viewMode", _viewMode, "ViewMode Unknown");
}
}
private void ShrinkCompass(float scale)
{
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_003c: Unknown result type (might be due to invalid IL or missing references)
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
//IL_0046: Unknown result type (might be due to invalid IL or missing references)
//IL_004b: Unknown result type (might be due to invalid IL or missing references)
//IL_0060: Unknown result type (might be due to invalid IL or missing references)
//IL_0062: 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_0084: Unknown result type (might be due to invalid IL or missing references)
Vector3 localScale = _root.transform.localScale;
_isRadarShrunk = localScale.x <= scale + 0.005f;
if (!_isRadarShrunk)
{
SmallMap.localPosition = SmallMap.localPosition.SmoothMove(Vector2.op_Implicit(CompassConstants.PositionShrink));
_root.transform.localScale = localScale.SmoothScale(scale);
Transform obj = ((Component)_windIcon).transform;
obj.localScale = obj.localScale.SmoothScale(scale - 0.3f);
}
}
private void ExpandCompass(float scale)
{
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_003c: Unknown result type (might be due to invalid IL or missing references)
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
//IL_0046: Unknown result type (might be due to invalid IL or missing references)
//IL_004b: Unknown result type (might be due to invalid IL or missing references)
//IL_0060: Unknown result type (might be due to invalid IL or missing references)
//IL_0062: 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_0084: Unknown result type (might be due to invalid IL or missing references)
Vector3 localScale = _root.transform.localScale;
_isRadarExpanded = localScale.x >= scale - 0.005f;
if (!_isRadarExpanded)
{
SmallMap.localPosition = SmallMap.localPosition.SmoothMove(Vector2.op_Implicit(CompassConstants.PositionInit));
_root.transform.localScale = localScale.SmoothScale(scale);
Transform obj = ((Component)_windIcon).transform;
obj.localScale = obj.localScale.SmoothScale(1f / scale);
}
}
private void SetVisible(bool isVisible)
{
Minimap.instance.m_smallRoot.SetActive(isVisible);
if (!isVisible)
{
return;
}
if (Configs.CraftToUse.Value)
{
bool flag = _inventoryItem.IsEquipped();
bool flag2 = _inventoryItem.IsCompass();
if (Configs.EquipToUse.Value)
{
AdjustParts(flag2 && flag);
}
else
{
AdjustParts(flag2);
}
}
else
{
AdjustParts(Configs.ShowNorthArrow.Value);
}
void AdjustParts(bool isCompass)
{
//IL_0051: 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_004a: Unknown result type (might be due to invalid IL or missing references)
bool active = (isCompass ? Configs.ShowHeadingCompass.Value : Configs.ShowHeadingSunstone.Value);
_heading.SetActive(active);
_needle.SetActive(isCompass);
_heading.transform.localScale = (isCompass ? Vector3.one : (Vector3.one * 1.3f));
}
}
private static GameObject LoadCompassImage(string resourceName, GameObject parent)
{
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_003e: Expected O, but got Unknown
GameObject val = new GameObject(resourceName.Replace(".png", ""));
val.transform.SetParent(parent.transform, false);
val.AddComponent<Image>().sprite = AssetIO.LoadSpriteFromResource((BaseUnityPlugin)(object)ZenMod<Plugin>.Instance, resourceName);
return val;
}
}
internal static class CompassConstants
{
internal enum ViewMode
{
None,
Small,
Large
}
internal enum Orientation
{
Fixed,
Rotating
}
internal const float AnimTime = 0.05f;
internal const float AnimErrMargin = 0.005f;
internal const float ShrinkScale = 1f;
internal const float ShrinkDelayWhenEmpty = 5f;
internal static readonly Vector2 PositionInit = Vector2.one * -138.59999f;
internal static readonly Vector2 PositionShrink = PositionInit * 0.39999998f;
private const float Margin = 15f;
internal const float StatusEffectHudOffset = 70f;
internal const float RenderScale = 1.4f;
internal const float CompassScale = 2f;
internal const float PinScale = 1f;
internal const float RadarRange = 0.005f;
internal const float ScanRadius = 84f;
}
internal static class CompassItem
{
public const string PrefabCompass = "ZenCompass";
public const string PrefabSunstone = "ZenSunstone";
private static readonly string[] PrefabNames = new string[2] { "ZenCompass", "ZenSunstone" };
private const string ItemAttachName = "compass";
public static bool IsEquipped(this ItemData? item)
{
return item?.m_equipped ?? false;
}
public static bool IsCompass(this ItemData? item)
{
return ((item != null) ? ItemDataExt.GetPrefabName(item) : null) == "ZenCompass";
}
public static bool IsSunstone(this ItemData? item)
{
return ((item != null) ? ItemDataExt.GetPrefabName(item) : null) == "ZenSunstone";
}
public static bool IsNavItem(this ItemData? item)
{
if (item != null)
{
return PrefabNames.Contains(ItemDataExt.GetPrefabName(item));
}
return false;
}
internal static Action AddCraftingItems()
{
//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
Sprite val = AssetIO.LoadSpriteFromResource((BaseUnityPlugin)(object)ZenMod<Plugin>.Instance, "compass_icon2.png");
Sprite icon = ItemDataExt.GetIcon(PrefabManager.Instance.GetPrefab("FlametalOre").GetComponent<ItemDrop>());
CustomItem craftingItem;
CustomItem craftingItem2;
List<Action> configSync = new List<Action>
{
AddCraftingItem("ZenCompass", "ShieldFlametal", val, "$item_compass", "$item_compass_description", 0.3f, Configs.CraftingStationCompass, Configs.CraftingStationLevelCompass, Configs.CraftingMaterialsCompass, Configs.CraftingEnabledCompass, out craftingItem),
AddCraftingItem("ZenSunstone", "FlametalOre", icon, "$item_sunstone", "$item_sunstone_description", 0.3f, Configs.CraftingStationSunstone, Configs.CraftingStationLevelSunstone, Configs.CraftingMaterialsSunstone, Configs.CraftingEnabledSunstone, out craftingItem2)
};
CustomItemExt.ApplyTextureToPrefab(craftingItem, val.texture, 0.25f, Vector2.one * 2f, new Vector2(0.1f, -0.85f), "compass", true, (Color?)null);
InitPrefabItem(craftingItem2, 0.25f);
return delegate
{
CollectionExtensions.Do<Action>((IEnumerable<Action>)configSync, (Action<Action>)delegate(Action sync)
{
sync();
});
};
}
private static void InitPrefabItem(CustomItem item, float scale3D)
{
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
((Object)item.ItemPrefab.transform.GetChild(0)).name = "compass";
Transform transform = ((Component)item.ItemPrefab.GetComponentInChildren<MeshRenderer>()).transform;
transform.localScale *= scale3D;
SharedData shared = item.ItemDrop.m_itemData.m_shared;
shared.m_movementModifier = 0f;
shared.m_useDurability = false;
shared.m_canBeReparied = false;
shared.m_maxQuality = 1;
shared.m_value = 0;
}
private static Action AddCraftingItem(string prefabName, string basePrefabName, Sprite? icon, string label, string description, float weight, ConfigEntry<string> station, ConfigEntry<int> stationLevel, ConfigEntry<StringList> materials, ConfigEntry<bool> isEnabled, out CustomItem craftingItem)
{
//IL_0063: Unknown result type (might be due to invalid IL or missing references)
//IL_0069: Expected O, but got Unknown
//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
//IL_00e3: Expected O, but got Unknown
ConfigEntry<bool> isEnabled2 = isEnabled;
string prefabName2 = prefabName;
string basePrefabName2 = basePrefabName;
ConfigEntry<string> station2 = station;
ConfigEntry<int> stationLevel2 = stationLevel;
ConfigEntry<StringList> materials2 = materials;
Logging<Plugin>.Info((object)("Add crafting item: " + prefabName2 + ", based on " + basePrefabName2), 0);
string text = prefabName2;
string text2 = basePrefabName2;
ItemConfig val = new ItemConfig();
val.Name = label;
val.Description = description;
val.CraftingStation = station2.Value;
val.MinStationLevel = stationLevel2.Value;
val.Requirements = materials2.Value.ToRequirementConfigs(':');
val.Icons = (Sprite[])(object)((!Object.op_Implicit((Object)(object)icon)) ? null : new Sprite[1] { icon });
val.StackSize = 1;
val.Weight = weight;
craftingItem = new CustomItem(text, text2, val);
SharedData shared = craftingItem.ItemDrop.m_itemData.m_shared;
SetPrefabItemType(shared);
ItemManager.Instance.AddItem(craftingItem);
shared.m_variants = 0;
shared.m_teleportable = true;
CustomRecipe customRecipe = craftingItem.Recipe;
return ConfigSync;
void ConfigSync()
{
SetPrefabItemType(shared);
if (Configs.CraftToUse.Value && isEnabled2.Value)
{
Logging<Plugin>.Info((object)("Update recipe: " + prefabName2 + ", based on " + basePrefabName2), 0);
Recipe recipe = customRecipe.Recipe;
recipe.m_craftingStation = PrefabManagerExt.GetCraftingStation(PrefabManager.Instance, station2.Value);
recipe.m_minStationLevel = stationLevel2.Value;
recipe.m_resources = materials2.Value.ToRequirements(':');
}
else
{
Logging<Plugin>.Info((object)("Remove recipe: " + prefabName2), 0);
ItemManager.Instance.RemoveRecipe(customRecipe);
}
}
}
private static void SetPrefabItemType(SharedData shared)
{
//IL_003a: 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)
if (Configs.CraftToUse.Value && Configs.EquipToUse.Value)
{
shared.m_equipDuration = 1f;
shared.m_itemType = (ItemType)18;
}
else
{
shared.m_equipDuration = 0f;
shared.m_itemType = (ItemType)16;
}
}
public static ItemData? FindInInventory()
{
if (!Object.op_Implicit((Object)(object)Player.m_localPlayer))
{
return null;
}
IEnumerable<ItemData> enumerable = ((Humanoid)Player.m_localPlayer).GetInventory().GetAllItems().Where(IsNavItem);
ItemData val = null;
foreach (ItemData item in enumerable)
{
if (val == null || (item.IsCompass() && !val.m_equipped))
{
val = item;
}
if (item.m_equipped)
{
val = item;
}
}
return val;
}
}
internal static class Configs
{
internal enum DeathRule
{
Tombstone,
Keep,
Destroy
}
public static readonly ConfigEntry<float> DisplayScale;
public static readonly ConfigEntry<bool> ShrinkWhenEmpty;
public static readonly ConfigEntry<int> RadarRangePercent;
public static readonly ConfigEntry<bool> ShowNorthArrow;
public static readonly ConfigEntry<bool> ShowHeadingSunstone;
public static readonly ConfigEntry<bool> ShowHeadingCompass;
public static readonly ConfigEntry<bool> RotatingCompass;
public static readonly ConfigEntry<bool> TrackTimeDay;
public static readonly ConfigEntry<bool> AllowInDungeon;
public static readonly ConfigEntry<bool> CraftToUse;
public static readonly ConfigEntry<bool> EquipToUse;
public static readonly ConfigEntry<StringList> MalfunctionConditions;
public static readonly ConfigEntry<float> MalfunctionTransitionDelay;
public static readonly ConfigEntry<bool> CraftingEnabledCompass;
public static readonly ConfigEntry<string> CraftingStationCompass;
public static readonly ConfigEntry<int> CraftingStationLevelCompass;
public static readonly ConfigEntry<StringList> CraftingMaterialsCompass;
public static readonly ConfigEntry<bool> CraftingEnabledSunstone;
public static readonly ConfigEntry<string> CraftingStationSunstone;
public static readonly ConfigEntry<int> CraftingStationLevelSunstone;
public static readonly ConfigEntry<StringList> CraftingMaterialsSunstone;
public static readonly ConfigEntry<DeathRule> PlayerDeath;
public static readonly ConfigEntry<bool> AutoRemoveDeathPin;
public static readonly ConfigEntry<KeyCode> ForceRemoveDeathPinKey;
public static readonly ConfigEntry<bool> RepositionStatusEffects;
public static readonly ConfigEntry<bool> RepositionShipPowerIndicator;
static Configs()
{
//IL_0148: Unknown result type (might be due to invalid IL or missing references)
//IL_014d: Unknown result type (might be due to invalid IL or missing references)
//IL_0162: Expected O, but got Unknown
//IL_0162: Unknown result type (might be due to invalid IL or missing references)
//IL_017c: Expected O, but got Unknown
//IL_017c: Unknown result type (might be due to invalid IL or missing references)
//IL_01a0: Expected O, but got Unknown
//IL_01b5: Expected O, but got Unknown
//IL_02a3: Unknown result type (might be due to invalid IL or missing references)
//IL_02a8: Unknown result type (might be due to invalid IL or missing references)
//IL_02b3: Expected O, but got Unknown
//IL_02b3: Unknown result type (might be due to invalid IL or missing references)
//IL_02be: Expected O, but got Unknown
//IL_02be: Unknown result type (might be due to invalid IL or missing references)
//IL_02c9: Expected O, but got Unknown
//IL_02c9: Unknown result type (might be due to invalid IL or missing references)
//IL_02d4: Expected O, but got Unknown
//IL_02de: Expected O, but got Unknown
//IL_034f: Unknown result type (might be due to invalid IL or missing references)
//IL_0354: Unknown result type (might be due to invalid IL or missing references)
//IL_035f: Expected O, but got Unknown
//IL_035f: Unknown result type (might be due to invalid IL or missing references)
//IL_036a: Expected O, but got Unknown
//IL_036a: Unknown result type (might be due to invalid IL or missing references)
//IL_0375: Expected O, but got Unknown
//IL_037f: Expected O, but got Unknown
DisplayScale = Config.Define<float>(false, "General", "Display Scale", 1f, Config.AcceptRange<float>(0.5f, 2f), "Adjust the display scale of the compass. It has two display modes: Small and Large.\r\nIt will be small while there are no pins on the radar and large when there are pins.\r\nSet your scale preference with both scenarios in mind.\r\nAlso this compounds with the vanilla GUI scaling options found in the Settings.");
ShrinkWhenEmpty = Config.Define<bool>(false, "General", "Shrink When Empty", true, "Automatically shrink the compass when there are no pins nearby.");
ShowHeadingSunstone = Config.Define<bool>(true, "General", "Show Heading Sunstone", false, "Show the sunstone facing direction gear-arrow.");
ShowHeadingCompass = Config.Define<bool>(true, "General", "Show Heading Compass", true, "Show the compass facing direction gear-arrow.");
ShowNorthArrow = Config.Define<bool>(true, "General", "Show North Arrow", true, "When Craft To Use is disabled this will toggle display of the north arrow on the compass.");
RotatingCompass = Config.Define<bool>(true, "General", "Rotating Compass", false, "If true the compass rotates around the player axis such that up is always the direction you are looking.");
TrackTimeDay = Config.Define<bool>(true, "General", "Track Time of Day", true, "Track the time of day with an indicator of the sun on the outer ring of the compass.\r\nThe sun rises in the east and sets in the west. Noon is at the top of the compass; midnight the bottom.\r\nDisabling this will make the Sunstone very difficult to use.\r\nNote: This can be confusing to interpret when used with Rotating Compass enabled at the same time.");
RadarRangePercent = Config.Define<int>(true, "General", "Radar Range Percent", 100, Config.AcceptRange<int>(0, 300), "How far to scan for pins, as percentage. Set to 0 to disable the radar function.");
AllowInDungeon = Config.Define<bool>(true, "General", "Allow In Dungeon", false, "Does the sunstone/compass work inside dungeons? If false it will malfunction inside dungeons.");
string text = GeneralExtensions.Join<Biome>(Enum.GetValues(typeof(Biome)).Cast<Biome>().Except(new <>z__ReadOnlySingleElementList<Biome>((Biome)0)), (Func<Biome, string>)null, ", ");
StringList val = new StringList();
((List<string>)val).Add("All:" + Weather.MountainBlizzard);
((List<string>)val).Add($"{(object)(Biome)512}:All");
((List<string>)val).Add($"{(object)(Biome)256}:{Weather.ThunderStorm}|{Weather.ClearThunderStorm}");
MalfunctionConditions = Config.Define<StringList>(true, "General", "Malfunction Conditions", val, "List of Biome:Weather conditions that cause the compass to malfunction.\r\nLeave blank to disable the malfunction conditions.\r\nUse the keyword 'All' to apply to all biomes or weathers.\r\nOnly one biome per entry, but a given biome can have multiple weathers.\r\nUse | to separate multiple weathers, example:\r\nBiome:Weather1|Weather2|Weather3|...\r\nPossible biomes: [" + text + "]\r\nPossible weather: https://valheim.fandom.com/wiki/Environment#Weather");
MalfunctionTransitionDelay = Config.Define<float>(true, "General", "Malfunction Transition Delay", 15f, Config.AcceptRange<float>(0f, 60f), "How many seconds to wait before transitioning to/from malfunction state once a condition is met.\r\nSet to 0 to for instant change.\r\nWhen entering a biome or a weather condition it can be helpful to wait a few seconds before malfunctioning\r\nThat way the environment can fully transition before the compass gives out. \r\nAlso it helps when on a biome line so it doesn't keep switching between malfunction and normal states.");
CraftToUse = Config.Define<bool>(true, "Crafting", "Craft To Use", true, "The item must be in your inventory before it can be used.\nFalse to make the sunstone/compass always available; no crafting required.");
EquipToUse = Config.Define<bool>(true, "Crafting", "Equip To Use", true, "If true the sunstone/compass must also be equipped before it can be used.\nNOTE: " + ((ConfigEntryBase)CraftToUse).Definition.Key + " must be true for this to have any effect");
CraftingEnabledCompass = Config.Define<bool>(true, "Crafting", "Item Compass - Enabled", true, "Enable / disable crafting of the compass item.\r\n[restart required for changes to take effect]");
CraftingStationCompass = Config.Define<string>(true, "Crafting", "Item Compass - Station", "Workbench", CraftingStations.GetAcceptableValueList(), "The station required to craft the compass.\r\nNOTE: For a more challenging game you can change this to a level 1 ArtisanTable\r\nThereby requiring defeat of the Dragon before you can get a compass.\r\nThe idea is to pair this mod with ZenMap and experience the first portion of the game with no compass.\r\n[restart required for changes to take effect]");
CraftingStationLevelCompass = Config.Define<int>(true, "Crafting", "Item Compass - Station Level", 5, Config.AcceptRange<int>(1, 5), "The station level required to craft the compass.\r\nYou will need to treck into the mountains to get a small bit of obsidian to make a level 5 workbench.\r\nNote: The sunstone is available at an earlier stage of progression.\r\n[restart required for changes to take effect]");
StringList val2 = new StringList();
((List<string>)val2).Add("ZenSunstone:1");
((List<string>)val2).Add("FineWood:2");
((List<string>)val2).Add("BoneFragments:4");
((List<string>)val2).Add("IronNails:1");
CraftingMaterialsCompass = Config.Define<StringList>(true, "Crafting", "Item Compass - Materials", val2, "The materials required to craft the compass. \r\nThe default requires you to get to the swamp and get an iron nail before you can get a compass.\r\nFor an easier game: To get the compass as soon as you enter the Black Forest remove the IronNails requirement and set the workbench requirement to level 1.\r\nThe idea is to pair this mod with ZenMap and experience the first portion of the game with no compass.\r\n[restart required for changes to take effect]");
CraftingEnabledSunstone = Config.Define<bool>(true, "Crafting", "Item Sunstone - Enabled", true, "Enable / disable crafting of the sunstone item.\r\n[restart required for changes to take effect]");
CraftingStationSunstone = Config.Define<string>(true, "Crafting", "Item Sunstone - Station", "Forge", CraftingStations.GetAcceptableValueList(), "The station required to craft the sunstone.\r\n[restart required for changes to take effect]");
CraftingStationLevelSunstone = Config.Define<int>(true, "Crafting", "Item Sunstone - Station Level", 1, Config.AcceptRange<int>(1, 5), "The station level required to craft the sunstone.\r\n[restart required for changes to take effect]");
StringList val3 = new StringList();
((List<string>)val3).Add("Ruby:1");
((List<string>)val3).Add("Copper:3");
((List<string>)val3).Add("Feathers:2");
CraftingMaterialsSunstone = Config.Define<StringList>(true, "Crafting", "Item Sunstone - Materials", val3, "The materials required to craft the sunstone.\r\nThe sunstone is a basic navigation aid. It lets you track time of day and wind position. \r\nHowever, it does not give you full cardinal directions.\r\nYou will need this to upgrade to a full compass later.\r\nThe idea is to pair this mod with ZenMap and experience the first portion of the game with no compass.\r\n[restart required for changes to take effect]");
PlayerDeath = Config.Define<DeathRule>(true, "Crafting", "Player Death", DeathRule.Tombstone, "What happens to the crafted item when the player dies?");
AutoRemoveDeathPin = Config.Define<bool>(true, "Death Pins", "Auto Remove Death Pin", true, "Death pins will be automatically removed from the map & compass after looting the tombstone");
ForceRemoveDeathPinKey = Config.Define<KeyCode>(false, "Death Pins", "Key - Force Remove Death Pin", (KeyCode)127, "Normally you don't need this key. However, if you were away and someone looted your tombstone\r\nwhile your character was not there then it is possible that your Death Pin would persist even\r\nthough the tombstone was gone. In that scenario you can stand near your pin and press this key\r\nto manually cleanup your map & compass.\r\nNOTE: The ZenMap mod automatically tracks and removes death pins reliably 100% of the time\r\neven if you are far away or offline and someone else loots your tombstone it will still work.");
RepositionStatusEffects = Config.Define<bool>(true, "Compatibility", "Resposition Status Effects", true, "Reposition the Status Effect icons to make room for the compass.\r\nDisable this for compatibility with other mods which reposition the Status Effects.");
RepositionShipPowerIndicator = Config.Define<bool>(true, "Compatibility", "Reposition Ship Power Indicator", true, "Reposition ship power indicator HUD element (sails / rudder power)\r\nThis mod will by default position it just to the right of the wheel for easy viewing\r\nDisable this for compatibility with other mods which reposition the ship power HUD element");
}
}
[HarmonyPatch]
internal static class DeathPinPatch
{
[HarmonyPatch(typeof(Player), "OnDeath")]
private static class PlayerOnDeath
{
private static bool _isInvEmpty;
[UsedImplicitly]
private static void Prefix(Player __instance)
{
_isInvEmpty = ((Humanoid)__instance).GetInventory().NrOfItems() == 0;
}
[UsedImplicitly]
private static void Postfix(Player __instance)
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
if (_isInvEmpty)
{
RemoveDeathPinAt(((Component)__instance).transform.position);
}
}
}
private static void RemoveDeathPinAt(Vector3 worldPosition, float radius = 5f)
{
//IL_0025: 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_0048: Unknown result type (might be due to invalid IL or missing references)
//IL_004e: Invalid comparison between Unknown and I4
//IL_0060: Unknown result type (might be due to invalid IL or missing references)
if (!Configs.AutoRemoveDeathPin.Value)
{
return;
}
if (Plugin.IsZenMapLoaded)
{
Logging<Plugin>.Info((object)"ZenMap is handling death pin cleanup", 0);
return;
}
Logging<Plugin>.Info((object)$"Looking death pins on map at {worldPosition}", 0);
PinData closestPin = Minimap.instance.GetClosestPin(worldPosition, radius, false);
if (closestPin != null && (int)closestPin.m_type == 4)
{
Minimap.instance.RemovePin(closestPin);
Logging<Plugin>.Info((object)$"Pin found and removed at {worldPosition}", 0);
}
else
{
Logging<Plugin>.Info((object)"Pin not found.", 0);
}
}
internal static void CheckForceRemoveButtonPress()
{
//IL_0012: 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)
if (Object.op_Implicit((Object)(object)Player.m_localPlayer) && ZInput.GetKeyDown(Configs.ForceRemoveDeathPinKey.Value, true))
{
RemoveDeathPinAt(((Component)Player.m_localPlayer).transform.position);
}
}
[HarmonyPostfix]
[HarmonyPatch(typeof(TombStone), "GiveBoost")]
private static void TombStone_GiveBoost(TombStone __instance)
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
RemoveDeathPinAt(((Component)__instance).transform.position);
}
}
internal static class Extensions
{
internal static float Yaw(this Vector3 v)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
return Utils.YawFromDirection(v);
}
public static Vector3 SmoothScale(this Vector3 v, float scale)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_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)
return v.SmoothMove(Vector3.one * scale);
}
public static Vector3 SmoothMove(this Vector3 orig, Vector3 target)
{
//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_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_000f: Unknown result type (might be due to invalid IL or missing references)
Vector3 zero = Vector3.zero;
return Vector3.SmoothDamp(orig, target, ref zero, 0.05f);
}
}
[HarmonyPatch]
internal class Patches
{
[HarmonyPatch(typeof(Minimap), "SetMapMode")]
private static class Minimap_SetMapMode
{
[UsedImplicitly]
private static void Prefix(Minimap __instance, ref MapMode mode)
{
if (Game.m_noMap && (int)mode == 0)
{
mode = (MapMode)1;
}
}
[UsedImplicitly]
private static void Postfix(Minimap __instance, MapMode mode)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0009: Invalid comparison between Unknown and I4
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
if (Game.m_noMap && (int)mode == 1)
{
__instance.m_mode = (MapMode)0;
}
}
}
[HarmonyPatch(typeof(Minimap), "CenterMap")]
private static class Minimap_CenterMap
{
[UsedImplicitly]
private static void Prefix(Minimap __instance)
{
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
if (Game.m_noMap && (int)__instance.m_mode == 0)
{
__instance.m_mode = (MapMode)1;
}
}
[UsedImplicitly]
private static void Postfix(Minimap __instance)
{
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_000e: Invalid comparison between Unknown and I4
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
if (Game.m_noMap && (int)__instance.m_mode == 1)
{
__instance.m_mode = (MapMode)0;
}
}
}
[HarmonyPostfix]
[HarmonyPatch(typeof(Hud), "UpdateShipHud")]
[HarmonyPriority(100)]
private static void Hud_UpdateShipHud(Hud __instance)
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_003a: 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_007d: Unknown result type (might be due to invalid IL or missing references)
//IL_0082: Unknown result type (might be due to invalid IL or missing references)
//IL_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_009b: Unknown result type (might be due to invalid IL or missing references)
//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
//IL_0100: Unknown result type (might be due to invalid IL or missing references)
//IL_010a: Unknown result type (might be due to invalid IL or missing references)
//IL_0115: Unknown result type (might be due to invalid IL or missing references)
//IL_0125: 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_00b3: Invalid comparison between Unknown and I4
//IL_00be: Unknown result type (might be due to invalid IL or missing references)
bool activeSelf = __instance.m_shipHudRoot.activeSelf;
Compass compass = Plugin.Compass;
if (compass != null)
{
((Transform)__instance.m_shipWindIndicatorRoot).position = compass.transform.position;
((Transform)__instance.m_shipWindIndicatorRoot).localScale = compass.transform.localScale;
Transform parent = __instance.m_rudder.transform.parent;
((Component)parent).gameObject.SetActive(activeSelf);
if (Configs.RepositionShipPowerIndicator.Value)
{
Vector3 val = 74f * UI.ScaleFactor * Vector3.right;
Transform transform = ((Component)__instance.m_shipRudderIndicator).transform;
parent.position = transform.position + val;
}
if (activeSelf)
{
bool flag = (int)Minimap.instance.m_mode == 2;
((Transform)__instance.m_shipWindIndicatorRoot).eulerAngles = compass.Heading;
__instance.m_shipControlsRoot.SetActive(!flag);
((Component)parent).gameObject.SetActive(!flag);
}
else
{
((Transform)__instance.m_shipWindIndicatorRoot).eulerAngles = compass.North;
((Transform)__instance.m_shipWindIconRoot).localEulerAngles = Vector3.forward * (0f - EnvMan.instance.GetWindDir().Yaw());
((Graphic)__instance.m_shipWindIcon).color = Color.white;
__instance.m_shipHudRoot.gameObject.SetActive(true);
}
}
}
[HarmonyTranspiler]
[HarmonyPatch(typeof(Hud), "UpdateStamina")]
private static IEnumerable<CodeInstruction> Hud_UpdateStamina_Transpile(IEnumerable<CodeInstruction> instructions)
{
return IgnoreShipHudRoot(instructions);
}
[HarmonyTranspiler]
[HarmonyPatch(typeof(Hud), "UpdateEitr")]
private static IEnumerable<CodeInstruction> Hud_UpdateEitr_Transpile(IEnumerable<CodeInstruction> instructions)
{
return IgnoreShipHudRoot(instructions);
}
private static IEnumerable<CodeInstruction> IgnoreShipHudRoot(IEnumerable<CodeInstruction> instructions)
{
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_0032: Expected O, but got Unknown
//IL_0047: Unknown result type (might be due to invalid IL or missing references)
//IL_004d: Expected O, but got Unknown
//IL_005b: Unknown result type (might be due to invalid IL or missing references)
//IL_0061: Expected O, but got Unknown
//IL_006f: Unknown result type (might be due to invalid IL or missing references)
//IL_0075: Expected O, but got Unknown
//IL_0098: Unknown result type (might be due to invalid IL or missing references)
//IL_009e: Expected O, but got Unknown
//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
//IL_00ac: Expected O, but got Unknown
FieldInfo fieldInfo = AccessTools.Field(typeof(Hud), "m_shipHudRoot");
MethodInfo methodInfo = AccessTools.PropertyGetter(typeof(GameObject), "activeSelf");
CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null);
val.MatchEndForward((CodeMatch[])(object)new CodeMatch[3]
{
new CodeMatch((OpCode?)OpCodes.Ldarg_0, (object)null, (string)null),
new CodeMatch((OpCode?)OpCodes.Ldfld, (object)fieldInfo, (string)null),
new CodeMatch((OpCode?)OpCodes.Callvirt, (object)methodInfo, (string)null)
}).ThrowIfInvalid("Unable to find IL match").Advance(1)
.Insert((CodeInstruction[])(object)new CodeInstruction[2]
{
new CodeInstruction(OpCodes.Pop, (object)null),
new CodeInstruction(OpCodes.Ldc_I4_0, (object)null)
});
return val.InstructionEnumeration();
}
[HarmonyPostfix]
[HarmonyPatch(typeof(Inventory), "MoveInventoryToGrave")]
private static void RestoreFromGraveInventory(Inventory __instance, Inventory original)
{
if (((Humanoid)Player.m_localPlayer).m_inventory != original || Configs.PlayerDeath.Value == Configs.DeathRule.Tombstone)
{
return;
}
bool flag = false;
for (int num = __instance.m_inventory.Count; num > 0; num--)
{
ItemData item = __instance.GetItem(num - 1);
if (!item.IsNavItem())
{
flag = true;
switch (Configs.PlayerDeath.Value)
{
case Configs.DeathRule.Keep:
Logging<Plugin>.Info((object)"Player died, keeping compass", 0);
__instance.m_inventory.Remove(item);
original.m_inventory.Add(item);
break;
case Configs.DeathRule.Destroy:
Logging<Plugin>.Info((object)"Player died, compass destroyed", 0);
__instance.m_inventory.Remove(item);
break;
default:
throw new ArgumentOutOfRangeException("DeathRule", "Invalid death rule");
}
}
}
if (flag)
{
__instance.Changed();
original.Changed();
}
}
}
[BepInPlugin("ZenDragon.ZenCompass", "ZenCompass", "1.4.7")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[SynchronizationMode(/*Could not decode attribute arguments.*/)]
[NetworkCompatibility(/*Could not decode attribute arguments.*/)]
internal class Plugin : ZenMod<Plugin>
{
public const string PluginName = "ZenCompass";
public const string PluginVersion = "1.4.7";
public const string PluginID = "ZenDragon.ZenCompass";
private const string ZenMapPluginID = "ZenDragon.ZenMap";
internal static Compass? Compass;
internal static bool IsZenMapLoaded => Chainloader.PluginInfos.ContainsKey("ZenDragon.ZenMap");
protected override void Setup()
{
if (IsZenMapLoaded)
{
Logging<Plugin>.Info((object)"ZenDragon.ZenMap is loaded", 0);
}
base.RegisterCraftingItems += CompassItem.AddCraftingItems;
}
protected override void TitleScene(bool isFirstBoot)
{
Compass = null;
}
protected override void WorldStart()
{
Compass = new Compass();
}
protected override void Shutdown()
{
Compass?.Destroy();
}
private void LateUpdate()
{
if (Compass != null)
{
Compass.Update();
DeathPinPatch.CheckForceRemoveButtonPress();
}
}
}
}
[CompilerGenerated]
internal sealed class <>z__ReadOnlySingleElementList<T> : IEnumerable, ICollection, IList, IEnumerable<T>, IReadOnlyCollection<T>, IReadOnlyList<T>, ICollection<T>, IList<T>
{
private sealed class Enumerator : IDisposable, IEnumerator, IEnumerator<T>
{
object IEnumerator.Current => _item;
T IEnumerator<T>.Current => _item;
public Enumerator(T item)
{
_item = item;
}
bool IEnumerator.MoveNext()
{
if (!_moveNextCalled)
{
return _moveNextCalled = true;
}
return false;
}
void IEnumerator.Reset()
{
_moveNextCalled = false;
}
void IDisposable.Dispose()
{
}
}
int ICollection.Count => 1;
bool ICollection.IsSynchronized => false;
object ICollection.SyncRoot => this;
object IList.this[int index]
{
get
{
if (index != 0)
{
throw new IndexOutOfRangeException();
}
return _item;
}
set
{
throw new NotSupportedException();
}
}
bool IList.IsFixedSize => true;
bool IList.IsReadOnly => true;
int IReadOnlyCollection<T>.Count => 1;
T IReadOnlyList<T>.this[int index]
{
get
{
if (index != 0)
{
throw new IndexOutOfRangeException();
}
return _item;
}
}
int ICollection<T>.Count => 1;
bool ICollection<T>.IsReadOnly => true;
T IList<T>.this[int index]
{
get
{
if (index != 0)
{
throw new IndexOutOfRangeException();
}
return _item;
}
set
{
throw new NotSupportedException();
}
}
public <>z__ReadOnlySingleElementList(T item)
{
_item = item;
}
IEnumerator IEnumerable.GetEnumerator()
{
return new Enumerator(_item);
}
void ICollection.CopyTo(Array array, int index)
{
array.SetValue(_item, index);
}
int IList.Add(object value)
{
throw new NotSupportedException();
}
void IList.Clear()
{
throw new NotSupportedException();
}
bool IList.Contains(object value)
{
return EqualityComparer<T>.Default.Equals(_item, (T)value);
}
int IList.IndexOf(object value)
{
if (!EqualityComparer<T>.Default.Equals(_item, (T)value))
{
return -1;
}
return 0;
}
void IList.Insert(int index, object value)
{
throw new NotSupportedException();
}
void IList.Remove(object value)
{
throw new NotSupportedException();
}
void IList.RemoveAt(int index)
{
throw new NotSupportedException();
}
IEnumerator<T> IEnumerable<T>.GetEnumerator()
{
return new Enumerator(_item);
}
void ICollection<T>.Add(T item)
{
throw new NotSupportedException();
}
void ICollection<T>.Clear()
{
throw new NotSupportedException();
}
bool ICollection<T>.Contains(T item)
{
return EqualityComparer<T>.Default.Equals(_item, item);
}
void ICollection<T>.CopyTo(T[] array, int arrayIndex)
{
array[arrayIndex] = _item;
}
bool ICollection<T>.Remove(T item)
{
throw new NotSupportedException();
}
int IList<T>.IndexOf(T item)
{
if (!EqualityComparer<T>.Default.Equals(_item, item))
{
return -1;
}
return 0;
}
void IList<T>.Insert(int index, T item)
{
throw new NotSupportedException();
}
void IList<T>.RemoveAt(int index)
{
throw new NotSupportedException();
}
}