123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151 |
- using System;
- using System.Collections.Generic;
- using System.IO;
- using wf;
- namespace MaidStatus.Old
- {
- public class Status
- {
- public Status(Status status)
- {
- this.mainStatus = status;
- this.relation = Relation.Contact;
- this.sexual = new Sexual();
- this.flags_ = new Dictionary<string, int>();
- this.flags = new ReadOnlyDictionary<string, int>(this.flags_);
- }
- public Relation relation
- {
- get
- {
- return this.relation_;
- }
- set
- {
- this.relation_ = value;
- if ((this.relation_ == Relation.Tonus || this.relation_ == Relation.Contact) && this.mainStatus.relation != Relation.Contact)
- {
- this.mainStatus.relation = Relation.Contact;
- }
- else if (this.relation_ == Relation.Trust && this.mainStatus.relation != Relation.Trust)
- {
- this.mainStatus.relation = Relation.Trust;
- }
- else if ((this.relation_ == Relation.Slave || this.relation_ == Relation.Lover) && this.mainStatus.relation != Relation.Lover)
- {
- this.mainStatus.relation = Relation.Lover;
- }
- this.relation_ = value;
- }
- }
- public int frustration
- {
- get
- {
- return (int)this.frustration_;
- }
- set
- {
- this.frustration_ = (short)wf.Math.RoundMinMax(value, 0, 100);
- }
- }
- public ReadOnlyDictionary<string, int> flags { get; private set; }
- public void SetFlag(string flagName, int value)
- {
- if (!this.flags_.ContainsKey(flagName))
- {
- this.flags_.Add(flagName, value);
- }
- else
- {
- this.flags_[flagName] = value;
- }
- }
- public void AddFlag(string flagName, int value)
- {
- if (!this.flags_.ContainsKey(flagName))
- {
- this.flags_.Add(flagName, value);
- }
- else
- {
- Dictionary<string, int> dictionary;
- (dictionary = this.flags_)[flagName] = dictionary[flagName] + value;
- }
- }
- public int GetFlag(string flagName)
- {
- return (!this.flags_.ContainsKey(flagName)) ? 0 : this.flags_[flagName];
- }
- public bool RemoveFlag(string flagName)
- {
- return this.flags_.ContainsKey(flagName) && this.flags_.Remove(flagName);
- }
- public void Serialize(BinaryWriter binary)
- {
- binary.Write(this.employmentElapsedDay);
- binary.Write((short)this.condition);
- this.sexual.Serialize(binary);
- binary.Write((short)this.relation);
- binary.Write((short)this.frustration);
- binary.Write(this.isMarriage);
- binary.Write(this.isNewWife);
- binary.Write(this.isRentalMaid);
- binary.Write((short)this.flags_.Count);
- foreach (KeyValuePair<string, int> keyValuePair in this.flags_)
- {
- binary.Write(keyValuePair.Key);
- binary.Write(keyValuePair.Value);
- }
- }
- public void Deserialize(BinaryReader binary, int version)
- {
- this.employmentElapsedDay = binary.ReadInt32();
- this.condition = (Condition)binary.ReadInt16();
- this.sexual.Deserialize(binary, version);
- this.relation = (Relation)binary.ReadInt16();
- this.frustration_ = binary.ReadInt16();
- this.isMarriage = binary.ReadBoolean();
- this.isNewWife = binary.ReadBoolean();
- this.isRentalMaid = binary.ReadBoolean();
- int num = (int)binary.ReadInt16();
- this.flags_.Clear();
- for (int i = 0; i < num; i++)
- {
- string key = binary.ReadString();
- int value = binary.ReadInt32();
- this.flags_.Add(key, value);
- }
- }
- public readonly Status mainStatus;
- public int employmentElapsedDay;
- public Condition condition;
- public Sexual sexual;
- public bool isMarriage;
- public bool isNewWife;
- public bool isRentalMaid;
- private Relation relation_;
- private short frustration_;
- private Dictionary<string, int> flags_;
- }
- }
|