public static WeaponBase GenerateRandomWeapon
            (List <WeaponPropertiesTemplate> templates,
            List <WeaponBase> weaponBases,
            List <GameObject> stocks,
            List <GameObject> handles,
            List <GameObject> magazines,
            List <GameObject> scopes,
            List <GameObject> barrels)
        {
            if (templates != null && weaponBases != null && weaponBases.Count != 0)
            {
                WeaponBase weaponBase = weaponBases.ElementAtOrDefault(Random.Range(0, weaponBases.Count));

                if (weaponBase != null)
                {
                    GameObject selectedStock    = stocks.ElementAtOrDefault(Random.Range(0, stocks.Count));
                    GameObject selectedHandle   = handles.ElementAtOrDefault(Random.Range(0, handles.Count));
                    GameObject selectedMagazine = magazines.ElementAtOrDefault(Random.Range(0, magazines.Count));
                    GameObject selectedScope    = scopes.ElementAtOrDefault(Random.Range(0, scopes.Count));
                    GameObject selectedBarrel   = barrels.ElementAtOrDefault(Random.Range(0, barrels.Count));

                    WeaponBase generatedWeaponBase = Object.Instantiate(weaponBase, new GameObject($"{GenerateRandomWeaponName()} {weaponBase.Properties.CategoryName}").transform);

                    generatedWeaponBase.Properties = GenerateRandomWeaponProperties(generatedWeaponBase.Category, templates.ElementAtOrDefault(Random.Range(0, templates.Count)));

                    if (selectedStock != null)
                    {
                        Transform stockTransform = generatedWeaponBase.StockTransform;

                        if (stockTransform != null)
                        {
                            _ = Object.Instantiate(selectedStock, stockTransform.position, stockTransform.rotation, stockTransform);
                        }
                    }

                    if (selectedHandle != null)
                    {
                        Transform handleTransform = generatedWeaponBase.HandleTransform;

                        if (handleTransform != null)
                        {
                            _ = Object.Instantiate(selectedHandle, handleTransform.position, handleTransform.rotation, handleTransform);
                        }
                    }

                    if (selectedMagazine != null)
                    {
                        Transform magazineTransform = generatedWeaponBase.MagazineTransform;

                        if (magazineTransform != null)
                        {
                            _ = Object.Instantiate(selectedMagazine, magazineTransform.position, magazineTransform.rotation, magazineTransform);
                        }
                    }

                    if (selectedScope != null)
                    {
                        Transform scopeTransform = generatedWeaponBase.ScopeTransform;

                        if (scopeTransform != null)
                        {
                            _ = Object.Instantiate(selectedScope, scopeTransform.position, scopeTransform.rotation, scopeTransform);
                        }
                    }

                    if (selectedBarrel != null)
                    {
                        Transform barrelTransform = generatedWeaponBase.BarrelTransform;

                        if (barrelTransform != null)
                        {
                            _ = Object.Instantiate(selectedBarrel, barrelTransform.position, barrelTransform.rotation, barrelTransform);
                        }
                    }

                    return(generatedWeaponBase);
                }
            }

            return(default);
        public static WeaponBase GenerateRandomWeapon(
            List <WeaponPropertiesTemplate> templates,
            List <WeaponBase> weaponBases,
            List <GameObject> stocks,
            List <GameObject> grips,
            List <GameObject> magazines,
            List <GameObject> scopes,
            List <GameObject> barrels)
        {
            if (templates == null || weaponBases == null || weaponBases.Count == 0)
            {
                return(null);
            }

            WeaponBase weaponBase = weaponBases.ElementAtOrDefault(Random.Range(0, weaponBases.Count));

            if (weaponBase == null)
            {
                return(null);
            }

            WeaponPropertiesTemplate selectedTemplate = templates.ElementAtOrDefault(Random.Range(0, templates.Count));

            if (selectedTemplate == null)
            {
                return(null);
            }

            string selectedNameFormat = selectedTemplate.NameFormats.ElementAtOrDefault(Random.Range(0, selectedTemplate.NameFormats.Count));

            GameObject selectedStock    = stocks.ElementAtOrDefault(Random.Range(0, stocks.Count));
            GameObject selectedGrip     = grips.ElementAtOrDefault(Random.Range(0, grips.Count));
            GameObject selectedMagazine = magazines.ElementAtOrDefault(Random.Range(0, magazines.Count));
            GameObject selectedScope    = scopes.ElementAtOrDefault(Random.Range(0, scopes.Count));
            GameObject selectedBarrel   = barrels.ElementAtOrDefault(Random.Range(0, barrels.Count));

            WeaponBase generatedWeaponBase = Object.Instantiate(weaponBase);

            generatedWeaponBase.name = $"{GenerateRandomWeaponName(selectedNameFormat)} {weaponBase.Properties.CategoryName}";

            generatedWeaponBase.Properties = GenerateRandomWeaponProperties(generatedWeaponBase.Category, templates.ElementAtOrDefault(Random.Range(0, templates.Count)));

            if (selectedStock != null)
            {
                Transform stockTransform = generatedWeaponBase.StockTransform;

                if (stockTransform != null)
                {
                    Object.Instantiate(selectedStock, stockTransform.position, stockTransform.rotation, stockTransform).name = "Stock";
                }
            }

            if (selectedGrip != null)
            {
                Transform gripTransform = generatedWeaponBase.GripTransform;

                if (gripTransform != null)
                {
                    Object.Instantiate(selectedGrip, gripTransform.position, gripTransform.rotation, gripTransform).name = "Grip";
                }
            }

            if (selectedMagazine != null)
            {
                Transform magazineTransform = generatedWeaponBase.MagazineTransform;

                if (magazineTransform != null)
                {
                    Object.Instantiate(selectedMagazine, magazineTransform.position, magazineTransform.rotation, magazineTransform).name = "Magazine";
                }
            }

            if (selectedScope != null)
            {
                Transform scopeTransform = generatedWeaponBase.ScopeTransform;

                if (scopeTransform != null)
                {
                    Object.Instantiate(selectedScope, scopeTransform.position, scopeTransform.rotation, scopeTransform).name = "Scope";
                }
            }

            if (selectedBarrel != null)
            {
                Transform barrelTransform = generatedWeaponBase.BarrelTransform;

                if (barrelTransform != null)
                {
                    Object.Instantiate(selectedBarrel, barrelTransform.position, barrelTransform.rotation, barrelTransform).name = "Barrel";
                }
            }

            return(generatedWeaponBase);
        }