public void SetValueFromBytes(byte[] bytes, CMCustomUDPData data) { if (type == typeof(float)) { SetValue(BitConverter.ToSingle(bytes, offset), data); } else if (type == typeof(UInt32)) { SetValue(BitConverter.ToUInt32(bytes, offset), data); } else if (type == typeof(int)) { SetValue(BitConverter.ToInt32(bytes, offset), data); } else if (type == typeof(fourcc)) { fourcc val = new fourcc(); val.data = Encoding.UTF8.GetString(bytes, offset, 4).ToCharArray(); SetValue(val, data); } }
public void SetValue(object value, CMCustomUDPData data) { if (fieldInfo != null) { fieldInfo.SetValue(data, value); } }
public object GetValue(CMCustomUDPData data) { if (fieldInfo != null) { return(fieldInfo.GetValue(data)); } return(0.0f); }
public byte[] GetBytes(CMCustomUDPData data) { object value = 0; if (fieldInfo != null) { value = fieldInfo.GetValue(data); } if (getBytesMethod != null) { return((byte[])getBytesMethod.Invoke(null, new object[] { value })); } else if (type == typeof(fourcc)) { return(Encoding.UTF8.GetBytes(((fourcc)value).data)); } return(null); }
public void Copy(CMCustomUDPData other) { total_time = other.total_time; paused = other.paused; yaw = other.yaw; pitch = other.pitch; roll = other.roll; yaw_velocity = other.yaw_velocity; pitch_velocity = other.pitch_velocity; roll_velocity = other.roll_velocity; yaw_acceleration = other.yaw_acceleration; pitch_acceleration = other.pitch_acceleration; roll_acceleration = other.roll_acceleration; position_x = other.position_x; position_y = other.position_y; position_z = other.position_z; local_velocity_x = other.local_velocity_x; local_velocity_y = other.local_velocity_y; local_velocity_z = other.local_velocity_z; gforce_lateral = other.gforce_lateral; gforce_longitudinal = other.gforce_longitudinal; gforce_vertical = other.gforce_vertical; speed = other.speed; suspension_position_bl = other.suspension_position_bl; suspension_position_br = other.suspension_position_br; suspension_position_fl = other.suspension_position_fl; suspension_position_fr = other.suspension_position_fr; suspension_velocity_bl = other.suspension_velocity_bl; suspension_velocity_br = other.suspension_velocity_br; suspension_velocity_fl = other.suspension_velocity_fl; suspension_velocity_fr = other.suspension_velocity_fr; suspension_acceleration_bl = other.suspension_acceleration_bl; suspension_acceleration_br = other.suspension_acceleration_br; suspension_acceleration_fl = other.suspension_acceleration_fl; suspension_acceleration_fr = other.suspension_acceleration_fr; wheel_patch_speed_bl = other.wheel_patch_speed_bl; wheel_patch_speed_br = other.wheel_patch_speed_br; wheel_patch_speed_fl = other.wheel_patch_speed_fl; wheel_patch_speed_fr = other.wheel_patch_speed_fr; throttle_input = other.throttle_input; steering_input = other.steering_input; brake_input = other.brake_input; clutch_input = other.clutch_input; gear = other.gear; max_gears = other.max_gears; engine_rate = other.engine_rate; race_position = other.race_position; race_sector = other.race_sector; sector_time_1 = other.sector_time_1; sector_time_2 = other.sector_time_2; brake_temp_bl = other.brake_temp_bl; brake_temp_br = other.brake_temp_br; brake_temp_fl = other.brake_temp_fl; brake_temp_fr = other.brake_temp_fr; tyre_pressure_bl = other.tyre_pressure_bl; tyre_pressure_br = other.tyre_pressure_br; tyre_pressure_fl = other.tyre_pressure_fl; tyre_pressure_fr = other.tyre_pressure_fr; lap = other.lap; laps_completed = other.laps_completed; total_laps = other.total_laps; lap_time = other.lap_time; lap_distance = other.lap_distance; track_length = other.track_length; last_lap_time = other.last_lap_time; max_rpm = other.max_rpm; idle_rpm = other.idle_rpm; channels = other.channels; }