Esempio n. 1
0
        static void BuildViewLookup()
        {
            string getViewName(BlueprintUnit bp)
            {
                if (!LibraryThing.GetResourceGuidMap().ContainsKey(bp.Prefab.AssetId))
                {
                    return("NULL");
                }
                var path = LibraryThing.GetResourceGuidMap()[bp.Prefab.AssetId].Split('/');

                return(path[path.Length - 1]);
            }

            var units = BluePrintThing.GetBlueprints <BlueprintUnit>().OrderBy(getViewName);

            foreach (var bp in units)
            {
                if (bp.Prefab.AssetId == "")
                {
                    continue;
                }
                if (!LibraryThing.GetResourceGuidMap().ContainsKey(bp.Prefab.AssetId))
                {
                    continue;
                }
                if (m_Units.ContainsKey(bp.Prefab.AssetId))
                {
                    continue;
                }
                m_Units[bp.Prefab.AssetId] = getViewName(bp);
            }
        }
Esempio n. 2
0
        static void BuildWeaponLookup()
        {
            var weapons = BluePrintThing.GetBlueprints <BlueprintItemEquipmentHand>().OrderBy((bp) => bp.name);

            foreach (var bp in weapons)
            {
                var visualParameters = bp.VisualParameters;
                var animationStyle   = visualParameters.AnimStyle.ToString();
                if (bp.VisualParameters.Model == null)
                {
                    continue;
                }
                Dictionary <BlueprintRef, string> eeList = null;
                if (!m_Weapons.ContainsKey(animationStyle))
                {
                    eeList = new Dictionary <BlueprintRef, string>();
                    m_Weapons[animationStyle] = eeList;
                }
                else
                {
                    eeList = m_Weapons[animationStyle];
                }
                if (eeList.ContainsKey(bp.AssetGuid))
                {
                    continue;
                }
                eeList[bp.AssetGuid] = bp.name;
            }
        }
        static void BuildLookup()
        {
            m_lookup = new Dictionary <string, EquipmentEntityInfo>();;
            var races       = BluePrintThing.GetBlueprints <BlueprintRace>();
            var racePresets = BluePrintThing.GetBlueprints <BlueprintRaceVisualPreset>();
            var classes     = BluePrintThing.GetBlueprints <BlueprintCharacterClass>();

            foreach (var race in races)
            {
                foreach (var gender in new Gender[] { Gender.Male, Gender.Female })
                {
                    CustomizationOptions customizationOptions = gender != Gender.Male ? race.FemaleOptions : race.MaleOptions;
                    AddLinks(customizationOptions.Heads, "Head", race.RaceId, gender);
                    AddLinks(customizationOptions.Hair, "Hair", race.RaceId, gender);
                    AddLinks(customizationOptions.Beards, "Beards", race.RaceId, gender);
                    AddLinks(customizationOptions.Eyebrows, "Eyebrows", race.RaceId, gender);
                }
            }
            foreach (var racePreset in racePresets)
            {
                foreach (var gender in new Gender[] { Gender.Male, Gender.Female })
                {
                    var raceSkin = racePreset.Skin;
                    if (raceSkin == null)
                    {
                        continue;
                    }
                    AddLinks(raceSkin.GetLinks(gender, racePreset.RaceId), "Skin", racePreset.RaceId, gender);
                }
            }
            foreach (var _class in classes)
            {
                foreach (var race in races)
                {
                    foreach (var gender in new Gender[] { Gender.Male, Gender.Female })
                    {
                        AddLinks(_class.GetClothesLinks(gender, race.RaceId).ToArray(), "ClassOutfit", race.RaceId, gender);
                    }
                }
            }
            var gear = BluePrintThing.GetBlueprints <KingmakerEquipmentEntity>();

            foreach (var race in races)
            {
                foreach (var gender in new Gender[] { Gender.Male, Gender.Female })
                {
                    foreach (var kee in gear)
                    {
                        AddLinks(kee.GetLinks(gender, race.RaceId), "Armor", race.RaceId, gender);
                    }
                }
            }
            blueprintBuffs = BluePrintThing.GetBlueprints <BlueprintBuff>().ToArray();
        }
        static void ShowAsksInfo(UnitEntityData unitEntityData)
        {
            var asks         = unitEntityData.Descriptor.Asks;
            var customAsks   = unitEntityData.Descriptor.CustomAsks;
            var overrideAsks = unitEntityData.Descriptor.OverrideAsks;

            GUILayout.Label($"Current Asks: {asks?.name}, Display: {asks?.DisplayName}", GUILayout.Width(200f));
            GUILayout.Label($"Current CustomAsks: {customAsks?.name}, Display: {customAsks?.DisplayName}", GUILayout.Width(200f));
            GUILayout.Label($"Current OverrideAsks: {overrideAsks?.name}, Display: {overrideAsks?.DisplayName}", GUILayout.Width(200f));
            foreach (var blueprint in BluePrintThing.GetBlueprints <BlueprintUnitAsksList>())
            {
                GUILayout.Label($"Asks: {blueprint}, Display: {blueprint.DisplayName}", GUILayout.Width(200f));
            }
        }
