static void BuildWeaponLookup()
        {
            var weapons = ResourcesLibrary.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;
                }
                UnorderedList <BlueprintRef, string> eeList = null;
                if (!m_Weapons.ContainsKey(animationStyle))
                {
                    eeList = new UnorderedList <BlueprintRef, string>();
                    m_Weapons[animationStyle] = eeList;
                }
                else
                {
                    eeList = m_Weapons[animationStyle];
                }
                if (eeList.ContainsKey(bp.AssetGuid))
                {
                    continue;
                }
                eeList[bp.AssetGuid] = bp.name;
            }
        }
Beispiel #2
0
        public static List <BlueprintItemShield> GetFilterShields(List <string> allowedEnchantments1,
                                                                  bool uniqueByName = true)
        {
            // Gets all shields and returns only those that have an enchantment from the specified list.
            var shields        = ResourcesLibrary.GetBlueprints <BlueprintItemShield>();
            var shieldsGeneric = shields.Where(shield =>
                                               shield.Icon != null &&
                                               shield.SellPrice > 25 &&
                                               shield.Description == "" &&
                                               shield.FlavorText == "" &&
                                               shield.IsNonRemovable == false);
            var shieldsFiltered = shieldsGeneric;

            shieldsFiltered = shieldsFiltered.Where(shield =>
                                                    (shield.Enchantments.Count == 1) &&
                                                    shield.Enchantments.Any(enchantment => allowedEnchantments1.Contains(enchantment.AssetGuid)));

            if (uniqueByName)
            {
                shieldsFiltered = shieldsFiltered
                                  .GroupBy(weapon => weapon.Name)
                                  .Select(group => group.First());
            }

            return(shieldsFiltered.ToList());
        }
        static void BuildViewLookup()
        {
            string getViewName(BlueprintUnit bp)
            {
                if (!ResourcesLibrary.LibraryObject.ResourceNamesByAssetId.ContainsKey(bp.Prefab.AssetId))
                {
                    return("NULL");
                }
                var path = ResourcesLibrary.LibraryObject.ResourceNamesByAssetId[bp.Prefab.AssetId].Split('/');

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

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

            foreach (var bp in units)
            {
                if (bp.Prefab.AssetId == "")
                {
                    continue;
                }
                if (!ResourcesLibrary.LibraryObject.ResourceNamesByAssetId.ContainsKey(bp.Prefab.AssetId))
                {
                    continue;
                }
                if (m_Units.ContainsKey(bp.Prefab.AssetId))
                {
                    continue;
                }
                m_Units[bp.Prefab.AssetId] = getViewName(bp);
            }
        }
Beispiel #4
0
        public static void DumpQuick()
        {
            var types = new HashSet <Type>()
            {
                typeof(BlueprintCharacterClass),
                typeof(BlueprintRaceVisualPreset),
                typeof(BlueprintRace),
                typeof(BlueprintArchetype),
                typeof(BlueprintProgression),
                typeof(BlueprintStatProgression),
                typeof(BlueprintFeature),
                typeof(BlueprintFeatureSelection),
                typeof(BlueprintSpellbook),
                typeof(BlueprintSpellList),
                typeof(BlueprintSpellsTable),
                typeof(BlueprintItemWeapon),
                typeof(BlueprintBuff)
            };

            foreach (var blueprint in ResourcesLibrary.GetBlueprints <BlueprintScriptableObject>())
            {
                if (types.Contains(blueprint.GetType()))
                {
                    DumpBlueprint(blueprint);
                }
            }
        }
Beispiel #5
0
        public static List <BlueprintItemWeapon> GetFilterWeapons(List <String> allowedEnchantments1,
                                                                  List <string> allowedEnchantments2 = null, List <string> allowedEnchantments3 = null,
                                                                  WeaponCategory category            = WeaponCategory.Touch, bool uniqueByName  = true)
        {
            // Gets all armors and filters them by provided enchantment GUID lists.
            // If more than one GUID list is provided, then the weapons must have an enchantment
            // from all provided lists.

            var weapons = ResourcesLibrary.GetBlueprints <BlueprintItemWeapon>();

            var weaponsGeneric = weapons.Where(weapon =>
                                               (weapon.FlavorText == "" &&
                                                weapon.IsMagic &&
                                                weapon.SellPrice > 25 &&
                                                weapon.DamageType.Physical.Material == 0 &&
                                                weapon.Icon != null &&
                                                weapon.Description == "" &&
                                                weapon.IsNonRemovable == false &&
                                                !WeaponCategoriesDisabled.Contains(weapon.Category) &&
                                                !WeaponGUIDSDisallowed.Contains(weapon.AssetGuid)));

            if (uniqueByName)
            {
                weaponsGeneric = weaponsGeneric
                                 .GroupBy(weapon => weapon.Name)
                                 .Select(group => group.First());
            }

            var weaponsFiltered = weaponsGeneric;

            if (category != WeaponCategory.Touch)
            {
                weaponsFiltered = weaponsFiltered.Where(weapon => weapon.Category == category);
            }

            if (allowedEnchantments2 == null)
            {
                weaponsFiltered = weaponsFiltered.Where(weapon =>
                                                        (weapon.Enchantments.Count == 1 &&
                                                         weapon.Enchantments.Any(enchantment => allowedEnchantments1.Contains(enchantment.AssetGuid))));
            }
            else if (allowedEnchantments3 == null)
            {
                weaponsFiltered = weaponsFiltered.Where(weapon =>
                                                        (weapon.Enchantments.Count == 2 &&
                                                         weapon.Enchantments.Any(enchantment => allowedEnchantments1.Contains(enchantment.AssetGuid)) &&
                                                         weapon.Enchantments.Any(enchantment => allowedEnchantments2.Contains(enchantment.AssetGuid))));
            }
            else
            {
                weaponsFiltered = weaponsFiltered.Where(weapon =>
                                                        (weapon.Enchantments.Count == 3 &&
                                                         weapon.Enchantments.Any(enchantment => allowedEnchantments1.Contains(enchantment.AssetGuid)) &&
                                                         weapon.Enchantments.Any(enchantment => allowedEnchantments2.Contains(enchantment.AssetGuid)) &&
                                                         weapon.Enchantments.Any(enchantment => allowedEnchantments3.Contains(enchantment.AssetGuid))));
            }

            return(weaponsFiltered.ToList());
        }
Beispiel #6
0
        public static void DumpList()
        {
            var resourceTypes = new Type[]
            {
                typeof(EquipmentEntity),
                typeof(Familiar),
                typeof(UnitEntityView),
                typeof(ProjectileView)
                //Note: PrefabLink : WeakResourceLink<GameObject> exists
            };

            Directory.CreateDirectory($"Blueprints/");
            var blueprints          = ResourcesLibrary.GetBlueprints <BlueprintScriptableObject>().ToList();
            var blueprintsByAssetId = ResourcesLibrary.LibraryObject.BlueprintsByAssetId;

            Main.DebugLog($"BlueprintsByAssetId contains  {blueprintsByAssetId.Count} blueprints");
            Main.DebugLog($"Dumping {blueprints.Count} blueprints");
            using (var file = new StreamWriter("Blueprints/Blueprints.txt"))
            {
                file.WriteLine($"name\tAssetId\tType");
                foreach (var blueprint in blueprints)
                {
                    file.WriteLine($"{blueprint.name}\t{blueprint.AssetGuid}\t{blueprint.GetType()}");
                }
            }
            var resourcePathsByAssetId = ResourcesLibrary.LibraryObject.ResourceNamesByAssetId;

            Main.DebugLog($"ResourcePathsByAssetId contains  {blueprintsByAssetId.Count} resources");
            using (var file = new StreamWriter("Blueprints/Resources.txt"))
            {
                file.WriteLine($"Name\tAssetId\tType\tBaseType\tInstanceId");
                foreach (var kv in ResourcesLibrary.LibraryObject.ResourceNamesByAssetId)
                {
                    var resource = ResourcesLibrary.TryGetResource <UnityEngine.Object>(kv.Key);
                    if (resource != null)
                    {
                        var baseType = resource.GetType().IsAssignableFrom(typeof(UnityEngine.GameObject)) ? "GameObject" :
                                       resource.GetType().IsAssignableFrom(typeof(UnityEngine.ScriptableObject)) ? "ScriptableObject" :
                                       resource.GetType().IsAssignableFrom(typeof(UnityEngine.Component)) ? "Component" :
                                       "Object";
                        var go       = resource as GameObject;
                        var typeName = resource?.GetType().Name ?? "NULL";
                        if (go != null)
                        {
                            foreach (var type in resourceTypes)
                            {
                                if (go.GetComponent(type) != null)
                                {
                                    typeName = type.Name;
                                }
                            }
                        }
                        file.WriteLine($"{kv.Value}\t{kv.Key}\t{typeName}\t{baseType}\t{resource?.GetInstanceID()}");
                        ResourcesLibrary.CleanupLoadedCache();
                    }
                }
            }
        }
Beispiel #7
0
        internal static void TestDefaultLevelPlan2()
        {
            var            defaultClass   = ResourcesLibrary.TryGetBlueprint <BlueprintCharacterClass>("0937bec61c0dabc468428f496580c721"); //Alchemist
            var            defaultBuild   = defaultClass.DefaultBuild;
            var            addClassLevels = defaultBuild.GetComponent <AddClassLevels>();
            var            targetPoints   = Main.settings.DefaultPointBuy25 ? 25 : 20;
            var            stats          = defaultBuild.GetComponents <StatsDistributionPreset>().FirstOrDefault(sd => sd.TargetPoints == targetPoints);
            UnitEntityData unitData       = Main.settings.DefaultPointBuy25 ?
                                            Game.Instance.CreateUnitVacuum(BlueprintRoot.Instance.DefaultPlayerCharacter) :
                                            Game.Instance.CreateUnitVacuum(BlueprintRoot.Instance.CustomCompanion);
            var unit = unitData.Descriptor;

            LogUnit("BlankUnit.txt", unit);
            var  levelUpController = TestLevelUpController.Start(unit: unit, instantCommit: true, unitJson: null, onSuccess: null, mode: LevelUpState.CharBuildMode.CharGen);
            bool success           = true;

            success = levelUpController.SelectPortrait(ResourcesLibrary.GetBlueprints <BlueprintPortrait>().First());
            if (!success)
            {
                Main.Log("Error selecting portrait");
            }
            success = levelUpController.SelectGender(Gender.Male);
            if (!success)
            {
                Main.Log("Error selecting gender");
            }
            var race = ResourcesLibrary.TryGetBlueprint <BlueprintRace>("0a5d473ead98b0646b94495af250fdc4"); //Human

            race    = ResourcesLibrary.TryGetBlueprint <BlueprintRace>("5c4e42124dc2b4647af6e36cf2590500");  //Tiefling
            success = levelUpController.SelectRace(race);
            if (!success)
            {
                Main.Log("Error selecting race");
            }
            levelUpController.State.SelectedClass = ResourcesLibrary.TryGetBlueprint <BlueprintCharacterClass>("0937bec61c0dabc468428f496580c721");
            ApplyDefaultBuild(levelUpController);
            //success = levelUpController.SelectClass(ResourcesLibrary.TryGetBlueprint<BlueprintCharacterClass>("0937bec61c0dabc468428f496580c721"));
            //if (!success) Main.Log("Error selecting class");
            //levelUpController.ApplyClassMechanics();
            //levelUpController.ApplySpellbook();
            //levelUpController.SelectDefaultClassBuild();

            var levelPlanHolder = new LevelPlanHolder();

            for (int i = 0; i < 20; i++)
            {
                var plan = unit.Progression.GetLevelPlan(i + 1);
                levelPlanHolder.LevelPlanData[i] = plan;
            }
            LevelPlanManager.CurrentLevelPlan = levelPlanHolder;

            var token = UnitSerialization.Serialize(unit);

            File.WriteAllText("TestDefaultAlch.json", token.ToString());
            LogUnit("TestDefaultAlch.txt", unit);
        }
Beispiel #8
0
        static void BuildLookup()
        {
            m_lookup = new Dictionary <string, EquipmentEntityInfo>();;
            var races       = ResourcesLibrary.GetBlueprints <BlueprintRace>();
            var racePresets = ResourcesLibrary.GetBlueprints <BlueprintRaceVisualPreset>();
            var classes     = ResourcesLibrary.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 = ResourcesLibrary.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 = ResourcesLibrary.GetBlueprints <BlueprintBuff>().ToArray();
        }
Beispiel #9
0
        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.Label($"Current CustomAsks: {customAsks?.name}, Display: {customAsks?.DisplayName}");
            GUILayout.Label($"Current OverrideAsks: {overrideAsks?.name}, Display: {overrideAsks?.DisplayName}");
            foreach (var blueprint in ResourcesLibrary.GetBlueprints <BlueprintUnitAsksList>())
            {
                GUILayout.Label($"Asks: {blueprint}, Display: {blueprint.DisplayName}");
            }
        }
