コード例 #1
0
        internal static void thrust_reduction_handler(sync_helper.message_types message_type, object entity, byte[] argument, int length)
        {
            var instance = entity as grid_logic;

            if (length != 1 || instance == null || instance._disposed)
            {
                return;
            }

            screen_info.set_displayed_thrust_reduction(instance._grid, argument[0], !instance._is_secondary && instance._secondary_grids == null);
        }
コード例 #2
0
        public static void remote_grid_settings(sync_helper.message_types message_type, object entity, byte[] argument, int length)
        {
            var grid = entity as IMyCubeGrid;

            if (grid == null)
            {
                return;
            }

            if (message_type == sync_helper.message_types.MANOEUVRE && length == 1)
            {
                _current_manoeuvre = (engine_control_unit.ID_manoeuvres)argument[0];
                //log_tagger_action("remote_grid_settings", $"received \"{grid.DisplayName}\" M={_current_manoeuvre}");
                update_grid_flags(grid, use_remote_manoeuvre: true);
            }
            else if (message_type == sync_helper.message_types.GRID_CONTROL_SENSITIVITY && length == 2)
            {
                _grid_control_sensitivity = (int)sync_helper.decode_signed(2, argument, 0);
                //log_tagger_action("remote_grid_settings", $"received \"{grid.DisplayName}\" P={_grid_control_sensitivity / GRID_CONTROL_SENSITIVITY_SCALE}");
                update_grid_flags(grid, use_remote_sensitivity: true);
            }
            else if (message_type == sync_helper.message_types.GRID_MODES)
            {
                if (length == 1)
                {
                    _grid_switches = argument[0];
                    //log_tagger_action("remote_grid_settings", $"received \"{grid.DisplayName}\" S={_grid_switches:X}h");
                    update_grid_flags(grid, use_remote_switches: true);
                }
                else if (length == 8 && sync_helper.running_on_server)
                {
                    update_grid_flags(grid);
                    _message[0] = (byte)_grid_switches;
                    _message[1] = (byte)_current_manoeuvre;
                    sync_helper.encode_signed(_grid_control_sensitivity, 2, _message, 2);
                    ulong recipient = sync_helper.decode_unsigned(8, argument, 0);
                    //log_tagger_action("remote_grid_settings", $"sending \"{grid.DisplayName}\" S={_grid_switches:X}h+M={_current_manoeuvre}+P={_grid_control_sensitivity / GRID_CONTROL_SENSITIVITY_SCALE} to {recipient}");
                    sync_helper.send_message_to(recipient, sync_helper.message_types.GRID_MODES, grid, _message, 4);
                }
                else if (length == 4 && !sync_helper.running_on_server)
                {
                    _pending_grid_requests.Remove(grid);
                    _have_pending_requests = _pending_thruster_requests != null && _pending_thruster_requests.Count > 0 ||
                                             _pending_grid_requests != null && _pending_grid_requests.Count > 0;

                    _grid_switches            = argument[0];
                    _current_manoeuvre        = (engine_control_unit.ID_manoeuvres)argument[1];
                    _grid_control_sensitivity = (int)sync_helper.decode_signed(2, argument, 2);
                    //log_tagger_action("remote_grid_settings", $"received \"{grid.DisplayName}\" S={_grid_switches:X}h+M={_current_manoeuvre}+P={_grid_control_sensitivity / GRID_CONTROL_SENSITIVITY_SCALE}");
                    update_grid_flags(grid, use_remote_switches: true, use_remote_manoeuvre: true, use_remote_sensitivity: true);
                }
            }
        }
