|
9 | 9 | using Exiled.Events.EventArgs.Player;
|
10 | 10 | using InventorySystem.Items.ThrowableProjectiles;
|
11 | 11 | using InventorySystem.Items.Jailbird;
|
| 12 | +using InventorySystem.Items.MicroHID; |
12 | 13 | using MEC;
|
13 | 14 |
|
14 | 15 | namespace UsefulHints.EventHandlers.Items
|
@@ -49,47 +50,42 @@ public static void UnregisterEvents()
|
49 | 50 | }
|
50 | 51 | private static void OnPickingUpMicroHid(PickingUpItemEventArgs ev)
|
51 | 52 | {
|
52 |
| - if (ev.Pickup.Type == ItemType.MicroHID) |
| 53 | + if (ev.Pickup.Base is MicroHIDPickup microHidPickup) |
53 | 54 | {
|
54 |
| - var microHidPickup = ev.Pickup.Base as InventorySystem.Items.MicroHID.MicroHIDPickup; |
| 55 | + float energyPercentage = microHidPickup.Energy * 100; |
| 56 | + float roundedEnergyPercentage = (float)Math.Round(energyPercentage, 1); |
55 | 57 |
|
56 |
| - if (microHidPickup != null) |
| 58 | + if (roundedEnergyPercentage < 5) |
57 | 59 | {
|
58 |
| - float energyPercentage = microHidPickup.Energy * 100; |
59 |
| - float roundedEnergyPercentage = (float)Math.Round(energyPercentage, 1); |
60 |
| - |
61 |
| - if (roundedEnergyPercentage < 5) |
62 |
| - { |
63 |
| - ev.Player.ShowHint($"<color=red>{string.Format(UsefulHints.Instance.Config.MicroLowEnergyMessage)}</color>", 4); |
64 |
| - } |
65 |
| - else |
66 |
| - { |
67 |
| - ev.Player.ShowHint($"<color=#4169E1>{string.Format(UsefulHints.Instance.Config.MicroEnergyMessage, roundedEnergyPercentage)}</color>", 4); |
68 |
| - } |
| 60 | + ev.Player.ShowHint($"<color=red>{string.Format(UsefulHints.Instance.Config.MicroLowEnergyMessage)}</color>", 4); |
| 61 | + } |
| 62 | + else |
| 63 | + { |
| 64 | + ev.Player.ShowHint($"<color=#4169E1>{string.Format(UsefulHints.Instance.Config.MicroEnergyMessage, roundedEnergyPercentage)}</color>", 4); |
69 | 65 | }
|
70 | 66 | }
|
71 | 67 | }
|
72 | 68 | public static void OnEquipMicroHid(ChangingItemEventArgs ev)
|
73 | 69 | {
|
74 | 70 | if (UsefulHints.Instance.Config.ShowHintOnEquip)
|
75 | 71 | {
|
76 |
| - if (ev.Item.Type == ItemType.MicroHID) |
| 72 | + if (ev.Item == null) |
| 73 | + { |
| 74 | + return; |
| 75 | + } |
| 76 | + if (ev.Item.Base is MicroHIDItem microHidItem) |
77 | 77 | {
|
78 |
| - var microHidItem = ev.Item.Base as InventorySystem.Items.MicroHID.MicroHIDItem; |
79 | 78 |
|
80 |
| - if (microHidItem != null) |
81 |
| - { |
82 |
| - float energyPercentage = microHidItem.RemainingEnergy * 100; |
83 |
| - float roundedEnergyPercentage = (float)Math.Round(energyPercentage, 1); |
| 79 | + float energyPercentage = microHidItem.RemainingEnergy * 100; |
| 80 | + float roundedEnergyPercentage = (float)Math.Round(energyPercentage, 1); |
84 | 81 |
|
85 |
| - if (roundedEnergyPercentage < 5) |
86 |
| - { |
87 |
| - ev.Player.ShowHint($"<color=red>{string.Format(UsefulHints.Instance.Config.MicroLowEnergyMessage)}</color>", 4); |
88 |
| - } |
89 |
| - else |
90 |
| - { |
91 |
| - ev.Player.ShowHint($"<color=#4169E1>{string.Format(UsefulHints.Instance.Config.MicroEnergyMessage, roundedEnergyPercentage)}</color>", 4); |
92 |
| - } |
| 82 | + if (roundedEnergyPercentage < 5) |
| 83 | + { |
| 84 | + ev.Player.ShowHint($"<color=red>{new string('\n', 10)}{string.Format(UsefulHints.Instance.Config.MicroLowEnergyMessage)}</color>", 4); |
| 85 | + } |
| 86 | + else |
| 87 | + { |
| 88 | + ev.Player.ShowHint($"<color=#4169E1>{new string('\n', 10)}{string.Format(UsefulHints.Instance.Config.MicroEnergyMessage, roundedEnergyPercentage)}</color>", 4); |
93 | 89 | }
|
94 | 90 | }
|
95 | 91 | }
|
@@ -259,27 +255,26 @@ private static void OnPickingUpJailbird(PickingUpItemEventArgs ev)
|
259 | 255 | }
|
260 | 256 | }
|
261 | 257 | }
|
262 |
| - private static void OnEquipJailbird(ChangingItemEventArgs ev) |
| 258 | + public static void OnEquipJailbird(ChangingItemEventArgs ev) |
263 | 259 | {
|
264 | 260 | if (UsefulHints.Instance.Config.ShowHintOnEquip)
|
265 | 261 | {
|
266 |
| - if (ev.Item.Type == ItemType.Jailbird) |
| 262 | + if (ev.Item == null) |
267 | 263 | {
|
268 |
| - var jailbirdItem = ev.Item.Base as JailbirdItem; |
| 264 | + return; |
| 265 | + } |
| 266 | + if (ev.Item.Base is JailbirdItem jailbirdItem) |
| 267 | + { |
| 268 | + int maxCharges = 5; |
| 269 | + int remainingCharges = maxCharges - jailbirdItem.TotalChargesPerformed; |
269 | 270 |
|
270 |
| - if (jailbirdItem != null) |
| 271 | + if (remainingCharges > 1) |
271 | 272 | {
|
272 |
| - int maxCharges = 5; |
273 |
| - int remainingCharges = maxCharges - jailbirdItem.TotalChargesPerformed; |
274 |
| - |
275 |
| - if (remainingCharges > 1) |
276 |
| - { |
277 |
| - ev.Player.ShowHint($"<color=#00B7EB>{string.Format(UsefulHints.Instance.Config.JailbirdUseMessage, remainingCharges)}</color>", 4); |
278 |
| - } |
279 |
| - else |
280 |
| - { |
281 |
| - ev.Player.ShowHint($"<color=#C73804>{string.Format(UsefulHints.Instance.Config.JailbirdUseMessage, remainingCharges)}</color>", 4); |
282 |
| - } |
| 273 | + ev.Player.ShowHint($"<color=#00B7EB>{new string('\n', 10)}{string.Format(UsefulHints.Instance.Config.JailbirdUseMessage, remainingCharges)}</color>", 4); |
| 274 | + } |
| 275 | + else |
| 276 | + { |
| 277 | + ev.Player.ShowHint($"<color=#C73804>{new string('\n', 10)}{string.Format(UsefulHints.Instance.Config.JailbirdUseMessage, remainingCharges)}</color>", 4); |
283 | 278 | }
|
284 | 279 | }
|
285 | 280 | }
|
|
0 commit comments