public void InitializeComponents() { components.Clear(); foreach (VehicleComponentProperties props in vehicle.VehicleDef.components) { VehicleComponent component = (VehicleComponent)Activator.CreateInstance(props.compClass); components.Add(component); component.Initialize(props); component.PostCreate(); RecacheStatCategories(component); } }
private void RecacheStatCategories(VehicleComponent comp) { if (!comp.props.categories.NullOrEmpty()) { foreach (VehicleStatCategoryDef category in comp.props.categories) { if (statComponents.TryGetValue(category, out var list)) { list.Add(comp); } else { statComponents.Add(category, new List <VehicleComponent>() { comp }); } } } }