Esempio n. 5
0
        static void BuildWeaponEnchantmentLookup()
        {
            var enchantments = BluePrintThing.GetBlueprints <BlueprintWeaponEnchantment>()
                               .Where(bp => bp.WeaponFxPrefab != null)
                               .OrderBy(bp => bp.WeaponFxPrefab.name);
            HashSet <int> seen = new HashSet <int>();

            foreach (var enchantment in enchantments)
            {
                if (seen.Contains(enchantment.WeaponFxPrefab.GetInstanceID()))
                {
                    continue;
                }
                seen.Add(enchantment.WeaponFxPrefab.GetInstanceID());
                var name = enchantment.WeaponFxPrefab.name.Replace("00_WeaponBuff", "");
                name = name.TrimEnd('_');
                m_WeaponEnchantments[enchantment.AssetGuid] = name;
            }
        }
        static void BuildOrphenedKingmakerEquipment()
        {
            m_OrphanedKingmakerEquipment = new Dictionary <string, string>();
            var itemLinks = EquipmentResourcesManager.Helm.Keys
                            .Concat(EquipmentResourcesManager.Shirt.Keys)
                            .Concat(EquipmentResourcesManager.Armor.Keys)
                            .Concat(EquipmentResourcesManager.Bracers.Keys)
                            .Concat(EquipmentResourcesManager.Gloves.Keys)
                            .Concat(EquipmentResourcesManager.Boots.Keys)
                            .Distinct()
                            .ToDictionary(key => key);

            foreach (var kee in BluePrintThing.GetBlueprints <KingmakerEquipmentEntity>())
            {
                if (!itemLinks.ContainsKey(kee.AssetGuid))
                {
                    m_OrphanedKingmakerEquipment[kee.AssetGuid] = kee.name;
                }
            }
        }
        static void BuildOrphanedEquipment()
        {
            string maleFilepath = "Mods/VisualAdjustments/MaleOrphanedEquipment.json";

            if (File.Exists(maleFilepath))
            {
                JsonSerializer serializer = new JsonSerializer();
                using (StreamReader sr = new StreamReader(maleFilepath))
                    using (JsonTextReader reader = new JsonTextReader(sr))
                    {
                        var result = serializer.Deserialize <Dictionary <string, string> >(reader);
                        m_OrphanedMaleEquipment = result;
                        if (m_OrphanedMaleEquipment == null)
                        {
                            Main.Log($"Error loading {maleFilepath}");
                        }
                    }
            }
            var femaleFilepath = "Mods/VisualAdjustments/FemaleOrphanedEquipment.json";

            if (File.Exists(femaleFilepath))
            {
                JsonSerializer serializer = new JsonSerializer();
                using (StreamReader sr = new StreamReader(femaleFilepath))
                    using (JsonTextReader reader = new JsonTextReader(sr))
                    {
                        var result = serializer.Deserialize <Dictionary <string, string> >(reader);
                        m_OrphanedFemaleEquipment = result;
                        if (m_OrphanedFemaleEquipment == null)
                        {
                            Main.Log($"Error loading {femaleFilepath}");
                        }
                    }
            }
            if (m_OrphanedMaleEquipment == null || m_OrphanedFemaleEquipment == null)
            {
                Main.Log("Rebuilding Orphaned Equipment Lookup");
                var eeBlacklist = new HashSet <string>();
                foreach (var gender in new Gender[] { Gender.Male, Gender.Female })
                {
                    foreach (var race in BlueprintRoot.Instance.Progression.CharacterRaces)
                    {
                        var armorLinks = BluePrintThing.GetBlueprints <KingmakerEquipmentEntity>()
                                         .SelectMany(kee => kee.GetLinks(gender, race.RaceId));
                        var options = gender == Gender.Male ? race.MaleOptions : race.FemaleOptions;
                        var links   = race.Presets
                                      .SelectMany(preset => preset.Skin.GetLinks(gender, race.RaceId))
                                      .Concat(armorLinks)
                                      .Concat(options.Beards)
                                      .Concat(options.Eyebrows)
                                      .Concat(options.Hair)
                                      .Concat(options.Heads)
                                      .Concat(options.Horns);
                        foreach (var link in links)
                        {
                            eeBlacklist.Add(link.AssetId);
                        }
                    }
                }

                m_OrphanedMaleEquipment   = new Dictionary <string, string>();
                m_OrphanedFemaleEquipment = new Dictionary <string, string>();
                foreach (var kv in LibraryThing.GetResourceGuidMap().OrderBy(kv => kv.Value))
                {
                    if (eeBlacklist.Contains(kv.Key))
                    {
                        continue;
                    }
                    var ee = ResourcesLibrary.TryGetResource <EquipmentEntity>(kv.Key);
                    if (ee == null)
                    {
                        continue;
                    }
                    var  nameParts = ee.name.Split('_');
                    bool isMale    = nameParts.Contains("M");
                    bool isFemale  = nameParts.Contains("F");
                    if (!isMale && !isFemale)
                    {
                        isMale   = true;
                        isFemale = true;
                    }
                    if (isMale)
                    {
                        m_OrphanedMaleEquipment[kv.Key] = kv.Value;
                    }
                    if (isFemale)
                    {
                        m_OrphanedFemaleEquipment[kv.Key] = kv.Value;
                    }
                }
                JsonSerializer serializer = new JsonSerializer();
                serializer.Formatting = Formatting.Indented;
                using (StreamWriter sw = new StreamWriter(maleFilepath))
                    using (JsonWriter writer = new JsonTextWriter(sw))
                    {
                        serializer.Serialize(writer, m_OrphanedMaleEquipment);
                    }
                using (StreamWriter sw = new StreamWriter(femaleFilepath))
                    using (JsonWriter writer = new JsonTextWriter(sw))
                    {
                        serializer.Serialize(writer, m_OrphanedFemaleEquipment);
                    }
                ResourcesLibrary.CleanupLoadedCache();
            }
        }
