コード例 #1
0
 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);
     }
 }
コード例 #2
0
 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
                 });
             }
         }
     }
 }