Skip to content

Commit

Permalink
Vehicle energy_consumption in units::power (CleverRaven#62365)
Browse files Browse the repository at this point in the history
* energy_consumption json

* energy_consumption

* doc
  • Loading branch information
Hirmuolio authored Dec 10, 2022
1 parent f9cc1b1 commit 89a86fc
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 38 deletions.
40 changes: 20 additions & 20 deletions data/json/vehicleparts/combustion.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
"durability": 400,
"epower": -350,
"power": 223800,
"energy_consumption": "559500 J",
"energy_consumption": "559500 W",
"breaks_into": [
{ "item": "steel_lump", "count": [ 30, 40 ] },
{ "item": "steel_chunk", "count": [ 30, 40 ] },
Expand All @@ -91,7 +91,7 @@
"durability": 300,
"epower": -200,
"power": 93250,
"energy_consumption": "266000 J",
"energy_consumption": "266000 W",
"breaks_into": [
{ "item": "steel_lump", "count": [ 20, 30 ] },
{ "item": "steel_chunk", "count": [ 20, 30 ] },
Expand All @@ -117,7 +117,7 @@
"durability": 400,
"epower": -250,
"power": 149200,
"energy_consumption": "373000 J",
"energy_consumption": "373000 W",
"breaks_into": [
{ "item": "steel_lump", "count": [ 30, 40 ] },
{ "item": "steel_chunk", "count": [ 30, 40 ] },
Expand All @@ -143,7 +143,7 @@
"durability": 400,
"epower": -350,
"power": 242450,
"energy_consumption": "606250 J",
"energy_consumption": "606250 W",
"breaks_into": [
{ "item": "steel_lump", "count": [ 30, 40 ] },
{ "item": "steel_chunk", "count": [ 30, 40 ] },
Expand All @@ -170,7 +170,7 @@
"durability": 150,
"epower": 0,
"power": 7370,
"energy_consumption": "18425 J",
"energy_consumption": "18425 W",
"folded_volume": "60 L",
"breaks_into": [
{ "item": "steel_lump", "count": [ 5, 10 ] },
Expand Down Expand Up @@ -198,7 +198,7 @@
"durability": 150,
"epower": 0,
"power": 41000,
"energy_consumption": "124500 J",
"energy_consumption": "124500 W",
"folded_volume": "90 L",
"breaks_into": [
{ "item": "steel_lump", "count": [ 6, 12 ] },
Expand Down Expand Up @@ -227,7 +227,7 @@
"durability": 120,
"epower": 0,
"power": 3728,
"energy_consumption": "9320 J",
"energy_consumption": "9320 W",
"folded_volume": "629 ml",
"breaks_into": [
{ "item": "steel_lump", "count": [ 2, 4 ] },
Expand All @@ -253,7 +253,7 @@
"durability": 300,
"epower": -200,
"power": 111900,
"energy_consumption": "373000 J",
"energy_consumption": "373000 W",
"breaks_into": [
{ "item": "steel_lump", "count": [ 30, 40 ] },
{ "item": "steel_chunk", "count": [ 30, 40 ] },
Expand All @@ -279,7 +279,7 @@
"durability": 300,
"epower": -150,
"power": 93250,
"energy_consumption": "311000 J",
"energy_consumption": "311000 W",
"breaks_into": [
{ "item": "steel_lump", "count": [ 20, 30 ] },
{ "item": "steel_chunk", "count": [ 20, 30 ] },
Expand All @@ -305,7 +305,7 @@
"durability": 600,
"epower": -350,
"power": 447600,
"energy_consumption": "1492000 J",
"energy_consumption": "1492000 W",
"breaks_into": [
{ "item": "steel_lump", "count": [ 45, 58 ] },
{ "item": "steel_chunk", "count": [ 45, 58 ] },
Expand All @@ -331,7 +331,7 @@
"durability": 600,
"epower": -400,
"power": 447600,
"energy_consumption": "1119000 J",
"energy_consumption": "1119000 W",
"breaks_into": [
{ "item": "steel_lump", "count": [ 45, 58 ] },
{ "item": "steel_chunk", "count": [ 45, 58 ] },
Expand All @@ -357,7 +357,7 @@
"durability": 400,
"epower": -200,
"power": 149200,
"energy_consumption": "497500 J",
"energy_consumption": "497500 W",
"breaks_into": [
{ "item": "steel_lump", "count": [ 30, 40 ] },
{ "item": "steel_chunk", "count": [ 30, 40 ] },
Expand All @@ -383,7 +383,7 @@
"durability": 400,
"epower": -250,
"power": 242450,
"energy_consumption": "808200 J",
"energy_consumption": "808200 W",
"breaks_into": [
{ "item": "steel_lump", "count": [ 40, 50 ] },
{ "item": "steel_chunk", "count": [ 40, 50 ] },
Expand All @@ -409,7 +409,7 @@
"durability": 200,
"epower": -50,
"power": 37300,
"energy_consumption": "124500 J",
"energy_consumption": "124500 W",
"folded_volume": "109 L",
"breaks_into": [
{ "item": "steel_lump", "count": [ 10, 20 ] },
Expand Down Expand Up @@ -451,7 +451,7 @@
"durability": 200,
"epower": 0,
"power": 55950,
"energy_consumption": "112000 J",
"energy_consumption": "112000 W",
"breaks_into": [
{ "item": "steel_lump", "count": [ 30, 60 ] },
{ "item": "steel_chunk", "count": [ 30, 60 ] },
Expand All @@ -477,7 +477,7 @@
"durability": 200,
"epower": 0,
"power": 93250,
"energy_consumption": "186500 J",
"energy_consumption": "186500 W",
"breaks_into": [
{ "item": "steel_lump", "count": [ 30, 60 ] },
{ "item": "steel_chunk", "count": [ 30, 60 ] },
Expand All @@ -503,7 +503,7 @@
"durability": 200,
"epower": -20,
"power": 149200,
"energy_consumption": "298500 J",
"energy_consumption": "298500 W",
"breaks_into": [
{ "item": "steel_lump", "count": [ 30, 60 ] },
{ "item": "steel_chunk", "count": [ 30, 60 ] },
Expand All @@ -530,7 +530,7 @@
"durability": 400,
"epower": -10,
"power": 1006695,
"energy_consumption": "4026780 J",
"energy_consumption": "4026780 W",
"breaks_into": [
{ "item": "alloy_plate", "count": [ 1, 2 ] },
{ "item": "steel_lump", "count": [ 45, 58 ] },
Expand All @@ -557,7 +557,7 @@
"durability": 400,
"epower": -10,
"power": 1416830,
"energy_consumption": "5667320 J",
"energy_consumption": "5667320 W",
"breaks_into": [
{ "item": "alloy_plate", "count": [ 2, 4 ] },
{ "item": "steel_lump", "count": [ 50, 65 ] },
Expand All @@ -584,7 +584,7 @@
"durability": 400,
"epower": -10,
"power": 4474199,
"energy_consumption": "17896796 J",
"energy_consumption": "17896796 W",
"breaks_into": [
{ "item": "alloy_plate", "count": [ 4, 6 ] },
{ "item": "steel_lump", "count": [ 100, 120 ] },
Expand Down
14 changes: 7 additions & 7 deletions data/json/vehicleparts/motor.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"looks_like": "motor_small",
"durability": 80,
"power": 800,
"energy_consumption": "1 kJ",
"energy_consumption": "1 kW",
"damage_modifier": 80,
"folded_volume": "250 ml",
"requirements": {
Expand All @@ -48,7 +48,7 @@
"item": "motor_small",
"durability": 120,
"power": 7040,
"energy_consumption": "8 kJ",
"energy_consumption": "8 kW",
"damage_modifier": 80,
"folded_volume": "250 ml",
"requirements": {
Expand Down Expand Up @@ -76,7 +76,7 @@
"item": "motor",
"durability": 200,
"power": 36000,
"energy_consumption": "40 kJ",
"energy_consumption": "40 kW",
"damage_modifier": 80,
"folded_volume": "1500 ml",
"requirements": {
Expand Down Expand Up @@ -113,7 +113,7 @@
"item": "motor_large",
"durability": 400,
"power": 150000,
"energy_consumption": "163 kJ",
"energy_consumption": "163 kW",
"damage_modifier": 80,
"requirements": {
"install": { "skills": [ [ "mechanics", 3 ] ], "time": "60 m", "using": [ [ "vehicle_wrench_2", 1 ] ] },
Expand Down Expand Up @@ -149,7 +149,7 @@
"item": "motor_enhanced",
"durability": 200,
"power": 282000,
"energy_consumption": "300 kJ",
"energy_consumption": "300 kW",
"damage_modifier": 80,
"requirements": {
"install": { "skills": [ [ "mechanics", 4 ] ], "time": "60 m", "using": [ [ "vehicle_wrench_2", 1 ] ] },
Expand Down Expand Up @@ -185,7 +185,7 @@
"item": "motor_super",
"durability": 400,
"power": 475000,
"energy_consumption": "500 kJ",
"energy_consumption": "500 kW",
"damage_modifier": 80,
"requirements": {
"install": { "skills": [ [ "mechanics", 5 ] ], "time": "60 m", "using": [ [ "vehicle_wrench_2", 1 ] ] },
Expand Down Expand Up @@ -221,7 +221,7 @@
"item": "motor_train1300",
"durability": 500,
"power": 1000000,
"energy_consumption": "1050 kJ",
"energy_consumption": "1050 kW",
"damage_modifier": 80,
"requirements": {
"install": { "skills": [ [ "mechanics", 8 ] ], "time": "60 m", "using": [ [ "vehicle_wrench_2", 1 ] ] },
Expand Down
12 changes: 6 additions & 6 deletions data/mods/BlazeIndustries/vehicleparts/blaze_combustion.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"durability": 200,
"epower": 0,
"power": 242450,
"energy_consumption": 485000,
"energy_consumption": "485000 W",
"breaks_into": [
{ "item": "steel_lump", "count": [ 30, 60 ] },
{ "item": "steel_chunk", "count": [ 30, 60 ] },
Expand All @@ -30,7 +30,7 @@
"durability": 200,
"epower": 0,
"power": 447600,
"energy_consumption": 895250,
"energy_consumption": "895250 W",
"breaks_into": [
{ "item": "steel_lump", "count": [ 30, 60 ] },
{ "item": "steel_chunk", "count": [ 30, 60 ] },
Expand Down Expand Up @@ -63,7 +63,7 @@
"durability": 200,
"epower": 0,
"power": 93250,
"energy_consumption": 207250,
"energy_consumption": "207250 W",
"breaks_into": [
{ "item": "steel_lump", "count": [ 30, 60 ] },
{ "item": "steel_chunk", "count": [ 30, 60 ] },
Expand All @@ -85,7 +85,7 @@
"durability": 200,
"epower": 0,
"power": 149200,
"energy_consumption": 331750,
"energy_consumption": "331750 W",
"breaks_into": [
{ "item": "steel_lump", "count": [ 30, 60 ] },
{ "item": "steel_chunk", "count": [ 30, 60 ] },
Expand All @@ -107,7 +107,7 @@
"durability": 200,
"epower": 0,
"power": 242450,
"energy_consumption": 539000,
"energy_consumption": "539000 W",
"breaks_into": [
{ "item": "steel_lump", "count": [ 30, 60 ] },
{ "item": "steel_chunk", "count": [ 30, 60 ] },
Expand All @@ -129,7 +129,7 @@
"durability": 200,
"epower": 0,
"power": 447600,
"energy_consumption": 994750,
"energy_consumption": "994750 W",
"breaks_into": [
{ "item": "steel_lump", "count": [ 30, 60 ] },
{ "item": "steel_chunk", "count": [ 30, 60 ] },
Expand Down
2 changes: 1 addition & 1 deletion data/mods/Magiclysm/vehicleparts/vehicle_parts.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"durability": 200,
"epower": -50,
"power": 37300,
"energy_consumption": 124500,
"energy_consumption": "124500 W",
"folded_volume": "2 L",
"breaks_into": [
{ "item": "steel_lump", "count": [ 10, 20 ] },
Expand Down
2 changes: 1 addition & 1 deletion doc/JSON_INFO.md
Original file line number Diff line number Diff line change
Expand Up @@ -2696,7 +2696,7 @@ Unless specified as optional, the following fields are mandatory for parts with
#### The following optional fields are specific to ENGINEs.
```c++
"power": 15000 // Engine motive power in watts.
"energy_consumption": 17500 // Engine power consumption at maximum power in watts. Defaults to
"energy_consumption": "55 W" // Engine power consumption at maximum power in watts. Defaults to
// electrical power and the E_COMBUSTION flag turns it to thermal
// power produced from fuel_type. Should always be larger than "power".
"m2c": 50, // The ratio of safe power to maximum power.
Expand Down
2 changes: 1 addition & 1 deletion src/veh_interact.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3033,7 +3033,7 @@ void veh_interact::display_details( const vpart_info *part )
c_white, _( "Charge: <color_light_gray>%s</color>" ),
item::nname( part->fuel_type ) );
}
int part_consumption = units::to_joule( part->energy_consumption );
int part_consumption = units::to_watt( part->energy_consumption );
if( part_consumption != 0 ) {
fold_and_print( w_details, point( col_2, line + 4 ), column_width, c_white,
_( "Drain: <color_light_gray>%+8d</color>" ), -part_consumption );
Expand Down
2 changes: 1 addition & 1 deletion src/veh_type.h
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ class vpart_info
* Energy consumed per second by engines and motors when delivering max @ref power
* Includes waste. Gets scaled based on powertrain demand.
*/
units::energy energy_consumption = 0_J;
units::power energy_consumption = 0_W;

/**
* For engines and motors this is maximum output (watts)
Expand Down
2 changes: 1 addition & 1 deletion src/vehicle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4595,7 +4595,7 @@ units::energy vehicle::engine_fuel_usage( int e ) const
}
const vpart_info &info = part_info( engines[ e ] );

units::energy usage = info.energy_consumption;
units::energy usage = info.energy_consumption * 1_seconds;
if( parts[ engines[ e ] ].has_fault_flag( "DOUBLE_FUEL_CONSUMPTION" ) ) {
usage *= 2;
}
Expand Down

0 comments on commit 89a86fc

Please sign in to comment.