using System.Collections; using System.Collections.Generic; using UnityEngine; using KairoEngine.Utilities; using Sirenix.OdinInspector; using KairoEngine.Core; using KairoEngine.Inventory; namespace KairoEngine.CharacterSystem { [CreateAssetMenu(fileName = "RandomCharacter", menuName = "KairoEngine/RandomCharacter", order = 7)] public class CharacterRandom : SerializedScriptableObject { [Title("Identification")] public Race race; public Faction faction; [Title("Details")] public Gender gender; [Range(18, 85)] public int minAge = 24; [Range(18, 85)] public int maxAge = 38; [HorizontalGroup("Hitpoints"), SuffixLabel("HP", true)] public int hitpoints; [HorizontalGroup("Hitpoints", 0.3f), HideLabel, SuffixLabel("Max HP", true)] public int maxHitpoints; public int armor; [Title("Visuals")] public List bodyModelList; public List headAttachmentPrefabList; public List faceAttachmentPrefabList; [Title("Items")] [MinMaxSlider(0, 5, true)] public Vector2 extraClips = new Vector2(1,2); public List randomFirearm; public List randomMeleeWeapon; public List randomItems = new List(); public CharacterData Generate(string id = "") { CharacterData data = ScriptableObject.CreateInstance(); if(id == "") id = KairoEngine.Core.Utilities.RandomString(12); data.characterName = ""; data.id = id; data.race = race; data.faction = faction; data.gender = gender; data.age = Random.Range(minAge, maxAge + 1); data.hitpoints = hitpoints; data.maxHitpoints = maxHitpoints; data.armor = armor; data.bodyModelData = bodyModelList[Random.Range(0, bodyModelList.Count)]; data.bodyMaterialNumber = Random.Range(0, data.bodyModelData.materials.Count); if(headAttachmentPrefabList.Count > 0) { GameObject headAttachment = headAttachmentPrefabList[Random.Range(0, headAttachmentPrefabList.Count)]; if(headAttachment != null) data.headAttachmentPrefab = headAttachment; } if(faceAttachmentPrefabList.Count > 0) { GameObject faceAttachment = faceAttachmentPrefabList[Random.Range(0, faceAttachmentPrefabList.Count)]; if(faceAttachment != null) data.faceAttachmentPrefab = faceAttachment; } if(randomFirearm.Count > 0) { ItemBaseFirearm firearm = randomFirearm[Random.Range(0, randomFirearm.Count)]; ItemFirearmRef firearmRef = new ItemFirearmRef(firearm, 1, firearm.ammoType, firearm.ammoCapacity); data.itemList.Add(firearmRef); ItemRef ammoRef = new ItemRef(firearm.ammoType, firearm.ammoCapacity * (int)Random.Range(extraClips.x, extraClips.y)); data.itemList.Add(ammoRef); } if(randomMeleeWeapon.Count > 0) { ItemBaseHandWeapon handWeapon = randomMeleeWeapon[Random.Range(0, randomMeleeWeapon.Count)]; ItemRef itemRef = new ItemRef(handWeapon, 1); data.itemList.Add(itemRef); } if(randomItems.Count > 0) { for (int i = 0; i < randomItems.Count; i++) { RandomItem item = randomItems[i]; float dice = Random.Range(0, 101); if(dice <= item.probability) { int quantity = Random.Range((int)item.quantity.x, ((int)item.quantity.y) + 1); if(item.item.category == ItemType.firearm) { ItemBaseFirearm itemBaseFirearm = (ItemBaseFirearm)item.item; ItemBaseAmmo itemBaseAmmo = (ItemBaseAmmo)itemBaseFirearm.ammoType; int ammo = itemBaseFirearm.ammoCapacity; ItemFirearmRef firearmRef = new ItemFirearmRef(itemBaseFirearm, quantity, itemBaseAmmo, ammo); data.itemList.Add(firearmRef); } else { ItemRef itemRef = new ItemRef(item.item, quantity, 10000); data.itemList.Add(itemRef); } } } } return data; } } }