Actor.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text.Json.Serialization;
  4. namespace SOTF_Struct.Generic {
  5. public class Actor {
  6. public const int MAX_TYPEID = 60;
  7. public enum eActorType {
  8. Unknown,
  9. Animal,
  10. NPC,
  11. Cannibal,
  12. Creep,
  13. Daemon
  14. }
  15. /// <summary>
  16. /// A class containing actor stats
  17. /// </summary>
  18. public class ActorStats {
  19. /// <summary>
  20. /// The actors health
  21. /// </summary>
  22. [JsonIgnore(Condition = JsonIgnoreCondition.Never)]
  23. public double Health { get; set; }
  24. /// <summary>
  25. /// The actors anger
  26. /// </summary>
  27. [JsonIgnore(Condition = JsonIgnoreCondition.Never)]
  28. public double Anger { get; set; }
  29. /// <summary>
  30. /// The actors fear
  31. /// </summary>
  32. [JsonIgnore(Condition = JsonIgnoreCondition.Never)]
  33. public double Fear { get; set; }
  34. /// <summary>
  35. /// The actors fullness
  36. /// </summary>
  37. [JsonIgnore(Condition = JsonIgnoreCondition.Never)]
  38. public double Fullness { get; set; }
  39. /// <summary>
  40. /// The actors hydration
  41. /// </summary>
  42. [JsonIgnore(Condition = JsonIgnoreCondition.Never)]
  43. public double Hydration { get; set; }
  44. /// <summary>
  45. /// The actors energy
  46. /// </summary>
  47. [JsonIgnore(Condition = JsonIgnoreCondition.Never)]
  48. public double Energy { get; set; }
  49. /// <summary>
  50. /// The actors affection
  51. /// </summary>
  52. [JsonIgnore(Condition = JsonIgnoreCondition.Never)]
  53. public double Affection { get; set; }
  54. }
  55. /// <summary>
  56. /// The actors unique id
  57. /// </summary>
  58. [JsonIgnore(Condition = JsonIgnoreCondition.Never)]
  59. public int UniqueId { get; set; }
  60. /// <summary>
  61. /// The actor type.
  62. /// For example: 9 is Kelvin, 10 is Virginia, 11 is the big mouth mutant
  63. /// </summary>
  64. [JsonIgnore(Condition = JsonIgnoreCondition.Never)]
  65. public int TypeId { get; set; }
  66. /// <summary>
  67. /// The actors family.
  68. /// 0 is neutral
  69. /// </summary>
  70. [JsonIgnore(Condition = JsonIgnoreCondition.Never)]
  71. public int FamilyId { get; set; }
  72. /// <summary>
  73. /// The actors position
  74. /// </summary>
  75. [JsonIgnore(Condition = JsonIgnoreCondition.Never)]
  76. public Position Position { get; set; }
  77. /// <summary>
  78. /// The actors rotation
  79. /// </summary>
  80. [JsonIgnore(Condition = JsonIgnoreCondition.Never)]
  81. public Rotation Rotation { get; set; }
  82. /// <summary>
  83. /// The spawner ID
  84. /// </summary>
  85. [JsonIgnore(Condition = JsonIgnoreCondition.Never)]
  86. public int SpawnerId { get; set; }
  87. [JsonIgnore(Condition = JsonIgnoreCondition.Never)]
  88. public int ActorSeed { get; set; }
  89. /// <summary>
  90. /// The looking variation the actor has got
  91. /// </summary>
  92. [JsonIgnore(Condition = JsonIgnoreCondition.Never)]
  93. public int VariationId { get; set; }
  94. /// <summary>
  95. /// The actors state
  96. /// </summary>
  97. [JsonIgnore(Condition = JsonIgnoreCondition.Never)]
  98. public int State { get; set; }
  99. [JsonIgnore(Condition = JsonIgnoreCondition.Never)]
  100. public int GraphMask { get; set; }
  101. [JsonIgnore(Condition = JsonIgnoreCondition.Always)]
  102. public int AreaMask {
  103. get {
  104. return SOTF_Savegame_Editor.SOTFSave.SOTF.MapGraphMaskToAreaMask(this.GraphMask);
  105. }
  106. set {
  107. this.GraphMask = SOTF_Savegame_Editor.SOTFSave.SOTF.MapAreaMaskToGraphMask(this.GraphMask);
  108. }
  109. }
  110. /// <summary>
  111. /// The equipment, the actor has got (shotgun, GPS, pistol, ...)
  112. /// </summary>
  113. [JsonIgnore(Condition = JsonIgnoreCondition.Never)]
  114. public List<int> EquippedItems { get; set; } // TODO
  115. /// <summary>
  116. /// The outfit this character is wearing
  117. /// </summary>
  118. [JsonIgnore(Condition = JsonIgnoreCondition.Never)]
  119. public int OutfitId { get; set; }
  120. [JsonIgnore(Condition = JsonIgnoreCondition.Never)]
  121. public double NextGiftTime { get; set; }
  122. [JsonIgnore(Condition = JsonIgnoreCondition.Never)]
  123. public double LastVisitTime { get; set; }
  124. /// <summary>
  125. /// The actor stats list
  126. /// </summary>
  127. [JsonIgnore(Condition = JsonIgnoreCondition.Never)]
  128. public ActorStats Stats { get; set; }
  129. [JsonIgnore(Condition = JsonIgnoreCondition.Never)]
  130. public int StateFlags { get; set; }
  131. /// <summary>
  132. /// Revives the actor
  133. /// </summary>
  134. public void Revive() {
  135. if(this.State==6) {
  136. this.State = 2;
  137. this.Stats.Health = 1;
  138. }
  139. }
  140. /// <summary>
  141. /// Returns the Display Name for this actor
  142. /// </summary>
  143. /// <returns>String with the Display Name. If the Actor Type wasn't found, it returns 'ACTOR_id'</returns>
  144. public string GetDisplayName() {
  145. return GetDisplayNameById(this.TypeId);
  146. }
  147. /// <summary>
  148. /// 0 = Diverse, 1 = Male, 2 = Female
  149. /// </summary>
  150. [JsonIgnore(Condition = JsonIgnoreCondition.Always)]
  151. public int Gendre {
  152. get {
  153. return GetGendreById(this.TypeId);
  154. }
  155. }
  156. [JsonIgnore(Condition = JsonIgnoreCondition.Always)]
  157. public eActorType ActorType {
  158. get {
  159. eActorType res = GetActorTypeById(this.TypeId);
  160. System.Diagnostics.Debug.WriteLine("ActorType = " + res.ToString());
  161. return res;
  162. }
  163. }
  164. public static eActorType GetActorTypeById(int TypeId) {
  165. System.Diagnostics.Debug.WriteLine("GetActorTypeById(" + TypeId + ")");
  166. if(TypeId == 24 ||TypeId == 32 ||TypeId == 35 || TypeId == 43)
  167. return eActorType.Unknown;
  168. if (TypeId <= 7) return eActorType.Animal;
  169. else if (TypeId <= 10) return eActorType.NPC;
  170. else if (TypeId == 11) return eActorType.Creep;
  171. else if (TypeId <= 16) return eActorType.Cannibal;
  172. else if (TypeId == 17) return eActorType.Animal;
  173. else if (TypeId <= 22) return eActorType.Creep;
  174. else if (TypeId <= 22) return eActorType.Creep;
  175. else if (TypeId <= 31) return eActorType.Cannibal;
  176. else if (TypeId <= 37) return eActorType.Animal;
  177. else if (TypeId == 38) return eActorType.Creep;
  178. else if (TypeId == 39) return eActorType.NPC;
  179. else if (TypeId <= 41) return eActorType.Creep;
  180. else if (TypeId == 42) return eActorType.Daemon;
  181. else if (TypeId == 43) return eActorType.Cannibal;
  182. else if (TypeId == 45) return eActorType.Daemon;
  183. else if (TypeId <= 47) return eActorType.Creep;
  184. else
  185. return eActorType.Unknown;
  186. }
  187. /// <summary>
  188. /// 0 = Diverse, 1 = Male, 2 = Female
  189. /// </summary>
  190. /// <param name="TypeId">The Actors TypeID</param>
  191. /// <returns>0 = Diverse, 1 = Male, 2 = Female</returns>
  192. public static int GetGendreById(int TypeId) {
  193. switch(TypeId) {
  194. case 8:
  195. case 9:
  196. case 12:
  197. case 13:
  198. case 14:
  199. case 15:
  200. case 16:
  201. case 20:
  202. case 27:
  203. case 29:
  204. case 30:
  205. case 31:
  206. case 38:
  207. case 41:
  208. case 43:
  209. case 46:
  210. return 1;
  211. case 21:
  212. case 23:
  213. case 25:
  214. case 26:
  215. case 28:
  216. case 39:
  217. case 45:
  218. case 47:
  219. return 2;
  220. }
  221. return 0;
  222. }
  223. public static string GetDisplayNameById(int TypeId) {
  224. if (TypeId == 0) return "ACTOR_0";
  225. else if (TypeId == 1) return "Rabbit";
  226. else if (TypeId == 2) return "Squirrel";
  227. else if (TypeId == 3) return "Sea turtle";
  228. else if (TypeId == 4) return "Shark";
  229. else if (TypeId == 5) return "Seagull";
  230. else if (TypeId == 6) return "Eagle";
  231. else if (TypeId == 7) return "Duck";
  232. else if (TypeId == 8) return "Timmy";
  233. else if (TypeId == 9) return "Kelvin";
  234. else if (TypeId == 10) return "Virginia";
  235. else if (TypeId == 11) return "Fingers";
  236. else if (TypeId == 12) return "Cannibal Carl";
  237. else if (TypeId == 13) return "Cannibal Andy";
  238. else if (TypeId == 14) return "Cannibal Danny";
  239. else if (TypeId == 15) return "Cannibal Billy";
  240. else if (TypeId == 16) return "Gold Mask";
  241. else if (TypeId == 17) return "Moose";
  242. else if (TypeId == 18) return "Baby";
  243. else if (TypeId == 19) return "Twins";
  244. else if (TypeId == 20) return "Mutant (Puffy Male)";
  245. else if (TypeId == 21) return "Mutant (Puffy Female)";
  246. else if (TypeId == 22) return "Sluggy";
  247. else if (TypeId == 23) return "Cannibal Angel"; // F
  248. //else if (TypeId == 24) return "";
  249. else if (TypeId == 25) return "Cannibal Brandy"; // F
  250. else if (TypeId == 26) return "CannibalCrystal"; // F
  251. else if (TypeId == 27) return "Cannibal Destiny"; // F
  252. else if (TypeId == 28) return "Muddy Female Cannibal"; // F
  253. else if (TypeId == 29) return "Muddy Male Cannibal";
  254. else if (TypeId == 30) return "Heavy Male Cannibal";
  255. else if (TypeId == 31) return "Red masked Cannibal"; // Sponge Test
  256. else if (TypeId == 32) return "Bat";
  257. else if (TypeId == 33) return "Deer";
  258. else if (TypeId == 34) return "Bluebird";
  259. //else if (TypeId == 35) return "";
  260. else if (TypeId == 36) return "Killer Whale";
  261. else if (TypeId == 37) return "Land turtle";
  262. else if (TypeId == 38) return "Fat Male Cannibal";
  263. else if (TypeId == 39) return "Fat Female Cannibal";
  264. else if (TypeId == 40) return "John / Cat Dog";
  265. else if (TypeId == 41) return "Faceless Male";
  266. else if (TypeId == 42) return "Deamon";
  267. else if (TypeId == 43) return "Painted Cannibal Male";
  268. //else if (TypeId == 44) return "";
  269. else if (TypeId == 45) return "Daemon Queen";
  270. else if (TypeId == 46) return "Mr. Pufton (Boss)";
  271. else if (TypeId == 47) return "Ms. Pufton (Boss)";
  272. else
  273. return "ACTOR_" + TypeId.ToString();
  274. }
  275. }
  276. }