/// <summary> /// Register new functionality that will be automatically added to all characters (where applicable). /// Offers easy API for saving and loading extended data, and for running logic to apply it to the characters. /// All necessary hooking and event subscribing is done for you. All you have to do is create a type /// that inherits from <code>CharaExtraBehaviour</code> (don't make instances, the API will make them for you). /// </summary> /// <typeparam name="T">Type with your custom logic to add to a character</typeparam> /// <param name="extendedDataId">Extended data ID used by this behaviour. Set to null if not used.</param> /// <param name="customDataCopier">Override default extended data copy logic</param> /// <param name="priority">Default value is 1000, Decrease to increase priority or vice versa such on <see cref="CharaCustomFunctionController.OnReload(GameMode)"/> or related functions.</param> public static void RegisterExtraBehaviour <T>(string extendedDataId, CopyExtendedDataFunc customDataCopier, int priority) where T : CharaCustomFunctionController, new() { while (_registeredHandlers.ContainsKey(priority)) { priority++; } _registeredHandlers.Add(priority, new ControllerRegistration(typeof(T), extendedDataId, customDataCopier)); }
internal ControllerRegistration(Type controllerType, string extendedDataId, CopyExtendedDataFunc extendedDataCopier) { ControllerType = controllerType; ExtendedDataId = extendedDataId; ExtendedDataCopier = extendedDataCopier; }
/// <summary> /// Register new functionality that will be automatically added to all characters (where applicable). /// Offers easy API for saving and loading extended data, and for running logic to apply it to the characters. /// All necessary hooking and event subscribing is done for you. All you have to do is create a type /// that inherits from <code>CharaExtraBehaviour</code> (don't make instances, the API will make them for you). /// </summary> /// <typeparam name="T">Type with your custom logic to add to a character</typeparam> /// <param name="extendedDataId">Extended data ID used by this behaviour. Set to null if not used.</param> /// <param name="customDataCopier">Override default extended data copy logic</param> public static void RegisterExtraBehaviour <T>(string extendedDataId, CopyExtendedDataFunc customDataCopier) where T : CharaCustomFunctionController, new() { _registeredHandlers.Add(new ControllerRegistration(typeof(T), extendedDataId, customDataCopier)); }
/// <summary> /// Register new functionality that will be automatically added to all characters (where applicable). /// Offers easy API for saving and loading extended data, and for running logic to apply it to the characters. /// All necessary hooking and event subscribing is done for you. All you have to do is create a type /// that inherits from <code>CharaExtraBehaviour</code> (don't make instances, the API will make them for you). /// </summary> /// <typeparam name="T">Type with your custom logic to add to a character</typeparam> /// <param name="extendedDataId">Extended data ID used by this behaviour. Set to null if not used.</param> /// <param name="customDataCopier">Override default extended data copy logic</param> public static void RegisterExtraBehaviour <T>(string extendedDataId, CopyExtendedDataFunc customDataCopier) where T : CharaCustomFunctionController, new() { RegisterExtraBehaviour <T>(extendedDataId, customDataCopier, 1000); }