コード例 #3
0
        public static void remote_thrust_settings(sync_helper.message_types message_type, object entity, byte[] argument, int length)
        {
            var thruster = entity as IMyTerminalBlock;

            if (thruster == null)
            {
                return;
            }

            if (message_type == sync_helper.message_types.MANUAL_THROTTLE && length == 2)
            {
                _manual_throttle = (int)sync_helper.decode_signed(2, argument, 0);
                //log_tagger_action("remote_thrust_settings", $"received \"{thruster.CustomName}\" T={_manual_throttle / MANUAL_THROTTLE_SCALE * 100.0f}");
                update_thruster_flags(thruster, use_remote_manual_throttle: true);
            }
            else if (message_type == sync_helper.message_types.THRUSTER_MODES)
            {
                if (length == 1)
                {
                    _thruster_switches = argument[0];
                    //log_tagger_action("remote_thrust_settings", $"received \"{thruster.CustomName}\" S={_thruster_switches:X}h");
                    update_thruster_flags(thruster, use_remote_switches: true);
                }
                else if (length == 8 && sync_helper.running_on_server)
                {
                    update_thruster_flags(thruster);
                    _message[0] = (byte)_thruster_switches;
                    sync_helper.encode_signed(_manual_throttle, 2, _message, 1);
                    ulong recipient = sync_helper.decode_unsigned(8, argument, 0);
                    //log_tagger_action("remote_thrust_settings", $"sending \"{thruster.CustomName}\" S={_thruster_switches:X}h+T={_manual_throttle / MANUAL_THROTTLE_SCALE * 100.0f} to {recipient}");
                    sync_helper.send_message_to(recipient, sync_helper.message_types.THRUSTER_MODES, thruster, _message, 3);
                }
                else if (length == 3 && !sync_helper.running_on_server)
                {
                    _pending_thruster_requests.Remove(thruster);
                    _have_pending_requests = _pending_thruster_requests != null && _pending_thruster_requests.Count > 0 ||
                                             _pending_grid_requests != null && _pending_grid_requests.Count > 0;

                    _thruster_switches = argument[0];
                    _manual_throttle   = (int)sync_helper.decode_signed(2, argument, 1);
                    //log_tagger_action("remote_thrust_settings", $"received \"{thruster.CustomName}\" S={_thruster_switches:X}h+T={_manual_throttle / MANUAL_THROTTLE_SCALE * 100.0f}");
                    update_thruster_flags(thruster, use_remote_switches: true, use_remote_manual_throttle: true);
                }
            }
        }
コード例 #4
0
        internal static void I_terms_handler(sync_helper.message_types message_type, object entity, byte[] argument, int length)
        {
            if (length != 18 || sync_helper.running_on_server)
            {
                return;
            }

            var instance = entity as grid_logic;

            if (instance == null || instance._disposed)
            {
                return;
            }

            engine_control_unit current_ECU = instance._ECU;

            current_ECU.current_trim    = structurise_vector(argument, 0);
            current_ECU.aux_trim        = structurise_vector(argument, 6);
            current_ECU.linear_integral = structurise_vector(argument, 12);
        }
コード例 #5
0
        public static void show_remote_text(sync_helper.message_types message_type, object entity, byte[] message, int length)
        {
            string[] message_parts = Encoding.UTF8.GetString(message, 0, length).Split(whitespace_char, 3);
            string   message_id    = message_parts[1];

            _remote_message_times[message_id] = int.Parse(message_parts[0]);
            _server_messages     [message_id] = message_parts[2];

            List <string> messages_to_remove = null;

            foreach (string cur_message in _remote_message_times.Keys)
            {
                if (_server_messages.ContainsKey(cur_message) && _client_messages.ContainsKey(cur_message))
                {
                    string output = _server_messages[cur_message];

                    if (_client_messages[cur_message] != "")
                    {
                        output += "\n" + _client_messages[cur_message];
                    }
                    screen_text(null, "", output, _remote_message_times[cur_message]);
                    if (messages_to_remove == null)
                    {
                        messages_to_remove = new List <string>();
                    }
                    messages_to_remove.Add(cur_message);
                }
            }
            if (messages_to_remove != null)
            {
                foreach (string cur_message in messages_to_remove)
                {
                    _remote_message_times.Remove(cur_message);
                    _server_messages.Remove(cur_message);
                    _client_messages.Remove(cur_message);
                }
            }
        }
コード例 #6
0
 public static void handle_remote_settings(sync_helper.message_types message_type, object entity, byte[] message, int length)
 {
     if (message[0] == 0 && length == 9 && sync_helper.running_on_server)
     {
         message[0] = 1;
         if (scripts_can_inspect_orbit_of_any_ship)
         {
             message[0] |= 0x2;
         }
         if (torque_disabled)
         {
             message[0] |= 0x4;
         }
         ulong recipient = sync_helper.decode_unsigned(8, message, 1);
         sync_helper.send_message_to(recipient, sync_helper.message_types.GLOBAL_MODES, null, message, 1);
     }
     else if (message[0] > 0 && length == 1 && !sync_helper.running_on_server)
     {
         scripts_can_inspect_orbit_of_any_ship = (message[0] & 0x2) != 0;
         torque_disabled         = (message[0] & 0x4) != 0;
         _server_settings_loaded = true;
     }
 }
コード例 #7
0
        private static void set_switch(IMyEntity entity, StringBuilder stored_settings, ref int switches, sync_helper.message_types sync_message,
                                       int switch_mask, bool new_state_on, int beginning, int end)
        {
            toggle_switch(ref switches, switch_mask, new_state_on);
            store_number(stored_settings, switches, beginning, end);
            entity.Storage[_uuid] = stored_settings.ToString();

            _message[0] = (byte)switches;
            sync_helper.send_message_to_others(sync_message, entity, _message, 1);
        }