Example #1
0
        public static void add_handler(Event_Type type, Handler fn, object user)
        {
            event_handler_entry e;

            Misc.assert(fn != null);

            /* Make a new entry */
            e = new event_handler_entry();
            e.fn = fn;
            e.user = user;

            /* Add it to the head of the appropriate list */
            e.next = event_handlers[(int)type];
            event_handlers[(int)type] = e;
        }
Example #2
0
        public static void signal_string(Event_Type type, string s)
        {
            Game_Event data = new Game_Event();
            data.text = s;

            dispatch(type, data);
        }
Example #3
0
        static void dispatch(Event_Type type, Game_Event data)
        {
            event_handler_entry t = event_handlers[(int)type];

            /*
             * Send the word out to all interested event handlers.
             */
            while (t != null)
            {
                /* Call the handler with the relevant data */
                t.fn(type, data, t.user);
                t = t.next;
            }
        }
Example #4
0
        public static void signal_point(Event_Type type, int x, int y)
        {
            Game_Event data = new Game_Event();
            data.point = new Loc(x, y);
            //data.point.x = x;
            //data.point.y = y;

            Game_Event.dispatch(type, data);
        }
Example #5
0
        public static void signal_flag(Event_Type type, bool flag)
        {
            Game_Event data = new Game_Event();
            data.flag = flag;

            dispatch(type, data);
        }
Example #6
0
 public static void signal(Event_Type type)
 {
     dispatch(type, null);
 }
Example #7
0
 //n_types was a size_t
 public static void remove_handler_set(Event_Type[] type, Handler fn, object user)
 {
     for (int i = 0; i < type.Length; i++)
         remove_handler(type[i], fn, user);
 }
Example #8
0
        public static void remove_handler(Event_Type type, Handler fn, object user)
        {
            event_handler_entry prev = null;
            event_handler_entry curr = event_handlers[(int)type];

            /* Look for the entry in the list */
            while (curr != null)
            {
                /* Check if this is the entry we want to remove */
                if (curr.fn == fn && curr.user == user)
                {
                    if (prev == null)
                    {
                        event_handlers[(int)type] = curr.next;
                    }
                    else
                    {
                        prev.next = curr.next;
                    }

                    //mem_free(curr);
                    return;
                }

                prev = curr;
                curr = curr.next;
            }
        }