private static void Add(string name, CustomComponent comp) { Registry.Add(name, comp); Registry = Registry .OrderBy(o => o.Value.Mod.Name) .ThenBy(o => o.Value.DisplayName) .ToDictionary(o => o.Key, o => o.Value); }
public static CustomComponent CreateNew(Mod mod, string name, string displayName, Builder builder) { if (Registry.TryGetValue(name, out var i) && i == null) { Registry.Remove(name); } var comp = new CustomComponent <EmptyHandler>(mod, name, displayName, builder.State); Add(name, comp); return(comp); }
/// <summary> /// Registers a new custom component with no update handler. /// </summary> /// <param name="mod">The mod that is registering this component.</param> /// <param name="name">The component's "ugly" name. This name will be used to uniquely identify the component, so make sure that no other mods will use it.</param> /// <param name="displayName">The name that will be shown in the components menu.</param> /// <param name="builder">The builder that you use to create the structure of the component. See <see cref="PrefabBuilder"/>.</param> /// <returns>A <see cref="CustomComponent"/> instance. You don't need to store this.</returns> public static CustomComponent CreateNew(string name, string displayName, Builder builder) { var mod = Bootstrapper.Instance.GetModByAssembly(Assembly.GetCallingAssembly()); if (Registry.TryGetValue(name, out var i) && i == null) { Registry.Remove(name); } var comp = new CustomComponent <EmptyHandler>(mod, name, displayName, builder.State); Add(name, comp); return(comp); }