static void TryPreloadUnitView(ResourceRef assetId, Gender gender, Race race)
 {
     if (string.IsNullOrEmpty(assetId))
     {
         return;
     }
     ResourcesLibrary.PreloadResource <UnitEntityView>(assetId);
 }
 static void TryPreloadEE(ResourceRef assetId, Gender gender, Race race)
 {
     if (string.IsNullOrEmpty(assetId))
     {
         return;
     }
     ResourcesLibrary.PreloadResource <EquipmentEntity>(assetId);
 }
        public static void PreloadUnit(UnitEntityView __instance)
        {
            if (__instance == null)
            {
                return;
            }
            var unit = __instance.EntityData;

            if (!unit.IsPlayerFaction)
            {
                return;
            }
            var characterSettings = Main.settings.GetCharacterSettings(unit);

            if (characterSettings == null)
            {
                return;
            }
            var blueprintRace = unit.Descriptor.Progression.Race;
            var race          = blueprintRace?.RaceId ?? Race.Human;
            var gender        = unit.Gender;

            TryPreloadKEE(characterSettings.overrideHelm, gender, race);
            TryPreloadKEE(characterSettings.overrideShirt, gender, race);
            TryPreloadKEE(characterSettings.overrideArmor, gender, race);
            TryPreloadKEE(characterSettings.overrideBracers, gender, race);
            TryPreloadKEE(characterSettings.overrideGloves, gender, race);
            TryPreloadKEE(characterSettings.overrideBoots, gender, race);
            TryPreloadEE(characterSettings.overrideTattoo, gender, race);
            foreach (var kv in characterSettings.overrideWeapons)
            {
                TryPreloadWeapon(kv.Value, gender, race);
            }
            if (!string.IsNullOrEmpty(characterSettings.overrideView))
            {
                ResourcesLibrary.PreloadResource <GameObject>(characterSettings.overrideView);
            }
            if (characterSettings.classOutfit.Name == "None")
            {
                var clothes = gender == Gender.Male ? BlueprintRoot.Instance.CharGen.MaleClothes : BlueprintRoot.Instance.CharGen.FemaleClothes;
                foreach (var clothing in clothes)
                {
                    clothing.Preload();
                }
            }
        }