Example #1
0
        private PrefabSets GetAvailablePrefabSetsForLocation(ChassisLocations location)
        {
            var locationString = VHLUtils.GetStringFromLocation(location);
            var weaponsData    = chassisDef.HardpointDataDef.HardpointData.FirstOrDefault(x => x.location == locationString);
            var sets           = new PrefabSets();

            if (weaponsData.weapons == null)
            {
                //Control.mod.Logger.LogDebug($"no hardpoint data found for {chassisDef.Description.Id} at {location}");
            }
            else
            {
                foreach (var weapons in weaponsData.weapons)
                {
                    var index = sets.Count;
                    try
                    {
                        var set = new PrefabSet(index, weapons);
                        sets.Add(set);
                    }
                    catch (Exception e)
                    {
                        Control.mod.Logger.LogDebug($"error processing hardpoint data for {chassisDef.Description.Id} at {location}: index={index} weapons=[{weapons?.JoinAsString()}]", e);
                        throw;
                    }
                }
            }
            return(sets);
        }
        private PrefabSets GetAvailablePrefabSetsForLocation(ChassisLocations location)
        {
            var weaponsData = GetWeaponData(location);
            var sets        = new PrefabSets();

            if (weaponsData.weapons == null)
            {
                //Control.mod.Logger.LogDebug($"no hardpoint data found for {chassisDef.Description.Id} at {location}");
            }
            else
            {
                foreach (var weapons in weaponsData.weapons)
                {
                    var index = sets.Count;
                    try
                    {
                        var set = new PrefabSet(index, weapons.Where(x => !preMappedPrefabNames.Contains(x)));
                        sets.Add(set);
                    }
                    catch (Exception e)
                    {
                        Control.mod.Logger.LogWarning($"error processing hardpoint data for {chassisDef.Description.Id} at {location}: index={index} weapons=[{weapons?.JoinAsString()}]", e);
                        //throw;
                    }
                }
            }
            return(sets);
        }