using System; using System.Collections.Generic; using System.ComponentModel; using System.Diagnostics; using System.IO; using System.Runtime.CompilerServices; using FacilityFlag; using UnityEngine; public class FacilityManager : MonoBehaviour { public int NowBusinessTypeID { get { return this.m_NowBusinessTypeID; } set { this.m_NowBusinessTypeID = value; } } public int NextDayBusinessTypeID { get { return this.m_NextDayBusinessTypeID; } set { this.m_NextDayBusinessTypeID = value; } } public Facility tempSelectFacility { get { return this.m_TempSelectingFacility; } set { this.m_TempSelectingFacility = value; } } private GameObject parentFacility { get { return this.m_ParentFacility; } } private GameObject parentNowFacility { get { if (this.m_ParentNowFacility == null) { this.m_ParentNowFacility = new GameObject("Parent Now Facility"); this.m_ParentNowFacility.transform.SetParent(this.parentFacility.transform, false); } return this.m_ParentNowFacility; } } private GameObject parentNextDayFacility { get { if (this.m_ParentNextDayFacility == null) { this.m_ParentNextDayFacility = new GameObject("Parent Next Day Facility"); this.m_ParentNextDayFacility.transform.SetParent(this.parentFacility.transform, false); } return this.m_ParentNextDayFacility; } } public void Init(GameMain gameMain) { if (this.m_ParentFacility == null) { this.m_ParentFacility = new GameObject("Facility"); this.m_ParentFacility.transform.SetParent(gameMain.transform, false); } FacilityDataTable.Init(); this.ResetData(); this.SetUpFixedFacilityArray(); } private void SetUpFixedFacilityArray() { Facility.FacilityStatus[] facilityStatusArray = FacilityDataTable.GetFacilityStatusArray(true); for (int i = 0; i < facilityStatusArray.Length; i++) { int typeID = facilityStatusArray[i].typeID; if (FacilityDataTable.GetFacilityDefaultPlacement(typeID, true)) { this.AddNewFacility(typeID); } } int[] facilityBusinessTypeIDArray = FacilityDataTable.GetFacilityBusinessTypeIDArray(true); foreach (int num in facilityBusinessTypeIDArray) { if (this.IsExistBusinessTypeFacility(num)) { this.m_NowBusinessTypeID = num; break; } } } public int GetEmptySlot() { bool flag = false; int i; for (i = 0; i < this.FacilityCountMax; i++) { if (this.m_FacilityArray.Count < i || !this.m_FacilityArray[i]) { flag = true; break; } } if (flag) { return i; } return -1; } public Facility[] GetFacilityArray() { return this.m_FacilityArray.ToArray(); } public Facility GetFacility(int index) { if (this.m_FacilityArray.Count <= index) { return null; } if (index < 0) { return null; } return this.m_FacilityArray[index]; } public bool GetFacilityExist(int index) { return index >= 0 && this.m_FacilityArray.Count > index && this.m_FacilityArray[index] != null; } public int GetFacilityIndex(Facility facility) { if (facility == null) { UnityEngine.Debug.LogError("[FacilityManager]引数にnullが指定されました"); return -1; } if (this.m_FacilityArray.Contains(facility)) { return this.m_FacilityArray.IndexOf(facility); } if (this.m_NextDayFacilityArray.ContainsValue(facility)) { List list = new List(this.m_NextDayFacilityArray.Keys); List list2 = new List(this.m_NextDayFacilityArray.Values); return list[list2.IndexOf(facility)]; } UnityEngine.Debug.Log(string.Format("[FacilityManager]施設『{0}』は施設マネージャクラスの管理外です", facility.facilityName)); return -1; } public bool GetFacilityPowerUpItemEnable(int materialID) { if (this.m_PowerUpMaterialArray == null) { UnityEngine.Debug.LogError("[FacilityManager]強化素材の配列が未初期化状態です"); return false; } return this.m_PowerUpMaterialArray.Get(materialID, false); } public Facility.PowerUpMaterial[] GetFacilityPowerUpItemEnableArray(int materialCategoryID) { Facility.PowerUpMaterial[] facilityPowerUpMaterialArray = FacilityDataTable.GetFacilityPowerUpMaterialArray(materialCategoryID); List list = new List(); for (int i = 0; i < facilityPowerUpMaterialArray.Length; i++) { if (this.GetFacilityPowerUpItemEnable(facilityPowerUpMaterialArray[i].id)) { list.Add(facilityPowerUpMaterialArray[i]); } } return list.ToArray(); } public bool AddNewFacility(int facilityTypeID) { int emptySlot = this.GetEmptySlot(); if (emptySlot < 0) { UnityEngine.Debug.Log(string.Format("[FacilityManager]施設は{0}個よりも多くは作れません", this.FacilityCountMax)); return false; } Facility facility = this.CreateNewFacility(facilityTypeID); this.SetFacility(emptySlot, facility); return true; } public Facility CreateNewFacility(int facilityTypeID) { GameObject gameObject = new GameObject("Facility"); Facility facility = gameObject.AddComponent(); facility.Init(facilityTypeID); gameObject.transform.SetParent(this.parentNowFacility.transform, false); return facility; } public Facility CreateNewFacility() { GameObject gameObject = new GameObject("Facility"); Facility facility = gameObject.AddComponent(); facility.Init(FacilityDataTable.GetFacilityTypeID("劇場")); gameObject.transform.SetParent(this.parentNowFacility.transform, false); return facility; } public bool AddFacility(Facility facility) { int emptySlot = this.GetEmptySlot(); if (emptySlot < 0) { UnityEngine.Debug.Log(string.Format("[FacilityManager]施設は{0}個よりも多くは作れません", this.FacilityCountMax)); return false; } this.SetFacility(emptySlot, facility); return true; } public bool SetFacility(int index, Facility facility) { if (this.m_FacilityArray.Count <= index || index < 0) { UnityEngine.Debug.LogError(string.Format("[FacilityManager]施設の管理インデックスの値が不正です\n指定された値:{0}", index)); return false; } if (facility != null && this.m_FacilityArray.Contains(facility)) { UnityEngine.Debug.LogError(string.Format("[FacilityManager]施設「{0}」は既にマネージャクラスで管理されています", facility.facilityName)); return false; } Facility facility2 = this.m_FacilityArray[index]; if (facility2) { UnityEngine.Debug.Log(string.Format("[FacilityManager]管理している施設を置き換えた\n[{0}]番目:「{1}」から「{2}」へ", index, facility2.facilityName, (!facility) ? "空き部屋" : facility.facilityName)); this.DestroyFacility(facility2); } this.m_FacilityArray[index] = facility; if (facility) { facility.gameObject.transform.SetParent(this.parentNowFacility.transform, false); int typeID = facility.param.typeID; int num = (!this.m_FacilityBuildCount.Contains(typeID)) ? 0 : this.m_FacilityBuildCount.Get(typeID, false); this.m_FacilityBuildCount.Add(typeID, num + 1, true); } return true; } public bool DestroyFacility(int index) { if (this.GetFacility(index) == null) { UnityEngine.Debug.Log(string.Format("[FacilityManager]施設の管理インデックス[{0}]番の施設は存在しない", index)); return false; } Facility facility = this.m_FacilityArray[index]; this.m_FacilityArray[index] = null; UnityEngine.Object.Destroy(facility.gameObject); return true; } public bool DestroyFacility(Facility facility) { if (facility == null) { UnityEngine.Debug.LogError("[FacilityManager]削除したい施設としてnullが指定されました"); return false; } string facilityName = facility.facilityName; if (!this.m_FacilityArray.Contains(facility)) { UnityEngine.Debug.Log(string.Format("[FacilityManager]施設『{0}』は施設マネージャクラスの管理外です", facilityName)); return false; } int facilityIndex = this.GetFacilityIndex(facility); this.m_FacilityArray[facilityIndex] = null; UnityEngine.Object.Destroy(facility.gameObject); UnityEngine.Debug.Log(string.Format("[FacilityManager]施設『{0}』の削除に成功", facilityName)); return true; } public void SetHavePowerUpMaterial(int materialID, bool isHave = true) { if (this.m_PowerUpMaterialArray == null) { UnityEngine.Debug.LogError("[FacilityManager]強化素材配列が未初期化状態です"); return; } if (!this.m_PowerUpMaterialArray.Contains(materialID)) { UnityEngine.Debug.Log(string.Format("[FacilityManager]強化素材ID[{0}]番は存在しない情報です", materialID)); return; } this.m_PowerUpMaterialArray.Add(materialID, isHave, true); } public int GetFacilityLevel(int facilityTypeID) { if (this.m_FacilityExpArray == null) { UnityEngine.Debug.LogError("[FacilityManager]施設の種類ごとの施設レベル配列が未初期化です"); return -1; } if (!this.m_FacilityExpArray.Contains(facilityTypeID)) { UnityEngine.Debug.LogWarningFormat("[FacilityManager]施設の種類ID[{0}]番に対応する施設レベル情報がありません", new object[] { facilityTypeID }); return -1; } return this.m_FacilityExpArray.Get(facilityTypeID, false).GetCurrentLevel(); } public SimpleExperienceSystem GetFacilityExpSystem(int facilityTypeID) { if (this.m_FacilityExpArray == null) { UnityEngine.Debug.LogError("[FacilityManager]施設の種類ごとの施設レベル配列が未初期化です"); return null; } if (!this.m_FacilityExpArray.Contains(facilityTypeID)) { UnityEngine.Debug.LogWarningFormat("[FacilityManager]施設の種類ID[{0}]番に対応する施設レベル情報がありません", new object[] { facilityTypeID }); return null; } return this.m_FacilityExpArray.Get(facilityTypeID, false); } public Dictionary GetNextDayFacilityArray() { return this.m_NextDayFacilityArray; } public Facility GetNextDayFacility(int nowFacilityIndex) { if (!this.GetNextDayFacilityExist(nowFacilityIndex)) { return null; } return this.m_NextDayFacilityArray[nowFacilityIndex]; } public Facility GetNextDayFacility(Facility nowFacility) { int facilityIndex = this.GetFacilityIndex(nowFacility); if (!this.GetNextDayFacilityExist(facilityIndex)) { UnityEngine.Debug.Log(string.Format("[FacilityManager]次の日に設置する施設の情報が存在しない\n管理インデックス:[{0}]", facilityIndex)); return null; } return this.m_NextDayFacilityArray[facilityIndex]; } public bool GetNextDayFacilityExist(int nowFacilityIndex) { return this.m_NextDayFacilityArray.ContainsKey(nowFacilityIndex); } public bool GetNextDayFacilityExist(Facility nowFacility) { int facilityIndex = this.GetFacilityIndex(nowFacility); return this.m_NextDayFacilityArray.ContainsKey(facilityIndex); } public void SetNextDayFacility(int index, Facility nextDayFacility) { if (this.m_NextDayFacilityArray.ContainsKey(index)) { this.m_NextDayFacilityArray[index] = nextDayFacility; UnityEngine.Debug.Log(string.Format("[FacilityManager]次の日の施設情報を上書きした\n[{0}]番目:{1}", index, (!nextDayFacility) ? "空き部屋" : nextDayFacility.facilityName)); return; } this.m_NextDayFacilityArray.Add(index, nextDayFacility); UnityEngine.Debug.Log(string.Format("[FacilityManager]次の日の施設情報を追加した\n[{0}]番目:{1}", index, (!nextDayFacility) ? "空き部屋" : nextDayFacility.facilityName)); if (nextDayFacility != null) { nextDayFacility.transform.SetParent(this.parentNextDayFacility.transform, false); } } public void RemoveNextDayFacility(int index) { if (!this.m_NextDayFacilityArray.ContainsKey(index)) { UnityEngine.Debug.Log(string.Format("[FacilityManager]キーの値[{0}]のノードは存在しない", index)); return; } this.m_NextDayFacilityArray.Remove(index); } public void ClearNextDayFacilityArray() { List list = new List(this.m_NextDayFacilityArray.Values); for (int i = 0; i < list.Count; i++) { if (list[i]) { UnityEngine.Object.Destroy(list[i].gameObject); } } this.m_NextDayFacilityArray.Clear(); } private void UpdateNextDayFacility() { CharacterMgr characterMgr = null; if (GameMain.Instance != null && GameMain.Instance.CharacterMgr != null) { characterMgr = GameMain.Instance.CharacterMgr; } Dictionary nextDayFacilityArray = this.GetNextDayFacilityArray(); int count = nextDayFacilityArray.Count; List list = new List(nextDayFacilityArray.Keys); List list2 = new List(nextDayFacilityArray.Values); for (int i = 0; i < count; i++) { int num = 0; if (list2[i] != null) { num = list2[i].defaultData.cost; } if (characterMgr != null && characterMgr.status.money - (long)num >= 0L) { characterMgr.status.money -= (long)num; this.RemoveNextDayFacility(list[i]); this.SetFacility(list[i], list2[i]); } else { this.RemoveNextDayFacility(list[i]); UnityEngine.Object.Destroy(list2[i].gameObject); } } } public void UpdateNextDay() { this.UpdateNextDayFacility(); if (this.m_NowBusinessTypeID != this.m_NextDayBusinessTypeID && FacilityDataTable.IsExistFacilityBusinessTypeData(this.m_NextDayBusinessTypeID)) { this.m_NowBusinessTypeID = this.m_NextDayBusinessTypeID; } int num = 0; foreach (Facility x in this.GetFacilityArray()) { if (x != null) { num++; } } int facilityAchievement = this.GetFacilityAchievement("施設総数"); if (facilityAchievement < num) { this.SetFacilityAchievement("施設総数", num.ToString()); } } public bool IsExistBusinessTypeFacility(int businessTypeID) { Facility[] array = this.m_FacilityArray.ToArray(); foreach (Facility facility in array) { if (!(facility == null)) { if (facility.defaultData.businessTypeID == businessTypeID) { return true; } } } return false; } public bool IsExistBusinessTypeFacility(FacilityDataTable.BusinessTypeData businessData) { return this.IsExistBusinessTypeFacility(businessData.ID); } public bool IsExistBusinessTypeFacility(string businessName) { return this.IsExistBusinessTypeFacility(FacilityDataTable.GetFacilityBusinessTypeData(businessName).ID); } public bool IsExistTypeFacility(int facilityTypeID) { Facility[] array = this.m_FacilityArray.ToArray(); foreach (Facility facility in array) { if (!(facility == null)) { if (facility.param.typeID == facilityTypeID) { return true; } } } return false; } public bool IsExistTypeFacility(int facilityTypeID, out Facility[] matchingFacilityArray) { Facility[] array = this.m_FacilityArray.ToArray(); List list = new List(); foreach (Facility facility in array) { if (!(facility == null)) { if (facility.param.typeID == facilityTypeID) { list.Add(facility); } } } matchingFacilityArray = list.ToArray(); return matchingFacilityArray.Length > 0; } public bool IsExistTypeFacilityInOperation(int facilityTypeID) { Facility[] array = this.m_FacilityArray.ToArray(); foreach (Facility facility in array) { if (!(facility == null)) { if (facility.isOperationDayTime && facility.param.typeID == facilityTypeID) { return true; } } } return false; } public bool IsExistTypeFacilityInOperation(int facilityTypeID, out Facility[] matchingFacilityArray) { Facility[] array = this.m_FacilityArray.ToArray(); List list = new List(); foreach (Facility facility in array) { if (!(facility == null)) { if (facility.isOperationDayTime && facility.param.typeID == facilityTypeID) { list.Add(facility); } } } matchingFacilityArray = list.ToArray(); return matchingFacilityArray.Length > 0; } public bool IsFacilityBuildFlag(int facilityTypeID) { return this.m_FacilityBuildCount.Contains(facilityTypeID) && this.m_FacilityBuildCount.Get(facilityTypeID, false) > 0; } public Facility GetMaidAssignedFacility(Maid maid, ScheduleMgr.ScheduleTime scheduleTime) { for (int i = 0; i < this.m_FacilityArray.Count; i++) { if (!(this.m_FacilityArray[i] == null)) { if (this.m_FacilityArray[i].IsAllocationMaid(maid, scheduleTime)) { return this.m_FacilityArray[i]; } } } return null; } public void UpdateFacilityAssignedMaidData() { for (int i = 0; i < this.m_FacilityArray.Count; i++) { if (!(this.m_FacilityArray[i] == null)) { this.m_FacilityArray[i].UpdateAllocationMaidList(); } } } public void AddCacheFacilityPowewrUpResult(Maid maid, Facility facility, Facility.RecipeData recipe) { if (maid == null) { NDebug.Assert("メイドにnullが指定されました", false); } if (this.m_CacheFacilityPowerUpResult.ContainsKey(maid.status.guid)) { UnityEngine.Debug.LogWarningFormat("メイド「{0}」の情報は既にキャッシュしています", new object[] { maid }); return; } this.m_CacheFacilityPowerUpResult.Add(maid.status.guid, new KeyValuePair(facility, recipe)); } public bool IsExistCacheFacilityPowerUpResult(Maid maid) { NDebug.Assert(maid != null, "メイドにnullが指定されました"); return this.m_CacheFacilityPowerUpResult.ContainsKey(maid.status.guid); } public bool TryGetCacheFacilityPowerUpResult(Maid maid, out Facility facility, out Facility.RecipeData recipe) { facility = null; recipe = null; if (!this.IsExistCacheFacilityPowerUpResult(maid)) { return false; } KeyValuePair keyValuePair = this.m_CacheFacilityPowerUpResult[maid.status.guid]; facility = keyValuePair.Key; recipe = keyValuePair.Value; return true; } public void ClearCacheFacilityPowerUpResult() { this.m_CacheFacilityPowerUpResult.Clear(); } public bool Serialize(BinaryWriter brWrite) { Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); brWrite.Write("CM3D21_FACILITY_MGR"); brWrite.Write(1350); brWrite.Write("5"); int num = 0; for (int i = 0; i < this.m_FacilityArray.Count; i++) { if (this.m_FacilityArray[i]) { num++; } } brWrite.Write(num); for (int j = 0; j < this.m_FacilityArray.Count; j++) { if (this.m_FacilityArray[j]) { brWrite.Write(j); this.m_FacilityArray[j].Serialize(brWrite); } } DataArray powerUpMaterialArray = this.m_PowerUpMaterialArray; if (FacilityManager.<>f__mg$cache0 == null) { FacilityManager.<>f__mg$cache0 = new Converter(Util.GetBytes); } Converter converter_key = FacilityManager.<>f__mg$cache0; if (FacilityManager.<>f__mg$cache1 == null) { FacilityManager.<>f__mg$cache1 = new Converter(Util.GetBytes); } powerUpMaterialArray.Serialize(brWrite, converter_key, FacilityManager.<>f__mg$cache1); int count = this.m_NextDayFacilityArray.Count; brWrite.Write(count); for (int k = 0; k < this.m_FacilityArray.Count; k++) { if (this.GetNextDayFacilityExist(k)) { Facility nextDayFacility = this.GetNextDayFacility(k); if (nextDayFacility) { brWrite.Write(k); brWrite.Write(true); nextDayFacility.Serialize(brWrite); } else { brWrite.Write(k); brWrite.Write(false); } } } DataArray facilityExpArray = this.m_FacilityExpArray; if (FacilityManager.<>f__mg$cache2 == null) { FacilityManager.<>f__mg$cache2 = new Converter(Util.GetBytes); } Converter converter_key2 = FacilityManager.<>f__mg$cache2; if (FacilityManager.<>f__mg$cache3 == null) { FacilityManager.<>f__mg$cache3 = new Converter(Util.GetBytes); } facilityExpArray.Serialize(brWrite, converter_key2, FacilityManager.<>f__mg$cache3); DataArray facilityBuildCount = this.m_FacilityBuildCount; if (FacilityManager.<>f__mg$cache4 == null) { FacilityManager.<>f__mg$cache4 = new Converter(Util.GetBytes); } Converter converter_key3 = FacilityManager.<>f__mg$cache4; if (FacilityManager.<>f__mg$cache5 == null) { FacilityManager.<>f__mg$cache5 = new Converter(Util.GetBytes); } facilityBuildCount.Serialize(brWrite, converter_key3, FacilityManager.<>f__mg$cache5); DataArray facilityAchievementList = this.m_FacilityAchievementList; if (FacilityManager.<>f__mg$cache6 == null) { FacilityManager.<>f__mg$cache6 = new Converter(Util.GetBytes); } Converter converter_key4 = FacilityManager.<>f__mg$cache6; if (FacilityManager.<>f__mg$cache7 == null) { FacilityManager.<>f__mg$cache7 = new Converter(Util.GetBytes); } facilityAchievementList.Serialize(brWrite, converter_key4, FacilityManager.<>f__mg$cache7); stopwatch.Stop(); return true; } public bool Deserialize(BinaryReader brRead) { Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); this.ResetData(); if (brRead.BaseStream.Length <= brRead.BaseStream.Position + 1L) { this.SetUpFixedFacilityArray(); return false; } long position = brRead.BaseStream.Position; string text = brRead.ReadString(); if (text != "CM3D21_FACILITY_MGR") { NDebug.Warning("セーブデータファイルのヘッダーが不正です。FACILITY_MGR\n" + text); brRead.BaseStream.Seek(position, SeekOrigin.Begin); return false; } int num = brRead.ReadInt32(); position = brRead.BaseStream.Position; string text2 = brRead.ReadString(); int num2; if (string.IsNullOrEmpty(text2)) { num2 = 0; brRead.BaseStream.Seek(position, SeekOrigin.Begin); } else { int num3 = 0; if (int.TryParse(text2, out num3) && num3 > 0 && 10 > num3) { num2 = num3; } else { num2 = 0; brRead.BaseStream.Seek(position, SeekOrigin.Begin); } } int num4 = brRead.ReadInt32(); for (int i = 0; i < num4; i++) { int index3 = brRead.ReadInt32(); Facility facility = this.CreateNewFacility(); if (facility.Deserialize(brRead, num2)) { this.m_FacilityArray[index3] = facility; } else { UnityEngine.Object.Destroy(facility); } } DataArray dataArray = new DataArray(); DataArray dataArray2 = dataArray; if (FacilityManager.<>f__mg$cache8 == null) { FacilityManager.<>f__mg$cache8 = new Func(Util.ToInt32); } Func func_read_key = FacilityManager.<>f__mg$cache8; if (FacilityManager.<>f__mg$cache9 == null) { FacilityManager.<>f__mg$cache9 = new Func(Util.ToBoolean); } dataArray2.Deserialize(brRead, func_read_key, FacilityManager.<>f__mg$cache9); dataArray.Loop(delegate(int index, int key, bool value) { this.m_PowerUpMaterialArray.Add(key, value, true); }); int num5 = brRead.ReadInt32(); for (int j = 0; j < num5; j++) { int index2 = brRead.ReadInt32(); bool flag = brRead.ReadBoolean(); bool flag2 = false; Facility facility2 = null; if (flag) { facility2 = this.CreateNewFacility(); flag2 = facility2.Deserialize(brRead, num2); } if (flag2) { this.SetNextDayFacility(index2, facility2); } else { UnityEngine.Object.Destroy(facility2); } } if (num2 > 1) { DataArray array = new DataArray(); DataArray array2 = array; if (FacilityManager.<>f__mg$cacheA == null) { FacilityManager.<>f__mg$cacheA = new Func(Util.ToInt32); } Func func_read_key2 = FacilityManager.<>f__mg$cacheA; if (FacilityManager.<>f__mg$cacheB == null) { FacilityManager.<>f__mg$cacheB = new Func(Util.ToSimpleExp); } array2.Deserialize(brRead, func_read_key2, FacilityManager.<>f__mg$cacheB); array.Loop(delegate(int index, int key, SimpleExperienceSystem value) { FacilityDataTable.FacilityDefaultData facilityDefaultData = FacilityDataTable.GetFacilityDefaultData(key, true); if (facilityDefaultData != null) { value.SetExreienceList(facilityDefaultData.levelTable); } else { string message = string.Format("施設Expテーブル:施設ID[{0}]のデータは存在しません", key); UnityEngine.Debug.LogWarning(message); } }); this.m_FacilityExpArray.Loop(delegate(int index, int id, SimpleExperienceSystem exp) { if (array.Contains(id)) { this.m_FacilityExpArray.Add(id, array.Get(id, false), true); } }); } else { if (FacilityManager.<>f__mg$cacheC == null) { FacilityManager.<>f__mg$cacheC = new Func(Util.ToInt32); } Func func_read_key3 = FacilityManager.<>f__mg$cacheC; if (FacilityManager.<>f__mg$cacheD == null) { FacilityManager.<>f__mg$cacheD = new Func(Util.ToInt32); } DataArray.Skip(brRead, func_read_key3, FacilityManager.<>f__mg$cacheD); } DataArray facilityBuildCount = this.m_FacilityBuildCount; if (FacilityManager.<>f__mg$cacheE == null) { FacilityManager.<>f__mg$cacheE = new Func(Util.ToInt32); } Func func_read_key4 = FacilityManager.<>f__mg$cacheE; if (FacilityManager.<>f__mg$cacheF == null) { FacilityManager.<>f__mg$cacheF = new Func(Util.ToInt32); } facilityBuildCount.Deserialize(brRead, func_read_key4, FacilityManager.<>f__mg$cacheF); if (num2 >= 4) { DataArray facilityAchievementList = this.m_FacilityAchievementList; if (FacilityManager.<>f__mg$cache10 == null) { FacilityManager.<>f__mg$cache10 = new Func(Util.ToString); } Func func_read_key5 = FacilityManager.<>f__mg$cache10; if (FacilityManager.<>f__mg$cache11 == null) { FacilityManager.<>f__mg$cache11 = new Func(Util.ToString); } facilityAchievementList.Deserialize(brRead, func_read_key5, FacilityManager.<>f__mg$cache11); } Facility.DeleteTmpEditCostumeThumnails(); stopwatch.Stop(); return true; } private void ResetData() { this.m_TempSelectingFacility = null; if (this.m_CacheFacilityPowerUpResult != null) { this.m_CacheFacilityPowerUpResult.Clear(); } if (this.m_FacilityArray != null) { foreach (Facility facility in this.m_FacilityArray) { if (facility) { UnityEngine.Object.Destroy(facility.gameObject); } } this.m_FacilityArray.Clear(); } this.m_FacilityArray = new List(); for (int i = 0; i < this.FacilityCountMax; i++) { this.m_FacilityArray.Add(null); } if (this.m_NextDayFacilityArray != null) { foreach (KeyValuePair keyValuePair in this.m_NextDayFacilityArray) { if (keyValuePair.Value) { UnityEngine.Object.Destroy(keyValuePair.Value.gameObject); } } this.m_NextDayFacilityArray.Clear(); } this.m_NextDayFacilityArray = new Dictionary(); this.m_PowerUpMaterialArray = new DataArray(); int[] facilityPowerUpMaterialIDArray = FacilityDataTable.GetFacilityPowerUpMaterialIDArray(); for (int j = 0; j < facilityPowerUpMaterialIDArray.Length; j++) { this.m_PowerUpMaterialArray.Add(facilityPowerUpMaterialIDArray[j], false, true); } Facility.FacilityStatus[] facilityStatusArray = FacilityDataTable.GetFacilityStatusArray(true); this.m_FacilityExpArray = new DataArray(); for (int k = 0; k < facilityStatusArray.Length; k++) { List need_exp_list = new List(); need_exp_list = FacilityDataTable.GetFacilityDefaultData(facilityStatusArray[k].typeID, true).levelTable; SimpleExperienceSystem value = new SimpleExperienceSystem(need_exp_list); this.m_FacilityExpArray.Add(facilityStatusArray[k].typeID, value, true); } this.m_FacilityBuildCount = new DataArray(); this.m_CacheFacilityPowerUpResult = new Dictionary>(); this.m_FacilityAchievementList = new DataArray(); } public T GetFacilityAchievement(string key) { T result = default(T); string text = this.m_FacilityAchievementList.Get(key, false); if (!string.IsNullOrEmpty(text)) { try { TypeConverter converter = TypeDescriptor.GetConverter(typeof(T)); if (converter != null) { result = (T)((object)converter.ConvertFromString(text)); } } catch (Exception ex) { UnityEngine.Debug.LogWarning(ex); NDebug.Warning(ex.Message); } } return result; } public void SetFacilityAchievement(string key, string value) { this.m_FacilityAchievementList.Add(key, value, true); } [Obsolete("[FacilityManager]使用しなくなる関数です\u3000Deserialize(BinaryReader)を使用して下さい", false)] public void Deserialize() { for (int i = 0; i < this.m_FacilityArray.Count; i++) { if (this.m_FacilityArray[i]) { UnityEngine.Object.Destroy(this.m_FacilityArray[i].gameObject); } this.m_FacilityArray[i] = null; } this.ClearNextDayFacilityArray(); string text = UTY.gameProjectPath + "\\SaveData(営業施設)\\"; string str = "Facility.save"; if (!Directory.Exists(text)) { Directory.CreateDirectory(text); } if (!File.Exists(text + str)) { UnityEngine.Debug.LogWarning("[FacilityManager]施設のセーブデータが見つかりません"); return; } using (FileStream fileStream = new FileStream(text + str, FileMode.Open)) { byte[] buffer = new byte[fileStream.Length]; fileStream.Read(buffer, 0, (int)fileStream.Length); using (BinaryReader binaryReader = new BinaryReader(new MemoryStream(buffer))) { this.Deserialize(binaryReader); } } UnityEngine.Debug.Log("[FacilityManager]ロード完了"); } [Obsolete("[FacilityManager]使用しなくなる関数です\u3000Serialize(BinaryWriter)を使用して下さい", false)] public void Serialize() { string text = UTY.gameProjectPath + "\\SaveData(営業施設)\\"; string str = "Facility.save"; if (!Directory.Exists(text)) { Directory.CreateDirectory(text); } using (MemoryStream memoryStream = new MemoryStream()) { using (BinaryWriter binaryWriter = new BinaryWriter(memoryStream)) { this.Serialize(binaryWriter); } File.WriteAllBytes(text + str, memoryStream.ToArray()); } UnityEngine.Debug.Log("[FacilityManager]セーブ完了"); } public void OnDestroy() { if (this.m_FacilityArray != null) { foreach (Facility facility in this.m_FacilityArray) { if (facility && facility.gameObject) { UnityEngine.Object.DestroyImmediate(facility.gameObject); } } this.m_FacilityArray.Clear(); } if (this.m_NextDayFacilityArray != null) { foreach (KeyValuePair keyValuePair in this.m_NextDayFacilityArray) { if (keyValuePair.Value && keyValuePair.Value.gameObject) { UnityEngine.Object.DestroyImmediate(keyValuePair.Value.gameObject); } } this.m_NextDayFacilityArray.Clear(); } if (this.m_PowerUpMaterialArray != null) { this.m_PowerUpMaterialArray.Clear(); } if (this.m_FacilityExpArray != null) { this.m_FacilityExpArray.Clear(); this.m_FacilityExpArray = null; } if (this.m_FacilityBuildCount != null) { this.m_FacilityBuildCount.Clear(); this.m_FacilityBuildCount = null; } if (this.m_ParentNowFacility) { UnityEngine.Object.DestroyImmediate(this.m_ParentNowFacility); } if (this.m_ParentNextDayFacility) { UnityEngine.Object.DestroyImmediate(this.m_ParentNextDayFacility); } } public readonly int FacilityCountMax = 12; private List m_FacilityArray; private Dictionary m_NextDayFacilityArray; private DataArray m_PowerUpMaterialArray; private int m_NowBusinessTypeID = -1; private int m_NextDayBusinessTypeID = -1; private Facility m_TempSelectingFacility; private DataArray m_FacilityExpArray; private DataArray m_FacilityBuildCount; private DataArray m_FacilityAchievementList; private GameObject m_ParentFacility; private GameObject m_ParentNowFacility; private GameObject m_ParentNextDayFacility; private Dictionary> m_CacheFacilityPowerUpResult; private const string STR_FACILITY_SERIALIZE_VER = "5"; [CompilerGenerated] private static Converter <>f__mg$cache0; [CompilerGenerated] private static Converter <>f__mg$cache1; [CompilerGenerated] private static Converter <>f__mg$cache2; [CompilerGenerated] private static Converter <>f__mg$cache3; [CompilerGenerated] private static Converter <>f__mg$cache4; [CompilerGenerated] private static Converter <>f__mg$cache5; [CompilerGenerated] private static Converter <>f__mg$cache6; [CompilerGenerated] private static Converter <>f__mg$cache7; [CompilerGenerated] private static Func <>f__mg$cache8; [CompilerGenerated] private static Func <>f__mg$cache9; [CompilerGenerated] private static Func <>f__mg$cacheA; [CompilerGenerated] private static Func <>f__mg$cacheB; [CompilerGenerated] private static Func <>f__mg$cacheC; [CompilerGenerated] private static Func <>f__mg$cacheD; [CompilerGenerated] private static Func <>f__mg$cacheE; [CompilerGenerated] private static Func <>f__mg$cacheF; [CompilerGenerated] private static Func <>f__mg$cache10; [CompilerGenerated] private static Func <>f__mg$cache11; }