@@ -17,6 +17,7 @@ public interface EntityObjectBase : DataObjectBase
17
17
IReadOnlyCollection < Module > Modules { get ; }
18
18
IReadOnlyCollection < Item > Fuels { get ; }
19
19
IReadOnlyCollection < Item > AssociatedItems { get ; }
20
+ IReadOnlyDictionary < string , double > Pollution { get ; }
20
21
21
22
EntityType EntityType { get ; }
22
23
string GetEntityTypeName ( bool plural ) ;
@@ -25,19 +26,19 @@ public interface EntityObjectBase : DataObjectBase
25
26
bool IsTemperatureFluidBurner { get ; }
26
27
fRange FluidFuelTemperatureRange { get ; }
27
28
28
- double GetBaseFuelConsumptionRate ( Item fuel , double temperature = double . NaN ) ;
29
+ double GetBaseFuelConsumptionRate ( Item fuel , Quality quality , double temperature = double . NaN ) ;
29
30
30
31
bool IsMissing { get ; }
31
32
32
- double Speed { get ; }
33
+ double GetSpeed ( Quality quality ) ;
33
34
34
35
int ModuleSlots { get ; }
35
36
36
- double EnergyDrain { get ; }
37
- double EnergyConsumption { get ; }
38
- double EnergyProduction { get ; }
37
+ double GetEnergyDrain ( ) ;
38
+ double GetEnergyConsumption ( Quality quality ) ;
39
+ double GetEnergyProduction ( Quality quality ) ;
40
+
39
41
double ConsumptionEffectivity { get ; }
40
- double Pollution { get ; }
41
42
42
43
//steam generators
43
44
double OperationTemperature { get ; }
@@ -53,10 +54,12 @@ internal class EntityObjectBasePrototype : DataObjectBasePrototype, EntityObject
53
54
public IReadOnlyCollection < Module > Modules { get { return modules ; } }
54
55
public IReadOnlyCollection < Item > Fuels { get { return fuels ; } }
55
56
public IReadOnlyCollection < Item > AssociatedItems { get { return associatedItems ; } }
57
+ public IReadOnlyDictionary < string , double > Pollution { get { return pollution ; } }
56
58
57
59
internal HashSet < ModulePrototype > modules { get ; private set ; }
58
60
internal HashSet < ItemPrototype > fuels { get ; private set ; }
59
61
internal List < ItemPrototype > associatedItems { get ; private set ; } //should honestly only be 1, but knowing modders....
62
+ internal Dictionary < string , double > pollution { get ; private set ; }
60
63
61
64
public EntityType EntityType { get ; private set ; }
62
65
public EnergySource EnergySource { get ; internal set ; }
@@ -65,56 +68,65 @@ internal class EntityObjectBasePrototype : DataObjectBasePrototype, EntityObject
65
68
public bool IsTemperatureFluidBurner { get ; set ; }
66
69
public fRange FluidFuelTemperatureRange { get ; set ; }
67
70
68
- private double speed ;
69
- public double Speed { get { return speed ; } internal set { speed = value == 0 ? 0.001 : value ; } }
71
+ internal Dictionary < Quality , double > speed { get ; private set ; }
72
+ internal Dictionary < Quality , double > energyConsumption { get ; private set ; }
73
+ internal Dictionary < Quality , double > energyProduction { get ; private set ; }
74
+
75
+ public double GetSpeed ( Quality quality ) { return speed . ContainsKey ( quality ) ? ( speed [ quality ] > 0 ? speed [ quality ] : 1 ) : 1 ; }
70
76
71
77
public int ModuleSlots { get ; internal set ; }
72
78
public double NeighbourBonus { get ; internal set ; }
73
79
74
- public double EnergyDrain { get ; internal set ; } //per second
75
- public double EnergyConsumption { get ; internal set ; }
76
- public double EnergyProduction { get ; internal set ; }
80
+ internal double energyDrain ;
81
+ public double GetEnergyDrain ( ) { return energyDrain ; }
82
+ public double GetEnergyConsumption ( Quality quality )
83
+ {
84
+ if ( this is BeaconPrototype )
85
+ return quality . BeaconPowerMultiplier * ( energyConsumption . ContainsKey ( quality ) ? energyConsumption [ quality ] : 1000 ) ;
86
+ else
87
+ return energyConsumption . ContainsKey ( quality ) ? energyConsumption [ quality ] : 1000 ;
88
+ }
89
+ public double GetEnergyProduction ( Quality quality ) { return energyConsumption . ContainsKey ( quality ) ? energyProduction [ quality ] : 0 ; }
90
+
77
91
public double ConsumptionEffectivity { get ; internal set ; }
78
92
public double OperationTemperature { get ; internal set ; }
79
93
80
- public double Pollution { get ; internal set ; }
81
-
82
94
public EntityObjectBasePrototype ( DataCache dCache , string name , string friendlyName , EntityType type , EnergySource source , bool isMissing ) : base ( dCache , name , friendlyName , "-" )
83
95
{
84
96
availableOverride = false ;
85
97
86
98
modules = new HashSet < ModulePrototype > ( ) ;
87
99
fuels = new HashSet < ItemPrototype > ( ) ;
88
100
associatedItems = new List < ItemPrototype > ( ) ;
101
+ pollution = new Dictionary < string , double > ( ) ;
102
+
103
+ speed = new Dictionary < Quality , double > ( ) ;
104
+ energyConsumption = new Dictionary < Quality , double > ( ) ;
105
+ energyProduction = new Dictionary < Quality , double > ( ) ;
89
106
90
107
IsMissing = isMissing ;
91
108
EntityType = type ;
92
109
EnergySource = source ;
93
110
94
111
//just some base defaults -> helps prevent overflow errors during solving if the assembler is a missing entity
95
- Speed = 1f ;
96
112
ModuleSlots = 0 ;
97
113
NeighbourBonus = 0 ;
98
- EnergyDrain = 0 ; //passive use (pretty much electricity only)
99
- EnergyConsumption = 1000 ; //default value to prevent issues with missing objects
100
- EnergyProduction = 0 ;
101
114
ConsumptionEffectivity = 1f ;
102
115
OperationTemperature = double . MaxValue ;
103
116
FluidFuelTemperatureRange = new fRange ( double . MinValue , double . MaxValue ) ;
104
117
105
- Pollution = 0 ;
106
118
}
107
119
108
- public double GetBaseFuelConsumptionRate ( Item fuel , double temperature = double . NaN )
120
+ public double GetBaseFuelConsumptionRate ( Item fuel , Quality quality , double temperature = double . NaN )
109
121
{
110
122
if ( ( EnergySource != EnergySource . Burner && EnergySource != EnergySource . FluidBurner && EnergySource != EnergySource . Heat ) )
111
123
Trace . Fail ( string . Format ( "Cant ask for fuel consumption rate on a non-burner! {0}" , this ) ) ;
112
124
else if ( ! fuels . Contains ( fuel ) )
113
125
Trace . Fail ( string . Format ( "Invalid fuel! {0} for entity {1}" , fuel , this ) ) ;
114
126
else if ( ! IsTemperatureFluidBurner )
115
- return EnergyConsumption / ( fuel . FuelValue * ConsumptionEffectivity ) ;
127
+ return GetEnergyConsumption ( quality ) / ( fuel . FuelValue * ConsumptionEffectivity ) ;
116
128
else if ( ! double . IsNaN ( temperature ) && ( fuel is Fluid fluidFuel ) && ( temperature > fluidFuel . DefaultTemperature ) && ( fluidFuel . SpecificHeatCapacity > 0 ) ) //temperature burn of liquid
117
- return EnergyConsumption / ( ( temperature - fluidFuel . DefaultTemperature ) * fluidFuel . SpecificHeatCapacity * ConsumptionEffectivity ) ;
129
+ return GetEnergyConsumption ( quality ) / ( ( temperature - fluidFuel . DefaultTemperature ) * fluidFuel . SpecificHeatCapacity * ConsumptionEffectivity ) ;
118
130
return 0.01 ; // we cant have a 0 consumption rate as that would mess with the solver.
119
131
}
120
132
0 commit comments