public void assign_thruster(IMyThrust thruster_ref) { var thruster = (MyThrust)thruster_ref; if (MyAPIGateway.Multiplayer == null || MyAPIGateway.Multiplayer.IsServer) { thruster.SetValueFloat("Override", 0.0f); } var new_thruster = new thruster_info(); new_thruster.grid_centre_pos = (thruster.Min + thruster.Max) * (_grid.GridSize / 2.0f); new_thruster.max_force = new_thruster.actual_max_force = thruster.BlockDefinition.ForceMagnitude; new_thruster.CoM_offset = new_thruster.reference_vector = new_thruster.grid_centre_pos - _grid_CoM_location; new_thruster.static_moment = new_thruster.grid_centre_pos * new_thruster.max_force; new_thruster.nozzle_direction = get_nozzle_orientation(thruster); new_thruster.override_cleared = false; new_thruster.is_RCS = new_thruster.group_no_RCS = _thruster_added_or_removed = true; _max_force[(int)new_thruster.nozzle_direction] += new_thruster.max_force; _lin_force[(int)new_thruster.nozzle_direction] += new_thruster.max_force; _thrusters[(int)new_thruster.nozzle_direction].Add(thruster, new_thruster); //log_ECU_action("assign_thruster", string.Format("{0} ({1}) [{2}]\n\t\t\tCentre position: {3}", // ((PB.IMyTerminalBlock) thruster).CustomName, new_thruster.nozzle_direction.ToString(), thruster.EntityId, // new_thruster.grid_centre_pos)); }
private void fill_control_sets(thruster_info cur_thruster_info) { if (cur_thruster_info.reference_vector.LengthSquared() < _grid.GridSize * _grid.GridSize) { return; } Vector3 sample_vector, reference_norm = Vector3.Normalize(cur_thruster_info.reference_vector); for (int dir_index = 0; dir_index < 6; ++dir_index) { __cur_firing_vector[dir_index] = 1.0f; recompose_vector(__cur_firing_vector, out sample_vector); decompose_vector(Vector3.Cross(sample_vector, reference_norm), __linear_component); if (__linear_component[(int)cur_thruster_info.nozzle_direction] > 0.0f) { _control_sets[dir_index].Add(cur_thruster_info); } __cur_firing_vector[dir_index] = 0.0f; } }
public void dispose_thruster(IMyThrust thruster_ref) { var thruster = (MyThrust)thruster_ref; for (int dir_index = 0; dir_index < 6; ++dir_index) { Dictionary <MyThrust, thruster_info> cur_direction = _thrusters[dir_index]; if (cur_direction.ContainsKey(thruster)) { thruster_info cur_thruster_info = cur_direction[thruster]; if (cur_thruster_info.is_RCS) { _max_force[(int)cur_thruster_info.nozzle_direction] -= cur_thruster_info.max_force; } _lin_force[(int)cur_thruster_info.nozzle_direction] -= cur_thruster_info.actual_max_force; cur_direction.Remove(thruster); _thruster_added_or_removed = true; //log_ECU_action("dispose_thruster", string.Format("{0} ({1}) [{2}]", ((PB.IMyTerminalBlock) thruster).CustomName, get_nozzle_orientation(thruster).ToString(), thruster.EntityId)); break; } } }