Esempio n. 8
0
        static void BuildEquipmentLookup()
        {
            var blueprints = BluePrintThing.GetBlueprints <BlueprintItemEquipment>()
                             .Where(bp => bp.EquipmentEntity != null)
                             .OrderBy(bp => bp.EquipmentEntity.name);

            foreach (var bp in blueprints)
            {
                switch (bp.ItemType)
                {
                case ItemType.Glasses:
                    if (m_Helm.ContainsKey(bp.EquipmentEntity.AssetGuid))
                    {
                        break;
                    }
                    m_Glasses[bp.EquipmentEntity.AssetGuid] = bp.EquipmentEntity.name;
                    break;

                case ItemType.Head:
                    if (m_Helm.ContainsKey(bp.EquipmentEntity.AssetGuid))
                    {
                        break;
                    }
                    m_Helm[bp.EquipmentEntity.AssetGuid] = bp.EquipmentEntity.name;
                    break;

                case ItemType.Shirt:
                    if (m_Shirt.ContainsKey(bp.EquipmentEntity.AssetGuid))
                    {
                        break;
                    }
                    m_Shirt[bp.EquipmentEntity.AssetGuid] = bp.EquipmentEntity.name;
                    break;

                case ItemType.Armor:
                    if (m_Armor.ContainsKey(bp.EquipmentEntity.AssetGuid))
                    {
                        break;
                    }
                    m_Armor[bp.EquipmentEntity.AssetGuid] = bp.EquipmentEntity.name;
                    break;

                case ItemType.Wrist:
                    if (m_Bracers.ContainsKey(bp.EquipmentEntity.AssetGuid))
                    {
                        break;
                    }
                    m_Bracers[bp.EquipmentEntity.AssetGuid] = bp.EquipmentEntity.name;
                    break;

                case ItemType.Gloves:
                    if (m_Gloves.ContainsKey(bp.EquipmentEntity.AssetGuid))
                    {
                        break;
                    }
                    m_Gloves[bp.EquipmentEntity.AssetGuid] = bp.EquipmentEntity.name;
                    break;

                case ItemType.Feet:
                    if (m_Boots.ContainsKey(bp.EquipmentEntity.AssetGuid))
                    {
                        break;
                    }
                    m_Boots[bp.EquipmentEntity.AssetGuid] = bp.EquipmentEntity.name;
                    break;

                default:
                    break;
                }
            }
        }
