CharacterData.cs 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using Sirenix.OdinInspector;
  5. using NodeCanvas.DialogueTrees;
  6. using KairoEngine.Core;
  7. using KairoEngine.Inventory;
  8. using KairoEngine.Stats;
  9. namespace KairoEngine.CharacterSystem
  10. {
  11. [CreateAssetMenu(fileName = "Character", menuName = "KairoEngine/Character", order = 5)]
  12. [HideMonoScript]
  13. public class CharacterData : SerializedScriptableObject
  14. {
  15. [HorizontalGroup("Id1", 0.45f), HideLabel, PropertySpace(4, 2)] public string characterName;
  16. [HorizontalGroup("Id1", 0.2f), HideLabel, PropertySpace(4, 2)] public Race race;
  17. [HorizontalGroup("Id1", 0.15f), HideLabel, PropertySpace(4, 2)] public Gender gender;
  18. [HorizontalGroup("Id1", 0.2f), HideLabel, SuffixLabel("Years", true), PropertySpace(4, 2)] public int age;
  19. [HorizontalGroup("Id2", 0.45f), HideLabel, PropertySpace(4, 2)] public Faction faction;
  20. [HorizontalGroup("Id2", 0.35f), HideLabel, PropertySpace(4, 2)] public string id;
  21. [HorizontalGroup("Id2", 0.2f), HideLabel, Button("Randomize"), PropertySpace(4, 2)]
  22. public void RandomizeId() { id = KairoEngine.Core.Utilities.RandomString(12); }
  23. [InlineProperty, HideLabel, PropertySpace(12, 6)] public StatsController stats = new StatsController();
  24. [ListDrawerSettings(HideAddButton = false, HideRemoveButton = false, DraggableItems = true, Expanded = true, ShowPaging = false, ShowItemCount = true)]
  25. [PropertySpace(4, 8)] public List<ItemRef> itemList = new List<ItemRef>();
  26. [HorizontalGroup("Hitpoints"), SuffixLabel("HP", true), HideInInspector] public int hitpoints;
  27. [HorizontalGroup("Hitpoints", 0.3f), HideLabel, SuffixLabel("Max HP", true), HideInInspector] public int maxHitpoints;
  28. [HideInInspector] public int armor;
  29. #region Visuals
  30. [FoldoutGroup("Visuals")] public ModelData bodyModelData;
  31. private string _bodyModel = "";
  32. public string bodyModel
  33. {
  34. get
  35. {
  36. if(_bodyModel != "") return _bodyModel;
  37. else if(bodyModelData != null) return bodyModelData.name;
  38. else return "";
  39. }
  40. set
  41. {
  42. _bodyModel = value;
  43. }
  44. }
  45. [FoldoutGroup("Visuals"), Range(0, 3)] public int bodyMaterialNumber;
  46. private string _bodyMaterial = "";
  47. public string bodyMaterial
  48. {
  49. get
  50. {
  51. if(_bodyMaterial != "") return _bodyMaterial;
  52. else if(bodyModelData != null) return bodyModelData.materials[bodyMaterialNumber].name;
  53. else return "";
  54. }
  55. set
  56. {
  57. _bodyMaterial = value;
  58. }
  59. }
  60. [FoldoutGroup("Visuals")] public GameObject headAttachmentPrefab;
  61. private string _headAttachment = "";
  62. public string headAttachment
  63. {
  64. get
  65. {
  66. if(_headAttachment != "") return _headAttachment;
  67. else if(headAttachmentPrefab != null) return headAttachmentPrefab.name;
  68. else return "";
  69. }
  70. set
  71. {
  72. _headAttachment = value;
  73. }
  74. }
  75. [FoldoutGroup("Visuals")] public GameObject faceAttachmentPrefab;
  76. private string _faceAttachment = "";
  77. public string faceAttachment
  78. {
  79. get
  80. {
  81. if(_faceAttachment != "") return _faceAttachment;
  82. else if(faceAttachmentPrefab != null) return faceAttachmentPrefab.name;
  83. else return "";
  84. }
  85. set
  86. {
  87. _faceAttachment = value;
  88. }
  89. }
  90. [FoldoutGroup("Visuals"), Button("Check Visual Data Values")]
  91. public void CheckVisualData()
  92. {
  93. if(bodyModelData == null) Debug.LogError("No bodyModelData found in " + this.name, this);
  94. else Debug.Log(bodyModel + " / " + bodyMaterial, this);
  95. if(headAttachment != "") Debug.Log(headAttachment, headAttachmentPrefab);
  96. if(faceAttachment != "") Debug.Log(faceAttachment, faceAttachmentPrefab);
  97. if(bodyModelData != null) Debug.Log($"Visuals data OK for CharacterData \'{name}\'");
  98. else Debug.LogError($"Visuals data ERROR for CharacterData \'{name}\'");
  99. }
  100. #endregion
  101. [FoldoutGroup("State")] public DialogueTree dialogueTree;
  102. [FoldoutGroup("State"), LabelText("Sensor Hearing")] public bool hearing = true;
  103. [FoldoutGroup("State"), LabelText("Sensor Vision")] public bool vision = true;
  104. [FoldoutGroup("State")] public bool hasSpawned = false;
  105. [FoldoutGroup("State"), ShowIf("$hasSpawned")] public Vector3 position;
  106. [FoldoutGroup("State"), ShowIf("$hasSpawned")] public Quaternion rotation;
  107. [FoldoutGroup("State"), ShowIf("$hasSpawned")] public bool isDead = false;
  108. [FoldoutGroup("State"), ShowIf("@hasSpawned && isDead")] public List<DataBone> bones = new List<DataBone>();
  109. }
  110. public enum Gender
  111. {
  112. Male,
  113. Female,
  114. Other
  115. }
  116. public enum Race
  117. {
  118. Human,
  119. Inorganic,
  120. Reptilian,
  121. Ghoul
  122. }
  123. }