123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344 |
- 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<Feature.Data> 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<int> hashSet = new HashSet<int>();
- foreach (KeyValuePair<int, ClassData<JobClass.Data>> keyValuePair in maid.status.jobClass.GetAllDatas())
- {
- hashSet.Add(keyValuePair.Key);
- }
- HashSet<int> hashSet2 = new HashSet<int>();
- foreach (JobClass.Data data2 in maid.status.jobClass.GetLearnPossibleClassDatas(false, classTypeFlags))
- {
- if (GameMain.Instance.CharacterMgr.status.IsJobClassOpenFlag(data2.id))
- {
- hashSet2.Add(data2.id);
- }
- }
- HashSet<int> hashSet3 = new HashSet<int>();
- foreach (int item in hashSet)
- {
- if (!hashSet2.Contains(item))
- {
- hashSet3.Add(item);
- }
- }
- HashSet<int> hashSet4 = new HashSet<int>();
- 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<Skill.Data> 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<ScoutMaidData.SimpleStatus>(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<ScoutInstanceData>(binaryReader.ReadString());
- }
- public object Clone()
- {
- ScoutMaidData scoutMaidData = (ScoutMaidData)base.MemberwiseClone();
- scoutMaidData.status = JsonUtility.FromJson<ScoutMaidData.SimpleStatus>(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;
- }
- }
- }
|