Exemple #1
0
        /// <summary>
        /// Used to register a handler.
        /// </summary>
        /// <param name="name">Name of the handler: it must be unique and without special characters.</param>
        /// <param name="onCharRead">Callback that will be called when the plugin reads a character card.</param>
        /// <param name="onCharWrite">Callback that will be called when the plugin saves a character card.</param>
        /// <param name="onSceneLoad">Callback that will be called when the plugin reads a scene card.</param>
        /// <param name="onSceneImport">Callback that will be called when the plugin reads a scene card (import).</param>
        /// <param name="onSceneWrite">Callback that will be called when the plugin saves a scene card.</param>
        /// <returns>true if the operation was successful, otherwise false</returns>
        public static bool RegisterHandler(string name, ExtSaveCharReadHandler onCharRead, ExtSaveCharWriteHandler onCharWrite, ExtSaveSceneReadHandler onSceneLoad, ExtSaveSceneReadHandler onSceneImport, ExtSaveSceneWriteHandler onSceneWrite, ExtSaveClothesReadHandler onClothesRead, ExtSaveClothesWriteHandler onClothesWrite)
        {
            if (string.IsNullOrEmpty(name))
            {
                UnityEngine.Debug.LogError(HSExtSave._logPrefix + "Name of the handler must not be null or empty...");
                return(false);
            }
            HandlerGroup group;

            if (_handlers.TryGetValue(name, out group))
            {
                UnityEngine.Debug.LogWarning(HSExtSave._logPrefix + "Handler is already registered, updating callbacks...");
            }
            else
            {
                group = new HandlerGroup();
                _handlers.Add(name, group);
            }
            group.onCharRead        = onCharRead;
            group.onCharWrite       = onCharWrite;
            group.onSceneReadLoad   = onSceneLoad;
            group.onSceneReadImport = onSceneImport;
            group.onSceneWrite      = onSceneWrite;
            group.onClothesRead     = onClothesRead;
            group.onClothesWrite    = onClothesWrite;
            return(true);
        }
Exemple #2
0
    /// <summary>
    /// 注册事件
    /// </summary>
    /// <param name="recv"></param>
    /// <typeparam name="T"></typeparam>
    /// <returns></returns>
    public Handler RegEventHandler <T>(OnEventRecv <T> recv) where T : Event
    {
        HandlerGroup g;

        if (!event_handlers.TryGetValue(typeof(T), out g))
        {
            g = new HandlerGroup(typeof(T));
            event_handlers.Add(typeof(T), g);
        }
        return(g.Create <T>(recv));
    }
 internal Configuration()
 {
     Handlers = new HandlerGroup();
     Handlers.Add(typeof(IList), (type, o) => Dump(((IList) o).Cast<object>()));
     Handlers.Add(typeof(IDictionary), (type, o) => DumpIDictionary(o));
     Handlers.Add(typeof(ICollection), (type, o) => Dump(((ICollection) o).Cast<object>()));
     Handlers.Add(typeof(CodeObject), (type, o) => Dump((CodeObject) o));
     Handlers.Add(typeof(Type), (type, o) => ((Type) o).PrettyName());
     Handlers.Add(typeof(string), (type, o) => ((string)o).Quote());
     Handlers.Add(t => t.IsPrimitive, (type, o) => o.ToString());
     Handlers.Add(IsOutlookClass, (type, o) => o.ToString());
 }
Exemple #4
0
 internal Configuration()
 {
     Handlers = new HandlerGroup();
     Handlers.Add(typeof(IList), (type, o) => Dump(((IList)o).Cast <object>()));
     Handlers.Add(typeof(IDictionary), (type, o) => DumpIDictionary(o));
     Handlers.Add(typeof(ICollection), (type, o) => Dump(((ICollection)o).Cast <object>()));
     Handlers.Add(typeof(CodeObject), (type, o) => Dump((CodeObject)o));
     Handlers.Add(typeof(Type), (type, o) => ((Type)o).PrettyName());
     Handlers.Add(typeof(string), (type, o) => ((string)o).Quote());
     Handlers.Add(t => t.IsEnum, DumpEnum);
     Handlers.Add(t => t.IsPrimitive, (type, o) => o.ToString());
     Handlers.Add(IsOutlookClass, (type, o) => o.ToString());
 }