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); }
internal PrefabSelectionCandidate(PrefabSets freeSets, List <PrefabMapping> prefabsMappings) { FreeSets = freeSets; Mappings = prefabsMappings ?? new List <PrefabMapping>(); MajorScore = Mappings.Count; MinorScore = Mappings.Select(x => x.MechComponentRef.Def.InventorySize).Sum(); }
internal PrefabSelectionCandidate(PrefabSets freeSets, List <PrefabMapping> prefabsMappings) { FreeSets = freeSets; Mappings = prefabsMappings ?? new List <PrefabMapping>(); MajorScore = Mappings.Count; // more mappings MinorScore = Mappings.Select(x => x.MechComponentRef.Def.InventorySize).Sum(); // bigger items ThirdScore = -Mappings.Select(x => x.Prefab.Index).Sum(); // lower indexed }