using System; using System.Collections.Generic; using System.IO; using Edit; using MaidStatus; using MaidStatus.CsvData; using UnityEngine; using Yotogis; namespace scoutmode { public class ScoutMaidData : ICloneable { public static string GetThumbnailFilePath(string guid, bool temp) { return Path.Combine(Maid.ThumbnailDictionary, ((!temp) ? "_scout_" : "_scout_tmp_thum_") + guid + ".png"); } public static string GetIconThumbnailFilePath(string guid, bool temp) { return Path.Combine(Maid.ThumbnailDictionary, ((!temp) ? "_scout_icon_thum_" : "_scout_tmp_icon_thum_") + guid + ".png"); } public static string GetKasizukiThumbnailFilePath(string guid, bool temp) { return Path.Combine(Maid.ThumbnailDictionary, ((!temp) ? "_scout_kasizuki_" : "_scout_tmp_kasizuki_") + guid + ".png"); } public ScoutMaidData.SimpleStatus status { get; private set; } public byte[] iconImageBinary { get; private set; } public byte[] pressetBinary { get; private set; } public byte[] statusBinary { get; private set; } public ScoutMaidOverrideData overrideData { get; private set; } public ScoutInstanceData instanceData { get; private set; } public bool isOverRideData { get { return this.overrideData.enabled; } } public void CreateData(Maid maid) { Status status = maid.status; this.pressetBinary = GameMain.Instance.CharacterMgr.PresetSaveNotWriteFile(maid, CharacterMgr.PresetType.All); MemoryStream memoryStream = new MemoryStream(); BinaryWriter binary = new BinaryWriter(memoryStream); status.isScoutMaid = true; status.Serialize(binary); status.isScoutMaid = false; this.statusBinary = memoryStream.ToArray(); this.iconImageBinary = maid.GetThumIcon().EncodeToPNG(); this.status = new ScoutMaidData.SimpleStatus(); this.status.guid = status.guid; this.status.creationTimeNum = status.creationTimeNum; NamePair charaName = status.charaName; this.status.name1 = charaName.name1; this.status.name2 = charaName.name2; this.status.personalId = status.personal.id; this.status.initSeikeiken = status.initSeikeiken; this.status.seikeiken = status.seikeiken; this.status.height = status.body.height; this.status.weight = status.body.weight; this.status.bust = status.body.bust; this.status.waist = status.body.waist; this.status.hip = status.body.hip; this.status.cup = status.body.cup; this.status.lovely = status.lovely; this.status.elegance = status.elegance; this.status.charm = status.charm; this.status.care = status.care; this.status.reception = status.reception; this.status.cooking = status.cooking; this.status.dance = status.dance; this.status.vocal = status.vocal; this.status.teachRate = status.teachRate; this.status.studyRate = status.studyRate; this.status.maxHp = status.maxHp; this.status.maxMind = status.maxMind; this.status.inyoku = status.inyoku; this.status.mvalue = status.mvalue; this.status.hentai = status.hentai; this.status.housi = status.housi; this.status.maidPoint = GameMain.Instance.CharacterMgr.status.maidPoint; this.status.playCountYotogi = status.playCountYotogi; this.overrideData = new ScoutMaidOverrideData(); this.instanceData = new ScoutInstanceData(); } public void Apply(Maid maid) { if (maid == null) { return; } byte[] pressetBinary = this.pressetBinary; if (this.overrideData.pressetBinary != null && this.overrideData.pressetBinary.Length > 0) { pressetBinary = this.overrideData.pressetBinary; } using (BinaryReader binaryReader = new BinaryReader(new MemoryStream(pressetBinary))) { GameMain.Instance.CharacterMgr.PresetSet(maid, GameMain.Instance.CharacterMgr.PresetLoad(binaryReader, string.Empty)); } using (BinaryReader binaryReader2 = new BinaryReader(new MemoryStream(this.statusBinary))) { maid.status.Deserialize(binaryReader2); } this.overrideData.Apply(maid); this.instanceData.Apply(maid); foreach (int featureId in maid.status.features.GetKeyArray()) { maid.status.RemoveFeature(featureId); } List allDatas = Feature.GetAllDatas(true); foreach (Personal.Data.LearnFeature learnFeature in maid.status.personal.acquisitionFeatureList) { if (learnFeature.isLearnPossible(maid.status)) { maid.status.AddFeature(learnFeature.feature); } } AbstractClassData.ClassType classTypeFlags = AbstractClassData.ClassType.Share | AbstractClassData.ClassType.New | AbstractClassData.ClassType.Old; maid.status.yotogiClass.Clear(); foreach (YotogiClass.Data data in maid.status.yotogiClass.GetLearnPossibleClassDatas(false, classTypeFlags)) { if (GameMain.Instance.CharacterMgr.status.IsYotogiClassOpenFlag(data.id)) { maid.status.yotogiClass.Add(data.id, false, true); } } int id = maid.status.selectedJobClass.data.id; HashSet hashSet = new HashSet(); foreach (KeyValuePair> keyValuePair in maid.status.jobClass.GetAllDatas()) { hashSet.Add(keyValuePair.Key); } HashSet hashSet2 = new HashSet(); foreach (JobClass.Data data2 in maid.status.jobClass.GetLearnPossibleClassDatas(false, classTypeFlags)) { if (GameMain.Instance.CharacterMgr.status.IsJobClassOpenFlag(data2.id)) { hashSet2.Add(data2.id); } } HashSet hashSet3 = new HashSet(); foreach (int item in hashSet) { if (!hashSet2.Contains(item)) { hashSet3.Add(item); } } HashSet hashSet4 = new HashSet(); foreach (int item2 in hashSet2) { if (!hashSet.Contains(item2)) { hashSet4.Add(item2); } } foreach (int id2 in hashSet3) { maid.status.jobClass.Remove(id2, true); } int num = -1; foreach (int num2 in hashSet4) { maid.status.jobClass.Add(num2, false, true); num = ((num >= num2) ? num : num2); } if (num != -1) { maid.status.ChangeJobClass(num); } maid.status.yotogiSkill.Clear(); List learnPossibleSkills = Skill.GetLearnPossibleSkills(maid.status); foreach (Skill.Data data3 in learnPossibleSkills) { maid.status.yotogiSkill.Add(data3.id); } maid.status.UpdateClassBonusStatus(); maid.status.sexPlayNumberOfPeople = MaidProfile.UpdateInitPlayNumber(maid.status.maid); maid.status.UpdateBodyParam(); maid.status.profileComment = MaidProfile.Create(maid.status.maid, true); maid.status.SetFlag("__スカウトメイド", 1); } public byte[] GetIconImageBinary() { return (this.overrideData.iconImageBinary == null || this.overrideData.iconImageBinary.Length <= 0) ? this.iconImageBinary : this.overrideData.iconImageBinary; } public byte[] GetPressetBinary() { return (this.overrideData.pressetBinary == null || this.overrideData.pressetBinary.Length <= 0) ? this.pressetBinary : this.overrideData.pressetBinary; } public byte[] Serialize() { MemoryStream memoryStream = new MemoryStream(); BinaryWriter binaryWriter = new BinaryWriter(memoryStream); binaryWriter.Write("COM3D2_SCOUT_DATA"); binaryWriter.Write(1000); binaryWriter.Write(JsonUtility.ToJson(this.status)); binaryWriter.Write(this.iconImageBinary.Length); binaryWriter.Write(this.iconImageBinary); binaryWriter.Write(this.pressetBinary.Length); binaryWriter.Write(this.pressetBinary); binaryWriter.Write(this.statusBinary.Length); binaryWriter.Write(this.statusBinary); byte[] array = this.overrideData.Serialize(); binaryWriter.Write(array.Length); binaryWriter.Write(array); binaryWriter.Write(JsonUtility.ToJson(this.instanceData)); return memoryStream.ToArray(); } public void DeSerialize(byte[] data) { MemoryStream input = new MemoryStream(data); BinaryReader binaryReader = new BinaryReader(input); NDebug.Assert(binaryReader.ReadString() == "COM3D2_SCOUT_DATA", "ScoutMaidData::DeSerialize Header Check error."); int num = binaryReader.ReadInt32(); this.status = JsonUtility.FromJson(binaryReader.ReadString()); int count = binaryReader.ReadInt32(); this.iconImageBinary = binaryReader.ReadBytes(count); count = binaryReader.ReadInt32(); this.pressetBinary = binaryReader.ReadBytes(count); count = binaryReader.ReadInt32(); this.statusBinary = binaryReader.ReadBytes(count); this.overrideData = new ScoutMaidOverrideData(); count = binaryReader.ReadInt32(); this.overrideData.DeSerialize(binaryReader.ReadBytes(count)); this.instanceData = JsonUtility.FromJson(binaryReader.ReadString()); } public object Clone() { ScoutMaidData scoutMaidData = (ScoutMaidData)base.MemberwiseClone(); scoutMaidData.status = JsonUtility.FromJson(JsonUtility.ToJson(this.status)); scoutMaidData.iconImageBinary = (byte[])this.iconImageBinary.Clone(); scoutMaidData.pressetBinary = (byte[])this.pressetBinary.Clone(); scoutMaidData.statusBinary = (byte[])this.statusBinary.Clone(); scoutMaidData.overrideData = (this.overrideData.Clone() as ScoutMaidOverrideData); scoutMaidData.instanceData = (this.instanceData.Clone() as ScoutInstanceData); return scoutMaidData; } private const int FixVersion = 1000; [Serializable] public class SimpleStatus : ISerializationCallbackReceiver { public Personal.Data personal { get { return Personal.GetData(this.personalId); } } public void OnBeforeSerialize() { this.version = 1000; } public void OnAfterDeserialize() { } public int version = 1000; public string guid; public ulong creationTimeNum; public string name1; public string name2; public int personalId; public Seikeiken initSeikeiken; public Seikeiken seikeiken; public int height; public int weight; public int bust; public int waist; public int hip; public string cup; public int care; public int reception; public int teachRate; public int studyRate; public int maxHp; public int maxMind; public int lovely; public int elegance; public int charm; public int cooking; public int dance; public int vocal; public int inyoku; public int mvalue; public int hentai; public int housi; public int maidPoint; public int playCountYotogi; } } }