Exemple #1
0
        private void on_entity_added(IMyEntity entity)
        {
            var grid = entity as IMyCubeGrid;

            if (grid != null)
            {
                var new_grid_logic = new grid_logic(grid);
                _grids_handle_60Hz      += new_grid_logic.handle_60Hz;
                _grids_handle_4Hz       += new_grid_logic.handle_4Hz;
                _grids_handle_2s_period += new_grid_logic.handle_2s_period;
                _grids.Add(grid, new_grid_logic);
            }
        }
Exemple #2
0
        private void on_entity_removed(IMyEntity entity)
        {
            var grid = entity as IMyCubeGrid;

            if (grid != null && _grids.ContainsKey(grid))
            {
                grid_logic grid_logic_to_remove = _grids[grid];
                _grids_handle_60Hz      -= grid_logic_to_remove.handle_60Hz;
                _grids_handle_4Hz       -= grid_logic_to_remove.handle_4Hz;
                _grids_handle_2s_period -= grid_logic_to_remove.handle_2s_period;
                grid_logic_to_remove.Dispose();
                _grids.Remove(grid);
            }
        }
 public static void register_logic_object(grid_logic obj, long entity_id)
 {
     entities.Add(entity_id, obj);
 }