CommonUtil.cs 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text.RegularExpressions;
  4. using UnityEngine;
  5. namespace COM3D2.PropMyItem.Plugin
  6. {
  7. // Token: 0x02000003 RID: 3
  8. public class CommonUtil
  9. {
  10. public enum ModKey
  11. {
  12. Control, Alt, Shift
  13. }
  14. // Token: 0x06000003 RID: 3 RVA: 0x000022A0 File Offset: 0x000004A0
  15. public static void Log(string text)
  16. {
  17. try
  18. {
  19. Console.WriteLine(string.Format("{0}({1}) : {2}", "PropMyItem", "2.3.0.0", text));
  20. }
  21. catch
  22. {
  23. }
  24. }
  25. // Token: 0x06000004 RID: 4 RVA: 0x000022DC File Offset: 0x000004DC
  26. public static string WildCardMatchEvaluator(Match match)
  27. {
  28. string value = match.Value;
  29. if (value.Equals("?"))
  30. {
  31. return ".";
  32. }
  33. if (value.Equals("*"))
  34. {
  35. return ".*";
  36. }
  37. return Regex.Escape(value);
  38. }
  39. // Token: 0x06000005 RID: 5 RVA: 0x0000231C File Offset: 0x0000051C
  40. public static Maid GetVisibleMaid(int index)
  41. {
  42. Maid result = null;
  43. try
  44. {
  45. List<Maid> visibleMaidList = CommonUtil.GetVisibleMaidList();
  46. if (visibleMaidList.Count > index)
  47. {
  48. result = visibleMaidList[index];
  49. }
  50. }
  51. catch (Exception ex)
  52. {
  53. CommonUtil.Log(ex.ToString());
  54. }
  55. return result;
  56. }
  57. // Token: 0x06000006 RID: 6 RVA: 0x00002364 File Offset: 0x00000564
  58. public static List<Maid> GetVisibleMaidList()
  59. {
  60. List<Maid> list = new List<Maid>();
  61. CharacterMgr characterMgr = GameMain.Instance.CharacterMgr;
  62. int maidCount = characterMgr.GetMaidCount();
  63. for (int i = 0; i < maidCount; i++)
  64. {
  65. Maid maid = characterMgr.GetMaid(i);
  66. if (maid != null && maid.isActiveAndEnabled && maid.Visible)
  67. {
  68. list.Add(maid);
  69. }
  70. }
  71. int stockMaidCount = characterMgr.GetStockMaidCount();
  72. for (int j = 0; j < stockMaidCount; j++)
  73. {
  74. Maid stockMaid = characterMgr.GetStockMaid(j);
  75. if (stockMaid != null && stockMaid.isActiveAndEnabled && stockMaid.Visible && !list.Contains(stockMaid))
  76. {
  77. list.Add(stockMaid);
  78. }
  79. }
  80. return list;
  81. }
  82. // Token: 0x06000007 RID: 7 RVA: 0x00002418 File Offset: 0x00000618
  83. public static string GetSelectedMenuFileName(MPN? mpn, Maid maid)
  84. {
  85. string result = string.Empty;
  86. if (mpn != null)
  87. {
  88. MPN? mpn2 = mpn;
  89. MPN mpn3 = MPN.set_maidwear;
  90. if (!(mpn2.GetValueOrDefault() == mpn3 & mpn2 != null))
  91. {
  92. mpn2 = mpn;
  93. mpn3 = MPN.set_mywear;
  94. if (!(mpn2.GetValueOrDefault() == mpn3 & mpn2 != null))
  95. {
  96. mpn2 = mpn;
  97. mpn3 = MPN.set_underwear;
  98. if (!(mpn2.GetValueOrDefault() == mpn3 & mpn2 != null))
  99. {
  100. result = maid.GetProp(mpn.Value).strFileName;
  101. }
  102. }
  103. }
  104. }
  105. return result;
  106. }
  107. public static bool IsModKey(ModKey key)
  108. {
  109. switch (key)
  110. {
  111. case ModKey.Control: return Input.GetKey(KeyCode.LeftControl) || Input.GetKey(KeyCode.RightControl);
  112. case ModKey.Alt: return Input.GetKey(KeyCode.LeftAlt) || Input.GetKey(KeyCode.RightAlt);
  113. case ModKey.Shift: return Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift);
  114. default: return false;
  115. }
  116. }
  117. }
  118. }