using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using Photon.Realtime;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.8.1", FrameworkDisplayName = ".NET Framework 4.8.1")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace DangerWarning
{
internal static class CondorLineConfig
{
public static ConfigEntry<bool> Enabled;
public static ConfigEntry<bool> OnlyWhenDive;
public static ConfigEntry<float> MaxLength;
public static ConfigEntry<float> LineThickness;
public static ConfigEntry<float> Opacity;
public static ConfigEntry<Color> LineColor;
public static bool Active
{
get
{
if (GeneralConfig.IsEnabled && Enabled != null)
{
return Enabled.Value;
}
return false;
}
}
public static void BindAll(ConfigFile config)
{
//IL_005b: Unknown result type (might be due to invalid IL or missing references)
//IL_0065: Expected O, but got Unknown
//IL_008f: Unknown result type (might be due to invalid IL or missing references)
//IL_0099: Expected O, but got Unknown
//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
//IL_00cd: Expected O, but got Unknown
//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
Enabled = config.Bind<bool>("Condor", "Beam Enabled", false, "秃鹫俯冲指示光柱(备用功能,默认关闭):沿秃鹫朝向画一条光柱,指向它正俯冲的目标方向;秃鹫常从背后袭来,光柱不一定在视野内,建议改用文字预警");
OnlyWhenDive = config.Bind<bool>("Condor", "Beam Only When Dive", true, "仅在秃鹫俯冲时显示光柱;关闭后它盘旋、搬运时也会显示");
MaxLength = config.Bind<float>("Condor", "Beam Max Length", 120f, new ConfigDescription("光柱最大长度,单位米;光柱会一直画到地面或该长度为止", (AcceptableValueBase)(object)new AcceptableValueRange<float>(10f, 300f), (object[])null));
LineThickness = config.Bind<float>("Condor", "Beam Line Thickness", 0.3f, new ConfigDescription("光柱粗细,单位是游戏世界长度", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.05f, 2f), (object[])null));
Opacity = config.Bind<float>("Condor", "Beam Opacity", 0.8f, new ConfigDescription("光柱不透明度,0 为完全透明,1 为完全不透明", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), (object[])null));
LineColor = config.Bind<Color>("Condor", "Beam Line Color", new Color(1f, 0.55f, 0.1f, 1f), "光柱颜色,仅 RGB 生效,不透明度由 Opacity 控制");
}
}
internal static class CondorLineHost
{
private sealed class Beam : MonoBehaviour
{
private Condor _condor;
private LineRenderer _line;
public LineRenderer Line => _line;
public void Bind(Condor condor, LineRenderer line)
{
_condor = condor;
_line = line;
}
private void LateUpdate()
{
//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_0050: Unknown result type (might be due to invalid IL or missing references)
//IL_0056: Invalid comparison between Unknown and I4
//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
//IL_00de: Unknown result type (might be due to invalid IL or missing references)
//IL_00df: 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_00e6: 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)
//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
//IL_010d: Unknown result type (might be due to invalid IL or missing references)
//IL_011a: Unknown result type (might be due to invalid IL or missing references)
//IL_0100: Unknown result type (might be due to invalid IL or missing references)
//IL_0105: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)_line == (Object)null || (Object)(object)_condor == (Object)null)
{
return;
}
if (!CondorLineConfig.Active)
{
if (((Renderer)_line).enabled)
{
((Renderer)_line).enabled = false;
}
return;
}
if (CondorLineConfig.OnlyWhenDive.Value && (int)GetState(_condor) != 1)
{
if (((Renderer)_line).enabled)
{
((Renderer)_line).enabled = false;
}
return;
}
Vector3 forward = ((Component)_condor).transform.forward;
if (((Vector3)(ref forward)).sqrMagnitude < 0.0001f)
{
if (((Renderer)_line).enabled)
{
((Renderer)_line).enabled = false;
}
return;
}
((Vector3)(ref forward)).Normalize();
Vector3 val = ((Component)_condor).transform.position + forward * 1.5f;
float value = CondorLineConfig.MaxLength.Value;
Vector3 val2 = val + forward * value;
RaycastHit val3 = default(RaycastHit);
if (Physics.Raycast(val, forward, ref val3, value, _terrainMask, (QueryTriggerInteraction)1))
{
val2 = ((RaycastHit)(ref val3)).point;
}
_line.SetPosition(0, val);
_line.SetPosition(1, val2);
if (!((Renderer)_line).enabled)
{
((Renderer)_line).enabled = true;
}
}
private void OnDestroy()
{
Detach(_condor);
_condor = null;
_line = null;
}
}
private const string BeamObjectName = "DangerWarningCondorBeam";
private static readonly Dictionary<Condor, Beam> Beams = new Dictionary<Condor, Beam>();
private static ManualLogSource _log;
private static Material _lineMaterial;
private static bool _failed;
private static bool _errorLogged;
private static int _terrainMask = -1;
private static FieldRef<Condor, CondorState> _stateRef;
private static FieldInfo _stateField;
public static void Init(ManualLogSource log)
{
//IL_008a: Unknown result type (might be due to invalid IL or missing references)
_log = log;
_lineMaterial = CreateMaterial();
if ((Object)(object)_lineMaterial == (Object)null)
{
_failed = true;
log.LogError((object)"[DangerWarning] 找不到可用线条着色器,秃鹫光柱已禁用");
return;
}
try
{
_stateRef = AccessTools.FieldRefAccess<Condor, CondorState>("_state");
}
catch
{
_stateRef = null;
_stateField = AccessTools.Field(typeof(Condor), "_state");
}
if (_stateRef == null && _stateField == null)
{
_failed = true;
log.LogError((object)"[DangerWarning] 读取秃鹫状态失败,秃鹫光柱已禁用");
}
else
{
_terrainMask = LayerMask.op_Implicit(HelperExtensions.ToLayerMask((LayerType)1));
}
}
private static Material CreateMaterial()
{
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: 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_0047: 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: Expected O, but got Unknown
Shader val = Shader.Find("Sprites/Default") ?? Shader.Find("Unlit/Transparent Color") ?? Shader.Find("Unlit/Color");
if ((Object)(object)val == (Object)null)
{
return null;
}
return new Material(val)
{
hideFlags = (HideFlags)61,
mainTexture = null,
color = Color.white
};
}
private static CondorState GetState(Condor condor)
{
//IL_0013: 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_0058: Unknown result type (might be due to invalid IL or missing references)
if (_stateRef != null)
{
try
{
return _stateRef.Invoke(condor);
}
catch
{
_stateRef = null;
_stateField = AccessTools.Field(typeof(Condor), "_state");
}
}
if (_stateField != null)
{
return (CondorState)_stateField.GetValue(condor);
}
return (CondorState)0;
}
public static void SafeAttach(Condor condor)
{
if (_failed)
{
return;
}
try
{
Attach(condor);
}
catch (Exception ex)
{
if (!_errorLogged)
{
_errorLogged = true;
if (_log != null)
{
_log.LogError((object)("[DangerWarning] 创建秃鹫光柱失败:" + ex.Message));
}
}
}
}
private static void Attach(Condor condor)
{
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
//IL_0039: 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_0049: 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_0059: Unknown result type (might be due to invalid IL or missing references)
//IL_0063: Unknown result type (might be due to invalid IL or missing references)
//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)condor == (Object)null) && !Beams.ContainsKey(condor))
{
GameObject val = new GameObject("DangerWarningCondorBeam");
val.transform.SetParent(((Component)condor).transform, false);
val.transform.localPosition = Vector3.zero;
val.transform.localRotation = Quaternion.identity;
val.transform.localScale = Vector3.one;
LineRenderer val2 = val.AddComponent<LineRenderer>();
((Renderer)val2).sharedMaterial = _lineMaterial;
val2.useWorldSpace = true;
val2.loop = false;
val2.positionCount = 2;
val2.numCapVertices = 0;
val2.numCornerVertices = 0;
((Renderer)val2).sortingOrder = -1;
((Renderer)val2).receiveShadows = false;
((Renderer)val2).enabled = false;
Color endColor = (val2.startColor = CurrentColor());
val2.endColor = endColor;
float endWidth = (val2.startWidth = CondorLineConfig.LineThickness.Value);
val2.endWidth = endWidth;
Beam beam = val.AddComponent<Beam>();
beam.Bind(condor, val2);
Beams.Add(condor, beam);
}
}
private static void Detach(Condor condor)
{
if ((Object)(object)condor != (Object)null)
{
Beams.Remove(condor);
}
}
private static Color CurrentColor()
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
Color value = CondorLineConfig.LineColor.Value;
value.a = Mathf.Clamp01(CondorLineConfig.Opacity.Value);
return value;
}
public static void ApplyConfig()
{
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_0080: Unknown result type (might be due to invalid IL or missing references)
//IL_008d: Unknown result type (might be due to invalid IL or missing references)
if (_failed)
{
return;
}
float value = CondorLineConfig.LineThickness.Value;
Color val = CurrentColor();
foreach (KeyValuePair<Condor, Beam> beam in Beams)
{
Beam value2 = beam.Value;
if (!((Object)(object)value2 == (Object)null) && !((Object)(object)value2.Line == (Object)null))
{
if (value2.Line.startWidth != value)
{
value2.Line.startWidth = value;
value2.Line.endWidth = value;
}
value2.Line.startColor = val;
value2.Line.endColor = val;
}
}
}
}
[HarmonyPatch(typeof(Condor), "Start")]
internal static class CondorStartPatch
{
private static void Postfix(Condor __instance)
{
CondorLineHost.SafeAttach(__instance);
}
}
[HarmonyPatch(typeof(Condor), "Swoop")]
internal static class CondorSwoopPatch
{
private static void Postfix(Condor __instance, Character character)
{
CondorWarning.Notify(__instance, character);
}
}
internal static class CondorWarning
{
private static ManualLogSource _log;
private static bool _loggedError;
public static void Init(ManualLogSource log)
{
_log = log;
}
public static void Notify(Condor condor, Character victim)
{
try
{
NotifyCore(condor, victim);
}
catch (Exception ex)
{
if (!_loggedError && _log != null)
{
_loggedError = true;
_log.LogError((object)("[DangerWarning] 秃鹫预警异常:" + ex));
}
}
}
private static void NotifyCore(Condor condor, Character victim)
{
//IL_0051: 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)
if (!CondorWarningConfig.Active || (Object)(object)condor == (Object)null || (Object)(object)victim == (Object)null)
{
return;
}
bool isLocal = victim.IsLocal;
if (CondorWarningConfig.TargetMode.Value == CondorWarningConfig.Target.OnlyMe && !isLocal)
{
return;
}
if (!isLocal && CondorWarningConfig.Range.Value == CondorWarningConfig.Scope.Nearby)
{
Character localCharacter = Character.localCharacter;
if ((Object)(object)localCharacter == (Object)null || Vector3.Distance(localCharacter.Center, victim.Center) > CondorWarningConfig.NearbyDistance.Value)
{
return;
}
}
string target = ((!isLocal) ? Truncate(Sanitize(GetPlayerName(victim)), CondorWarningConfig.NameLength.Value) : "你");
CondorWarningState.Set(target, CondorWarningConfig.Duration.Value);
}
private static string GetPlayerName(Character character)
{
try
{
PhotonView photonView = ((MonoBehaviourPun)character).photonView;
Player val = (((Object)(object)photonView != (Object)null) ? photonView.Owner : null);
string text = ((val != null) ? val.NickName : null);
if (!string.IsNullOrEmpty(text))
{
return text;
}
}
catch
{
}
return "其他玩家";
}
private static string Sanitize(string value)
{
if (string.IsNullOrEmpty(value))
{
return value;
}
if (value.IndexOf('<') < 0 && value.IndexOf('>') < 0)
{
return value;
}
return value.Replace("<", string.Empty).Replace(">", string.Empty);
}
private static string Truncate(string value, int max)
{
if (string.IsNullOrEmpty(value) || max <= 0 || value.Length <= max)
{
return value;
}
int num = max;
if (char.IsHighSurrogate(value[num - 1]))
{
num--;
}
return value.Substring(0, num);
}
}
internal static class CondorWarningConfig
{
public enum Scope
{
Nearby,
WholeMap
}
public enum Target
{
OnlyMe,
AnyPlayer
}
public static ConfigEntry<bool> Enabled;
public static ConfigEntry<Scope> Range;
public static ConfigEntry<float> NearbyDistance;
public static ConfigEntry<Target> TargetMode;
public static ConfigEntry<float> Duration;
public static ConfigEntry<float> TextScale;
public static ConfigEntry<float> PosX;
public static ConfigEntry<float> PosY;
public static ConfigEntry<bool> Background;
public static ConfigEntry<Color> LabelColor;
public static ConfigEntry<Color> NameColor;
public static ConfigEntry<int> NameLength;
public static bool Active
{
get
{
if (GeneralConfig.IsEnabled && Enabled != null)
{
return Enabled.Value;
}
return false;
}
}
public static void BindAll(ConfigFile config)
{
//IL_005b: Unknown result type (might be due to invalid IL or missing references)
//IL_0065: Expected O, but got Unknown
//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
//IL_00b4: Expected O, but got Unknown
//IL_00de: Unknown result type (might be due to invalid IL or missing references)
//IL_00e8: Expected O, but got Unknown
//IL_0112: Unknown result type (might be due to invalid IL or missing references)
//IL_011c: Expected O, but got Unknown
//IL_0146: Unknown result type (might be due to invalid IL or missing references)
//IL_0150: Expected O, but got Unknown
//IL_018f: Unknown result type (might be due to invalid IL or missing references)
//IL_01c2: 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_01fa: Expected O, but got Unknown
Enabled = config.Bind<bool>("Condor", "Warning Enabled", true, "秃鹫俯冲时在屏幕上方弹出文字提示,从背后袭来也能及时察觉");
Range = config.Bind<Scope>("Condor", "Warning Scope", Scope.Nearby, "预警范围:Nearby 只提示附近的俯冲(按被扑玩家与你的距离判断),WholeMap 提示全图所有俯冲");
NearbyDistance = config.Bind<float>("Condor", "Warning Nearby Distance", 30f, new ConfigDescription("Warning Scope 为 Nearby 时的距离阈值,单位米;被扑玩家在此范围内才提示", (AcceptableValueBase)(object)new AcceptableValueRange<float>(5f, 200f), (object[])null));
TargetMode = config.Bind<Target>("Condor", "Warning Target", Target.OnlyMe, "预警目标:OnlyMe 只提示锁定自己的秃鹫,AnyPlayer 锁定任何玩家都提示并显示被锁定的玩家名");
Duration = config.Bind<float>("Condor", "Warning Duration", 2.5f, new ConfigDescription("提示文字停留的秒数", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.5f, 10f), (object[])null));
TextScale = config.Bind<float>("Condor", "Warning Text Scale", 0.5f, new ConfigDescription("提示文字大小,1 为参考大小,默认 0.5 即参考大小的一半", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.2f, 4f), (object[])null));
PosX = config.Bind<float>("Condor", "Warning Position X", 0.5f, new ConfigDescription("提示文字水平位置,占屏幕宽度的比例,0 最左、0.5 居中、1 最右", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), (object[])null));
PosY = config.Bind<float>("Condor", "Warning Position Y", 0.5f, new ConfigDescription("提示文字垂直位置,占屏幕高度的比例,0 最上、0.5 居中、1 最下", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), (object[])null));
Background = config.Bind<bool>("Condor", "Warning Background", true, "提示文字背后是否绘制一层半透明衬底,开启更醒目、关闭则只有文字");
LabelColor = config.Bind<Color>("Condor", "Warning Label Color", new Color(1f, 0.2f, 0.2f, 1f), "「秃鹫锁定」四个字的颜色,仅 RGB 生效,默认红");
NameColor = config.Bind<Color>("Condor", "Warning Name Color", new Color(1f, 0.9f, 0.2f, 1f), "玩家名字(或「你」)的颜色,仅 RGB 生效,默认黄");
NameLength = config.Bind<int>("Condor", "Warning Name Length", 6, new ConfigDescription("玩家名最多显示几个字,超出部分截断", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 20), (object[])null));
}
}
internal static class CondorWarningHud
{
private static GameObject _host;
public static void Init()
{
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_001d: Expected O, but got Unknown
if (!((Object)(object)_host != (Object)null))
{
_host = new GameObject("DangerWarningCondorHud");
Object.DontDestroyOnLoad((Object)(object)_host);
_host.AddComponent<CondorWarningHudBehaviour>();
}
}
}
internal sealed class CondorWarningHudBehaviour : MonoBehaviour
{
private Font _font;
private GUIStyle _style;
private int _styleScreenHeight;
private float _styleScale = -1f;
private readonly GUIContent _content = new GUIContent();
private int _builtVersion = -1;
private Color _builtLabel;
private Color _builtName;
private string _builtTarget;
private string _builtText;
private string _measuredText;
private float _measuredFontSize = -1f;
private Vector2 _measuredSize;
private void Awake()
{
_font = ResolveFont();
}
private void OnGUI()
{
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: Invalid comparison between Unknown and I4
//IL_0039: 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_0063: Unknown result type (might be due to invalid IL or missing references)
//IL_0080: Unknown result type (might be due to invalid IL or missing references)
//IL_0095: Unknown result type (might be due to invalid IL or missing references)
//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
//IL_017e: 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_0103: Unknown result type (might be due to invalid IL or missing references)
//IL_0145: Unknown result type (might be due to invalid IL or missing references)
//IL_016a: Unknown result type (might be due to invalid IL or missing references)
Event current = Event.current;
if (current == null || (int)current.type != 7 || !CondorWarningState.Active)
{
return;
}
string target = CondorWarningState.Target;
if (!string.IsNullOrEmpty(target))
{
EnsureStyle();
string text = BuildText(target);
Vector2 val = Measure(text);
float num = (float)Screen.width * CondorWarningConfig.PosX.Value;
float num2 = (float)Screen.height * CondorWarningConfig.PosY.Value;
float num3 = Mathf.Clamp(num - val.x * 0.5f, 0f, Mathf.Max(0f, (float)Screen.width - val.x));
float num4 = Mathf.Clamp(num2 - val.y * 0.5f, 0f, Mathf.Max(0f, (float)Screen.height - val.y));
Rect val2 = default(Rect);
((Rect)(ref val2))..ctor(num3, num4, val.x, val.y);
if (CondorWarningConfig.Background != null && CondorWarningConfig.Background.Value)
{
float num5 = val.y * 0.6f;
float num6 = val.y * 0.15f;
GUI.DrawTexture(new Rect(((Rect)(ref val2)).x - num5, ((Rect)(ref val2)).y - num6, ((Rect)(ref val2)).width + num5 * 2f, ((Rect)(ref val2)).height + num6 * 2f), (Texture)(object)Texture2D.whiteTexture, (ScaleMode)0, true, 0f, new Color(0f, 0f, 0f, 0.55f), 0f, 0f);
}
GUI.Label(val2, _content, _style);
}
}
private Vector2 Measure(string text)
{
//IL_0054: Unknown result type (might be due to invalid IL or missing references)
//IL_0059: 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)
if (_measuredText != text || _measuredFontSize != (float)_style.fontSize)
{
_measuredText = text;
_measuredFontSize = _style.fontSize;
_content.text = text;
_measuredSize = _style.CalcSize(_content);
}
return _measuredSize;
}
private string BuildText(string target)
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_000a: 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_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_006f: Unknown result type (might be due to invalid IL or missing references)
//IL_0070: Unknown result type (might be due to invalid IL or missing references)
//IL_0076: Unknown result type (might be due to invalid IL or missing references)
//IL_0077: Unknown result type (might be due to invalid IL or missing references)
//IL_008d: Unknown result type (might be due to invalid IL or missing references)
//IL_009e: 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_0037: Unknown result type (might be due to invalid IL or missing references)
//IL_0040: Unknown result type (might be due to invalid IL or missing references)
//IL_0045: Unknown result type (might be due to invalid IL or missing references)
Color value = CondorWarningConfig.LabelColor.Value;
Color value2 = CondorWarningConfig.NameColor.Value;
if (_builtVersion == CondorWarningState.Version && _builtTarget == target && _builtLabel == value && _builtName == value2 && _builtText != null)
{
return _builtText;
}
_builtVersion = CondorWarningState.Version;
_builtTarget = target;
_builtLabel = value;
_builtName = value2;
_builtText = "<color=#" + ColorUtility.ToHtmlStringRGB(value) + ">秃鹫锁定</color><color=#" + ColorUtility.ToHtmlStringRGB(value2) + ">" + target + "</color>";
return _builtText;
}
private void EnsureStyle()
{
//IL_0069: Unknown result type (might be due to invalid IL or missing references)
//IL_0073: Expected O, but got Unknown
float value = CondorWarningConfig.TextScale.Value;
if (_style == null || _styleScreenHeight != Screen.height || _styleScale != value)
{
_styleScreenHeight = Screen.height;
_styleScale = value;
int fontSize = Mathf.Max(8, Mathf.RoundToInt((float)Screen.height * 0.042f * value));
if (_style == null)
{
_style = new GUIStyle(GUI.skin.label);
}
_style.alignment = (TextAnchor)4;
_style.wordWrap = false;
_style.richText = true;
_style.clipping = (TextClipping)1;
_style.fontStyle = (FontStyle)1;
if ((Object)(object)_font != (Object)null)
{
_style.font = _font;
}
_style.fontSize = fontSize;
}
}
private static Font ResolveFont()
{
string[] array = new string[7] { "Microsoft YaHei UI", "Microsoft YaHei", "SimHei", "SimSun", "Noto Sans CJK SC", "PingFang SC", "Arial Unicode MS" };
string[] oSInstalledFontNames = Font.GetOSInstalledFontNames();
if (oSInstalledFontNames == null)
{
return null;
}
for (int i = 0; i < array.Length; i++)
{
if (Array.IndexOf(oSInstalledFontNames, array[i]) >= 0)
{
Font val = Font.CreateDynamicFontFromOSFont(array[i], 24);
if ((Object)(object)val != (Object)null)
{
return val;
}
}
}
return null;
}
}
internal static class CondorWarningState
{
private static string _target;
private static float _until;
private static int _version;
public static bool Active
{
get
{
if (_until > 0f)
{
return Time.unscaledTime < _until;
}
return false;
}
}
public static string Target => _target;
public static int Version => _version;
public static void Set(string target, float seconds)
{
_target = target;
_until = Time.unscaledTime + seconds;
_version++;
}
public static void Clear()
{
_until = 0f;
_target = null;
}
}
internal static class FrogBeaconConfig
{
public static ConfigEntry<bool> Enabled;
public static ConfigEntry<float> Height;
public static ConfigEntry<float> Width;
public static ConfigEntry<float> MaxDistance;
public static ConfigEntry<Color> Color;
public static bool IsEnabled
{
get
{
if (GeneralConfig.IsEnabled && Enabled != null)
{
return Enabled.Value;
}
return false;
}
}
public static void BindAll(ConfigFile config)
{
//IL_0040: Unknown result type (might be due to invalid IL or missing references)
//IL_004a: Expected O, but got Unknown
//IL_0074: Unknown result type (might be due to invalid IL or missing references)
//IL_007e: Expected O, but got Unknown
//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
//IL_00b2: Expected O, but got Unknown
//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
Enabled = config.Bind<bool>("Frog", "Enabled", true, "在每只青蛙头顶画一根竖直光柱,隔着地形也能看到它的位置");
Height = config.Bind<float>("Frog", "Height", 20f, new ConfigDescription("光柱高度,单位米", (AcceptableValueBase)(object)new AcceptableValueRange<float>(3f, 60f), (object[])null));
Width = config.Bind<float>("Frog", "Width", 3f, new ConfigDescription("光柱在屏幕上的宽度,单位像素", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 12f), (object[])null));
MaxDistance = config.Bind<float>("Frog", "Max Distance", 120f, new ConfigDescription("超过该距离的青蛙不再显示光柱,单位米;调大可看到更远处", (AcceptableValueBase)(object)new AcceptableValueRange<float>(10f, 500f), (object[])null));
Color = config.Bind<Color>("Frog", "Color", new Color(1f, 0.85f, 0.2f, 1f), "光柱颜色,仅 RGB 生效,距离越远越淡");
}
}
internal sealed class FrogBeaconHost : MonoBehaviour
{
private void OnGUI()
{
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: Invalid comparison between Unknown and I4
Event current = Event.current;
if (current != null && (int)current.type == 7)
{
FrogBeaconRenderer.Draw();
}
}
}
internal static class FrogBeaconRenderer
{
private static Texture2D _pixel;
private static Camera _camera;
private static GameObject _host;
public static void Init()
{
//IL_0004: Unknown result type (might be due to invalid IL or missing references)
//IL_0009: 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)
//IL_001d: Expected O, but got Unknown
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
//IL_0054: Expected O, but got Unknown
_pixel = new Texture2D(1, 1, (TextureFormat)4, false)
{
hideFlags = (HideFlags)61,
filterMode = (FilterMode)0
};
_pixel.SetPixel(0, 0, Color.white);
_pixel.Apply();
if ((Object)(object)_host == (Object)null)
{
_host = new GameObject("DangerWarningFrogBeacon");
Object.DontDestroyOnLoad((Object)(object)_host);
_host.AddComponent<FrogBeaconHost>();
}
}
public static void Draw()
{
//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_01bb: Unknown result type (might be due to invalid IL or missing references)
//IL_00b9: 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_00c0: Unknown result type (might be due to invalid IL or missing references)
//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
//IL_00dc: 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_00e1: 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_00e8: Unknown result type (might be due to invalid IL or missing references)
//IL_00f9: 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_0118: 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_0135: Unknown result type (might be due to invalid IL or missing references)
//IL_0160: Unknown result type (might be due to invalid IL or missing references)
//IL_0162: Unknown result type (might be due to invalid IL or missing references)
//IL_0172: Unknown result type (might be due to invalid IL or missing references)
//IL_0184: 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)
if ((Object)(object)_pixel == (Object)null || !FrogBeaconConfig.IsEnabled)
{
return;
}
MobManager instance = MobManager.instance;
if ((Object)(object)instance == (Object)null)
{
return;
}
Camera val = _camera;
if ((Object)(object)val == (Object)null)
{
val = (_camera = Camera.main);
if ((Object)(object)val == (Object)null)
{
return;
}
}
float value = FrogBeaconConfig.Height.Value;
float num = FrogBeaconConfig.Width.Value * 0.5f;
float value2 = FrogBeaconConfig.MaxDistance.Value;
Color value3 = FrogBeaconConfig.Color.Value;
List<Mob> mobs = instance.mobs;
for (int i = 0; i < mobs.Count; i++)
{
Mob obj = mobs[i];
FrogTongue val2 = (FrogTongue)(object)((obj is FrogTongue) ? obj : null);
if (val2 != null && !((Object)(object)val2 == (Object)null))
{
Vector3 position = ((Component)val2).transform.position;
Vector3 val3 = position + Vector3.up * value;
Vector3 val4 = val.WorldToScreenPoint(position);
Vector3 val5 = val.WorldToScreenPoint(val3);
if (!(val4.z <= 0f) && !(val5.z <= 0f) && !(val4.z > value2))
{
float x = val4.x;
float num2 = (float)Screen.height - val4.y;
float num3 = (float)Screen.height - val5.y;
float num4 = Mathf.Min(num2, num3);
float num5 = Mathf.Max(1f, Mathf.Abs(num2 - num3));
Color color = value3;
color.a *= Mathf.Clamp01(1f - val4.z / value2);
GUI.color = color;
GUI.DrawTexture(new Rect(x - num, num4, num * 2f, num5), (Texture)(object)_pixel);
}
}
}
GUI.color = Color.white;
}
}
internal static class GeneralConfig
{
public static ConfigEntry<bool> Enabled;
public static bool IsEnabled
{
get
{
if (Enabled != null)
{
return Enabled.Value;
}
return true;
}
}
public static void BindAll(ConfigFile config)
{
Enabled = config.Bind<bool>("General", "Enabled", true, "总开关,关闭后蜘蛛红线、秃鹫光柱与青蛙光柱全部停用");
}
}
[BepInPlugin("DangerWarning", "DangerWarning", "0.7.0")]
public class Plugin : BaseUnityPlugin
{
private void Awake()
{
//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
GeneralConfig.BindAll(((BaseUnityPlugin)this).Config);
SpiderLineConfig.BindAll(((BaseUnityPlugin)this).Config);
CondorLineConfig.BindAll(((BaseUnityPlugin)this).Config);
CondorWarningConfig.BindAll(((BaseUnityPlugin)this).Config);
FrogBeaconConfig.BindAll(((BaseUnityPlugin)this).Config);
SpiderLineHost.Init(((BaseUnityPlugin)this).Logger);
CondorLineHost.Init(((BaseUnityPlugin)this).Logger);
CondorWarning.Init(((BaseUnityPlugin)this).Logger);
CondorWarningHud.Init();
FrogBeaconRenderer.Init();
((BaseUnityPlugin)this).Config.ConfigReloaded += delegate
{
ApplyConfigs();
};
((BaseUnityPlugin)this).Config.SettingChanged += delegate
{
ApplyConfigs();
};
new Harmony("DangerWarning").PatchAll(Assembly.GetExecutingAssembly());
ApplyConfigs();
((BaseUnityPlugin)this).Logger.LogInfo((object)"[DangerWarning] v0.7.0 已加载");
}
private static void ApplyConfigs()
{
SpiderLineHost.ApplyConfig();
CondorLineHost.ApplyConfig();
}
}
public static class PluginInfo
{
public const string Guid = "DangerWarning";
public const string Name = "DangerWarning";
public const string Version = "0.7.0";
}
[HarmonyPatch(typeof(Spider), "GetHit")]
internal static class SpiderGetHitPatch
{
[HarmonyPostfix]
private static void Postfix(Spider __instance, RaycastHit __result)
{
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
if (SpiderLineConfig.IsEnabled && !((Object)(object)__instance == (Object)null))
{
SpiderLineHost.ApplyHit(__instance, __result);
}
}
}
internal static class SpiderLineConfig
{
public static ConfigEntry<bool> Enabled;
public static ConfigEntry<float> LineThickness;
public static ConfigEntry<float> Opacity;
public static ConfigEntry<Color> LineColor;
private static bool _enabled = true;
public static bool IsEnabled
{
get
{
if (GeneralConfig.IsEnabled)
{
return _enabled;
}
return false;
}
}
public static bool RefreshEnabled()
{
_enabled = Enabled.Value;
return IsEnabled;
}
public static void BindAll(ConfigFile config)
{
//IL_0040: Unknown result type (might be due to invalid IL or missing references)
//IL_004a: Expected O, but got Unknown
//IL_0074: Unknown result type (might be due to invalid IL or missing references)
//IL_007e: Expected O, but got Unknown
//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
Enabled = config.Bind<bool>("Spider", "Enabled", true, "蜘蛛红线开关:从蛛丝锚点垂直向下一条线,指向它正下方的危险地面");
LineThickness = config.Bind<float>("Spider", "Line Thickness", 0.2f, new ConfigDescription("线条粗细,单位是游戏世界长度", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.05f, 2f), (object[])null));
Opacity = config.Bind<float>("Spider", "Opacity", 0.8f, new ConfigDescription("线条不透明度,0 为完全透明,1 为完全不透明", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), (object[])null));
LineColor = config.Bind<Color>("Spider", "Line Color", new Color(1f, 0.15f, 0.15f, 1f), "线条颜色,仅 RGB 生效,不透明度由 Opacity 控制");
_enabled = Enabled.Value;
}
}
internal static class SpiderLineHost
{
private sealed class LineTracker : MonoBehaviour
{
private SpiderLineRecord _record;
public void Bind(SpiderLineRecord record)
{
_record = record;
}
private void OnDestroy()
{
if (_record != null && Records.Remove(_record.Spider))
{
_record = null;
}
}
}
private const string LineObjectName = "DangerWarning";
private static readonly Dictionary<Spider, SpiderLineRecord> Records = new Dictionary<Spider, SpiderLineRecord>();
private static Material _lineMaterial;
private static bool _failed;
public static void Init(ManualLogSource log)
{
_lineMaterial = CreateMaterial();
if ((Object)(object)_lineMaterial == (Object)null)
{
_failed = true;
log.LogError((object)"[DangerWarning] 找不到可用线条着色器,功能已禁用");
}
}
private static Material CreateMaterial()
{
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: 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_0047: 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: Expected O, but got Unknown
Shader val = Shader.Find("Sprites/Default") ?? Shader.Find("Unlit/Transparent Color") ?? Shader.Find("Unlit/Color");
if ((Object)(object)val == (Object)null)
{
return null;
}
return new Material(val)
{
hideFlags = (HideFlags)61,
mainTexture = null,
color = Color.white
};
}
public static void ApplyHit(Spider spider, RaycastHit hit)
{
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)spider == (Object)null || _failed || !SpiderLineConfig.IsEnabled)
{
return;
}
if (!Records.TryGetValue(spider, out var value) || value == null)
{
value = Create(spider);
if (value == null)
{
return;
}
}
value.Apply(hit);
}
private static SpiderLineRecord Create(Spider spider)
{
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
//IL_002f: 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_0047: Unknown result type (might be due to invalid IL or missing references)
//IL_0051: 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_0061: 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_0071: Unknown result type (might be due to invalid IL or missing references)
//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
//IL_00c2: 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)
Transform startPoint = spider.startPoint;
if ((Object)(object)startPoint == (Object)null)
{
return null;
}
GameObject val = new GameObject("DangerWarning", new Type[1] { typeof(LineTracker) });
val.transform.SetParent(((Component)spider).transform, false);
val.transform.localPosition = Vector3.zero;
val.transform.localRotation = Quaternion.identity;
val.transform.localScale = Vector3.one;
LineRenderer val2 = val.AddComponent<LineRenderer>();
((Renderer)val2).sharedMaterial = _lineMaterial;
val2.useWorldSpace = true;
val2.loop = false;
val2.positionCount = 2;
val2.numCapVertices = 0;
val2.numCornerVertices = 0;
((Renderer)val2).sortingOrder = -1;
((Renderer)val2).receiveShadows = false;
((Renderer)val2).enabled = false;
Color endColor = (val2.startColor = CurrentColor());
val2.endColor = endColor;
float endWidth = (val2.startWidth = SpiderLineConfig.LineThickness.Value);
val2.endWidth = endWidth;
SpiderLineRecord spiderLineRecord = new SpiderLineRecord(spider, val2, startPoint, spider.castRadius, spider.castDistance);
val.GetComponent<LineTracker>().Bind(spiderLineRecord);
Records.Add(spider, spiderLineRecord);
return spiderLineRecord;
}
private static Color CurrentColor()
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
Color value = SpiderLineConfig.LineColor.Value;
value.a = Mathf.Clamp01(SpiderLineConfig.Opacity.Value);
return value;
}
public static void ApplyConfig()
{
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_0084: Unknown result type (might be due to invalid IL or missing references)
//IL_0091: Unknown result type (might be due to invalid IL or missing references)
if (_failed)
{
return;
}
float value = SpiderLineConfig.LineThickness.Value;
Color val = CurrentColor();
bool flag = SpiderLineConfig.RefreshEnabled();
foreach (KeyValuePair<Spider, SpiderLineRecord> record in Records)
{
SpiderLineRecord value2 = record.Value;
if (value2 != null && !((Object)(object)value2.Line == (Object)null))
{
if (value2.Line.startWidth != value)
{
value2.Line.startWidth = value;
value2.Line.endWidth = value;
}
value2.Line.startColor = val;
value2.Line.endColor = val;
((Renderer)value2.Line).enabled = flag && value2.Visible;
}
}
}
public static void Dispose()
{
if ((Object)(object)_lineMaterial != (Object)null)
{
Object.Destroy((Object)(object)_lineMaterial);
_lineMaterial = null;
}
Records.Clear();
}
}
internal sealed class SpiderLineRecord
{
public Spider Spider;
public LineRenderer Line;
public Transform Top;
public bool Visible;
private readonly float _castRadius;
private readonly float _castDistance;
private Vector3 _topPosition;
private bool _topPositionWritten;
private float _lastBottomY = float.NaN;
public SpiderLineRecord(Spider spider, LineRenderer line, Transform top, float castRadius, float castDistance)
{
Spider = spider;
Line = line;
Top = top;
_castRadius = castRadius;
_castDistance = castDistance;
}
public void Apply(RaycastHit hit)
{
//IL_005c: Unknown result type (might be due to invalid IL or missing references)
//IL_0061: 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)
//IL_0077: Unknown result type (might be due to invalid IL or missing references)
//IL_0093: Unknown result type (might be due to invalid IL or missing references)
//IL_0085: Unknown result type (might be due to invalid IL or missing references)
//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
//IL_00ef: 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_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_00fe: Unknown result type (might be due to invalid IL or missing references)
//IL_0105: Unknown result type (might be due to invalid IL or missing references)
//IL_010b: Unknown result type (might be due to invalid IL or missing references)
LineRenderer line = Line;
if ((Object)(object)line == (Object)null)
{
return;
}
if ((Object)(object)((RaycastHit)(ref hit)).collider == (Object)null)
{
if (Visible)
{
Visible = false;
_lastBottomY = float.NaN;
}
if (((Renderer)line).enabled)
{
((Renderer)line).enabled = false;
}
return;
}
Transform top = Top;
if ((Object)(object)top == (Object)null)
{
return;
}
Vector3 position = top.position;
float num = ((RaycastHit)(ref hit)).point.y - _castRadius;
if (num > position.y - 0.5f)
{
num = position.y - 0.5f;
}
if (num < position.y - _castDistance)
{
num = position.y - _castDistance;
}
if (!Visible || _lastBottomY != num)
{
Visible = true;
_lastBottomY = num;
if (!_topPositionWritten || _topPosition != position)
{
line.SetPosition(0, position);
_topPosition = position;
_topPositionWritten = true;
}
line.SetPosition(1, new Vector3(position.x, num, position.z));
if (!((Renderer)line).enabled)
{
((Renderer)line).enabled = true;
}
}
}
}
}