Kerbal Space Program
1.12.4
|
Classes | |
class | ResourcePrioritySet |
This class just links up the double-list of part resources with a hashset of them for fast contains checks. More... | |
Public Types | |
enum | PartBuildSetOptions { PartBuildSetOptions.Real = 1, PartBuildSetOptions.Simulate = 2, PartBuildSetOptions.Both = 3 } |
Options for the BuildPartSets method More... | |
Public Member Functions | |
bool | ContainsPart (Part p) |
Checks if the part is handled by the partset More... | |
virtual void | GetConnectedResourceTotals (int id, out double amount, out double maxAmount, bool pulling) |
Gets the amount and maxamount of the given resource in the partset More... | |
virtual void | GetConnectedResourceTotals (int id, out double amount, out double maxAmount, bool pulling, bool simulate) |
Gets the amount and maxamount of the given resource in the partset More... | |
virtual void | GetConnectedResourceTotals (int id, out double amount, out double maxAmount, double threshold, bool pulling) |
Gets the amount and maxamount of the given resource in the partset, obeying threshold More... | |
virtual void | GetConnectedResourceTotals (int id, out double amount, out double maxAmount, double threshold, bool pulling, bool simulate) |
Gets the amount and maxamount of the given resource in the partset, obeying threshold More... | |
HashSet< Part > | GetParts () |
Returns the set of parts or a new set if the set is null. NOTE DO NOT CHANGE THIS. For getting only. If you want to change it, use RebuildParts() More... | |
ResourcePrioritySet | GetResourceList (int id, bool pulling, bool simulate) |
Get the Resource List More... | |
void | HookEvents () |
PartSet (HashSet< Part > parts) | |
Construct a crossfeed (non-vesselwide) partset More... | |
PartSet (Vessel v) | |
Construct a vessel-wide partset More... | |
PartSet (PartSet set) | |
Makes a deep copy of the hash set but DOES NOT copy the caches More... | |
PartSet (ShipConstruct shipRef) | |
Construct a vessel-wide partset from ShipConstruct More... | |
PartSet (ShipConstruct shipRef, HashSet< Part > newParts) | |
Construct a partset from ShipConstruct - sets the target parts list in the PartSet to the passed in HashSet. More... | |
virtual void | RebuildInPlace () |
Clears cache without recreating the targetparts More... | |
virtual void | RebuildParts (HashSet< Part > newParts) |
Rebuild the partset as a crossfeed set Note: Does not clear targetPats, merely replaces it More... | |
virtual void | RebuildVessel (Vessel newVessel) |
Recreate the partset as a vessel-wide set More... | |
virtual void | RebuildVessel (ShipConstruct newShip) |
Recreate the partset as a vessel-wide set More... | |
virtual void | RebuildVessel (ShipConstruct newShip, HashSet< Part > newParts) |
Recreate the partset - sets the target parts list in the PartSet to the passed in HashSet. More... | |
virtual void | RemovePart (Part part) |
Will remove a Part from the Partset. More... | |
virtual double | RequestResource (Part part, int id, double demand, bool usePri) |
This method replaces the old RequestResource mechanic, and is called by Part.RequestResource. More... | |
virtual double | RequestResource (Part part, int id, double demand, bool usePri, bool simulate) |
This method replaces the old RequestResource mechanic, and is called by Part.RequestResource. More... | |
bool | SetsEqual (HashSet< Part > set) |
Checks if the set of parts this covers is the same as the passed set More... | |
Static Public Member Functions | |
static void | AddPartToSet (HashSet< Part > set, Part p, Vessel v) |
Recursively add parts to a hashset, obeying crossfeed flow rules. If we are not in the editor, we check that vessels match. More... | |
static void | BuildPartSets (List< Part > parts, Vessel v) |
Build the partsets for the list of parts (editor) or parts on a vessel (if vessel not null). If so, we pass back the list of sets too. More... | |
static void | BuildPartSets (List< Part > parts, Vessel v, bool simulate) |
Build the partsets for the list of parts (editor) or parts on a vessel (if vessel not null) or parts in a ShipConstruct (if ship not null). If so, we pass back the list of sets too. More... | |
static void | BuildPartSets (List< Part > parts, Vessel v, PartBuildSetOptions buildoptions) |
Build the partsets for the list of parts (editor) or parts on a vessel (if vessel not null) or parts in a ShipConstruct (if ship not null). If so, we pass back the list of sets too. More... | |
static HashSet< PartSet > | BuildPartSimulationSets (List< Part > parts) |
Build simulation partsets for the list of parts. More... | |
Public Attributes | |
int | setId |
Static Public Attributes | |
static int | _id = 0 |
Protected Member Functions | |
void | AddPartResource (PartResource r, Dictionary< int, ResourcePrioritySet > dict) |
This will add a new partresource to the given (push/pull) dictionary. More... | |
ResourcePrioritySet | BuildResList (int id, bool pull) |
This will build the res list for a given resource id and pull/push It will iterate over all parts in the set and see if they have the resource of the given ID and whether it can flow in the given direction. If so it's added, with its priority, to the set. More... | |
ResourcePrioritySet | BuildResList (int id, bool pull, bool simulate) |
This will build the res list for a given resource id and pull/push It will iterate over all parts in the set and see if they have the resource of the given ID and whether it can flow in the given direction. If so it's added, with its priority, to the set. More... | |
ResourcePrioritySet | GetOrCreateList (int id, bool pulling) |
This will get the ResourcePrioritySet for the appropriate resource ID and whether we are pulling or pushing. If it does not yet exist, it is created. More... | |
ResourcePrioritySet | GetOrCreateList (int id, bool pulling, bool simulate) |
This will get the ResourcePrioritySet for the appropriate resource ID and whether we are pulling or pushing. If it does not yet exist, it is created. More... | |
void | OnFlowModeChange (GameEvents.HostedFromToAction< PartResource, PartResource.FlowMode > data) |
void | OnFlowStateChange (GameEvents.HostedFromToAction< PartResource, bool > data) |
double | ProcessRequest (Part part, ResourcePrioritySet resList, double demand, bool usePri, bool pulling) |
This works on the list of resources (in priority order) and handles the demand. More... | |
double | ProcessRequest (Part part, ResourcePrioritySet resList, double demand, bool usePri, bool pulling, bool simulate) |
This works on the list of resources (in priority order) and handles the demand. More... | |
void | RemovePartResource (PartResource r, Dictionary< int, ResourcePrioritySet > dict) |
This will remove a partresource from the given (push/pull) dictionary More... | |
Protected Attributes | |
Dictionary< int, ResourcePrioritySet > | pullList = new Dictionary<int, ResourcePrioritySet>() |
Dictionary< int, ResourcePrioritySet > | pushList = new Dictionary<int, ResourcePrioritySet>() |
ShipConstruct | ship |
if in editor scene in ShipConstruct mode, the current ship More... | |
bool | simulationSet = false |
HashSet< Part > | targetParts |
if in partset mode, the set of parts we care about More... | |
Vessel | vessel |
if in vessel mode, the current vessel More... | |
bool | vesselWide |
determines what mode this PartResourceSet is in More... | |
Static Protected Attributes | |
static Dictionary< HashSet < Part >, PartSet > | setsHolder = new Dictionary<HashSet<Part>, PartSet>() |
Temporary holder for the sets. Used to interact with the flow graph code. More... | |
Properties | |
bool | ListsExist [get] |
static int | NextID [get] |
|
inline |
Construct a crossfeed (non-vesselwide) partset
parts |
|
inline |
Construct a vessel-wide partset
v |
|
inline |
Makes a deep copy of the hash set but DOES NOT copy the caches
set |
|
inline |
Construct a vessel-wide partset from ShipConstruct
shipRef |
|
inline |
Construct a partset from ShipConstruct - sets the target parts list in the PartSet to the passed in HashSet.
shipRef | The ShipConstruct reference |
newParts | HashSet of parts to set to the target parts list in the PartSet - if Null target parts list is determined from the ShipRef |
|
inlineprotected |
This will add a new partresource to the given (push/pull) dictionary.
r | |
dict |
Recursively add parts to a hashset, obeying crossfeed flow rules. If we are not in the editor, we check that vessels match.
set | |
p | |
v |
< check fuel lines
< check surface attachments (i.e. our children)
Build the partsets for the list of parts (editor) or parts on a vessel (if vessel not null). If so, we pass back the list of sets too.
parts | |
v |
Build the partsets for the list of parts (editor) or parts on a vessel (if vessel not null) or parts in a ShipConstruct (if ship not null). If so, we pass back the list of sets too.
parts | The list of parts |
v | The vessel reference or null |
simulate | true to use the simulation resource set. Otherwise false to use the real resource set. |
|
inlinestatic |
Build the partsets for the list of parts (editor) or parts on a vessel (if vessel not null) or parts in a ShipConstruct (if ship not null). If so, we pass back the list of sets too.
parts | The list of parts |
v | The vessel reference or null |
buildoptions | whether to build the simulation resource set, real resourec set or both |
Build simulation partsets for the list of parts.
parts | The list of parts |
|
inlineprotected |
This will build the res list for a given resource id and pull/push It will iterate over all parts in the set and see if they have the resource of the given ID and whether it can flow in the given direction. If so it's added, with its priority, to the set.
id | The resource id |
pull | are we pulling or pushing? |
|
inlineprotected |
This will build the res list for a given resource id and pull/push It will iterate over all parts in the set and see if they have the resource of the given ID and whether it can flow in the given direction. If so it's added, with its priority, to the set.
id | The resource id |
pull | are we pulling or pushing? |
simulate | true to use the simulation resource set. Otherwise false to use the real resource set. |
< iterator for the target parts
< a holder for the values
< the list of lists to return
< go through all parts, finding relevant resources
< asc order
|
inline |
Checks if the part is handled by the partset
p |
|
inlinevirtual |
Gets the amount and maxamount of the given resource in the partset
id | |
amount | |
maxAmount | |
pulling |
|
inlinevirtual |
Gets the amount and maxamount of the given resource in the partset
id | The resource id |
amount | will be populated with the amount available |
maxAmount | will be populated with the maxamount available |
pulling | true if pulling resource or false if pushing |
simulate | true to use the simulation resource set. Otherwise false to use the real resource set. |
|
inlinevirtual |
Gets the amount and maxamount of the given resource in the partset, obeying threshold
id | |
amount | |
maxAmount | |
threshold | |
pulling | true if pulling resource or false if pushing |
|
inlinevirtual |
Gets the amount and maxamount of the given resource in the partset, obeying threshold
id | The resource id |
amount | will be populated with the amount available |
maxAmount | will be populated with the maxamount available |
threshold | The threshold amount to obey |
pulling | true if pulling resource or false if pushing |
simulate | true to use the simulation resource set. Otherwise false to use the real resource set. |
|
inlineprotected |
This will get the ResourcePrioritySet for the appropriate resource ID and whether we are pulling or pushing. If it does not yet exist, it is created.
id | The resource id |
pulling | true if pulling resource or false if pushing |
|
inlineprotected |
This will get the ResourcePrioritySet for the appropriate resource ID and whether we are pulling or pushing. If it does not yet exist, it is created.
id | The resource id |
pulling | true if pulling resource or false if pushing |
simulate | true to use the simulation resource set. Otherwise false to use the real resource set. |
|
inline |
Returns the set of parts or a new set if the set is null. NOTE DO NOT CHANGE THIS. For getting only. If you want to change it, use RebuildParts()
|
inline |
Get the Resource List
id | The resource id |
pulling | true if pulling resource or false if pushing |
simulate | true if simulation otherwise false to use the real resource list. |
|
inline |
|
inlineprotected |
|
inlineprotected |
|
inlineprotected |
This works on the list of resources (in priority order) and handles the demand.
part | Source part |
resList | the set to work on for that ID and mode |
demand | the amount demanded |
usePri | do we draw equally or use priority? |
pulling | are we pulling or pushing? |
|
inlineprotected |
This works on the list of resources (in priority order) and handles the demand.
part | Source part |
resList | the set to work on for that ID and mode |
demand | the amount demanded |
usePri | do we draw equally or use priority? |
pulling | are we pulling or pushing? |
simulate | true to use the simulation resource set. Otherwise false to use the real resource set. |
< in this case we go through each priority list individually in order
< cache the pre-request demand to know if we drained successfully
< first get the sum of the amount we can request.
< check if that sum is more than we're requesting or not
< we are checking each iteration, so don't bother to check afterwards
< check if that sum is more than we're requesting or not
< shared across all partresources
< we don't need to check if we met the demand because we already went through all parts anyway.
|
inlinevirtual |
Clears cache without recreating the targetparts
|
inlinevirtual |
Rebuild the partset as a crossfeed set Note: Does not clear targetPats, merely replaces it
newParts |
|
inlinevirtual |
Recreate the partset as a vessel-wide set
newVessel |
|
inlinevirtual |
Recreate the partset as a vessel-wide set
newShip | The ShipConstruct reference |
|
inlinevirtual |
Recreate the partset - sets the target parts list in the PartSet to the passed in HashSet.
newShip | The ShipConstruct reference |
newParts | HashSet of parts to set to the target parts list in the PartSet - if Null target parts list is determined from the ShipRef |
|
inlinevirtual |
|
inlineprotected |
This will remove a partresource from the given (push/pull) dictionary
r | |
dict |
|
inlinevirtual |
This method replaces the old RequestResource mechanic, and is called by Part.RequestResource.
part | the requesting part |
id | the resource hash |
demand | the demand |
usePri | do we draw across all tracked parts or do we draw by priority set? |
|
inlinevirtual |
This method replaces the old RequestResource mechanic, and is called by Part.RequestResource.
part | the requesting part |
id | the resource hash |
demand | the demand |
usePri | do we draw across all tracked parts or do we draw by priority set? |
simulate | true to use the simulation resource set. Otherwise false to use the real resource set. |
|
inline |
Checks if the set of parts this covers is the same as the passed set
set |
< they aren't the same type of set!
< faster than SetsEqual, and no GC
|
static |
|
protected |
|
protected |
int PartSet.setId |
|
staticprotected |
Temporary holder for the sets. Used to interact with the flow graph code.
|
protected |
if in editor scene in ShipConstruct mode, the current ship
|
protected |
|
protected |
if in partset mode, the set of parts we care about
|
protected |
if in vessel mode, the current vessel
|
protected |
determines what mode this PartResourceSet is in
|
get |
|
staticget |