using System;
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.Config;
using Zen.Lib;
using Zen.Logging;
[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+3c8635d66e9e9579910a8e51d074a2c52aca4c60")]
[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 = CompassConstants.ViewMode.Small;
private CompassConstants.Orientation _orientation = CompassConstants.Orientation.Rotating;
private readonly GameObject _root;
private readonly GameObject _ring;
private readonly GameObject _needle;
private readonly GameObject _heading;
private readonly GameObject _looking;
private readonly GameObject _glass;
private readonly GameObject _mask;
private readonly GameObject _ship;
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 _isNightMode;
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();
internal Compass()
{
//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
//IL_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_010a: Unknown result type (might be due to invalid IL or missing references)
//IL_0114: Expected O, but got Unknown
//IL_0145: Unknown result type (might be due to invalid IL or missing references)
//IL_014f: Unknown result type (might be due to invalid IL or missing references)
//IL_0189: Unknown result type (might be due to invalid IL or missing references)
//IL_0193: Unknown result type (might be due to invalid IL or missing references)
//IL_02fb: Unknown result type (might be due to invalid IL or missing references)
//IL_0305: 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_heading.png", _root);
_needle = LoadCompassImage("compass_needle.png", _root);
_heading = LoadCompassImage("compass_arrow.png", _root);
_glass = LoadCompassImage("compass_glass.png", _root);
_mask = LoadCompassImage("compass_mask.png", _root);
_ring = LoadCompassImage(Configs.TrackTimeDay.Value ? "compass_ring_time.png" : "compass_ring.png", _root);
_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)
Log.Info((object)"Unloading", (ushort)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))
{
_orientation = (Configs.RotatingCompass.Value ? CompassConstants.Orientation.Rotating : CompassConstants.Orientation.Fixed);
if (Minimap.IsOpen())
{
_orientation = CompassConstants.Orientation.Fixed;
}
bool isShipControlled = Object.op_Implicit((Object)(object)Player.m_localPlayer.GetControlledShip());
MalfunctionCheck();
UpdateRadar();
CheckCompassViewMode(isShipControlled);
UpdateCompassScale(isShipControlled);
UpdateStatusEffectsPosition();
UpdateRotation(isShipControlled);
UpdateShipIndicator(isShipControlled);
UpdateWindIndicator(isShipControlled);
UpdateTimeOfDay();
}
}
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;
Log.Debug((object)$"Malfunction? {malfunction} Biome: {currentBiome} Env: {currentEnv.m_name} InBiome: {flag2} InEnv: {flag3}", (ushort)0);
if (malfunction != _isMalfunction && _malfunctionDelayCoroutine == null)
{
_malfunctionDelayCoroutine = Timing.Delay(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)
{
Log.Error((object)("Malformed config for malfunction condition: " + text + "=" + text2 + " " + ex.Message), (ushort)0);
}
}
}
private void CheckCompassViewMode(bool isShipControlled)
{
if (((Character)Player.m_localPlayer).IsDead())
{
_viewMode = CompassConstants.ViewMode.None;
return;
}
if (Configs.CraftToUse.Value)
{
if (!CompassItem.HaveInInventory(out var isEquipped))
{
_viewMode = CompassConstants.ViewMode.None;
return;
}
if (Configs.EquipToUse.Value && !isEquipped)
{
_viewMode = CompassConstants.ViewMode.None;
return;
}
}
if (InDungeon)
{
_viewMode = (Configs.AllowInDungeon.Value ? CompassConstants.ViewMode.Small : CompassConstants.ViewMode.None);
return;
}
if (Minimap.IsOpen())
{
_viewMode = CompassConstants.ViewMode.Small;
return;
}
int num = ((isShipControlled && Plugin.IsZenMapLoaded) ? 1 : 0);
if (_radarPinCount <= num)
{
if (_isRadarEmptyForDuration)
{
if (Time.time - _radarEmptyTimestamp > 5f)
{
_viewMode = CompassConstants.ViewMode.Small;
}
}
else
{
_isRadarEmptyForDuration = true;
_radarEmptyTimestamp = Time.time;
}
}
else
{
_isRadarEmptyForDuration = false;
_viewMode = CompassConstants.ViewMode.Large;
}
}
private void UpdateRotation(bool isShipControlled)
{
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
//IL_0040: Unknown result type (might be due to invalid IL or missing references)
//IL_0043: Unknown result type (might be due to invalid IL or missing references)
//IL_0048: Unknown result type (might be due to invalid IL or missing references)
//IL_0053: 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_005b: Unknown result type (might be due to invalid IL or missing references)
//IL_0060: Unknown result type (might be due to invalid IL or missing references)
//IL_0078: Unknown result type (might be due to invalid IL or missing references)
//IL_0083: Unknown result type (might be due to invalid IL or missing references)
//IL_0088: Unknown result type (might be due to invalid IL or missing references)
//IL_008f: 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_00a6: Unknown result type (might be due to invalid IL or missing references)
//IL_0113: Unknown result type (might be due to invalid IL or missing references)
//IL_00b3: 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_00be: Unknown result type (might be due to invalid IL or missing references)
//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
//IL_00d4: 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_00df: Unknown result type (might be due to invalid IL or missing references)
//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
//IL_0138: Unknown result type (might be due to invalid IL or missing references)
//IL_015e: Unknown result type (might be due to invalid IL or missing references)
//IL_0131: Unknown result type (might be due to invalid IL or missing references)
//IL_0183: Unknown result type (might be due to invalid IL or missing references)
//IL_0198: Unknown result type (might be due to invalid IL or missing references)
//IL_017c: Unknown result type (might be due to invalid IL or missing references)
//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
//IL_01c4: Unknown result type (might be due to invalid IL or missing references)
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 (isShipControlled ? 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_0017: 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)
//IL_004b: Unknown result type (might be due to invalid IL or missing references)
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
//IL_0052: Unknown result type (might be due to invalid IL or missing references)
//IL_0083: Unknown result type (might be due to invalid IL or missing references)
//IL_0084: Unknown result type (might be due to invalid IL or missing references)
if (Configs.TrackTimeDay.Value)
{
_ring.transform.eulerAngles = Vector3.forward * ((EnvMan.instance.GetDayFraction() - 0.25f) * 360f);
}
if (_isNightMode && EnvMan.IsDay())
{
Color white = Color.white;
AdjustAmbiance(white);
_isNightMode = false;
}
if (!_isNightMode && EnvMan.IsNight())
{
Color32 val = default(Color32);
((Color32)(ref val))..ctor((byte)0, (byte)127, byte.MaxValue, byte.MaxValue);
AdjustAmbiance(Color32.op_Implicit(val));
_isNightMode = true;
}
void AdjustAmbiance(Color targetColor)
{
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
Log.Info((object)"Adjusting ambiance", (ushort)0);
float transitionDuration = EnvMan.instance.m_transitionDuration;
((Graphic)_ring.GetComponent<Image>()).CrossFadeColor(targetColor, transitionDuration, false, false);
((Graphic)_looking.GetComponent<Image>()).CrossFadeColor(targetColor, transitionDuration, false, false);
}
}
private void UpdateWindIndicator(bool isShipControlled)
{
((Behaviour)_windIcon).enabled = (_viewMode != 0 && !InDungeon && !_isMalfunction) || isShipControlled;
((Component)_windRing).gameObject.SetActive(isShipControlled);
_ring.gameObject.SetActive(!isShipControlled);
}
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 isShipControlled)
{
((Behaviour)_shipIndicatorOver).enabled = isShipControlled && _viewMode == CompassConstants.ViewMode.None;
((Behaviour)_shipIndicatorUnder).enabled = isShipControlled && !((Behaviour)_shipIndicatorOver).enabled;
Hud.instance.m_shipControlsRoot.SetActive(isShipControlled);
}
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 void UpdateCompassScale(bool isShipControlled)
{
switch (_viewMode)
{
case CompassConstants.ViewMode.None:
SetVisible(state: false);
ShrinkCompass(1f);
break;
case CompassConstants.ViewMode.Small:
SetVisible(state: true);
ShrinkCompass(1f);
break;
case CompassConstants.ViewMode.Large:
SetVisible(state: 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 static void SetVisible(bool state)
{
Minimap.instance.m_smallRoot.SetActive(state);
}
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_003a: Expected O, but got Unknown
GameObject val = new GameObject(resourceName.Replace(".png", ""));
val.transform.SetParent(parent.transform, false);
val.AddComponent<Image>().sprite = AssetIO.LoadSprite(resourceName, (Assembly)null);
return val;
}
}
public 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;
}
public static class CompassItem
{
public const string PrefabName = "ZenCompass";
private const string DisplayName = "Compass";
private const string Description = "Useful for finding your way in the wild.";
private static readonly Sprite Icon = AssetIO.LoadSprite("compass_icon.png", (Assembly)null);
internal static Action AddCraftingItem()
{
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: Expected O, but got Unknown
//IL_0096: Unknown result type (might be due to invalid IL or missing references)
//IL_00a0: Expected O, but got Unknown
//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
//IL_00e7: 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_0121: Unknown result type (might be due to invalid IL or missing references)
//IL_012c: Unknown result type (might be due to invalid IL or missing references)
Log.Info((object)"Add crafting item: ZenCompass", (ushort)0);
ItemConfig val = new ItemConfig();
val.Name = "Compass";
val.Description = "Useful for finding your way in the wild.";
val.CraftingStation = Configs.CraftingStation.Value;
val.MinStationLevel = Configs.CraftingStationLevel.Value;
val.Requirements = Configs.CraftingMaterials.Value.ToRequirementConfigs(':');
val.Icons = (Sprite[])(object)new Sprite[1] { Icon };
val.StackSize = 1;
val.Weight = 0.1f;
CustomItem compassItem = new CustomItem("ZenCompass", "ShieldFlametal", val);
((Object)compassItem.ItemPrefab.transform.GetChild(0)).name = "compass";
MeshRenderer componentInChildren = compassItem.ItemPrefab.GetComponentInChildren<MeshRenderer>();
Material material = ((Renderer)componentInChildren).material;
Transform transform = ((Component)componentInChildren).transform;
transform.localScale *= 0.25f;
material.mainTexture = (Texture)(object)Icon.texture;
material.mainTextureScale = new Vector2(2f, 2f);
material.mainTextureOffset = new Vector2(0.1f, 0.1f);
material.color = Color.white;
SharedData shared = compassItem.ItemDrop.m_itemData.m_shared;
shared.m_movementModifier = 0f;
shared.m_useDurability = false;
shared.m_canBeReparied = false;
shared.m_maxQuality = 1;
SetItemType();
ItemManager.Instance.AddItem(compassItem);
shared.m_variants = 0;
return ConfigSync;
void ConfigSync()
{
SetItemType();
if (Configs.CraftToUse.Value)
{
Log.Info((object)"Update recipe: ZenCompass", (ushort)0);
Recipe recipe = compassItem.Recipe.Recipe;
recipe.m_craftingStation = PrefabManagerExt.GetCraftingStation(PrefabManager.Instance, Configs.CraftingStation.Value);
recipe.m_minStationLevel = Configs.CraftingStationLevel.Value;
recipe.m_resources = Configs.CraftingMaterials.Value.ToRequirements(':');
}
else
{
Log.Info((object)"Remove recipe: ZenCompass", (ushort)0);
ItemManager.Instance.RemoveRecipe(compassItem.Recipe);
}
}
void SetItemType()
{
//IL_004e: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
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;
}
}
}
private static ItemData? GetFromInventory()
{
Player localPlayer = Player.m_localPlayer;
if (!Object.op_Implicit((Object)(object)localPlayer))
{
return null;
}
return ((IEnumerable<ItemData>)((Humanoid)localPlayer).GetInventory().GetAllItems()).FirstOrDefault((Func<ItemData, bool>)((ItemData item) => ItemDataExt.GetPrefabName(item) == "ZenCompass"));
}
public static bool HaveInInventory(out bool isEquipped)
{
ItemData fromInventory = GetFromInventory();
isEquipped = fromInventory?.m_equipped ?? false;
return fromInventory != null;
}
}
internal static class Configs
{
internal enum DeathRule
{
Tombstone,
Keep,
Destroy
}
public static readonly ConfigEntry<int> RadarRangePercent;
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<StringList> CraftingMaterials;
public static readonly ConfigEntry<string> CraftingStation;
public static readonly ConfigEntry<int> CraftingStationLevel;
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_00a3: 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_00b3: Expected O, but got Unknown
//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
//IL_00be: Expected O, but got Unknown
//IL_00be: Unknown result type (might be due to invalid IL or missing references)
//IL_00c9: Expected O, but got Unknown
//IL_00de: Expected O, but got Unknown
//IL_016b: Unknown result type (might be due to invalid IL or missing references)
//IL_0170: Unknown result type (might be due to invalid IL or missing references)
//IL_017b: Expected O, but got Unknown
//IL_017b: Unknown result type (might be due to invalid IL or missing references)
//IL_0186: Expected O, but got Unknown
//IL_0186: Unknown result type (might be due to invalid IL or missing references)
//IL_0191: Expected O, but got Unknown
//IL_019b: Expected O, but got Unknown
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.\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, 200), "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 compass work inside dungeons? If false it will malfunction inside dungeons.");
string text = GeneralExtensions.Join<Biome>(Enum.GetValues(typeof(Biome)).Cast<Biome>(), (Func<Biome, string>)null, ", ");
StringList val = new StringList();
((List<string>)val).Add("All:SnowStorm");
((List<string>)val).Add("Mistlands:All");
((List<string>)val).Add("Ocean:ThunderStorm|nofogts");
MalfunctionConditions = Config.Define<StringList>(true, "General", "Malfunction Conditions", val, "List of Biome:Weather conditions that cause the compass to malfunction.\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 compass must be in your inventory before it can be used.\nFalse to make the compass always available; no crafting required.");
EquipToUse = Config.Define<bool>(true, "Crafting", "Equip To Use", true, "If true the compass must also be equipped before it can be used.\nNOTE: " + ((ConfigEntryBase)CraftToUse).Definition.Key + " must be true for this to have any effect");
StringList val2 = new StringList();
((List<string>)val2).Add("Feathers:1");
((List<string>)val2).Add("Flint:4");
((List<string>)val2).Add("BoneFragments:2");
CraftingMaterials = Config.Define<StringList>(true, "Crafting", "Materials", val2, "The materials required to craft the compass.");
CraftingStation = Config.Define<string>(true, "Crafting", "Station", "Workbench", CraftingStations.GetAcceptableValueList(), "The station required to craft the compass.");
CraftingStationLevel = Config.Define<int>(true, "Crafting", "Station Level", 1, Config.AcceptRange<int>(1, 5), "The station level required to craft the compass.");
PlayerDeath = Config.Define<DeathRule>(true, "Crafting", "Player Death", DeathRule.Tombstone, "What happens to the compass 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]
public 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)
{
Log.Info((object)"ZenMap is handling death pin cleanup", (ushort)0);
return;
}
Log.Info((object)$"Looking death pins on map at {worldPosition}", (ushort)0);
PinData closestPin = Minimap.instance.GetClosestPin(worldPosition, radius, false);
if (closestPin != null && (int)closestPin.m_type == 4)
{
Minimap.instance.RemovePin(closestPin);
Log.Info((object)$"Pin found and removed at {worldPosition}", (ushort)0);
}
else
{
Log.Info((object)"Pin not found.", (ushort)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_00dc: Unknown result type (might be due to invalid IL or missing references)
//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
//IL_00f6: 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_0111: 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_00c4: Unknown result type (might be due to invalid IL or missing references)
//IL_00ca: Invalid comparison between Unknown and I4
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)
{
((Transform)__instance.m_shipWindIndicatorRoot).eulerAngles = compass.Heading;
__instance.m_shipControlsRoot.SetActive((int)Minimap.instance.m_mode != 2);
return;
}
((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 (!(((Object)item.m_dropPrefab).name != "ZenCompass"))
{
flag = true;
switch (Configs.PlayerDeath.Value)
{
case Configs.DeathRule.Keep:
Log.Info((object)"Player died, keeping compass", (ushort)0);
__instance.m_inventory.Remove(item);
original.m_inventory.Add(item);
break;
case Configs.DeathRule.Destroy:
Log.Info((object)"Player died, compass destroyed", (ushort)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.1.5")]
[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.1.5";
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)
{
Log.Message((object)"ZenDragon.ZenMap is loaded", (ushort)0);
}
((ZenMod)this).RegisterCraftingItems += CompassItem.AddCraftingItem;
}
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();
}
}
}
}