EmpireLifeModeManager.cs 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.IO;
  5. using System.Linq;
  6. using System.Runtime.CompilerServices;
  7. using FacilityFlag;
  8. using UnityEngine;
  9. public class EmpireLifeModeManager : MonoBehaviour
  10. {
  11. public List<EmpireLifeModeManager.EventDataObject> nowEventList
  12. {
  13. get
  14. {
  15. return this.m_EventList;
  16. }
  17. }
  18. public Dictionary<Facility, List<Maid>> nowMaidAllocationDic
  19. {
  20. get
  21. {
  22. return this.m_NowMaidAllocationDic;
  23. }
  24. }
  25. public List<EmpireLifeModeManager.EventDataObject> executedEventList
  26. {
  27. get
  28. {
  29. return this.m_ExecutedEventList;
  30. }
  31. }
  32. public List<Maid> lifeModeAllMaidList
  33. {
  34. get
  35. {
  36. return this.m_LifeModeAllMaidList;
  37. }
  38. }
  39. public void SetAllMaidList(IEnumerable<Maid> maidCorrection)
  40. {
  41. this.m_LifeModeAllMaidList = new List<Maid>(maidCorrection);
  42. }
  43. public void UpdateAllMaidList()
  44. {
  45. this.m_LifeModeAllMaidList = new List<Maid>(from maid in this.m_LifeModeAllMaidList
  46. where maid != null
  47. select maid);
  48. }
  49. public List<Maid> executedMaidList
  50. {
  51. get
  52. {
  53. return this.m_ExecutedMaidList;
  54. }
  55. }
  56. private void CreateAndCacheEvent(EmpireLifeModeData.Data data, Facility targetFacility, IEnumerable<Maid> targetMaidList)
  57. {
  58. EmpireLifeModeManager.EventDataObject eventDataObject = new EmpireLifeModeManager.EventDataObject();
  59. eventDataObject.targetEvent = data;
  60. eventDataObject.targetFacility = targetFacility;
  61. eventDataObject.targetMaidList = new List<Maid>(targetMaidList);
  62. this.nowEventList.Add(eventDataObject);
  63. }
  64. public void CreateStoryEvent()
  65. {
  66. if (this.nowEventList.Exists((EmpireLifeModeManager.EventDataObject d) => d.targetEvent.dataScenarioType == EmpireLifeModeData.ScenarioType.スト\u30FCリ\u30FC))
  67. {
  68. Debug.Log("既にストーリーイベントが存在していたので、ストーリーイベントの追加は行いません。");
  69. return;
  70. }
  71. if (this.executedEventList.Exists((EmpireLifeModeManager.EventDataObject d) => d.targetEvent.dataScenarioType == EmpireLifeModeData.ScenarioType.スト\u30FCリ\u30FC))
  72. {
  73. Debug.Log("既にストーリーイベントは実行された後なので、ストーリーイベントの追加は行いません。");
  74. return;
  75. }
  76. List<EmpireLifeModeData.Data> datas = EmpireLifeModeData.GetDatas((EmpireLifeModeData.Data d) => EmpireLifeModeData.IsEnabled(d.ID) && d.dataScenarioType == EmpireLifeModeData.ScenarioType.スト\u30FCリ\u30FC, true);
  77. if (datas == null || datas.Count <= 0)
  78. {
  79. Debug.Log("種類が「ストーリー」であるイベントは存在しなかった。");
  80. return;
  81. }
  82. foreach (EmpireLifeModeData.Data data in datas)
  83. {
  84. if (data.IsCorrectScenarioAnyNumberPlay())
  85. {
  86. if (data.IsCorrectUniqueComparisonObject())
  87. {
  88. List<Facility> correctFacilityList = data.GetCorrectFacilityList();
  89. if (correctFacilityList != null && correctFacilityList.Count > 0)
  90. {
  91. List<Maid> list;
  92. if (EmpireLifeModeManager.TryGetMaidListOfEventDataBodyTypeEquals(data, this.GetNotAllocatedMaidList(this.lifeModeAllMaidList), out list))
  93. {
  94. Facility facility = correctFacilityList[UnityEngine.Random.Range(0, correctFacilityList.Count)];
  95. this.CreateAndCacheEvent(data, facility, list);
  96. if (!this.nowMaidAllocationDic.ContainsKey(facility))
  97. {
  98. this.nowMaidAllocationDic.Add(facility, new List<Maid>());
  99. }
  100. this.nowMaidAllocationDic[facility].AddRange(list);
  101. break;
  102. }
  103. }
  104. }
  105. }
  106. }
  107. }
  108. public void CreateRandomEventOfNowState()
  109. {
  110. Debug.Log("イベント基準で何かしらのイベントを作成します。");
  111. List<EmpireLifeModeData.Data> datas = EmpireLifeModeData.GetDatas((EmpireLifeModeData.Data data) => data.IsCorrectUniqueComparisonObject() && data.dataScenarioType != EmpireLifeModeData.ScenarioType.スト\u30FCリ\u30FC && data.dataMaidPersonalUniqueNameAndActiveSlotDic.Count > 1 && !this.nowEventList.Exists((EmpireLifeModeManager.EventDataObject d) => d.targetEvent.ID == data.ID) && !this.executedEventList.Exists((EmpireLifeModeManager.EventDataObject d) => d.targetEvent.ID == data.ID), true);
  112. IOrderedEnumerable<EmpireLifeModeData.Data> orderedEnumerable = from d in datas
  113. orderby d.dataMaidPersonalUniqueNameAndActiveSlotDic.Count descending, this.GetScenarioExecuteCount(d.ID)
  114. select d;
  115. foreach (EmpireLifeModeData.Data data2 in orderedEnumerable)
  116. {
  117. List<Facility> correctFacilityList = data2.GetCorrectFacilityList();
  118. foreach (KeyValuePair<Facility, List<Maid>> keyValuePair in this.nowMaidAllocationDic)
  119. {
  120. if (correctFacilityList.Contains(keyValuePair.Key) && 3 - keyValuePair.Value.Count < data2.dataMaidPersonalUniqueNameAndActiveSlotDic.Count)
  121. {
  122. correctFacilityList.Remove(keyValuePair.Key);
  123. }
  124. }
  125. if (correctFacilityList != null && correctFacilityList.Count > 0)
  126. {
  127. List<Maid> list;
  128. if (EmpireLifeModeManager.TryGetMaidListOfEventDataBodyTypeEquals(data2, this.GetNotAllocatedMaidList(this.lifeModeAllMaidList), out list))
  129. {
  130. Facility facility = correctFacilityList[UnityEngine.Random.Range(0, correctFacilityList.Count)];
  131. this.CreateAndCacheEvent(data2, facility, list);
  132. if (!this.nowMaidAllocationDic.ContainsKey(facility))
  133. {
  134. this.nowMaidAllocationDic.Add(facility, new List<Maid>());
  135. }
  136. this.nowMaidAllocationDic[facility].AddRange(list);
  137. break;
  138. }
  139. }
  140. }
  141. }
  142. public void AllMaidRandomAllocate()
  143. {
  144. Dictionary<Facility, int> dictionary = new Dictionary<Facility, int>();
  145. foreach (Facility key in EmpireLifeModeAPI.GetEnabledFacilityList())
  146. {
  147. int num = 0;
  148. if (!this.nowMaidAllocationDic.ContainsKey(key))
  149. {
  150. this.nowMaidAllocationDic.Add(key, new List<Maid>());
  151. }
  152. else if (this.nowMaidAllocationDic[key] != null)
  153. {
  154. num = this.nowMaidAllocationDic[key].Count;
  155. }
  156. else
  157. {
  158. num = 0;
  159. }
  160. if (num < 3)
  161. {
  162. if (!dictionary.ContainsKey(key))
  163. {
  164. dictionary.Add(key, num);
  165. }
  166. }
  167. }
  168. List<Maid> notAllocatedMaidList = this.GetNotAllocatedMaidList(this.lifeModeAllMaidList);
  169. from maid in notAllocatedMaidList
  170. orderby UnityEngine.Random.Range(0, 100)
  171. select maid;
  172. foreach (Maid item in notAllocatedMaidList)
  173. {
  174. List<Facility> list = new List<Facility>(dictionary.Keys);
  175. List<int> list2 = new List<int>(dictionary.Values);
  176. int index = UnityEngine.Random.Range(0, dictionary.Count);
  177. this.nowMaidAllocationDic[list[index]].Add(item);
  178. Dictionary<Facility, int> dictionary2;
  179. Facility key2;
  180. if (((dictionary2 = dictionary)[key2 = list[index]] = dictionary2[key2] + 1) >= 3)
  181. {
  182. dictionary.Remove(list[index]);
  183. if (dictionary.Count <= 0)
  184. {
  185. break;
  186. }
  187. }
  188. }
  189. }
  190. public void CreateEventListOfMaidAllocateData()
  191. {
  192. foreach (KeyValuePair<Facility, List<Maid>> keyValuePair in this.nowMaidAllocationDic)
  193. {
  194. Facility facility = keyValuePair.Key;
  195. List<Maid> list = new List<Maid>(keyValuePair.Value);
  196. foreach (EmpireLifeModeManager.EventDataObject eventDataObject in from d in this.nowEventList
  197. where d.targetFacility == facility
  198. select d)
  199. {
  200. foreach (Maid item in eventDataObject.targetMaidList)
  201. {
  202. list.Remove(item);
  203. }
  204. }
  205. List<EmpireLifeModeData.Data> datas = EmpireLifeModeData.GetDatas((EmpireLifeModeData.Data data) => data.IsCorrectUniqueComparisonObject() && data.dataScenarioType != EmpireLifeModeData.ScenarioType.スト\u30FCリ\u30FC && data.IsCorrectFacility(facility.defaultName) && data.IsCorrectScenarioAnyNumberPlay(), true);
  206. IOrderedEnumerable<EmpireLifeModeData.Data> source = from d in datas
  207. orderby d.dataMaidPersonalUniqueNameAndActiveSlotDic.Count descending
  208. select d;
  209. if (EmpireLifeModeManager.<>f__mg$cache0 == null)
  210. {
  211. EmpireLifeModeManager.<>f__mg$cache0 = new Func<EmpireLifeModeData.Data, int>(EmpireLifeModeAPI.GetPriorityScenarioType);
  212. }
  213. IOrderedEnumerable<EmpireLifeModeData.Data> orderedEnumerable = source.ThenByDescending(EmpireLifeModeManager.<>f__mg$cache0);
  214. Dictionary<int, int> eventSelectCountDic = new Dictionary<int, int>();
  215. foreach (EmpireLifeModeData.Data data3 in orderedEnumerable)
  216. {
  217. eventSelectCountDic.Add(data3.ID, 0);
  218. }
  219. while (list.Count > 0)
  220. {
  221. bool flag = false;
  222. foreach (EmpireLifeModeData.Data data2 in orderedEnumerable.ThenBy((EmpireLifeModeData.Data d) => eventSelectCountDic[d.ID]).ThenBy((EmpireLifeModeData.Data d) => UnityEngine.Random.Range(0, 10)))
  223. {
  224. List<Maid> list2;
  225. if (EmpireLifeModeManager.TryGetMaidListOfEventDataBodyTypeEquals(data2, list, out list2))
  226. {
  227. this.CreateAndCacheEvent(data2, facility, list2);
  228. Dictionary<int, int> eventSelectCountDic2;
  229. int id;
  230. (eventSelectCountDic2 = eventSelectCountDic)[id = data2.ID] = eventSelectCountDic2[id] + 1;
  231. flag = true;
  232. foreach (Maid item2 in list2)
  233. {
  234. list.Remove(item2);
  235. }
  236. if (list.Count == 0)
  237. {
  238. break;
  239. }
  240. }
  241. }
  242. if (!flag)
  243. {
  244. break;
  245. }
  246. }
  247. }
  248. }
  249. public void DeleteNowEventList()
  250. {
  251. this.nowEventList.Clear();
  252. this.nowMaidAllocationDic.Clear();
  253. }
  254. public void OnTimeZoneChanged()
  255. {
  256. this.nowEventList.Clear();
  257. this.nowMaidAllocationDic.Clear();
  258. this.executedEventList.Clear();
  259. this.executedMaidList.Clear();
  260. this.UpdateAllMaidList();
  261. EmpireLifeModeAPI.DestroyScenarioTypeIconDic();
  262. }
  263. public void OnNextDay()
  264. {
  265. this.nowEventList.Clear();
  266. this.nowMaidAllocationDic.Clear();
  267. this.executedEventList.Clear();
  268. this.executedMaidList.Clear();
  269. }
  270. public void SetupScenarioEvent(EmpireLifeModeManager.EventDataObject eventObj, Action OnComplete)
  271. {
  272. base.StartCoroutine(this.CoSetupScenarioEvent(eventObj, OnComplete));
  273. GameMain.Instance.ScriptMgr.EvalScript("&tf['scenario_file_name'] = '" + eventObj.targetEvent.dataScenarioFileName + "';");
  274. GameMain.Instance.ScriptMgr.EvalScript("&tf['label_name'] = '" + eventObj.targetEvent.dataScenarioFileLabel + "';");
  275. this.nowEventList.Remove(eventObj);
  276. this.executedEventList.Add(eventObj);
  277. foreach (Maid maid in eventObj.targetMaidList)
  278. {
  279. this.IncrementMaidScenarioExecuteCount(eventObj.targetEvent.ID, maid);
  280. }
  281. foreach (Maid item in eventObj.targetMaidList)
  282. {
  283. this.executedMaidList.Add(item);
  284. }
  285. }
  286. private IEnumerator CoSetupScenarioEvent(EmpireLifeModeManager.EventDataObject eventObj, Action OnComplete)
  287. {
  288. EmpireLifeModeData.Data data = eventObj.targetEvent;
  289. List<Maid> targetMaidList = new List<Maid>(eventObj.targetMaidList);
  290. foreach (KeyValuePair<int, string> maidPersonalSlotPair in data.dataMaidPersonalUniqueNameAndActiveSlotDic)
  291. {
  292. int slotNo = maidPersonalSlotPair.Key;
  293. string personalUniqueName = maidPersonalSlotPair.Value;
  294. Maid maid = targetMaidList.Find((Maid m) => m.status.personal.uniqueName == personalUniqueName);
  295. targetMaidList.Remove(maid);
  296. GameMain.Instance.CharacterMgr.SetActiveMaid(maid, slotNo);
  297. maid.Visible = true;
  298. maid.AllProcPropSeqStart();
  299. while (maid.IsBusy)
  300. {
  301. yield return null;
  302. }
  303. if (data.dataFacilityCostumeChange)
  304. {
  305. if (eventObj.targetFacility.typeCostume == Facility.CostumeType.Default)
  306. {
  307. eventObj.targetFacility.UpdateMaidCostumeToDefaultCostume(maid);
  308. }
  309. else if (eventObj.targetFacility.typeCostume == Facility.CostumeType.Edit)
  310. {
  311. eventObj.targetFacility.UpdateMaidCostumeToEditCostume(maid, false);
  312. }
  313. }
  314. maid.AllProcPropSeqStart();
  315. }
  316. for (;;)
  317. {
  318. bool isAllMaidLoadComplete = true;
  319. foreach (Maid maid2 in eventObj.targetMaidList)
  320. {
  321. if (maid2.IsBusy)
  322. {
  323. isAllMaidLoadComplete = false;
  324. break;
  325. }
  326. }
  327. if (isAllMaidLoadComplete)
  328. {
  329. break;
  330. }
  331. yield return null;
  332. }
  333. if (OnComplete != null)
  334. {
  335. OnComplete();
  336. }
  337. yield break;
  338. }
  339. private static bool TryGetMaidListOfEventData(EmpireLifeModeData.Data data, IEnumerable<Maid> maidList, out List<Maid> resultList)
  340. {
  341. resultList = new List<Maid>();
  342. List<string> list = new List<string>(data.dataMaidPersonalUniqueNameAndActiveSlotDic.Values);
  343. List<Maid> list2 = new List<Maid>(maidList);
  344. if (list.Count > list2.Count)
  345. {
  346. return false;
  347. }
  348. foreach (string b in list)
  349. {
  350. Maid maid = null;
  351. foreach (Maid maid2 in list2)
  352. {
  353. if (maid2.status.personal.uniqueName == b && data.IsCorrectMaid(maid2))
  354. {
  355. maid = maid2;
  356. break;
  357. }
  358. }
  359. if (!(maid != null))
  360. {
  361. return false;
  362. }
  363. resultList.Add(maid);
  364. if (resultList.Count == list.Count)
  365. {
  366. return true;
  367. }
  368. list2.Remove(maid);
  369. }
  370. return false;
  371. }
  372. private static bool TryGetMaidListOfEventDataBodyTypeEquals(EmpireLifeModeData.Data data, IEnumerable<Maid> maidList, out List<Maid> resultList)
  373. {
  374. List<Maid> list = new List<Maid>(from d in maidList
  375. where !data.dataNewBodyBlock || (data.dataNewBodyBlock && !d.IsCrcBody)
  376. select d);
  377. if (!data.dataRequestBodyTypeEquals)
  378. {
  379. return EmpireLifeModeManager.TryGetMaidListOfEventData(data, list, out resultList);
  380. }
  381. if (data.dataMaidPersonalUniqueNameAndActiveSlotDic.Count == 1)
  382. {
  383. return EmpireLifeModeManager.TryGetMaidListOfEventData(data, list, out resultList);
  384. }
  385. if (EmpireLifeModeManager.TryGetMaidListOfEventData(data, from d in list
  386. where d.IsCrcBody
  387. select d, out resultList))
  388. {
  389. return true;
  390. }
  391. return EmpireLifeModeManager.TryGetMaidListOfEventData(data, from d in list
  392. where !d.IsCrcBody
  393. select d, out resultList);
  394. }
  395. public List<Maid> GetNotAllocatedMaidList(List<Maid> maidList)
  396. {
  397. List<Maid> list = new List<Maid>();
  398. if (maidList == null || maidList.Count <= 0)
  399. {
  400. return list;
  401. }
  402. for (int i = maidList.Count - 1; i >= 0; i--)
  403. {
  404. if (!this.executedMaidList.Contains(maidList[i]))
  405. {
  406. if (!this.IsAllocatedMaid(maidList[i]))
  407. {
  408. list.Add(maidList[i]);
  409. }
  410. }
  411. }
  412. return list;
  413. }
  414. public bool IsAllocatedMaid(Maid maid)
  415. {
  416. NDebug.Assert(maid != null, "判定するキャラクターにnullが指定されました");
  417. foreach (EmpireLifeModeManager.EventDataObject eventDataObject in this.nowEventList)
  418. {
  419. if (eventDataObject.targetMaidList != null && eventDataObject.targetMaidList.Contains(maid))
  420. {
  421. return true;
  422. }
  423. }
  424. return false;
  425. }
  426. private DataArray<int, byte> CreateMaidDataArray(Maid maid)
  427. {
  428. NDebug.AssertNull(maid);
  429. string guid = maid.status.guid;
  430. if (this.m_SaveDataMaidScenarioExecuteCountArray.ContainsKey(guid))
  431. {
  432. return this.m_SaveDataMaidScenarioExecuteCountArray[guid];
  433. }
  434. DataArray<int, byte> dataArray = new DataArray<int, byte>();
  435. this.m_SaveDataMaidScenarioExecuteCountArray.Add(guid, dataArray);
  436. Debug.LogFormat("メイド「{0}」の情報を作成しました。", new object[]
  437. {
  438. maid.status.fullNameJpStyle
  439. });
  440. return dataArray;
  441. }
  442. public int GetMaidScenarioExecuteCount(int eventID, Maid maid)
  443. {
  444. NDebug.AssertNull(maid);
  445. string guid = maid.status.guid;
  446. if (!this.m_SaveDataMaidScenarioExecuteCountArray.ContainsKey(guid))
  447. {
  448. return 0;
  449. }
  450. return (int)this.m_SaveDataMaidScenarioExecuteCountArray[guid].Get(eventID, false);
  451. }
  452. private void IncrementMaidScenarioExecuteCount(int eventID, Maid maid)
  453. {
  454. NDebug.AssertNull(maid);
  455. string guid = maid.status.guid;
  456. DataArray<int, byte> dataArray = this.CreateMaidDataArray(maid);
  457. byte b = dataArray.Get(eventID, false);
  458. if (b < 255)
  459. {
  460. b += 1;
  461. }
  462. dataArray.Add(eventID, b, true);
  463. this.m_SaveDataScenarioExecuteCountArray.Add(eventID, b, true);
  464. }
  465. public int GetScenarioExecuteCount(int eventID)
  466. {
  467. if (!this.m_SaveDataScenarioExecuteCountArray.Contains(eventID))
  468. {
  469. return 0;
  470. }
  471. return (int)this.m_SaveDataScenarioExecuteCountArray.Get(eventID, false);
  472. }
  473. public bool Serialize(BinaryWriter brWrite)
  474. {
  475. brWrite.Write("CM3D21_LIFE_MODE_MGR");
  476. brWrite.Write(1570);
  477. brWrite.Write("2");
  478. DataArray<int, byte> saveDataScenarioExecuteCountArray = this.m_SaveDataScenarioExecuteCountArray;
  479. if (EmpireLifeModeManager.<>f__mg$cache1 == null)
  480. {
  481. EmpireLifeModeManager.<>f__mg$cache1 = new Converter<int, byte[]>(Util.GetBytes);
  482. }
  483. saveDataScenarioExecuteCountArray.Serialize(brWrite, EmpireLifeModeManager.<>f__mg$cache1, (byte data) => new byte[]
  484. {
  485. data
  486. });
  487. int count = this.m_SaveDataMaidScenarioExecuteCountArray.Count;
  488. brWrite.Write(count);
  489. foreach (KeyValuePair<string, DataArray<int, byte>> keyValuePair in this.m_SaveDataMaidScenarioExecuteCountArray)
  490. {
  491. brWrite.Write(keyValuePair.Key);
  492. DataArray<int, byte> value = keyValuePair.Value;
  493. if (EmpireLifeModeManager.<>f__mg$cache2 == null)
  494. {
  495. EmpireLifeModeManager.<>f__mg$cache2 = new Converter<int, byte[]>(Util.GetBytes);
  496. }
  497. value.Serialize(brWrite, EmpireLifeModeManager.<>f__mg$cache2, (byte data) => new byte[]
  498. {
  499. data
  500. });
  501. }
  502. List<string> list = new List<string>();
  503. foreach (Maid maid in this.lifeModeAllMaidList)
  504. {
  505. if (maid != null)
  506. {
  507. list.Add(maid.status.guid);
  508. }
  509. }
  510. brWrite.Write(list.Count);
  511. foreach (string value2 in list)
  512. {
  513. brWrite.Write(value2);
  514. }
  515. return true;
  516. }
  517. public bool Deserialize(BinaryReader brRead)
  518. {
  519. this.m_SaveDataScenarioExecuteCountArray.Clear();
  520. this.m_SaveDataMaidScenarioExecuteCountArray.Clear();
  521. if (brRead.BaseStream.Length <= brRead.BaseStream.Position + 1L)
  522. {
  523. Debug.Log("LifeMode\nこれ以上は読めない");
  524. return false;
  525. }
  526. long position = brRead.BaseStream.Position;
  527. string text = brRead.ReadString();
  528. if (text != "CM3D21_LIFE_MODE_MGR")
  529. {
  530. Debug.Log("LifeMode\nヘッダー取得に失敗しました。\n" + text);
  531. brRead.BaseStream.Seek(position, SeekOrigin.Begin);
  532. return false;
  533. }
  534. int num = brRead.ReadInt32();
  535. position = brRead.BaseStream.Position;
  536. string text2 = brRead.ReadString();
  537. int num2;
  538. if (string.IsNullOrEmpty(text2))
  539. {
  540. num2 = 0;
  541. brRead.BaseStream.Seek(position, SeekOrigin.Begin);
  542. }
  543. else
  544. {
  545. int num3 = 0;
  546. if (int.TryParse(text2, out num3) && num3 > 0 && 100 > num3)
  547. {
  548. num2 = num3;
  549. }
  550. else
  551. {
  552. num2 = 0;
  553. brRead.BaseStream.Seek(position, SeekOrigin.Begin);
  554. }
  555. }
  556. if (num2 <= 1)
  557. {
  558. if (EmpireLifeModeManager.<>f__mg$cache3 == null)
  559. {
  560. EmpireLifeModeManager.<>f__mg$cache3 = new Func<BinaryReader, int>(Util.ToInt32);
  561. }
  562. Func<BinaryReader, int> func_read_key = EmpireLifeModeManager.<>f__mg$cache3;
  563. if (EmpireLifeModeManager.<>f__mg$cache4 == null)
  564. {
  565. EmpireLifeModeManager.<>f__mg$cache4 = new Func<BinaryReader, int>(Util.ToInt32);
  566. }
  567. DataArray<int, int>.Skip(brRead, func_read_key, EmpireLifeModeManager.<>f__mg$cache4);
  568. }
  569. else
  570. {
  571. DataArray<int, byte> saveDataScenarioExecuteCountArray = this.m_SaveDataScenarioExecuteCountArray;
  572. if (EmpireLifeModeManager.<>f__mg$cache5 == null)
  573. {
  574. EmpireLifeModeManager.<>f__mg$cache5 = new Func<BinaryReader, int>(Util.ToInt32);
  575. }
  576. Func<BinaryReader, int> func_read_key2 = EmpireLifeModeManager.<>f__mg$cache5;
  577. if (EmpireLifeModeManager.<>f__mg$cache6 == null)
  578. {
  579. EmpireLifeModeManager.<>f__mg$cache6 = new Func<BinaryReader, byte>(Util.ToByte);
  580. }
  581. saveDataScenarioExecuteCountArray.Deserialize(brRead, func_read_key2, EmpireLifeModeManager.<>f__mg$cache6);
  582. int num4 = brRead.ReadInt32();
  583. for (int i = 0; i < num4; i++)
  584. {
  585. string text3 = brRead.ReadString();
  586. Maid stockMaid = GameMain.Instance.CharacterMgr.GetStockMaid(text3);
  587. if (stockMaid == null)
  588. {
  589. Debug.LogFormat("■GUID「{0}」のメイドは存在しなかったので、このメイドの情報は読み飛ばします", new object[]
  590. {
  591. text3
  592. });
  593. if (EmpireLifeModeManager.<>f__mg$cache7 == null)
  594. {
  595. EmpireLifeModeManager.<>f__mg$cache7 = new Func<BinaryReader, int>(Util.ToInt32);
  596. }
  597. Func<BinaryReader, int> func_read_key3 = EmpireLifeModeManager.<>f__mg$cache7;
  598. if (EmpireLifeModeManager.<>f__mg$cache8 == null)
  599. {
  600. EmpireLifeModeManager.<>f__mg$cache8 = new Func<BinaryReader, byte>(Util.ToByte);
  601. }
  602. DataArray<int, byte>.Skip(brRead, func_read_key3, EmpireLifeModeManager.<>f__mg$cache8);
  603. }
  604. else
  605. {
  606. DataArray<int, byte> dataArray = this.CreateMaidDataArray(stockMaid);
  607. DataArray<int, byte> dataArray2 = dataArray;
  608. if (EmpireLifeModeManager.<>f__mg$cache9 == null)
  609. {
  610. EmpireLifeModeManager.<>f__mg$cache9 = new Func<BinaryReader, int>(Util.ToInt32);
  611. }
  612. Func<BinaryReader, int> func_read_key4 = EmpireLifeModeManager.<>f__mg$cache9;
  613. if (EmpireLifeModeManager.<>f__mg$cacheA == null)
  614. {
  615. EmpireLifeModeManager.<>f__mg$cacheA = new Func<BinaryReader, byte>(Util.ToByte);
  616. }
  617. dataArray2.Deserialize(brRead, func_read_key4, EmpireLifeModeManager.<>f__mg$cacheA);
  618. }
  619. }
  620. List<Maid> list = new List<Maid>();
  621. num4 = brRead.ReadInt32();
  622. for (int j = 0; j < num4; j++)
  623. {
  624. string guid = brRead.ReadString();
  625. Maid stockMaid2 = GameMain.Instance.CharacterMgr.GetStockMaid(guid);
  626. if (stockMaid2 != null)
  627. {
  628. list.Add(stockMaid2);
  629. }
  630. }
  631. this.SetAllMaidList(list);
  632. }
  633. return true;
  634. }
  635. private const int MAX_COUNT_MAID_ALLOCATE = 3;
  636. private List<EmpireLifeModeManager.EventDataObject> m_EventList = new List<EmpireLifeModeManager.EventDataObject>();
  637. private Dictionary<Facility, List<Maid>> m_NowMaidAllocationDic = new Dictionary<Facility, List<Maid>>();
  638. private List<EmpireLifeModeManager.EventDataObject> m_ExecutedEventList = new List<EmpireLifeModeManager.EventDataObject>();
  639. private List<Maid> m_LifeModeAllMaidList = new List<Maid>();
  640. private List<Maid> m_ExecutedMaidList = new List<Maid>();
  641. private Dictionary<string, DataArray<int, byte>> m_SaveDataMaidScenarioExecuteCountArray = new Dictionary<string, DataArray<int, byte>>();
  642. private DataArray<int, byte> m_SaveDataScenarioExecuteCountArray = new DataArray<int, byte>();
  643. private const string STR_LOG_HEAD = "LifeMode\n";
  644. private const string STR_LIFE_MODE_SERIALIZE_HEADER = "CM3D21_LIFE_MODE_MGR";
  645. private const string STR_LIFE_MODE_SERIALIZE_VER = "2";
  646. [CompilerGenerated]
  647. private static Func<EmpireLifeModeData.Data, int> <>f__mg$cache0;
  648. [CompilerGenerated]
  649. private static Converter<int, byte[]> <>f__mg$cache1;
  650. [CompilerGenerated]
  651. private static Converter<int, byte[]> <>f__mg$cache2;
  652. [CompilerGenerated]
  653. private static Func<BinaryReader, int> <>f__mg$cache3;
  654. [CompilerGenerated]
  655. private static Func<BinaryReader, int> <>f__mg$cache4;
  656. [CompilerGenerated]
  657. private static Func<BinaryReader, int> <>f__mg$cache5;
  658. [CompilerGenerated]
  659. private static Func<BinaryReader, byte> <>f__mg$cache6;
  660. [CompilerGenerated]
  661. private static Func<BinaryReader, int> <>f__mg$cache7;
  662. [CompilerGenerated]
  663. private static Func<BinaryReader, byte> <>f__mg$cache8;
  664. [CompilerGenerated]
  665. private static Func<BinaryReader, int> <>f__mg$cache9;
  666. [CompilerGenerated]
  667. private static Func<BinaryReader, byte> <>f__mg$cacheA;
  668. public class EventDataObject
  669. {
  670. public Facility targetFacility { get; set; }
  671. public EmpireLifeModeData.Data targetEvent { get; set; }
  672. public List<Maid> targetMaidList;
  673. }
  674. }