Esempio n. 9
0
        static private void Init()
        {
            var races       = BluePrintThing.GetBlueprints <BlueprintRace>();
            var racePresets = BluePrintThing.GetBlueprints <BlueprintRaceVisualPreset>();
            var classes     = BluePrintThing.GetBlueprints <BlueprintCharacterClass>();

            foreach (var race in races)
            {
                foreach (var gender in new Gender[] { Gender.Male, Gender.Female })
                {
                    CustomizationOptions customizationOptions = gender != Gender.Male ? race.FemaleOptions : race.MaleOptions;
                    AddLinks(head, customizationOptions.Heads);
                    AddLinks(hair, customizationOptions.Hair);
                    AddLinks(beard, customizationOptions.Beards);
                    AddLinks(eyebrows, customizationOptions.Eyebrows);
                    AddLinks(tails, customizationOptions.TailSkinColors);
                    AddLinks(horns, customizationOptions.Horns);
                }
            }
            foreach (var racePreset in racePresets)
            {
                foreach (var gender in new Gender[] { Gender.Male, Gender.Female })
                {
                    var raceSkin = racePreset.Skin;
                    if (raceSkin == null)
                    {
                        continue;
                    }
                    AddLinks(skin, raceSkin.GetLinks(gender, racePreset.RaceId));
                }
            }
            foreach (var _class in classes)
            {
                foreach (var race in races)
                {
                    foreach (var gender in new Gender[] { Gender.Male, Gender.Female })
                    {
                        AddLinks(classOutfits, _class.GetClothesLinks(gender, race.RaceId).ToArray());
                    }
                }
            }
            foreach (var bp in BluePrintThing.GetBlueprints <BlueprintPortrait>())
            {
                //Note there are two wolf portraits
                if (bp == BlueprintRoot.Instance.CharGen.CustomPortrait || bp.Data.IsCustom)
                {
                    continue;
                }
                if (!portraits.ContainsKey(bp.name))
                {
                    portraits.Add(bp.name, bp);
                }
            }
            customPortraits.AddRange(CustomPortraitsManager.Instance.GetExistingCustomPortraitIds());
            foreach (var bp in BluePrintThing.GetBlueprints <BlueprintUnitAsksList>())
            {
                var component = bp.GetComponent <UnitAsksComponent>();
                if (component == null)
                {
                    continue;
                }
                if (!component.Selected.HasBarks && bp.name != "PC_None_Barks")
                {
                    continue;
                }
                asks.Add(bp.name, bp);
            }
            loaded = true;
        }