Kerbal Space Program  1.12.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros
Public Member Functions | Public Attributes | Protected Member Functions | List of all members
ModuleResourceHandler Class Reference

A subclass of PartModule to handle ModuleResource-limited PartModules. More...

Public Member Functions

virtual double GetAverageInput ()
 Gets the average input rate (or 0 if 0 inputs) More...
 
bool HasEnoughResourcesToAutoStart ()
 Determines if there are currently enough resources in the vessel to auto-start if that behavior is activated More...
 
bool IsResourceBelowShutOffLimit (PartResource partRes)
 Determines if there are currently enough resources in the vessel to keep operating if using auto-shutoff behavior More...
 
virtual void OnAwake ()
 
virtual void OnLoad (ConfigNode node)
 
virtual string PrintModuleResources (double mult=1d)
 Returns a pretty-formatted string containing all resources and rates More...
 
virtual string PrintModuleResources (bool showFlowModeDesc, double mult=1d)
 Returns a pretty-formatted string containing all resources and rates More...
 
void SetPartModule (PartModule p)
 
virtual double UpdateModuleResourceInputs (ref string error, double rateMultiplier, double threshold, bool returnOnFirstLack, bool average, bool stringOps=true)
 Updates the input resource state, requesting all resources and reporting a lack if any as the min fraction available (or 0 if returnOnFirstLack is true) More...
 
virtual double UpdateModuleResourceInputs (ref string error, bool useFlowMode, double rateMultiplier, double threshold, bool returnOnFirstLack, bool average, bool stringOps=true)
 Updates the input resource state, requesting all resources and reporting a lack if any as the min fraction available (or 0 if returnOnFirstLack is true) More...
 
virtual bool UpdateModuleResourceInputs (ref string error, bool useFlowMode, double rateMultiplier, double threshold, bool returnOnFirstLack, bool stringOps=true)
 Updates the input resource state, requesting all resources and reporting a lack if any More...
 
virtual bool UpdateModuleResourceInputs (ref string error, double rateMultiplier, double threshold, bool returnOnFirstLack, bool stringOps=true)
 Updates the input resource state, requesting all resources and reporting a lack if any More...
 
virtual double UpdateModuleResourceOutputs (double rateMultiplier=1d, double minAbsValue=0d)
 Updates the output resources, pushing the resources out More...
 

Public Attributes

bool currentResourceLowerThanLayoff
 
List< ModuleResourceinputResources = new List<ModuleResource>()
 
bool moduleResourceBasedPrimaryIsInput = true
 
List< ModuleResourceoutputResources = new List<ModuleResource>()
 
PartModule partModule
 

Protected Member Functions

void LoadResList (List< ModuleResource > list, ConfigNode node)
 

Detailed Description

A subclass of PartModule to handle ModuleResource-limited PartModules.

Member Function Documentation

virtual double ModuleResourceHandler.GetAverageInput ( )
inlinevirtual

Gets the average input rate (or 0 if 0 inputs)

Returns
bool ModuleResourceHandler.HasEnoughResourcesToAutoStart ( )
inline

Determines if there are currently enough resources in the vessel to auto-start if that behavior is activated

bool ModuleResourceHandler.IsResourceBelowShutOffLimit ( PartResource  partRes)
inline

Determines if there are currently enough resources in the vessel to keep operating if using auto-shutoff behavior

Parameters
partResThe PartResource to test for amount and limits
void ModuleResourceHandler.LoadResList ( List< ModuleResource list,
ConfigNode  node 
)
inlineprotected
virtual void ModuleResourceHandler.OnAwake ( )
inlinevirtual
virtual void ModuleResourceHandler.OnLoad ( ConfigNode  node)
inlinevirtual
virtual string ModuleResourceHandler.PrintModuleResources ( double  mult = 1d)
inlinevirtual

Returns a pretty-formatted string containing all resources and rates

Parameters
multmultiplier to the bas rate
Returns
virtual string ModuleResourceHandler.PrintModuleResources ( bool  showFlowModeDesc,
double  mult = 1d 
)
inlinevirtual