Beispiel #10
0
        public static void DumpBlueprints()
        {
            var seen = new HashSet <Type>();

            var blueprints = ResourcesLibrary.GetBlueprints <BlueprintScriptableObject>();

            foreach (var blueprint in blueprints)
            {
                if (!seen.Contains(blueprint.GetType()))
                {
                    seen.Add(blueprint.GetType());
                    DumpBlueprint(blueprint);
                }
            }
        }
Beispiel #11
0
 public static IList <BlueprintUnit> GetCompanionUnits()
 {
     if (m_Companions == null)
     {
         m_Companions = new List <BlueprintUnit>();
         foreach (var unit in ResourcesLibrary.GetBlueprints <BlueprintUnit>())
         {
             if (unit.IsCompanion)
             {
                 m_Companions.Add(unit);
             }
         }
     }
     return(m_Companions);
 }
        public static void DumpList()
        {
            var typemap = new Dictionary <Type, string>();

            Directory.CreateDirectory($"Blueprints/");
            var blueprints          = ResourcesLibrary.GetBlueprints <BlueprintScriptableObject>().ToList();
            var blueprintsByAssetID = ResourcesLibrary.LibraryObject.BlueprintsByAssetId;

            Main.DebugLog($"BlueprintsByAssetId contains  {blueprintsByAssetID.Count} blueprints");
            Main.DebugLog($"Dumping {blueprints.Count} blueprints");
            using (var file = new StreamWriter("Blueprints/Blueprints.txt"))
            {
                foreach (var blueprint in blueprints)
                {
                    typemap[blueprint.GetType()] = "Blueprint";
                    file.WriteLine($"{blueprint.name}\t{blueprint.AssetGuid}\t{blueprint.GetType()}");
                }
            }
            var resourcePathsByAssetId = ResourcesLibrary.LibraryObject.ResourcePathsByAssetId;

            Main.DebugLog($"ResourcePathsByAssetId contains  {blueprintsByAssetID.Count} resources");
            using (var file = new StreamWriter("Blueprints/Resources.txt"))
            {
                foreach (var kv in ResourcesLibrary.LibraryObject.ResourcePathsByAssetId)
                {
                    var resource = ResourcesLibrary.TryGetResource <UnityEngine.Object>(kv.Key);
                    if (resource != null)
                    {
                        var baseType = resource.GetType().IsAssignableFrom(typeof(UnityEngine.GameObject)) ? "GameObject" :
                                       resource.GetType().IsAssignableFrom(typeof(UnityEngine.ScriptableObject)) ? "ScriptableObject" :
                                       resource.GetType().IsAssignableFrom(typeof(UnityEngine.Component)) ? "Component" :
                                       "Object";
                        typemap[resource.GetType()] = $"Resource:{baseType}";
                    }
                    file.WriteLine($"{resource?.name ?? "NULL"}\t{kv.Key}\t{resource?.GetType()?.Name ?? "NULL"}\t{kv.Value}");
                }
            }
            using (var file = new StreamWriter("Blueprints/Types.txt"))
            {
                foreach (var kv in typemap.OrderBy(kv => kv.Value))
                {
                    file.WriteLine($"{kv.Key}\t{kv.Value}");
                }
            }
        }
        static void BuildWeaponEnchantmentLookup()
        {
            var enchantments = ResourcesLibrary.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;
            }
        }
Beispiel #14
0
        public static void DumpList()
        {
            Directory.CreateDirectory($"Blueprints/");
            var blueprints          = ResourcesLibrary.GetBlueprints <BlueprintScriptableObject>().ToList();
            var blueprintsByAssetId = ResourcesLibrary.LibraryObject.BlueprintsByAssetId;

            Main.DebugLog($"BlueprintsByAssetId contains  {blueprintsByAssetId.Count} blueprints");
            Main.DebugLog($"Dumping {blueprints.Count} blueprints");
            using (var file = new StreamWriter("Blueprints/Blueprints.txt"))
            {
                file.WriteLine($"name\tAssetId\tType");
                foreach (var blueprint in blueprints)
                {
                    file.WriteLine($"{blueprint.name}\t{blueprint.AssetGuid}\t{blueprint.GetType()}");
                }
            }
            var resourcePathsByAssetId = ResourcesLibrary.LibraryObject.ResourceNamesByAssetId;

            Main.DebugLog($"ResourcePathsByAssetId contains  {blueprintsByAssetId.Count} resources");
            using (var file = new StreamWriter("Blueprints/Resources.txt"))
            {
                file.WriteLine($"name\tResourcenName\tAssetId\tType\tBaseType\tInstanceId");
                foreach (var kv in ResourcesLibrary.LibraryObject.ResourceNamesByAssetId)
                {
                    var resource = ResourcesLibrary.TryGetResource <UnityEngine.Object>(kv.Key);
                    if (resource != null)
                    {
                        var baseType = resource.GetType().IsAssignableFrom(typeof(UnityEngine.GameObject)) ? "GameObject" :
                                       resource.GetType().IsAssignableFrom(typeof(UnityEngine.ScriptableObject)) ? "ScriptableObject" :
                                       resource.GetType().IsAssignableFrom(typeof(UnityEngine.Component)) ? "Component" :
                                       "Object";
                        var go       = resource as GameObject;
                        var typeName = resource?.GetType().Name ?? "NULL";
                        if (go != null)
                        {
                            typeName = go.GetComponents <MonoBehaviour>().Join(c => c.GetType().Name);
                        }
                        file.WriteLine($"{resource?.name ?? "NULL"}\t{kv.Key}\t{kv.Value}\t{typeName}\t{baseType}\t{resource?.GetInstanceID()}");
                        ResourcesLibrary.CleanupLoadedCache();
                    }
                }
            }
        }
Beispiel #15
0
        //NOT TESTED YET!!!!
        public static void startCoroutineExample()
        {
            List <string> guids = new List <string>();

            guids.Add("18a65db9e92055240bea7c7a5783587a");
            guids.Add("06d447a763b392c438a93e145a95e2d1");
            guids.Add("a92e3099b69e41e41818b4853a432118");

            List <BlueprintUnit> blueprintUnits = new List <BlueprintUnit>();

            foreach (BlueprintUnit blueprintUnit in ResourcesLibrary.GetBlueprints <BlueprintUnit>().Where(x => guids.Contains(x.AssetGuid)))
            {
                blueprintUnits.Add(blueprintUnit);
            }

            coroutineExample = new GameObject("coroutineExample").AddComponent <CoroutineExample>();

            coroutineExample.Run(blueprintUnits);
        }
Beispiel #16
0
        public static List <BlueprintItemArmor> GetFilterArmors(List <string> allowedEnchantments1,
                                                                List <string> allowedEnchantments2 = null, bool uniqueByName = true)
        {
            // Gets all armors and filters them by provided enchantment GUID lists.
            // If two GUID lists are provided, then the armors must have an enchantment
            // from both lists.

            var armors = ResourcesLibrary.GetBlueprints <BlueprintItemArmor>();

            var armorsGeneric = armors.Where(armor =>
                                             armor.SellPrice > 25 &&
                                             armor.Description == "" &&
                                             armor.FlavorText == "" &&
                                             armor.IsNonRemovable == false &&
                                             armor.Icon != null &&
                                             !ArmorGUIDSDisallowed.Contains(armor.AssetGuid));



            var armorsFiltered = armorsGeneric;

            if (allowedEnchantments2 == null)
            {
                armorsFiltered = armorsFiltered.Where(armor =>
                                                      (armor.Enchantments.Count == 1 &&
                                                       armor.Enchantments.Any(enchantment => allowedEnchantments1.Contains(enchantment.AssetGuid))));
            }
            else
            {
                armorsFiltered = armorsFiltered.Where(armor =>
                                                      (armor.Enchantments.Count == 2 &&
                                                       armor.Enchantments.Any(enchantment => allowedEnchantments1.Contains(enchantment.AssetGuid)) &&
                                                       armor.Enchantments.Any(enchantment => allowedEnchantments2.Contains(enchantment.AssetGuid))));
            }

            if (uniqueByName)
            {
                armorsFiltered = armorsFiltered
                                 .GroupBy(weapon => weapon.Name)
                                 .Select(group => group.First());
            }
            return(armorsFiltered.ToList());
        }
Beispiel #17
0
        public static void Init(Locale locale)
        {
            var pack = new LocalizationPack();

            pack.Locale  = locale;
            pack.Strings = new Dictionary <string, string>(LocalizationManager.CurrentPack.Strings);
            foreach (var dialog in ResourcesLibrary.GetBlueprints <BlueprintDialog>())
            {
                var dialogPack = LoadPack($"Localization/{locale}{dialog.AssetGuid}.json", locale);
                if (dialogPack == null)
                {
                    continue;
                }
                foreach (var kv in dialogPack.Strings)
                {
                    pack.Strings[kv.Key] = kv.Value;
                }
            }
            Pack = pack;
        }
Beispiel #18
0
        static void BuildOrphenedKingmakerEquipment()
        {
            m_OrphanedKingmakerEquipment = new UnorderedList <string, string>();
            var itemLinks = EquipmentResourcesManager.Helm.Keys
                            .Concat(EquipmentResourcesManager.Cloak.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 ResourcesLibrary.GetBlueprints <KingmakerEquipmentEntity>())
            {
                if (!itemLinks.ContainsKey(kee.AssetGuid))
                {
                    m_OrphanedKingmakerEquipment[kee.AssetGuid] = kee.name;
                }
            }
        }
Beispiel #19
0
        public static void DumpAllBlueprints()
        {
            var blueprints = ResourcesLibrary.GetBlueprints <BlueprintScriptableObject>();

            Directory.CreateDirectory("Blueprints");
            using (var file = new StreamWriter("Blueprints/log.txt"))
            {
                foreach (var blueprint in blueprints)
                {
                    Main.DebugLog($"Dumping {blueprint.name} - {blueprint.AssetGuid}");
                    try
                    {
                        DumpBlueprint(blueprint);
                    }
                    catch (Exception ex)
                    {
                        file.WriteLine($"Error dumping {blueprint.name}:{blueprint.AssetGuid}:{blueprint.GetType().FullName}, {ex.ToString()}");
                    }
                }
            }
        }
        public static void DumpAllBlueprints()
        {
            var blueprints = ResourcesLibrary.GetBlueprints <BlueprintScriptableObject>();

            Directory.CreateDirectory("Blueprints");
            using (var file = new StreamWriter("Blueprints/log.txt"))
            {
                foreach (var blueprint in blueprints)
                {
                    if (blueprint.AssetGuid.Length != 32)
                    {
                        continue;
                    }
                    try
                    {
                        JsonBlueprints.Dump(blueprint);
                    } catch (Exception ex)
                    {
                        file.WriteLine($"Error dumping {blueprint.name}:{blueprint.AssetGuid}:{blueprint.GetType().FullName}, {ex.ToString()}");
                    }
                }
            }
        }
Beispiel #21
0
        public static List <BlueprintItemEquipmentUsable> GetFilterMagicUsables(int casterLevel, string scrollsOrWands = "scrolls",
                                                                                string arcaneOrDivine = "arcane")
        {
            // Gets all usables and filters them to return arcane or divine scrolls/wands of a particular caster level.

            var usables             = ResourcesLibrary.GetBlueprints <BlueprintItemEquipmentUsable>();
            var wizardSpellList     = library.Get <BlueprintSpellList>(SpellListIds["Wizard"]);
            var bardSpellList       = library.Get <BlueprintSpellList>(SpellListIds["Bard"]);
            var clericSpellList     = library.Get <BlueprintSpellList>(SpellListIds["Cleric"]);
            var paladinSpellList    = library.Get <BlueprintSpellList>(SpellListIds["Paladin"]);
            var inquisitorSpellList = library.Get <BlueprintSpellList>(SpellListIds["Inquisitor"]);
            var rangerSpellList     = library.Get <BlueprintSpellList>(SpellListIds["Ranger"]);
            var druidSpellList      = library.Get <BlueprintSpellList>(SpellListIds["Druid"]);

            usables = usables.Where(usable => usable.SellPrice > 0 &&
                                    usable.RequireUMDIfCasterHasNoSpellInSpellList == true);
            usables = usables.GroupBy(usable => usable.name).Select(group => group.First());

            usables = usables.Where(usable => usable.IsActuallyStackable == (scrollsOrWands.Equals("scrolls")));

            if (arcaneOrDivine == "arcane")
            {
                usables = usables.Where(usable => usable.Ability.IsInSpellList(wizardSpellList) ||
                                        usable.Ability.IsInSpellList(bardSpellList));
            }
            else
            {
                usables = usables.Where(usable => usable.Ability.IsInSpellList(clericSpellList) ||
                                        usable.Ability.IsInSpellList(paladinSpellList) ||
                                        usable.Ability.IsInSpellList(rangerSpellList) ||
                                        usable.Ability.IsInSpellList(inquisitorSpellList) ||
                                        usable.Ability.IsInSpellList(druidSpellList));
            }

            return(usables.Where(usable => usable.CasterLevel == casterLevel).ToList());
        }
        public static void Functions(int index)
        {
            switch (index)
            {
            case 0:
                break;

            case 1:
                GameInfo();
                break;

            case 2:
                KillFunctions();
                break;

            case 3:
                UnitEntityDataUtils.ResurrectAndFullRestore(Common.GetUnitUnderMouse());
                break;

            case 4:
                UnitEntityDataUtils.Buff(Common.GetUnitUnderMouse(), FavouritesFactory.GetFavouriteBuffs.FavouritesList[Main.settings.actionKeyBuffIndex]);
                break;

            case 5:
                editUnit = Common.GetUnitUnderMouse();
                break;

            case 6:
                teleportUnit = Common.GetUnitUnderMouse();
                if (teleportUnit != null && StringUtils.ToToggleBool(Main.settings.toggleAddToLog))
                {
                    Common.AddLogEntry(Strings.GetText("label_TeleportUnit") + $": {teleportUnit.CharacterName}", Color.black);
                }
                break;

            case 7:
                if (StringUtils.ToToggleBool(settings.toggleSpawnEnemiesFromUnitFavourites))
                {
                    try {
                        Vector3 pos = Common.MousePositionLocalMap();
                        float   x   = 0.0f;
                        float   z   = 0.0f;
                        foreach (string guid in SpawnUnits.GetStoredGUIDs)
                        {
                            Vector3 finalPos = new Vector3(pos.x + 1.5f * x, pos.y, pos.z + 1.5f * z);
                            SpawnUnits.UnitSpawner(finalPos, guid);
                            x++;
                            if (x > 10f)
                            {
                                x = 0.0f;
                                z++;
                            }
                        }
                    }
                    catch (Exception e) {
                        modLogger.Log(e.ToString());
                    }
                }
                else if (settings.actionKeySpawnRandomEnemy && StringUtils.ToToggleBool(settings.toggleActionKeyExperimental))
                {
                    try {
                        Common.SpawnHostileUnit(Common.MousePositionLocalMap(), ResourcesLibrary.GetBlueprints <BlueprintUnit>().RandomElement());
                    }
                    catch (Exception e) {
                        modLogger.Log(e.ToString());
                    }
                }
                else
                {
                    Common.SpawnHostileUnit(Common.MousePositionLocalMap(), banditsGuids[banidtCrIndex]);
                }
                break;

            case 8:
                rotateUnit = Common.GetUnitUnderMouse();
                if (rotateUnit != null && StringUtils.ToToggleBool(Main.settings.toggleAddToLog))
                {
                    Common.AddLogEntry(Strings.GetText("arrayItem_ActionKeyMain_RotateUnit") + $": {rotateUnit.CharacterName}", Color.black);
                }
                break;

            case 9:
                Common.GetUnitUnderMouse().View.AnimationManager.Execute(animationTypes[animationTypesIndex]);
                break;

            case 10:
                FxHelper.SpawnFxOnPoint(BlueprintRoot.Instance.Cheats.SillyCheatBlood, Common.MousePositionLocalMap());
                break;

            case 11:
                UnitEntityDataUtils.Charm(Common.GetUnitUnderMouse());
                break;

            case 12:
                UnitEntityDataUtils.AddToParty(Common.GetUnitUnderMouse());
                break;

            case 13:
                Common.GetUnitUnderMouse().Descriptor.Recreate = true;
                break;
            }
        }
        public static void ItemTypesMenu()
        {
            showItemTypes = GL.Toggle(showItemTypes, RichText.Bold(Strings.GetText("toggle_ShowItemTypes")));
            if (showItemTypes)
            {
                GL.Space(10);
                itemTypesGrid.Render();
                GL.Space(10);
                if (selectedItemTypeOld != itemTypesGrid.selected)
                {
                    selectedItemTypeOld = itemTypesGrid.selected;
                    refreshItemTypes    = true;
                }
                switch (itemTypesGrid.selected)
                {
                case 0:
                    List <BlueprintArmorType> blueprintArmorTypes = ResourcesLibrary.GetBlueprints <BlueprintArmorType>().ToList();
                    if (refreshItemTypes)
                    {
                        itemTypeEdit.Clear();
                        foreach (BlueprintArmorType b in blueprintArmorTypes)
                        {
                            itemTypeEdit.Add(false);
                        }
                        refreshItemTypes = false;
                    }

                    for (int i = 0; i < blueprintArmorTypes.Count(); i++)
                    {
                        itemTypeEdit[i] = GL.Toggle(itemTypeEdit[i], blueprintArmorTypes[i].name);
                        if (itemTypeEdit[i])
                        {
                            GL.BeginVertical("box");

                            GL.BeginHorizontal();
                            GL.Label("m_ArcaneSpellFailureChance: " + blueprintArmorTypes[i].ArcaneSpellFailureChance.ToString());
                            itemTypesTextFieldInt.RenderFieldNoGroup();
                            SetModifiedValueButton <ModifiedArmourType>(itemTypesTextFieldInt.finalAmount, "m_ArcaneSpellFailureChance", blueprintArmorTypes[i].AssetGuid);
                            GL.EndHorizontal();

                            GL.BeginHorizontal();
                            GL.Label("m_ArmorBonus: " + blueprintArmorTypes[i].ArmorBonus.ToString());
                            itemTypesTextFieldInt.RenderFieldNoGroup();
                            SetModifiedValueButton <ModifiedArmourType>(itemTypesTextFieldInt.finalAmount, "m_ArmorBonus", blueprintArmorTypes[i].AssetGuid);
                            GL.EndHorizontal();

                            GL.BeginHorizontal();
                            GL.Label("m_ArmorChecksPenalty: " + blueprintArmorTypes[i].ArmorChecksPenalty.ToString());
                            itemTypesTextFieldInt.RenderFieldNoGroup();
                            SetModifiedValueButton <ModifiedArmourType>(itemTypesTextFieldInt.finalAmount, "m_ArmorChecksPenalty", blueprintArmorTypes[i].AssetGuid);
                            GL.EndHorizontal();

                            GL.BeginHorizontal();
                            GL.Label("m_HasDexterityBonusLimit: " + blueprintArmorTypes[i].HasDexterityBonusLimit.ToString());
                            SetModifiedValueButtonBool <ModifiedArmourType>("m_HasDexterityBonusLimit", blueprintArmorTypes[i].AssetGuid);
                            GL.EndHorizontal();


                            GL.BeginHorizontal();
                            GL.Label("m_MaxDexterityBonus: " + blueprintArmorTypes[i].MaxDexterityBonus.ToString());
                            itemTypesTextFieldInt.RenderFieldNoGroup();
                            SetModifiedValueButton <ModifiedArmourType>(itemTypesTextFieldInt.finalAmount, "m_MaxDexterityBonus", blueprintArmorTypes[i].AssetGuid);
                            GL.EndHorizontal();

                            GL.BeginHorizontal();
                            GL.Label("m_Weight: " + blueprintArmorTypes[i].Weight.ToString());
                            itemTypesTextFieldFloat.RenderFieldNoGroup();
                            SetModifiedValueButton <ModifiedArmourType>(itemTypesTextFieldFloat.finalAmount, "m_Weight", blueprintArmorTypes[i].AssetGuid);
                            GL.EndHorizontal();

                            GL.EndVertical();
                        }
                    }
                    break;

                case 1:
                    List <BlueprintShieldType> blueprintShieldTypes = ResourcesLibrary.GetBlueprints <BlueprintShieldType>().ToList();
                    if (refreshItemTypes)
                    {
                        itemTypeEdit.Clear();
                        foreach (BlueprintShieldType b in blueprintShieldTypes)
                        {
                            itemTypeEdit.Add(false);
                        }
                        refreshItemTypes = false;
                    }

                    for (int i = 0; i < blueprintShieldTypes.Count(); i++)
                    {
                        itemTypeEdit[i] = GL.Toggle(itemTypeEdit[i], blueprintShieldTypes[i].name);
                        if (itemTypeEdit[i])
                        {
                            GL.BeginVertical("box");

                            GL.BeginHorizontal();
                            GL.Label("m_ArcaneSpellFailureChance: " + blueprintShieldTypes[i].ArcaneSpellFailureChance.ToString());
                            itemTypesTextFieldInt.RenderFieldNoGroup();
                            SetModifiedValueButton <ModifiedArmourType>(itemTypesTextFieldInt.finalAmount, "m_ArcaneSpellFailureChance", blueprintShieldTypes[i].AssetGuid);
                            GL.EndHorizontal();

                            GL.BeginHorizontal();
                            GL.Label("m_ArmorBonus: " + blueprintShieldTypes[i].ArmorBonus.ToString());
                            itemTypesTextFieldInt.RenderFieldNoGroup();
                            SetModifiedValueButton <ModifiedArmourType>(itemTypesTextFieldInt.finalAmount, "m_ArmorBonus", blueprintShieldTypes[i].AssetGuid);
                            GL.EndHorizontal();

                            GL.BeginHorizontal();
                            GL.Label("m_ArmorChecksPenalty: " + blueprintShieldTypes[i].ArmorChecksPenalty.ToString());
                            itemTypesTextFieldInt.RenderFieldNoGroup();
                            SetModifiedValueButton <ModifiedArmourType>(itemTypesTextFieldInt.finalAmount, "m_ArmorChecksPenalty", blueprintShieldTypes[i].AssetGuid);
                            GL.EndHorizontal();

                            GL.BeginHorizontal();
                            GL.Label("m_HasDexterityBonusLimit: " + blueprintShieldTypes[i].HasDexterityBonusLimit.ToString());
                            SetModifiedValueButtonBool <ModifiedArmourType>("m_HasDexterityBonusLimit", blueprintShieldTypes[i].AssetGuid);
                            GL.EndHorizontal();


                            GL.BeginHorizontal();
                            GL.Label("m_MaxDexterityBonus: " + blueprintShieldTypes[i].MaxDexterityBonus.ToString());
                            itemTypesTextFieldInt.RenderFieldNoGroup();
                            SetModifiedValueButton <ModifiedArmourType>(itemTypesTextFieldInt.finalAmount, "m_MaxDexterityBonus", blueprintShieldTypes[i].AssetGuid);
                            GL.EndHorizontal();

                            GL.BeginHorizontal();
                            GL.Label("m_Weight: " + blueprintShieldTypes[i].Weight.ToString());
                            itemTypesTextFieldFloat.RenderFieldNoGroup();
                            SetModifiedValueButton <ModifiedArmourType>(itemTypesTextFieldFloat.finalAmount, "m_Weight", blueprintShieldTypes[i].AssetGuid);
                            GL.EndHorizontal();

                            GL.EndVertical();
                        }
                    }
                    break;

                case 2:
                    List <BlueprintWeaponType> blueprintWeaponTypes = ResourcesLibrary.GetBlueprints <BlueprintWeaponType>().ToList();
                    if (refreshItemTypes)
                    {
                        itemTypeEdit.Clear();
                        foreach (BlueprintWeaponType b in blueprintWeaponTypes)
                        {
                            itemTypeEdit.Add(false);
                        }
                        refreshItemTypes = false;
                    }

                    for (int i = 0; i < blueprintWeaponTypes.Count(); i++)
                    {
                        itemTypeEdit[i] = GL.Toggle(itemTypeEdit[i], blueprintWeaponTypes[i].name);
                        if (itemTypeEdit[i])
                        {
                            GL.BeginVertical("box");

                            GL.BeginHorizontal();
                            GL.Label("m_AttackType: " + blueprintWeaponTypes[i].AttackType.ToString());
                            SetModifiedValueButtonAttackType <ModifiedWeaponType>("m_AttackType", blueprintWeaponTypes[i].AssetGuid);
                            GL.EndHorizontal();


                            GL.BeginHorizontal();
                            GL.Label("m_AttackRange: " + Traverse.Create(blueprintWeaponTypes[i]).Field("m_AttackRange").GetValue().ToString());
                            itemTypesTextFieldInt.RenderFieldNoGroup();
                            SetModifiedValueButton <ModifiedWeaponType>(itemTypesTextFieldInt.finalAmount.Feet(), "m_AttackRange", blueprintWeaponTypes[i].AssetGuid);
                            GL.EndHorizontal();
                            MenuTools.SingleLineLabel("AttackRange = (m_AttackRange > 10) ? m_AttackRange : Math.Max(2, m_AttackRange - 4)");

                            GL.BeginVertical("box");
                            GL.BeginHorizontal();
                            GL.Label("m_BaseDamage: " + blueprintWeaponTypes[i].BaseDamage.ToString());
                            GL.EndHorizontal();

                            GL.BeginHorizontal();
                            itemTypesTextFieldInt.RenderFieldNoGroup("misc_NumberOfRolls");
                            GL.EndHorizontal();

                            diceTypesGrid.Render();

                            GL.BeginHorizontal();
                            GL.FlexibleSpace();
                            SetModifiedValueButtonDiceFormula <ModifiedWeaponType>(itemTypesTextFieldInt.finalAmount, Common.IntToDiceType(diceTypesGrid.selected), "m_BaseDamage", blueprintWeaponTypes[i].AssetGuid);
                            GL.EndHorizontal();
                            GL.EndVertical();

                            GL.BeginHorizontal();
                            GL.Label("m_CriticalRollEdge: " + blueprintWeaponTypes[i].CriticalRollEdge.ToString());
                            itemTypesTextFieldInt.RenderFieldNoGroup();
                            SetModifiedValueButton <ModifiedWeaponType>(itemTypesTextFieldInt.finalAmount, "m_CriticalRollEdge", blueprintWeaponTypes[i].AssetGuid);
                            GL.EndHorizontal();

                            GL.BeginHorizontal();
                            GL.Label("m_CriticalModifier: " + blueprintWeaponTypes[i].CriticalModifier.ToString());
                            SetModifiedValueDamageCriticalModifierType <ModifiedWeaponType>("m_CriticalModifier", blueprintWeaponTypes[i].AssetGuid);
                            GL.EndHorizontal();

                            GL.BeginHorizontal();
                            GL.Label("m_Weight: " + blueprintWeaponTypes[i].Weight.ToString());
                            itemTypesTextFieldFloat.RenderFieldNoGroup();
                            SetModifiedValueButton <ModifiedWeaponType>(itemTypesTextFieldFloat.finalAmount, "m_Weight", blueprintWeaponTypes[i].AssetGuid);
                            GL.EndHorizontal();

                            GL.BeginHorizontal();
                            GL.Label("m_IsTwoHanded: " + blueprintWeaponTypes[i].IsTwoHanded.ToString());
                            SetModifiedValueButtonBool <ModifiedWeaponType>("m_IsTwoHanded", blueprintWeaponTypes[i].AssetGuid);
                            GL.EndHorizontal();

                            GL.BeginHorizontal();
                            GL.Label("m_IsLight: " + blueprintWeaponTypes[i].IsLight.ToString());
                            SetModifiedValueButtonBool <ModifiedWeaponType>("m_IsLight", blueprintWeaponTypes[i].AssetGuid);
                            GL.EndHorizontal();

                            GL.BeginHorizontal();
                            GL.Label("m_IsMonk: " + blueprintWeaponTypes[i].IsMonk.ToString());
                            SetModifiedValueButtonBool <ModifiedWeaponType>("m_IsMonk", blueprintWeaponTypes[i].AssetGuid);
                            GL.EndHorizontal();

                            GL.BeginHorizontal();
                            GL.Label("m_IsNatural: " + blueprintWeaponTypes[i].IsNatural.ToString());
                            SetModifiedValueButtonBool <ModifiedWeaponType>("m_IsNatural", blueprintWeaponTypes[i].AssetGuid);
                            GL.EndHorizontal();

                            GL.BeginHorizontal();
                            GL.Label("m_IsUnarmed: " + blueprintWeaponTypes[i].IsUnarmed.ToString());
                            SetModifiedValueButtonBool <ModifiedWeaponType>("m_IsUnarmed", blueprintWeaponTypes[i].AssetGuid);
                            GL.EndHorizontal();

                            GL.BeginHorizontal();
                            GL.Label("m_OverrideAttackBonusStat: " + Traverse.Create(blueprintWeaponTypes[i]).Field("m_OverrideAttackBonusStat").GetValue().ToString());
                            SetModifiedValueButtonBool <ModifiedWeaponType>("m_OverrideAttackBonusStat", blueprintWeaponTypes[i].AssetGuid);
                            GL.EndHorizontal();


                            GL.BeginVertical("box");
                            GL.BeginHorizontal();
                            GL.Label("m_AttackBonusStatOverride: " + Traverse.Create(blueprintWeaponTypes[i]).Field("m_AttackBonusStatOverride").GetValue().ToString());
                            GL.EndHorizontal();
                            SetModifiedValueStatType <ModifiedWeaponType>("m_AttackBonusStatOverride", blueprintWeaponTypes[i].AssetGuid);
                            GL.EndVertical();


                            GL.EndVertical();
                        }
                    }
                    break;
                }
            }
        }
        static void OnGUI(UnityModManager.ModEntry modEntry)
        {
            try
            {
                if (!enabled)
                {
                    return;
                }
#if (DEBUG)
                GUILayout.Label($"Game Version: {GameVersion.GetVersion()}");
                if (GUILayout.Button("DumpAssets"))
                {
                    AssetsDump.DumpAssets();
                }
                if (GUILayout.Button("DumpClassRaceBlueprints"))
                {
                    AssetsDump.DumpQuick();
                }
                if (GUILayout.Button("DumpSampleOfBlueprints"))
                {
                    AssetsDump.DumpBlueprints();
                }
                if (GUILayout.Button("DumpAllBlueprints"))
                {
                    AssetsDump.DumpAllBlueprints();
                }
                if (GUILayout.Button("DumpAllBlueprintsVerbose"))
                {
                    AssetsDump.DumpAllBlueprintsVerbose();
                }
                if (GUILayout.Button("DumpFlags"))
                {
                    var blueprints = ResourcesLibrary.GetBlueprints <BlueprintUnlockableFlag>();
                    Directory.CreateDirectory("Blueprints");
                    using (var file = new StreamWriter("Blueprints/log.txt"))
                    {
                        foreach (var blueprint in blueprints)
                        {
                            if (blueprint.AssetGuid.Length != 32)
                            {
                                continue;
                            }
                            Main.DebugLog($"Dumping {blueprint.name} - {blueprint.AssetGuid}");
                            try
                            {
                                AssetsDump.DumpBlueprint(blueprint);
                            }
                            catch (Exception ex)
                            {
                                file.WriteLine($"Error dumping {blueprint.name}:{blueprint.AssetGuid}:{blueprint.GetType().FullName}, {ex.ToString()}");
                            }
                        }
                    }
                }
                if (GUILayout.Button("DumpEquipmentEntities"))
                {
                    AssetsDump.DumpEquipmentEntities();
                }
                if (GUILayout.Button("DumpUnitViews"))
                {
                    AssetsDump.DumpUnitViews();
                }
                if (GUILayout.Button("DumpList"))
                {
                    AssetsDump.DumpList();
                }
                if (GUILayout.Button("DumpScriptableObjects"))
                {
                    AssetsDump.DumpScriptableObjects();
                }
                if (GUILayout.Button("DumpAssetBundles"))
                {
                    AssetsDump.DumpAssetBundles();
                }
                if (GUILayout.Button("DumpUI"))
                {
                    AssetsDump.DumpUI();
                }
                if (GUILayout.Button("DumpSceneList"))
                {
                    AssetsDump.DumpSceneList();
                }
                if (GUILayout.Button("DumpKingdom"))
                {
                    AssetsDump.DumpKingdom();
                }
                if (GUILayout.Button("DumpView"))
                {
                    var view      = ResourcesLibrary.TryGetResource <GameObject>("adf003833b2463543a065d5160c7e8f1");
                    var character = view.GetComponent <Character>();
                    JsonBlueprints.Dump(character, "adf003833b2463543a065d5160c7e8f1");
                }
                if (GUILayout.Button("TestLoad"))
                {
                    var vp = JsonBlueprints.Load <BlueprintRaceVisualPreset>("mods/customraces/data/TestPreset.json");
                    DebugLog("Loaded " + vp.name);
                }
#endif
            } catch (Exception e)
            {
                DebugLog(e.ToString() + " " + e.StackTrace);
            }
        }
Beispiel #25
0
        internal static void TestLevelUp()
        {
            var            defaultClass   = ResourcesLibrary.TryGetBlueprint <BlueprintCharacterClass>("0937bec61c0dabc468428f496580c721"); //Alchemist
            var            defaultBuild   = defaultClass.DefaultBuild;
            var            addClassLevels = defaultBuild.GetComponent <AddClassLevels>();
            var            targetPoints   = Main.settings.DefaultPointBuy25 ? 25 : 20;
            var            stats          = defaultBuild.GetComponents <StatsDistributionPreset>().FirstOrDefault(sd => sd.TargetPoints == targetPoints);
            UnitEntityData unitData       = Main.settings.DefaultPointBuy25 ?
                                            Game.Instance.CreateUnitVacuum(BlueprintRoot.Instance.DefaultPlayerCharacter) :
                                            Game.Instance.CreateUnitVacuum(BlueprintRoot.Instance.CustomCompanion);
            var  unit              = unitData.Descriptor;
            bool success           = false;
            var  levelUpController = TestLevelUpController.Start(unit: unit, instantCommit: true, unitJson: null, onSuccess: null, mode: LevelUpState.CharBuildMode.CharGen);

            success = levelUpController.SelectPortrait(ResourcesLibrary.GetBlueprints <BlueprintPortrait>().First());
            if (!success)
            {
                Main.Log("Error selecting portrait");
            }
            success = levelUpController.SelectGender(Gender.Male);
            if (!success)
            {
                Main.Log("Error selecting gender");
            }
            success = levelUpController.SelectRace(ResourcesLibrary.TryGetBlueprint <BlueprintRace>("0a5d473ead98b0646b94495af250fdc4"));
            if (!success)
            {
                Main.Log("Error selecting race");
            }
            success = levelUpController.SelectRaceStat(Kingmaker.EntitySystem.Stats.StatType.Intelligence);
            if (!success)
            {
                Main.Log("Error selecting race stat");
            }
            success = levelUpController.SelectClass(ResourcesLibrary.TryGetBlueprint <BlueprintCharacterClass>("0937bec61c0dabc468428f496580c721"));
            if (!success)
            {
                Main.Log("Error selecting class");
            }
            levelUpController.ApplyClassMechanics();
            levelUpController.ApplySpellbook();
            success  = levelUpController.RemoveStatPoint(Kingmaker.EntitySystem.Stats.StatType.Charisma);
            success &= levelUpController.RemoveStatPoint(Kingmaker.EntitySystem.Stats.StatType.Charisma);
            success &= levelUpController.RemoveStatPoint(Kingmaker.EntitySystem.Stats.StatType.Charisma);
            success &= levelUpController.AddStatPoint(Kingmaker.EntitySystem.Stats.StatType.Constitution);
            success &= levelUpController.AddStatPoint(Kingmaker.EntitySystem.Stats.StatType.Constitution);
            success &= levelUpController.AddStatPoint(Kingmaker.EntitySystem.Stats.StatType.Dexterity);
            success &= levelUpController.AddStatPoint(Kingmaker.EntitySystem.Stats.StatType.Dexterity);
            success &= levelUpController.AddStatPoint(Kingmaker.EntitySystem.Stats.StatType.Dexterity);
            success &= levelUpController.AddStatPoint(Kingmaker.EntitySystem.Stats.StatType.Dexterity);
            success &= levelUpController.AddStatPoint(Kingmaker.EntitySystem.Stats.StatType.Dexterity);
            success &= levelUpController.AddStatPoint(Kingmaker.EntitySystem.Stats.StatType.Dexterity);
            success &= levelUpController.AddStatPoint(Kingmaker.EntitySystem.Stats.StatType.Intelligence);
            success &= levelUpController.AddStatPoint(Kingmaker.EntitySystem.Stats.StatType.Intelligence);
            success &= levelUpController.AddStatPoint(Kingmaker.EntitySystem.Stats.StatType.Intelligence);
            success &= levelUpController.AddStatPoint(Kingmaker.EntitySystem.Stats.StatType.Intelligence);
            success &= levelUpController.AddStatPoint(Kingmaker.EntitySystem.Stats.StatType.Intelligence);
            success &= levelUpController.AddStatPoint(Kingmaker.EntitySystem.Stats.StatType.Intelligence);
            success &= levelUpController.AddStatPoint(Kingmaker.EntitySystem.Stats.StatType.Intelligence);
            success &= levelUpController.AddStatPoint(Kingmaker.EntitySystem.Stats.StatType.Intelligence);
            success &= levelUpController.AddStatPoint(Kingmaker.EntitySystem.Stats.StatType.Intelligence);
            if (!success)
            {
                Main.Log("Error selecting stats");
            }
            success  = levelUpController.SpendSkillPoint(Kingmaker.EntitySystem.Stats.StatType.SkillUseMagicDevice);
            success &= levelUpController.SpendSkillPoint(Kingmaker.EntitySystem.Stats.StatType.SkillKnowledgeWorld);
            success &= levelUpController.SpendSkillPoint(Kingmaker.EntitySystem.Stats.StatType.SkillPerception);
            success &= levelUpController.SpendSkillPoint(Kingmaker.EntitySystem.Stats.StatType.SkillThievery);
            success &= levelUpController.SpendSkillPoint(Kingmaker.EntitySystem.Stats.StatType.SkillStealth);
            success &= levelUpController.SpendSkillPoint(Kingmaker.EntitySystem.Stats.StatType.SkillLoreNature);
            success &= levelUpController.SpendSkillPoint(Kingmaker.EntitySystem.Stats.StatType.SkillKnowledgeArcana);
            if (!success)
            {
                Main.Log("Error selecting skills");
            }
            var selection         = ResourcesLibrary.TryGetBlueprint <BlueprintFeatureSelection>("247a4068296e8be42890143f451b4b45"); //BasicFeatSelection
            var featurePointBlack = ResourcesLibrary.TryGetBlueprint <BlueprintFeature>("0da0c194d6e1d43419eb8d990b28e0ab");          //PointBlankFeature

            success = levelUpController.SelectFeature(new FeatureSelectionState(null, null, selection, 0, 0), featurePointBlack);
            if (!success)
            {
                Main.Log("Error selecting point blank");
            }
            var featurePreciseShot = ResourcesLibrary.TryGetBlueprint <BlueprintFeature>("8f3d1e6b4be006f4d896081f2f889665"); //PreciseShotFeature

            success = levelUpController.SelectFeature(new FeatureSelectionState(null, null, selection, 1, 0), featurePreciseShot);
            if (!success)
            {
                Main.Log("Error selecting precise shot");
            }
            var spells = new List <string>()
            {
                "4f8181e7a7f1d904fbaea64220e83379",
                "5590652e1c2225c4ca30c4a699ab3649",
                "4e0e9aba6447d514f88eff1464cc4763",
                "ef768022b0785eb43a18969903c537c4",
                "2c38da66e5a599347ac95b3294acbe00",
                "9d504f8dff6e93b4ab6afc938ed6a23d",
                "24afb2c948c731440a3aaf5411904c89",
                "c60969e7f264e6d4b84a1499fdcf9039",
            };
            var alchemistSpellBook = ResourcesLibrary.TryGetBlueprint <BlueprintSpellbook>("fcbf2a5447624528a3f333bced844d06");
            var alchemistSpellList = ResourcesLibrary.TryGetBlueprint <BlueprintSpellList>("f60d0cd93edc65c42ad31e34a905fb2f");

            success = true;
            for (var i = 0; i < spells.Count; i++)
            {
                var spell = ResourcesLibrary.TryGetBlueprint <BlueprintAbility>(spells[i]);
                success &= levelUpController.SelectSpell(alchemistSpellBook, alchemistSpellList, 1, spell, i);
            }
            if (!success)
            {
                Main.Log("Error selecting spells");
            }
            success = levelUpController.SelectVoice(ResourcesLibrary.TryGetBlueprint <BlueprintUnitAsksList>("e7b22776ba8e2b84eaaff98e439639a7"));
            if (!success)
            {
                Main.Log("Error selecting voice");
            }
            success = levelUpController.SelectName("ABC");
            if (!success)
            {
                Main.Log("Error selecting name");
            }
            var token = UnitSerialization.Serialize(unit);

            File.WriteAllText("TestUnit.json", token.ToString());
            LogUnit("TestUnit.txt", unit);
        }
Beispiel #26
0
        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 <UnorderedList <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 <UnorderedList <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 = ResourcesLibrary.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 UnorderedList <string, string>();
                m_OrphanedFemaleEquipment = new UnorderedList <string, string>();
                foreach (var kv in ResourcesLibrary.LibraryObject.ResourceNamesByAssetId.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();
            }
        }
Beispiel #27
0
        static private void Init()
        {
            var races       = ResourcesLibrary.GetBlueprints <BlueprintRace>();
            var racePresets = ResourcesLibrary.GetBlueprints <BlueprintRaceVisualPreset>();
            var classes     = ResourcesLibrary.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 ResourcesLibrary.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 ResourcesLibrary.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;
        }
        public static void Functions(int index)
        {
            switch (index)
            {
            case 0:
                break;

            case 1:
                GameInfo();
                break;

            case 2:
                KillFunctions();
                break;

            case 3:
                Common.ResurrectAndFullRestore(Common.GetUnitUnderMouse());
                break;

            case 4:
                Common.Buff(Common.GetUnitUnderMouse(),
                            Storage.buffFavouritesGuids[Main.Settings.actionKeyBuffIndex]);
                break;

            case 5:
                editUnit = Common.GetUnitUnderMouse();
                break;

            case 6:
                teleportUnit = Common.GetUnitUnderMouse();
                if (teleportUnit != null && Strings.ToBool(Main.Settings.toggleAddToLog))
                {
                    Common.AddLogEntry(Strings.GetText("label_TeleportUnit") + $": {teleportUnit.CharacterName}",
                                       Color.black);
                }
                break;

            case 7:
                if (settings.actionKeySpawnRandomEnemy && Strings.ToBool(settings.toggleActionKeyExperimental))
                {
                    try
                    {
                        Common.SpawnHostileUnit(Common.MousePositionLocalMap(),
                                                ResourcesLibrary.GetBlueprints <BlueprintUnit>().RandomElement());
                    }
                    catch (Exception e)
                    {
                        modLogger.Log(e.ToString());
                    }
                }
                else
                {
                    Common.SpawnHostileUnit(Common.MousePositionLocalMap(), banditsGuids[banidtCrIndex]);
                }

                break;

            case 8:
                rotateUnit = Common.GetUnitUnderMouse();
                if (rotateUnit != null && Strings.ToBool(Main.Settings.toggleAddToLog))
                {
                    Common.AddLogEntry(
                        Strings.GetText("arrayItem_ActionKeyMain_RotateUnit") + $": {rotateUnit.CharacterName}",
                        Color.black);
                }
                break;

            case 9:
                Common.GetUnitUnderMouse().View.AnimationManager.Execute(animationTypes[animationTypesIndex]);
                break;

            case 10:
                FxHelper.SpawnFxOnPoint(BlueprintRoot.Instance.Cheats.SillyCheatBlood,
                                        Common.MousePositionLocalMap());
                break;

            case 11:
                Common.Charm(Common.GetUnitUnderMouse());
                break;

            case 12:
                Common.AddToParty(Common.GetUnitUnderMouse());
                break;

            case 13:
                Common.GetUnitUnderMouse().Descriptor.Recreate = true;
                break;
            }
        }
        static void BuildEquipmentLookup()
        {
            var blueprints = ResourcesLibrary.GetBlueprints <BlueprintItemEquipment>()
                             .Where(bp => bp.EquipmentEntity != null)
                             .OrderBy(bp => bp.EquipmentEntity.name);

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

                case ItemType.Shoulders:
                    if (m_Cloak.ContainsKey(bp.EquipmentEntity.AssetGuid))
                    {
                        break;
                    }
                    m_Cloak[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;
                }
            }
        }