ScoutMaidOverrideData.cs 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263
  1. using System;
  2. using System.IO;
  3. using MaidStatus;
  4. using UnityEngine;
  5. using wf;
  6. namespace scoutmode
  7. {
  8. public class ScoutMaidOverrideData : ICloneable
  9. {
  10. public string guid { get; private set; }
  11. public bool enabled { get; private set; }
  12. public void CreateStatus(ScoutMaidData.SimpleStatus status)
  13. {
  14. this.enabled = true;
  15. this.guid = Guid.NewGuid().ToString();
  16. this.status.SetStatus(status);
  17. }
  18. public void Apply(Maid maid)
  19. {
  20. if (!this.enabled)
  21. {
  22. return;
  23. }
  24. if (!string.IsNullOrEmpty(this.guid))
  25. {
  26. maid.status.SetNewGuidAndCreationTime(this.guid, maid.status.creationTime);
  27. }
  28. MaidStatus.Status status = maid.status;
  29. status.SetPersonal(this.status.personalId);
  30. status.seikeiken = (status.initSeikeiken = this.status.seikeiken);
  31. status.baseLovely = this.status.lovely;
  32. status.baseElegance = this.status.elegance;
  33. status.baseCharm = this.status.charm;
  34. status.baseCooking = this.status.cooking;
  35. status.baseDance = this.status.dance;
  36. status.baseVocal = this.status.vocal;
  37. status.baseInyoku = this.status.inyoku;
  38. status.baseMvalue = this.status.mvalue;
  39. status.baseHentai = this.status.hentai;
  40. status.baseHousi = this.status.housi;
  41. }
  42. public void Destroy()
  43. {
  44. this.enabled = false;
  45. }
  46. public byte[] Serialize()
  47. {
  48. MemoryStream memoryStream = new MemoryStream();
  49. BinaryWriter binaryWriter = new BinaryWriter(memoryStream);
  50. binaryWriter.Write("COM3D2_SCOUT_OVERRIDE_DATA");
  51. binaryWriter.Write(1000);
  52. binaryWriter.Write((this.guid != null) ? this.guid : string.Empty);
  53. binaryWriter.Write(JsonUtility.ToJson(this.status));
  54. binaryWriter.Write(this.enabled);
  55. int num = (this.iconImageBinary != null && this.iconImageBinary.Length > 0) ? this.iconImageBinary.Length : 0;
  56. binaryWriter.Write(num);
  57. if (num > 0)
  58. {
  59. binaryWriter.Write(this.iconImageBinary);
  60. }
  61. num = ((this.pressetBinary != null && this.pressetBinary.Length > 0) ? this.pressetBinary.Length : 0);
  62. binaryWriter.Write(num);
  63. if (num > 0)
  64. {
  65. binaryWriter.Write(this.pressetBinary);
  66. }
  67. return memoryStream.ToArray();
  68. }
  69. public void DeSerialize(byte[] data)
  70. {
  71. MemoryStream input = new MemoryStream(data);
  72. BinaryReader binaryReader = new BinaryReader(input);
  73. NDebug.Assert(binaryReader.ReadString() == "COM3D2_SCOUT_OVERRIDE_DATA", "ScoutMaidData::ScoutMaidOverrideData::DeSerialize Header Check error.");
  74. int num = binaryReader.ReadInt32();
  75. this.guid = binaryReader.ReadString();
  76. this.status = JsonUtility.FromJson<ScoutMaidOverrideData.Status>(binaryReader.ReadString());
  77. this.enabled = binaryReader.ReadBoolean();
  78. int num2 = binaryReader.ReadInt32();
  79. this.iconImageBinary = ((num2 > 0) ? binaryReader.ReadBytes(num2) : null);
  80. num2 = binaryReader.ReadInt32();
  81. this.pressetBinary = ((num2 > 0) ? binaryReader.ReadBytes(num2) : null);
  82. }
  83. public object Clone()
  84. {
  85. ScoutMaidOverrideData scoutMaidOverrideData = (ScoutMaidOverrideData)base.MemberwiseClone();
  86. scoutMaidOverrideData.status = JsonUtility.FromJson<ScoutMaidOverrideData.Status>(JsonUtility.ToJson(this.status));
  87. scoutMaidOverrideData.iconImageBinary = ((this.iconImageBinary != null && this.iconImageBinary.Length > 0) ? ((byte[])this.iconImageBinary.Clone()) : null);
  88. scoutMaidOverrideData.pressetBinary = ((this.pressetBinary != null && this.pressetBinary.Length > 0) ? ((byte[])this.pressetBinary.Clone()) : null);
  89. return scoutMaidOverrideData;
  90. }
  91. private const int FixVersion = 1000;
  92. public ScoutMaidOverrideData.Status status = new ScoutMaidOverrideData.Status();
  93. public byte[] iconImageBinary;
  94. public byte[] pressetBinary;
  95. [Serializable]
  96. public class Status : ISerializationCallbackReceiver
  97. {
  98. public Personal.Data personal
  99. {
  100. get
  101. {
  102. return Personal.GetData(this.personalId);
  103. }
  104. }
  105. public void SetStatus(ScoutMaidData.SimpleStatus status)
  106. {
  107. this.personalId = status.personalId;
  108. this.seikeiken = status.seikeiken;
  109. this.lovely = status.lovely;
  110. this.elegance = status.elegance;
  111. this.charm = status.charm;
  112. this.cooking = status.cooking;
  113. this.dance = status.dance;
  114. this.vocal = status.vocal;
  115. this.inyoku = status.inyoku;
  116. this.mvalue = status.mvalue;
  117. this.hentai = status.hentai;
  118. this.housi = status.housi;
  119. }
  120. public void ClearStatus()
  121. {
  122. this.lovely = 0;
  123. this.elegance = 0;
  124. this.charm = 0;
  125. this.cooking = 0;
  126. this.dance = 0;
  127. this.vocal = 0;
  128. this.inyoku = 0;
  129. this.mvalue = 0;
  130. this.hentai = 0;
  131. this.housi = 0;
  132. }
  133. public bool AddRandomStatusValue(int value)
  134. {
  135. switch (UnityEngine.Random.Range(0, 10))
  136. {
  137. case 0:
  138. if (this.lovely == 9999)
  139. {
  140. return false;
  141. }
  142. this.lovely = wf.Math.Round4(this.lovely + value);
  143. break;
  144. case 1:
  145. if (this.elegance == 9999)
  146. {
  147. return false;
  148. }
  149. this.elegance = wf.Math.Round4(this.elegance + value);
  150. break;
  151. case 2:
  152. if (this.charm == 9999)
  153. {
  154. return false;
  155. }
  156. this.charm = wf.Math.Round4(this.charm + value);
  157. break;
  158. case 3:
  159. if (this.cooking == 9999)
  160. {
  161. return false;
  162. }
  163. this.cooking = wf.Math.Round4(this.cooking + value);
  164. break;
  165. case 4:
  166. if (this.dance == 9999)
  167. {
  168. return false;
  169. }
  170. this.dance = wf.Math.Round4(this.dance + value);
  171. break;
  172. case 5:
  173. if (this.vocal == 9999)
  174. {
  175. return false;
  176. }
  177. this.vocal = wf.Math.Round4(this.vocal + value);
  178. break;
  179. case 6:
  180. if (this.inyoku == 9999)
  181. {
  182. return false;
  183. }
  184. this.inyoku = wf.Math.Round4(this.inyoku + value);
  185. break;
  186. case 7:
  187. if (this.mvalue == 9999)
  188. {
  189. return false;
  190. }
  191. this.mvalue = wf.Math.Round4(this.mvalue + value);
  192. break;
  193. case 8:
  194. if (this.hentai == 9999)
  195. {
  196. return false;
  197. }
  198. this.hentai = wf.Math.Round4(this.hentai + value);
  199. break;
  200. case 9:
  201. if (this.housi == 9999)
  202. {
  203. return false;
  204. }
  205. this.housi = wf.Math.Round4(this.housi + value);
  206. break;
  207. }
  208. return true;
  209. }
  210. public void OnBeforeSerialize()
  211. {
  212. this.version = 1000;
  213. }
  214. public void OnAfterDeserialize()
  215. {
  216. }
  217. public int version = 1000;
  218. public int personalId;
  219. public Seikeiken seikeiken;
  220. public int lovely;
  221. public int elegance;
  222. public int charm;
  223. public int cooking;
  224. public int dance;
  225. public int vocal;
  226. public int inyoku;
  227. public int mvalue;
  228. public int hentai;
  229. public int housi;
  230. }
  231. }
  232. }