Status.cs 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. using System;
  2. using System.Collections.Generic;
  3. using System.IO;
  4. using wf;
  5. namespace MaidStatus.Old
  6. {
  7. public class Status
  8. {
  9. public Status(Status status)
  10. {
  11. this.mainStatus = status;
  12. this.relation = Relation.Contact;
  13. this.sexual = new Sexual();
  14. this.flags_ = new Dictionary<string, int>();
  15. this.flags = new ReadOnlyDictionary<string, int>(this.flags_);
  16. }
  17. public Relation relation
  18. {
  19. get
  20. {
  21. return this.relation_;
  22. }
  23. set
  24. {
  25. this.relation_ = value;
  26. if ((this.relation_ == Relation.Tonus || this.relation_ == Relation.Contact) && this.mainStatus.relation != Relation.Contact)
  27. {
  28. this.mainStatus.relation = Relation.Contact;
  29. }
  30. else if (this.relation_ == Relation.Trust && this.mainStatus.relation != Relation.Trust)
  31. {
  32. this.mainStatus.relation = Relation.Trust;
  33. }
  34. else if ((this.relation_ == Relation.Slave || this.relation_ == Relation.Lover) && this.mainStatus.relation != Relation.Lover)
  35. {
  36. this.mainStatus.relation = Relation.Lover;
  37. }
  38. this.relation_ = value;
  39. }
  40. }
  41. public int frustration
  42. {
  43. get
  44. {
  45. return (int)this.frustration_;
  46. }
  47. set
  48. {
  49. this.frustration_ = (short)wf.Math.RoundMinMax(value, 0, 100);
  50. }
  51. }
  52. public ReadOnlyDictionary<string, int> flags { get; private set; }
  53. public void SetFlag(string flagName, int value)
  54. {
  55. if (!this.flags_.ContainsKey(flagName))
  56. {
  57. this.flags_.Add(flagName, value);
  58. }
  59. else
  60. {
  61. this.flags_[flagName] = value;
  62. }
  63. }
  64. public void AddFlag(string flagName, int value)
  65. {
  66. if (!this.flags_.ContainsKey(flagName))
  67. {
  68. this.flags_.Add(flagName, value);
  69. }
  70. else
  71. {
  72. Dictionary<string, int> dictionary;
  73. (dictionary = this.flags_)[flagName] = dictionary[flagName] + value;
  74. }
  75. }
  76. public int GetFlag(string flagName)
  77. {
  78. return (!this.flags_.ContainsKey(flagName)) ? 0 : this.flags_[flagName];
  79. }
  80. public bool RemoveFlag(string flagName)
  81. {
  82. return this.flags_.ContainsKey(flagName) && this.flags_.Remove(flagName);
  83. }
  84. public void Serialize(BinaryWriter binary)
  85. {
  86. binary.Write(this.employmentElapsedDay);
  87. binary.Write((short)this.condition);
  88. this.sexual.Serialize(binary);
  89. binary.Write((short)this.relation);
  90. binary.Write((short)this.frustration);
  91. binary.Write(this.isMarriage);
  92. binary.Write(this.isNewWife);
  93. binary.Write(this.isRentalMaid);
  94. binary.Write((short)this.flags_.Count);
  95. foreach (KeyValuePair<string, int> keyValuePair in this.flags_)
  96. {
  97. binary.Write(keyValuePair.Key);
  98. binary.Write(keyValuePair.Value);
  99. }
  100. }
  101. public void Deserialize(BinaryReader binary, int version)
  102. {
  103. this.employmentElapsedDay = binary.ReadInt32();
  104. this.condition = (Condition)binary.ReadInt16();
  105. this.sexual.Deserialize(binary, version);
  106. this.relation = (Relation)binary.ReadInt16();
  107. this.frustration_ = binary.ReadInt16();
  108. this.isMarriage = binary.ReadBoolean();
  109. this.isNewWife = binary.ReadBoolean();
  110. this.isRentalMaid = binary.ReadBoolean();
  111. int num = (int)binary.ReadInt16();
  112. this.flags_.Clear();
  113. for (int i = 0; i < num; i++)
  114. {
  115. string key = binary.ReadString();
  116. int value = binary.ReadInt32();
  117. this.flags_.Add(key, value);
  118. }
  119. }
  120. public readonly Status mainStatus;
  121. public int employmentElapsedDay;
  122. public Condition condition;
  123. public Sexual sexual;
  124. public bool isMarriage;
  125. public bool isNewWife;
  126. public bool isRentalMaid;
  127. private Relation relation_;
  128. private short frustration_;
  129. private Dictionary<string, int> flags_;
  130. }
  131. }