123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123 |
- using System;
- using System.Collections.Generic;
- using MaidStatus;
- using UnityEngine;
- namespace scoutmode
- {
- [Serializable]
- public class ScoutInstanceData : ISerializationCallbackReceiver, ICloneable
- {
- public void Apply(Maid maid)
- {
- if (this.enabled)
- {
- maid.status.relation = this.relation;
- maid.status.additionalRelation = this.additionalRelation;
- maid.status.likability = this.likability;
- maid.status.seikeiken = this.seikeiken;
- foreach (string flagName in maid.status.flags.GetKeyArray())
- {
- maid.status.RemoveFlag(flagName);
- }
- foreach (KeyValuePair<string, int> keyValuePair in this.maidFlags)
- {
- maid.status.AddFlag(keyValuePair.Key, keyValuePair.Value);
- }
- }
- }
- public void Create(Maid maid, string stageName, ScoutOptionData options)
- {
- if (maid == null || this.enabled)
- {
- return;
- }
- this.enabled = true;
- this.stageName = stageName;
- this.options = options;
- this.Update(maid);
- }
- public void Update(Maid maid)
- {
- if (maid == null)
- {
- return;
- }
- this.relation = maid.status.relation;
- this.additionalRelation = maid.status.additionalRelation;
- this.likability = maid.status.likability;
- this.seikeiken = maid.status.seikeiken;
- this.maidFlags = maid.status.flags.Copy();
- }
- public void Destroy()
- {
- this.enabled = false;
- }
- public void OnBeforeSerialize()
- {
- this.version = 1000;
- if (this.maidFlags == null)
- {
- this.maidFlags = new Dictionary<string, int>();
- }
- if (!this.enabled)
- {
- this.maidFlags.Clear();
- }
- this.maidFlags_Key = new string[this.maidFlags.Count];
- this.maidFlags_Value = new int[this.maidFlags.Count];
- int num = 0;
- foreach (KeyValuePair<string, int> keyValuePair in this.maidFlags)
- {
- this.maidFlags_Key[num] = keyValuePair.Key;
- this.maidFlags_Value[num] = keyValuePair.Value;
- num++;
- }
- }
- public void OnAfterDeserialize()
- {
- this.maidFlags = new Dictionary<string, int>();
- for (int i = 0; i < this.maidFlags_Key.Length; i++)
- {
- this.maidFlags.Add(this.maidFlags_Key[i], this.maidFlags_Value[i]);
- }
- }
- public object Clone()
- {
- ScoutInstanceData scoutInstanceData = (ScoutInstanceData)base.MemberwiseClone();
- return JsonUtility.FromJson<ScoutInstanceData>(JsonUtility.ToJson(this));
- }
- private const int FixVersion = 1000;
- public int version = 1000;
- public bool enabled;
- public Relation relation;
- public AdditionalRelation additionalRelation;
- public int likability;
- public string stageName;
- public Seikeiken seikeiken;
- public Dictionary<string, int> maidFlags = new Dictionary<string, int>();
- public ScoutOptionData options;
- [SerializeField]
- private string[] maidFlags_Key;
- [SerializeField]
- private int[] maidFlags_Value;
- }
- }
|