CommonUtil.cs 2.5 KB

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