Returns a pretty-formatted string containing all resources and rates

Parameters
showFlowModeDescIf true will also include a flow mode description for each resource.
multmultiplier to the bas rate
Returns
void ModuleResourceHandler.SetPartModule ( PartModule  p)
inline
virtual double ModuleResourceHandler.UpdateModuleResourceInputs ( ref string  error,
double  rateMultiplier,
double  threshold,
bool  returnOnFirstLack,
bool  average,
bool  stringOps = true 
)
inlinevirtual

Updates the input resource state, requesting all resources and reporting a lack if any as the min fraction available (or 0 if returnOnFirstLack is true)

Parameters
errorthe string to write the lack to
rateMultipliera multiplier to the resource request
thresholdthe threshold multiplier below which the resource will be considered lacking
returnOnFirstLackif true, will report the first lacking resource, else will report all resources lacking
averagedo we average the returned values or clamp to the lowest? Obviously false if returnOnFirstLack
stringOpsDo we write errors to the string?
Returns
per average parameter, or 1 if no input resources
virtual double ModuleResourceHandler.UpdateModuleResourceInputs ( ref string  error,
bool  useFlowMode,
double  rateMultiplier,
double  threshold,
bool  returnOnFirstLack,
bool  average,
bool  stringOps = true 
)
inlinevirtual

Updates the input resource state, requesting all resources and reporting a lack if any as the min fraction available (or 0 if returnOnFirstLack is true)

Parameters
errorthe string to write the lack to
useFlowModeIf True will use flowMode defined in inputResources, If false will use the Default flowMode.
rateMultipliera multiplier to the resource request
thresholdthe threshold multiplier below which the resource will be considered lacking
returnOnFirstLackif true, will report the first lacking resource, else will report all resources lacking
averagedo we average the returned values or clamp to the lowest? Obviously false if returnOnFirstLack
stringOpsDo we write errors to the string?
Returns
per average parameter, or 1 if no input resources
virtual bool ModuleResourceHandler.UpdateModuleResourceInputs ( ref string  error,
bool  useFlowMode,
double  rateMultiplier,
double  threshold,
bool  returnOnFirstLack,
bool  stringOps = true 
)
inlinevirtual

Updates the input resource state, requesting all resources and reporting a lack if any

Parameters
errorthe string to write the lack to
useFlowModeIf True will use flowMode defined in inputResources, If false will use the Default flowMode.
rateMultipliera multiplier to the resource request
thresholdthe threshold multiplier below which the resource will be considered lacking
returnOnFirstLackif true, will report the first lacking resource, else will report all resources lacking
stringOpsDo we write errors to the string?
Returns
virtual bool ModuleResourceHandler.UpdateModuleResourceInputs ( ref string  error,
double  rateMultiplier,
double  threshold,
bool  returnOnFirstLack,
bool  stringOps = true 
)
inlinevirtual

Updates the input resource state, requesting all resources and reporting a lack if any

Parameters
errorthe string to write the lack to
rateMultipliera multiplier to the resource request
thresholdthe threshold multiplier below which the resource will be considered lacking
returnOnFirstLackif true, will report the first lacking resource, else will report all resources lacking
stringOpsDo we write errors to the string?
Returns
virtual double ModuleResourceHandler.UpdateModuleResourceOutputs ( double  rateMultiplier = 1d,
double  minAbsValue = 0d 
)
inlinevirtual

Updates the output resources, pushing the resources out

Parameters
rateMultipliera multiplier to the resource requests
minAbsValuethe minimum single-tick value pushed out to the network
Returns
the maximum rate, or 0 if no outputs

Member Data Documentation

bool ModuleResourceHandler.currentResourceLowerThanLayoff
List<ModuleResource> ModuleResourceHandler.inputResources = new List<ModuleResource>()
bool ModuleResourceHandler.moduleResourceBasedPrimaryIsInput = true
List<ModuleResource> ModuleResourceHandler.outputResources = new List<ModuleResource>()
PartModule ModuleResourceHandler.partModule

The documentation for this class was generated from the following file: