private void AddCategory(CategoryDescriptor category) { #if CCDEBUG Control.Logger.LogDebug($"Add Category: {category.Name}"); #endif if (Categories.TryGetValue(category.Name, out var c)) { #if CCDEBUG Control.Logger.LogDebug($"Already have, apply: {category.Name}"); #endif c.Apply(category); } else { #if CCDEBUG Control.Logger.LogDebug($"Adding new: {category.Name}"); #endif Categories.Add(category.Name, category); category.InitDefaults(); } #if CCDEBUG Control.Logger.LogDebug($"Current Categories"); foreach (var categoryDescriptor in Categories) { Control.Logger.LogDebug($" - {categoryDescriptor.Value.Name}"); } #endif }
public void OnLoaded(Dictionary <string, object> values) { CategoryDescriptor = CategoryController.Shared.GetOrCreateCategory(CategoryID); if (CategoryDescriptor.Defaults == null) { return; } Registry.ProcessCustomFactories(Def, CategoryDescriptor.Defaults, false); }
internal CategoryDescriptor GetOrCreateCategory(string name) { if (Categories.TryGetValue(name, out var c)) { return(c); } c = new CategoryDescriptor { Name = name }; Categories.Add(name, c); return(c); }
public void Complete(CategoryDescriptor cat_info) { if (LocationLimits == null) { if (Limits == null || Limits.Length == 0) { LocationLimits = new Dictionary <ChassisLocations, CategoryLimit>(); } else { LocationLimits = Limits.Distinct().ToDictionary(i => i.Location, i => new CategoryLimit(i.Min, i.Max, cat_info?.ReplaceDefaultsFirst ?? true)); } } MinLimited = LocationLimits.Count > 0 && LocationLimits.Values.Any(i => i.Min > 0); MaxLimited = LocationLimits.Count > 0 && LocationLimits.Values.Any(i => i.Max >= 0); }