Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of Supermans Trophy Pedestal v1.0.2
SupermansTrophyPedestal.dll
Decompiled 2 weeks agousing 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 UnityEngine; using UnityEngine.Rendering; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: IgnoresAccessChecksTo("assembly_utils")] [assembly: IgnoresAccessChecksTo("assembly_valheim")] [assembly: TargetFramework(".NETFramework,Version=v4.6.2", FrameworkDisplayName = ".NET Framework 4.6.2")] [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 TrophyPedestal { public class EgoEffect : StatusEffect { public int Pedestals; public override void ModifyAttack(SkillType skill, ref HitData hitData) { ((DamageTypes)(ref hitData.m_damage)).Modify(1f + Plugin.EgoDamage.Value / 100f); } public override void ModifyStaminaRegen(ref float staminaRegen) { staminaRegen *= 1f + Plugin.EgoStaminaRegen.Value / 100f; } public override string GetTooltipString() { return "Your trophies remind everyone how mighty you are.\n" + $"Damage: <color=orange>+{Plugin.EgoDamage.Value:0.#}%</color>\n" + $"Stamina regen: <color=orange>+{Plugin.EgoStaminaRegen.Value:0.#}%</color>\n" + $"Trophies nearby: <color=orange>{Pedestals}</color>"; } } internal static class Ego { internal const string EffectName = "SupermansEgo"; private static readonly int Hash = StringExtensionMethods.GetStableHashCode("SupermansEgo"); private static EgoEffect _template; private static float _next; internal static void Tick() { if (!Plugin.EgoEnabled.Value || Time.time < _next) { return; } _next = Time.time + 1f; Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null || ((Character)localPlayer).IsDead()) { return; } int num = Count(localPlayer); if (num <= 0) { return; } float ttl = Mathf.Min(Plugin.EgoMinutesPerPedestal.Value * (float)num, Plugin.EgoMaxMinutes.Value) * 60f; SEMan sEMan = ((Character)localPlayer).GetSEMan(); EgoEffect egoEffect = sEMan.GetStatusEffect(Hash) as EgoEffect; if ((Object)(object)egoEffect == (Object)null) { egoEffect = sEMan.AddStatusEffect((StatusEffect)(object)Template(), false, 0, 0f, (short)(-1)) as EgoEffect; if ((Object)(object)egoEffect == (Object)null) { return; } } ((StatusEffect)egoEffect).m_ttl = ttl; ((StatusEffect)egoEffect).m_time = 0f; egoEffect.Pedestals = num; } private static int Count(Player p) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: 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_0052: Unknown result type (might be due to invalid IL or missing references) float value = Plugin.EgoRange.Value; long playerID = p.GetPlayerID(); Vector3 position = ((Component)p).transform.position; int num = 0; foreach (Pedestal item in Pedestal.All) { if (!((Object)(object)item == (Object)null) && item.HasTrophy && !(Vector3.Distance(position, ((Component)item).transform.position) > value) && (!Plugin.EgoOnlyOwn.Value || item.Creator == playerID)) { num++; } } return num; } private static EgoEffect Template() { //IL_0050: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_template != (Object)null) { return _template; } _template = ScriptableObject.CreateInstance<EgoEffect>(); ((Object)_template).name = "SupermansEgo"; ((StatusEffect)_template).m_name = "Ego"; ((StatusEffect)_template).m_category = "SupermansEgo"; ((StatusEffect)_template).m_startMessageType = (MessageType)1; ((StatusEffect)_template).m_startMessage = "Your trophies fill you with pride"; ((StatusEffect)_template).m_ttl = 60f; GameObject val = (((Object)(object)ObjectDB.instance != (Object)null) ? ObjectDB.instance.GetItemPrefab("TrophyEikthyr") : null); ItemDrop val2 = (((Object)(object)val != (Object)null) ? val.GetComponent<ItemDrop>() : null); if ((Object)(object)val2 != (Object)null) { ((StatusEffect)_template).m_icon = val2.m_itemData.GetIcon(); } return _template; } } internal static class Hologram { internal sealed class Instance { public GameObject Root; public Vector3 LifeSize; public Light Light; public Color Color; } internal static readonly string[] ColorNames = new string[10] { "Default", "Blue", "Cyan", "Green", "Gold", "Orange", "Red", "Pink", "Purple", "White" }; private static readonly Color[] Palette = (Color[])(object)new Color[10] { Color.clear, new Color(0.25f, 0.5f, 1f), new Color(0.3f, 0.95f, 1f), new Color(0.3f, 1f, 0.45f), new Color(1f, 0.8f, 0.25f), new Color(1f, 0.5f, 0.15f), new Color(1f, 0.25f, 0.2f), new Color(1f, 0.45f, 0.85f), new Color(0.7f, 0.4f, 1f), new Color(0.95f, 0.95f, 1f) }; private static readonly Dictionary<long, Material> Mats = new Dictionary<long, Material>(); private static readonly Dictionary<int, List<Material>> MatsByColor = new Dictionary<int, List<Material>>(); private static Shader _shader; internal static Color ColorFor(int index) { //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_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: 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_0044: 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) Color value = Plugin.DefaultColor.Value; index = (index % Palette.Length + Palette.Length) % Palette.Length; if (index == 0) { return value; } Color result = Palette[index]; result.a = value.a; return result; } internal static void ClearMaterials() { Mats.Clear(); MatsByColor.Clear(); } private static Material HoloMaterial(Material src, int colorIndex) { //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Expected O, but got Unknown //IL_00b8: 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) long key = ((long)(((Object)(object)src != (Object)null) ? ((Object)src).GetInstanceID() : 0) << 16) ^ (colorIndex & 0xFFFF); if (Mats.TryGetValue(key, out var value) && (Object)(object)value != (Object)null) { return value; } if ((Object)(object)_shader == (Object)null) { _shader = Shader.Find("Sprites/Default") ?? Shader.Find("Unlit/Transparent"); } value = new Material(_shader) { color = ColorFor(colorIndex), renderQueue = 3100 }; if ((Object)(object)src != (Object)null && src.HasProperty("_MainTex") && (Object)(object)src.mainTexture != (Object)null) { value.mainTexture = src.mainTexture; value.mainTextureScale = src.mainTextureScale; value.mainTextureOffset = src.mainTextureOffset; } Mats[key] = value; if (!MatsByColor.TryGetValue(colorIndex, out var value2)) { value2 = (MatsByColor[colorIndex] = new List<Material>()); } value2.Add(value); return value; } internal static void Pulse() { //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_0070: Unknown result type (might be due to invalid IL or missing references) float num = 0.82f + 0.18f * Mathf.Sin(Time.time * 2.4f); foreach (KeyValuePair<int, List<Material>> item in MatsByColor) { Color color = ColorFor(item.Key); color.a *= num; foreach (Material item2 in item.Value) { if ((Object)(object)item2 != (Object)null) { item2.color = color; } } } } internal static Instance Build(GameObject creature, Transform parent, Vector3 localPos, int colorIndex) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown //IL_0025: 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) //IL_0036: Expected O, but got Unknown //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_018d: Unknown result type (might be due to invalid IL or missing references) //IL_01eb: 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_021e: Unknown result type (might be due to invalid IL or missing references) //IL_0225: Unknown result type (might be due to invalid IL or missing references) //IL_022f: Unknown result type (might be due to invalid IL or missing references) //IL_0239: Unknown result type (might be due to invalid IL or missing references) //IL_0243: Unknown result type (might be due to invalid IL or missing references) //IL_024d: Unknown result type (might be due to invalid IL or missing references) //IL_0257: Unknown result type (might be due to invalid IL or missing references) //IL_025f: Unknown result type (might be due to invalid IL or missing references) //IL_0264: Unknown result type (might be due to invalid IL or missing references) //IL_0274: Unknown result type (might be due to invalid IL or missing references) //IL_028d: Unknown result type (might be due to invalid IL or missing references) //IL_0292: Unknown result type (might be due to invalid IL or missing references) //IL_0299: Unknown result type (might be due to invalid IL or missing references) //IL_029e: Unknown result type (might be due to invalid IL or missing references) //IL_01f7: Unknown result type (might be due to invalid IL or missing references) //IL_01f9: Unknown result type (might be due to invalid IL or missing references) //IL_0203: Unknown result type (might be due to invalid IL or missing references) //IL_0208: Unknown result type (might be due to invalid IL or missing references) //IL_020d: Unknown result type (might be due to invalid IL or missing references) //IL_02b9: Unknown result type (might be due to invalid IL or missing references) //IL_02be: Unknown result type (might be due to invalid IL or missing references) //IL_02cb: Unknown result type (might be due to invalid IL or missing references) //IL_02d1: Unknown result type (might be due to invalid IL or missing references) //IL_02d2: Unknown result type (might be due to invalid IL or missing references) //IL_02dc: Unknown result type (might be due to invalid IL or missing references) //IL_02e1: Unknown result type (might be due to invalid IL or missing references) //IL_0325: Unknown result type (might be due to invalid IL or missing references) //IL_01cd: Unknown result type (might be due to invalid IL or missing references) //IL_01be: Unknown result type (might be due to invalid IL or missing references) //IL_01c3: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("SupermansHologram"); val.SetActive(false); val.transform.SetParent(parent, false); val.transform.localPosition = localPos; GameObject val2 = new GameObject("model"); val2.transform.SetParent(val.transform, false); GameObject val3 = Object.Instantiate<GameObject>(creature, val2.transform, false); ((Object)val3).name = ((Object)creature).name; Strip(val3); if (Plugin.ShowGear.Value) { AddGear(creature, val3); } Renderer[] componentsInChildren = val3.GetComponentsInChildren<Renderer>(true); foreach (Renderer val4 in componentsInChildren) { if (!IsEffect(val4)) { Material[] sharedMaterials = val4.sharedMaterials; Material[] array = (Material[])(object)new Material[sharedMaterials.Length]; for (int j = 0; j < sharedMaterials.Length; j++) { array[j] = HoloMaterial(sharedMaterials[j], colorIndex); } val4.sharedMaterials = array; val4.shadowCastingMode = (ShadowCastingMode)0; val4.receiveShadows = false; SkinnedMeshRenderer val5 = (SkinnedMeshRenderer)(object)((val4 is SkinnedMeshRenderer) ? val4 : null); if (val5 != null) { val5.updateWhenOffscreen = true; } } } Animator[] componentsInChildren2 = val3.GetComponentsInChildren<Animator>(true); foreach (Animator val6 in componentsInChildren2) { val6.applyRootMotion = false; val6.fireEvents = false; val6.cullingMode = (AnimatorCullingMode)0; if (!Plugin.Animate.Value) { val6.speed = 0f; } } val.transform.rotation = Quaternion.identity; val.transform.localScale = Vector3.one; val.SetActive(true); bool flag = false; Bounds val7 = default(Bounds); componentsInChildren = val3.GetComponentsInChildren<Renderer>(); foreach (Renderer val8 in componentsInChildren) { if (!IsEffect(val8) && val8.enabled) { if (!flag) { val7 = val8.bounds; flag = true; } else { ((Bounds)(ref val7)).Encapsulate(val8.bounds); } } } Vector3 position = val.transform.position; if (!flag) { ((Bounds)(ref val7))..ctor(position + Vector3.up * 0.5f, Vector3.one); } Transform transform = val2.transform; transform.position -= new Vector3(((Bounds)(ref val7)).center.x - position.x, ((Bounds)(ref val7)).min.y - position.y, ((Bounds)(ref val7)).center.z - position.z); val.transform.localRotation = Quaternion.identity; Instance instance = new Instance { Root = val, LifeSize = ((Bounds)(ref val7)).size, Color = ColorFor(colorIndex) }; if (Plugin.Glow.Value) { GameObject val9 = new GameObject("SupermansHologramGlow"); val9.transform.SetParent(parent, false); val9.transform.localPosition = localPos + Vector3.up * 0.3f; Light val10 = val9.AddComponent<Light>(); val10.type = (LightType)2; val10.color = new Color(instance.Color.r, instance.Color.g, instance.Color.b, 1f); val10.intensity = 1.3f; val10.range = 4f; val10.shadows = (LightShadows)0; instance.Light = val10; } return instance; } internal static void Destroy(Instance inst) { if (inst != null) { if ((Object)(object)inst.Root != (Object)null) { Object.Destroy((Object)(object)inst.Root); } if ((Object)(object)inst.Light != (Object)null) { Object.Destroy((Object)(object)((Component)inst.Light).gameObject); } } } private static bool IsEffect(Renderer r) { if (!(r is ParticleSystemRenderer) && !(r is TrailRenderer)) { return r is LineRenderer; } return true; } private static void Strip(GameObject go) { for (int i = 0; i < 4; i++) { MonoBehaviour[] componentsInChildren = go.GetComponentsInChildren<MonoBehaviour>(true); if (componentsInChildren.Length == 0) { break; } for (int num = componentsInChildren.Length - 1; num >= 0; num--) { if ((Object)(object)componentsInChildren[num] != (Object)null) { Object.DestroyImmediate((Object)(object)componentsInChildren[num]); } } } Joint[] componentsInChildren2 = go.GetComponentsInChildren<Joint>(true); for (int j = 0; j < componentsInChildren2.Length; j++) { Object.DestroyImmediate((Object)(object)componentsInChildren2[j]); } Rigidbody[] componentsInChildren3 = go.GetComponentsInChildren<Rigidbody>(true); for (int j = 0; j < componentsInChildren3.Length; j++) { Object.DestroyImmediate((Object)(object)componentsInChildren3[j]); } Collider[] componentsInChildren4 = go.GetComponentsInChildren<Collider>(true); for (int j = 0; j < componentsInChildren4.Length; j++) { Object.DestroyImmediate((Object)(object)componentsInChildren4[j]); } AudioSource[] componentsInChildren5 = go.GetComponentsInChildren<AudioSource>(true); for (int j = 0; j < componentsInChildren5.Length; j++) { Object.DestroyImmediate((Object)(object)componentsInChildren5[j]); } Light[] componentsInChildren6 = go.GetComponentsInChildren<Light>(true); for (int j = 0; j < componentsInChildren6.Length; j++) { Object.DestroyImmediate((Object)(object)componentsInChildren6[j]); } } private static void AddGear(GameObject creature, GameObject copy) { //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Invalid comparison between Unknown and I4 //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Invalid comparison between Unknown and I4 //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Invalid comparison between Unknown and I4 //IL_014d: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Invalid comparison between Unknown and I4 //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Invalid comparison between Unknown and I4 //IL_01b3: Unknown result type (might be due to invalid IL or missing references) //IL_01c3: Unknown result type (might be due to invalid IL or missing references) Humanoid component = creature.GetComponent<Humanoid>(); VisEquipment component2 = creature.GetComponent<VisEquipment>(); if ((Object)(object)component == (Object)null || (Object)(object)component2 == (Object)null) { return; } List<GameObject> list = new List<GameObject>(); if (component.m_defaultItems != null) { list.AddRange(component.m_defaultItems); } if (component.m_randomWeapon != null && component.m_randomWeapon.Length != 0) { list.Add(component.m_randomWeapon[0]); } if (component.m_randomShield != null && component.m_randomShield.Length != 0) { list.Add(component.m_randomShield[0]); } if (component.m_randomSets != null && component.m_randomSets.Length != 0 && component.m_randomSets[0].m_items != null) { list.AddRange(component.m_randomSets[0].m_items); } Transform val = Mirror(component2.m_rightHand, creature.transform, copy.transform); Transform val2 = Mirror(component2.m_leftHand, creature.transform, copy.transform); bool flag = false; bool flag2 = false; foreach (GameObject item in list) { ItemDrop val3 = (((Object)(object)item != (Object)null) ? item.GetComponent<ItemDrop>() : null); if ((Object)(object)val3 == (Object)null) { continue; } Transform val4 = null; ItemType itemType = val3.m_itemData.m_shared.m_itemType; if ((int)itemType <= 5) { if ((int)itemType == 3) { goto IL_0160; } if (itemType - 4 <= 1) { goto IL_0153; } } else { if (itemType - 14 <= 1) { goto IL_0160; } if ((int)itemType == 22) { goto IL_0153; } } goto IL_0177; IL_0153: if (!flag2) { val4 = val2; flag2 = true; } goto IL_0177; IL_0160: if (!flag) { val4 = val; flag = true; } else if (!flag2) { val4 = val2; flag2 = true; } goto IL_0177; IL_0177: if (!((Object)(object)val4 == (Object)null)) { Transform val5 = item.transform.Find("attach"); if (!((Object)(object)val5 == (Object)null)) { GameObject obj = Object.Instantiate<GameObject>(((Component)val5).gameObject, val4, false); obj.transform.localPosition = Vector3.zero; obj.transform.localRotation = Quaternion.identity; Strip(obj); } } } } private static Transform Mirror(Transform t, Transform srcRoot, Transform dstRoot) { if ((Object)(object)t == (Object)null) { return null; } List<string> list = new List<string>(); Transform val = t; while ((Object)(object)val != (Object)null && (Object)(object)val != (Object)(object)srcRoot) { list.Add(((Object)val).name); val = val.parent; } list.Reverse(); if (list.Count != 0) { return dstRoot.Find(string.Join("/", list.ToArray())); } return dstRoot; } } internal class Pedestal : MonoBehaviour { internal static readonly List<Pedestal> All = new List<Pedestal>(); private const string KeySize = "supermans_pedestal_size"; private const string KeyColor = "supermans_pedestal_color"; private const string RpcSize = "SupermansPedestal_Size"; private const string RpcColor = "SupermansPedestal_Color"; private const string KeyTrophyTurn = "supermans_pedestal_trophyturn"; private const string RpcTrophyTurn = "SupermansPedestal_TrophyTurn"; internal static readonly float[] Sizes = new float[15] { 0f, 0.05f, 0.1f, 0.15f, 0.2f, 0.25f, 0.33f, 0.5f, 0.75f, 1f, 1.25f, 1.5f, 2f, 2.5f, 3f }; private ZNetView _nview; private Piece _piece; private Hologram.Instance _holo; private string _shownItem; private int _shownColor = -1; private int _shownRevision = -1; private float _nextCheck; private float _spin; private bool _registered; private Transform _attach; private Quaternion _attachBase; private float _shownTrophyAngle = float.NaN; internal bool Valid { get { if ((Object)(object)_nview != (Object)null) { return _nview.IsValid(); } return false; } } internal string Item { get { if (!Valid) { return ""; } return _nview.GetZDO().GetString(ZDOVars.s_item, ""); } } internal bool HasTrophy => !string.IsNullOrEmpty(Item); internal int SizeIndex { get { if (!Valid) { return 0; } return Mathf.Clamp(_nview.GetZDO().GetInt("supermans_pedestal_size", 0), 0, Sizes.Length - 1); } } internal int ColorIndex { get { if (!Valid) { return 0; } return _nview.GetZDO().GetInt("supermans_pedestal_color", 0); } } internal long Creator { get { if (!((Object)(object)_piece != (Object)null)) { return 0L; } return _piece.GetCreator(); } } internal int TrophyTurn { get { if (!Valid) { return 0; } return _nview.GetZDO().GetInt("supermans_pedestal_trophyturn", 0); } } private float TrophyAngle => Mathf.Repeat((float)TrophyTurn * Plugin.TrophyTurnStep.Value, 360f); private void Awake() { //IL_004c: 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_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_0066: Unknown result type (might be due to invalid IL or missing references) _nview = ((Component)this).GetComponent<ZNetView>(); _piece = ((Component)this).GetComponent<Piece>(); ItemStand component = ((Component)this).GetComponent<ItemStand>(); _attach = (((Object)(object)component != (Object)null) ? component.m_attachOther : null); if ((Object)(object)_attach != (Object)null) { _attachBase = Quaternion.Inverse(((Component)this).transform.rotation) * _attach.rotation; } _spin = Random.Range(0f, 360f); All.Add(this); } private void Start() { TryRegister(); } private void TryRegister() { if (!_registered && !((Object)(object)_nview == (Object)null) && _nview.GetZDO() != null) { _nview.Register<int>("SupermansPedestal_Size", (Action<long, int>)RPC_Size); _nview.Register("SupermansPedestal_Color", (Action<long>)RPC_Color); _nview.Register<int>("SupermansPedestal_TrophyTurn", (Action<long, int>)RPC_TrophyTurn); _registered = true; } } private void OnDestroy() { All.Remove(this); Hologram.Destroy(_holo); } internal void RequestSize(int delta) { TryRegister(); _nview.InvokeRPC("SupermansPedestal_Size", new object[1] { delta }); } internal void RequestColor() { TryRegister(); _nview.InvokeRPC("SupermansPedestal_Color", Array.Empty<object>()); } internal void RequestTrophyTurn(int delta) { TryRegister(); _nview.InvokeRPC("SupermansPedestal_TrophyTurn", new object[1] { delta }); } private void RPC_TrophyTurn(long sender, int delta) { if (_nview.IsOwner()) { int num = Mathf.Max(1, Mathf.RoundToInt(360f / Mathf.Max(1f, Plugin.TrophyTurnStep.Value))); int num2 = ((TrophyTurn + delta) % num + num) % num; _nview.GetZDO().Set("supermans_pedestal_trophyturn", num2); } } private void ApplyTrophyTurn() { //IL_0033: 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_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)_attach == (Object)null)) { float trophyAngle = TrophyAngle; if (trophyAngle != _shownTrophyAngle) { _shownTrophyAngle = trophyAngle; _attach.rotation = ((Component)this).transform.rotation * Quaternion.Euler(0f, trophyAngle, 0f) * _attachBase; } } } private void RPC_Size(long sender, int delta) { if (_nview.IsOwner()) { _nview.GetZDO().Set("supermans_pedestal_size", Mathf.Clamp(SizeIndex + delta, 0, Sizes.Length - 1)); } } private void RPC_Color(long sender) { if (_nview.IsOwner()) { _nview.GetZDO().Set("supermans_pedestal_color", (ColorIndex + 1) % Hologram.ColorNames.Length); } } private void Update() { //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: 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) if (Plugin.Headless || !Valid) { return; } ApplyTrophyTurn(); if (Time.time >= _nextCheck) { _nextCheck = Time.time + 0.25f; string item = Item; int colorIndex = ColorIndex; if (item != _shownItem || colorIndex != _shownColor || Plugin.VisualRevision != _shownRevision) { Rebuild(item, colorIndex); } } if (!((Object)(object)_holo?.Root == (Object)null)) { _spin = (_spin + Plugin.SpinSpeed.Value * Time.deltaTime) % 360f; Transform transform = _holo.Root.transform; transform.localRotation = Quaternion.Euler(0f, _spin, 0f); transform.localScale = Vector3.one * Scale(); transform.localPosition = new Vector3(0f, BaseY() + Mathf.Sin(Time.time * 1.3f) * 0.04f, 0f); } } private static float BaseY() { return PedestalPiece.TrophyY + Plugin.HoverHeight.Value; } private void Rebuild(string item, int color) { //IL_0054: Unknown result type (might be due to invalid IL or missing references) _shownItem = item; _shownColor = color; _shownRevision = Plugin.VisualRevision; Hologram.Destroy(_holo); _holo = null; GameObject val = TrophyMap.Creature(item); if ((Object)(object)val == (Object)null) { return; } try { _holo = Hologram.Build(val, ((Component)this).transform, new Vector3(0f, BaseY(), 0f), color); } catch (Exception ex) { Plugin.Log.LogWarning((object)("Couldn't make a hologram of " + ((Object)val).name + ": " + ex.Message)); } } private float Scale() { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_002d: 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) int sizeIndex = SizeIndex; if (sizeIndex > 0) { return Sizes[sizeIndex]; } if (_holo == null) { return 1f; } Vector3 lifeSize = _holo.LifeSize; float num = Mathf.Max(lifeSize.y, Mathf.Max(lifeSize.x, lifeSize.z) * 0.8f); if (!(num > 0.01f)) { return 1f; } return Plugin.FitSize.Value / num; } internal string HoverExtra() { //IL_010b: 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_018e: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Unknown result type (might be due to invalid IL or missing references) if (!Valid) { return ""; } string text = ""; string item = Item; if (!string.IsNullOrEmpty(item)) { GameObject val = TrophyMap.Creature(item); Character val2 = (((Object)(object)val != (Object)null) ? val.GetComponent<Character>() : null); text += (((Object)(object)val2 != (Object)null) ? ("\nHologram: <color=#7fdcff>" + Localization.instance.Localize(val2.m_name) + "</color>") : "\n<color=#ff8080>No creature found for this trophy</color>"); } int sizeIndex = SizeIndex; string text2; if (sizeIndex == 0) { text2 = $"Auto ({Plugin.FitSize.Value:0.#} m)"; } else { text2 = $"{Sizes[sizeIndex] * 100f:0}% of real size"; if (_holo != null) { text2 += $" ({_holo.LifeSize.y * Sizes[sizeIndex]:0.#} m tall)"; } } text = text + "\n[<color=yellow><b>" + Key(Plugin.BiggerKey.Value) + "</b></color>/<color=yellow><b>" + Key(Plugin.SmallerKey.Value) + "</b></color>] Size: " + text2; if (!string.IsNullOrEmpty(item)) { text += $"\n[<color=yellow><b>{Key(Plugin.TurnTrophyKey.Value)}</b></color>] Turn trophy ({TrophyAngle:0}°, hold Shift to turn back)"; } return text + "\n[<color=yellow><b>" + Key(Plugin.ColorKey.Value) + "</b></color>] Color: " + Hologram.ColorNames[(ColorIndex % Hologram.ColorNames.Length + Hologram.ColorNames.Length) % Hologram.ColorNames.Length]; } private unsafe static string Key(KeyCode k) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Invalid comparison between Unknown and I4 //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Invalid comparison between Unknown and I4 if ((int)k != 45) { if ((int)k == 61) { return "+"; } return ((object)(*(KeyCode*)(&k))/*cast due to .constrained prefix*/).ToString(); } return "-"; } } internal static class PedestalPiece { [HarmonyPatch(typeof(ZNetScene), "Awake")] private static class ZNetSceneAwakePatch { private static void Postfix() { Register(); } } [HarmonyPatch(typeof(ObjectDB), "Awake")] private static class ObjectDBAwakePatch { private static void Postfix() { Register(); } } [HarmonyPatch(typeof(ItemStand), "GetHoverText")] private static class HoverPatch { private static void Postfix(ItemStand __instance, ref string __result) { Pedestal component = ((Component)__instance).GetComponent<Pedestal>(); if ((Object)(object)component != (Object)null) { __result += component.HoverExtra(); } } } internal const string PrefabName = "SupermansTrophyPedestal"; internal const string DisplayName = "Trophy Pedestal"; private const float StoneHeight = 1f; internal static GameObject Prefab; internal static float TrophyY = 1.3f; private static GameObject _holder; private static void Register() { ZNetScene instance = ZNetScene.instance; if ((Object)(object)instance == (Object)null) { return; } if ((Object)(object)Prefab == (Object)null) { Prefab = Create(instance); } if (!((Object)(object)Prefab == (Object)null)) { if (!instance.m_prefabs.Contains(Prefab)) { instance.m_prefabs.Add(Prefab); } instance.m_namedPrefabs[StringExtensionMethods.GetStableHashCode("SupermansTrophyPedestal")] = Prefab; AddToHammer(); } } private static void AddToHammer() { if (!((Object)(object)Prefab == (Object)null) && !((Object)(object)ObjectDB.instance == (Object)null)) { GameObject itemPrefab = ObjectDB.instance.GetItemPrefab("Hammer"); PieceTable val = ((!((Object)(object)itemPrefab != (Object)null)) ? null : itemPrefab.GetComponent<ItemDrop>()?.m_itemData.m_shared.m_buildPieces); if ((Object)(object)val != (Object)null && !val.m_pieces.Contains(Prefab)) { val.m_pieces.Add(Prefab); } } } private static GameObject Create(ZNetScene zs) { //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Expected O, but got Unknown //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Expected O, but got Unknown //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_01e8: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_025a: Unknown result type (might be due to invalid IL or missing references) //IL_025f: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_0283: Unknown result type (might be due to invalid IL or missing references) //IL_018f: Unknown result type (might be due to invalid IL or missing references) //IL_0194: Unknown result type (might be due to invalid IL or missing references) //IL_019e: Unknown result type (might be due to invalid IL or missing references) //IL_01a3: Unknown result type (might be due to invalid IL or missing references) GameObject prefab = zs.GetPrefab("itemstandh"); if ((Object)(object)prefab == (Object)null) { Plugin.Log.LogError((object)"Couldn't find the vanilla item stand (itemstandh); the Trophy Pedestal is unavailable."); return null; } if ((Object)(object)_holder == (Object)null) { _holder = new GameObject("SupermansTrophyPedestal_Templates"); _holder.SetActive(false); Object.DontDestroyOnLoad((Object)(object)_holder); } GameObject val = Object.Instantiate<GameObject>(prefab, _holder.transform, false); ((Object)val).name = "SupermansTrophyPedestal"; List<Transform> list = new List<Transform>(); foreach (Transform item2 in val.transform) { Transform item = item2; list.Add(item); } foreach (Transform item3 in list) { item3.localPosition += Vector3.up * 1f; } Collider[] components = val.GetComponents<Collider>(); foreach (Collider val2 in components) { BoxCollider val3 = (BoxCollider)(object)((val2 is BoxCollider) ? val2 : null); if (val3 != null) { val3.center += Vector3.up * 1f; continue; } SphereCollider val4 = (SphereCollider)(object)((val2 is SphereCollider) ? val2 : null); if (val4 != null) { val4.center += Vector3.up * 1f; continue; } CapsuleCollider val5 = (CapsuleCollider)(object)((val2 is CapsuleCollider) ? val2 : null); if (val5 != null) { val5.center += Vector3.up * 1f; } } BuildStone(zs, val.transform); Piece component = val.GetComponent<Piece>(); component.m_name = "Trophy Pedestal"; component.m_description = "Place a trophy on it to project a glowing hologram of the creature it came from. Trophies on pedestals near you give you Ego."; component.m_category = (PieceCategory)4; component.m_resources = ParseCost(zs, Plugin.Cost.Value); ItemStand component2 = val.GetComponent<ItemStand>(); component2.m_name = "Trophy Pedestal"; component2.m_supportedTypes = new List<ItemType> { (ItemType)13 }; component2.m_supportedItems = new List<ItemDrop>(); component2.m_canBeRemoved = true; component2.m_autoAttach = false; if ((Object)(object)component2.m_attachOther != (Object)null) { TrophyY = val.transform.InverseTransformPoint(component2.m_attachOther.position).y; } WearNTear component3 = val.GetComponent<WearNTear>(); if ((Object)(object)component3 != (Object)null) { component3.m_materialType = (MaterialType)1; component3.m_health = 1000f; } val.AddComponent<Pedestal>(); Plugin.Log.LogInfo((object)"Trophy Pedestal registered"); return val; } private static void BuildStone(ZNetScene zs, Transform parent) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Expected O, but got Unknown //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_005a: 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_0094: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) int layer = LayerMask.NameToLayer("piece"); GameObject val = new GameObject("stone_pedestal"); val.layer = layer; val.transform.SetParent(parent, false); Block(zs, val.transform, layer, "stone_floor_2x2", new Vector3(0f, 0.08f, 0f), new Vector3(0.95f, 0.16f, 0.95f)); Block(zs, val.transform, layer, "stone_pillar", new Vector3(0f, 0.5f, 0f), new Vector3(0.55f, 0.68f, 0.55f)); Block(zs, val.transform, layer, "stone_floor_2x2", new Vector3(0f, 0.92f, 0f), new Vector3(0.8f, 0.16f, 0.8f)); } private static void Block(ZNetScene zs, Transform parent, int layer, string source, Vector3 center, Vector3 size) { //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Expected O, but got Unknown //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_0159: Unknown result type (might be due to invalid IL or missing references) //IL_0166: 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) //IL_016f: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Unknown result type (might be due to invalid IL or missing references) //IL_0176: 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_0195: Unknown result type (might be due to invalid IL or missing references) Mesh val = null; Material[] sharedMaterials = null; GameObject val2 = zs.GetPrefab(source) ?? zs.GetPrefab("stone_wall_1x1"); if ((Object)(object)val2 != (Object)null) { MeshRenderer[] componentsInChildren = val2.GetComponentsInChildren<MeshRenderer>(true); foreach (MeshRenderer val3 in componentsInChildren) { MeshFilter component = ((Component)val3).GetComponent<MeshFilter>(); if (!((Object)(object)component == (Object)null) && !((Object)(object)component.sharedMesh == (Object)null) && ((Component)val3).gameObject.activeSelf) { val = component.sharedMesh; sharedMaterials = ((Renderer)val3).sharedMaterials; break; } } } GameObject val4; Bounds bounds = default(Bounds); if ((Object)(object)val != (Object)null) { val4 = new GameObject(source); val4.AddComponent<MeshFilter>().sharedMesh = val; ((Renderer)val4.AddComponent<MeshRenderer>()).sharedMaterials = sharedMaterials; bounds = val.bounds; } else { val4 = GameObject.CreatePrimitive((PrimitiveType)3); Object.DestroyImmediate((Object)(object)val4.GetComponent<Collider>()); ((Bounds)(ref bounds))..ctor(Vector3.zero, Vector3.one); } val4.layer = layer; val4.transform.SetParent(parent, false); Vector3 val5 = default(Vector3); ((Vector3)(ref val5))..ctor(size.x / Mathf.Max(((Bounds)(ref bounds)).size.x, 0.01f), size.y / Mathf.Max(((Bounds)(ref bounds)).size.y, 0.01f), size.z / Mathf.Max(((Bounds)(ref bounds)).size.z, 0.01f)); val4.transform.localScale = val5; val4.transform.localPosition = center - Vector3.Scale(((Bounds)(ref bounds)).center, val5); BoxCollider obj = val4.AddComponent<BoxCollider>(); obj.center = ((Bounds)(ref bounds)).center; obj.size = ((Bounds)(ref bounds)).size; } private static Requirement[] ParseCost(ZNetScene zs, string text) { //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Expected O, but got Unknown //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: 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_00d0: Expected O, but got Unknown List<Requirement> list = new List<Requirement>(); string[] array = (text ?? "").Split(new char[1] { ',' }); for (int i = 0; i < array.Length; i++) { string[] array2 = array[i].Split(new char[1] { ':' }); if (array2.Length == 2 && int.TryParse(array2[1].Trim(), out var result) && result > 0) { GameObject prefab = zs.GetPrefab(array2[0].Trim()); ItemDrop val = (((Object)(object)prefab != (Object)null) ? prefab.GetComponent<ItemDrop>() : null); if ((Object)(object)val == (Object)null) { Plugin.Log.LogWarning((object)("Cost: unknown item '" + array2[0].Trim() + "'")); continue; } list.Add(new Requirement { m_resItem = val, m_amount = result, m_recover = true }); } } if (list.Count == 0) { GameObject prefab2 = zs.GetPrefab("Stone"); ItemDrop val2 = ((prefab2 != null) ? prefab2.GetComponent<ItemDrop>() : null); if ((Object)(object)val2 != (Object)null) { list.Add(new Requirement { m_resItem = val2, m_amount = 10, m_recover = true }); } } return list.ToArray(); } } [BepInPlugin("supermans.trophypedestal", "Supermans Trophy Pedestal", "1.0.2")] public class Plugin : BaseUnityPlugin { public const string Guid = "supermans.trophypedestal"; public const string Name = "Supermans Trophy Pedestal"; public const string Version = "1.0.2"; internal static ManualLogSource Log; internal static ConfigEntry<string> Cost; internal static ConfigEntry<Color> DefaultColor; internal static ConfigEntry<float> SpinSpeed; internal static ConfigEntry<float> FitSize; internal static ConfigEntry<float> HoverHeight; internal static ConfigEntry<bool> Animate; internal static ConfigEntry<bool> Glow; internal static ConfigEntry<bool> ShowGear; internal static ConfigEntry<string> CreatureOverrides; internal static ConfigEntry<KeyCode> BiggerKey; internal static ConfigEntry<KeyCode> SmallerKey; internal static ConfigEntry<KeyCode> TurnTrophyKey; internal static ConfigEntry<float> TrophyTurnStep; internal static ConfigEntry<KeyCode> ColorKey; internal static ConfigEntry<bool> EgoEnabled; internal static ConfigEntry<float> EgoRange; internal static ConfigEntry<float> EgoMinutesPerPedestal; internal static ConfigEntry<float> EgoMaxMinutes; internal static ConfigEntry<float> EgoDamage; internal static ConfigEntry<float> EgoStaminaRegen; internal static ConfigEntry<bool> EgoOnlyOwn; internal static int VisualRevision; internal static bool Headless; private void Awake() { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Invalid comparison between Unknown and I4 //IL_0060: 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_00ac: Expected O, but got Unknown //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Expected O, but got Unknown //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Expected O, but got Unknown //IL_0268: Unknown result type (might be due to invalid IL or missing references) //IL_0272: Expected O, but got Unknown //IL_02c5: Unknown result type (might be due to invalid IL or missing references) //IL_02cf: Expected O, but got Unknown //IL_0302: Unknown result type (might be due to invalid IL or missing references) //IL_030c: Expected O, but got Unknown //IL_033f: Unknown result type (might be due to invalid IL or missing references) //IL_0349: Expected O, but got Unknown //IL_037c: Unknown result type (might be due to invalid IL or missing references) //IL_0386: Expected O, but got Unknown //IL_03b9: Unknown result type (might be due to invalid IL or missing references) //IL_03c3: Expected O, but got Unknown //IL_0450: Unknown result type (might be due to invalid IL or missing references) Log = ((BaseUnityPlugin)this).Logger; Headless = (int)SystemInfo.graphicsDeviceType == 4; Cost = ((BaseUnityPlugin)this).Config.Bind<string>("1 - Pedestal", "Cost", "Stone:10,SurtlingCore:1", "What the Trophy Pedestal costs to build, as Item:Amount pairs separated by commas (prefab names). Restart the game after changing it."); DefaultColor = ((BaseUnityPlugin)this).Config.Bind<Color>("2 - Hologram", "DefaultColor", new Color(0.35f, 0.85f, 1f, 0.6f), "Color of a new pedestal's hologram (the alpha is how see-through it is). Each pedestal can then cycle through other colors with the ChangeColor key."); SpinSpeed = ((BaseUnityPlugin)this).Config.Bind<float>("2 - Hologram", "SpinSpeed", 12f, new ConfigDescription("How fast the hologram turns, in degrees per second.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 90f), Array.Empty<object>())); FitSize = ((BaseUnityPlugin)this).Config.Bind<float>("2 - Hologram", "AutoSize", 1.5f, new ConfigDescription("On the Auto size step, the hologram is scaled so its biggest side is this many meters.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.3f, 6f), Array.Empty<object>())); HoverHeight = ((BaseUnityPlugin)this).Config.Bind<float>("2 - Hologram", "HoverHeight", 0.45f, new ConfigDescription("How far above the trophy the hologram floats (meters).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 3f), Array.Empty<object>())); Animate = ((BaseUnityPlugin)this).Config.Bind<bool>("2 - Hologram", "Animate", true, "Play the creature's idle animation. Off = frozen pose."); Glow = ((BaseUnityPlugin)this).Config.Bind<bool>("2 - Hologram", "GlowLight", true, "Cast a small light in the hologram's color around the pedestal."); ShowGear = ((BaseUnityPlugin)this).Config.Bind<bool>("2 - Hologram", "ShowWeapons", true, "Show the weapons and shields that creatures like draugr, skeletons and fulings carry."); CreatureOverrides = ((BaseUnityPlugin)this).Config.Bind<string>("2 - Hologram", "CreatureOverrides", "", "Pick the creature shown for a trophy yourself, as Trophy=Creature pairs separated by commas, e.g. TrophySkeleton=Skeleton_Poison. Normally the mod works it out from what drops each trophy."); BiggerKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("3 - Keys", "Bigger", (KeyCode)61, "Look at a pedestal and press this to make its hologram bigger."); SmallerKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("3 - Keys", "Smaller", (KeyCode)45, "Look at a pedestal and press this to make its hologram smaller."); ColorKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("3 - Keys", "ChangeColor", (KeyCode)116, "Look at a pedestal and press this to change its hologram's color."); TurnTrophyKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("3 - Keys", "TurnTrophy", (KeyCode)114, "Look at a pedestal and press this to turn the trophy sitting on it. Hold Left Shift to turn it the other way."); TrophyTurnStep = ((BaseUnityPlugin)this).Config.Bind<float>("3 - Keys", "TrophyTurnStep", 15f, new ConfigDescription("How many degrees the trophy turns per press.", (AcceptableValueBase)(object)new AcceptableValueList<float>(new float[7] { 5f, 10f, 15f, 22.5f, 30f, 45f, 90f }), Array.Empty<object>())); EgoEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("4 - Ego", "Enabled", true, "Being near your trophy pedestals gives you the Ego buff (works like Rested)."); EgoRange = ((BaseUnityPlugin)this).Config.Bind<float>("4 - Ego", "Range", 20f, new ConfigDescription("How close (meters) a pedestal has to be to count.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(3f, 60f), Array.Empty<object>())); EgoMinutesPerPedestal = ((BaseUnityPlugin)this).Config.Bind<float>("4 - Ego", "MinutesPerPedestal", 2f, new ConfigDescription("Ego lasts this many minutes for each pedestal with a trophy near you.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.5f, 30f), Array.Empty<object>())); EgoMaxMinutes = ((BaseUnityPlugin)this).Config.Bind<float>("4 - Ego", "MaxMinutes", 20f, new ConfigDescription("Longest the Ego buff can last, however many pedestals there are.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 120f), Array.Empty<object>())); EgoDamage = ((BaseUnityPlugin)this).Config.Bind<float>("4 - Ego", "DamageBonus", 5f, new ConfigDescription("Extra damage (percent) while Ego is active.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 50f), Array.Empty<object>())); EgoStaminaRegen = ((BaseUnityPlugin)this).Config.Bind<float>("4 - Ego", "StaminaRegenBonus", 10f, new ConfigDescription("Extra stamina regeneration (percent) while Ego is active.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 100f), Array.Empty<object>())); EgoOnlyOwn = ((BaseUnityPlugin)this).Config.Bind<bool>("4 - Ego", "OnlyYourOwnPedestals", false, "Only pedestals you built count toward your Ego. Off = any pedestal near you counts."); ConfigEntryBase[] array = (ConfigEntryBase[])(object)new ConfigEntryBase[5] { (ConfigEntryBase)DefaultColor, (ConfigEntryBase)Animate, (ConfigEntryBase)Glow, (ConfigEntryBase)ShowGear, (ConfigEntryBase)CreatureOverrides }; foreach (ConfigEntryBase c in array) { ((BaseUnityPlugin)this).Config.SettingChanged += delegate(object _, SettingChangedEventArgs ev) { if (ev.ChangedSetting == c) { VisualRevision++; Hologram.ClearMaterials(); TrophyMap.Reset(); } }; } new Harmony("supermans.trophypedestal").PatchAll(); Log.LogInfo((object)"Supermans Trophy Pedestal 1.0.2 loaded"); } private void Update() { if (!((Object)(object)ZNet.instance == (Object)null) && !Headless) { Hologram.Pulse(); HandleKeys(); Ego.Tick(); } } private static void HandleKeys() { //IL_008b: Unknown result type (might be due to invalid IL or missing references) Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null || TypingOrMenu()) { return; } bool flag = KeyDown(BiggerKey); bool flag2 = KeyDown(SmallerKey); bool flag3 = KeyDown(ColorKey); bool flag4 = KeyDown(TurnTrophyKey); if (!flag && !flag2 && !flag3 && !flag4) { return; } GameObject hoverObject = ((Humanoid)localPlayer).GetHoverObject(); Pedestal pedestal = (((Object)(object)hoverObject != (Object)null) ? hoverObject.GetComponentInParent<Pedestal>() : null); if (!((Object)(object)pedestal == (Object)null) && pedestal.Valid && PrivateArea.CheckAccess(((Component)pedestal).transform.position, 0f, true, false)) { if (flag) { pedestal.RequestSize(1); } if (flag2) { pedestal.RequestSize(-1); } if (flag3) { pedestal.RequestColor(); } if (flag4 && pedestal.HasTrophy) { pedestal.RequestTrophyTurn((!Input.GetKey((KeyCode)304) && !Input.GetKey((KeyCode)303)) ? 1 : (-1)); } } } internal static bool TypingOrMenu() { if (!Console.IsVisible() && (!((Object)(object)Chat.instance != (Object)null) || !Chat.instance.HasFocus()) && !TextInput.IsVisible() && !Menu.IsVisible() && !InventoryGui.IsVisible() && !Minimap.IsOpen()) { return StoreGui.IsVisible(); } return true; } internal static bool KeyDown(ConfigEntry<KeyCode> k) { //IL_0001: 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) if ((int)k.Value != 0) { return Input.GetKeyDown(k.Value); } return false; } } internal static class TrophyMap { private static Dictionary<string, GameObject> _map; private static ZNetScene _builtFor; internal static void Reset() { _map = null; } internal static GameObject Creature(string trophy) { if (string.IsNullOrEmpty(trophy) || (Object)(object)ZNetScene.instance == (Object)null) { return null; } if (_map == null || (Object)(object)_builtFor != (Object)(object)ZNetScene.instance) { Build(); } if (!_map.TryGetValue(trophy, out var value)) { return null; } return value; } private static void Build() { //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Invalid comparison between Unknown and I4 ZNetScene val = (_builtFor = ZNetScene.instance); _map = new Dictionary<string, GameObject>(); Dictionary<string, List<GameObject>> dictionary = new Dictionary<string, List<GameObject>>(); foreach (GameObject prefab2 in val.m_prefabs) { if ((Object)(object)prefab2 == (Object)null || (Object)(object)prefab2.GetComponent<Character>() == (Object)null) { continue; } CharacterDrop component = prefab2.GetComponent<CharacterDrop>(); if ((Object)(object)component == (Object)null || component.m_drops == null) { continue; } foreach (Drop drop in component.m_drops) { ItemDrop val2 = (((Object)(object)drop?.m_prefab != (Object)null) ? drop.m_prefab.GetComponent<ItemDrop>() : null); if (!((Object)(object)val2 == (Object)null) && (int)val2.m_itemData.m_shared.m_itemType == 13) { if (!dictionary.TryGetValue(((Object)drop.m_prefab).name, out var value)) { value = (dictionary[((Object)drop.m_prefab).name] = new List<GameObject>()); } if (!value.Contains(prefab2)) { value.Add(prefab2); } } } } foreach (KeyValuePair<string, List<GameObject>> item in dictionary) { GameObject value2 = null; int num = int.MinValue; foreach (GameObject item2 in item.Value) { int num2 = Score(item.Key, ((Object)item2).name); if (num2 > num) { num = num2; value2 = item2; } } _map[item.Key] = value2; } string[] array = (Plugin.CreatureOverrides.Value ?? "").Split(new char[1] { ',' }); for (int i = 0; i < array.Length; i++) { string[] array2 = array[i].Split(new char[1] { '=' }); if (array2.Length == 2) { GameObject prefab = val.GetPrefab(array2[1].Trim()); if ((Object)(object)prefab != (Object)null && (Object)(object)prefab.GetComponent<Character>() != (Object)null) { _map[array2[0].Trim()] = prefab; } else { Plugin.Log.LogWarning((object)("CreatureOverrides: unknown creature '" + array2[1].Trim() + "'")); } } } Plugin.Log.LogInfo((object)$"Found creatures for {_map.Count} trophies"); } private static int Score(string trophy, string creature) { string text = Norm(trophy.StartsWith("Trophy") ? trophy.Substring(6) : trophy); string text2 = Norm(creature); int num = 0; if (text2 == text) { num = 1000; } else if (text2.StartsWith(text) || text.StartsWith(text2)) { num = 500; } else if (text2.Contains(text) || text.Contains(text2)) { num = 300; } return num - text2.Length; } private static string Norm(string s) { return s.Replace("_", "").Replace(" ", "").ToLowerInvariant(); } } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public IgnoresAccessChecksToAttribute(string assemblyName) { } } }