Bug fixes for metabolisable reagents (#4385)
* HealthChangeMetabolism now scales with ticktime and metabolism rate
Both Food and Drink metabolisms scale with ticktime, Now HealthChangeMetabolism also does so.
Additionally, 'healthChange' now correctly scales with the metabolism rate, so it's description is now correct.
* LiverBehaviour now uses correct frameTime
Previously, the liver only metabolised reagants once every second, but incorrectly passes the current frameTime to the metabilism function, not 1 second.
* Stomach now only transfers non-empty solutions.
Makes debugging bloodstream bugs easier if the stomach is not constantly adding empty solution to it.
* Fixed StomachBehaviour using wrong SolutionContainerComponent
Stomach was using the first SolutionContainerComponent in the owner of the body, instead of the container in the owner of the mechanism (stomach). As a result, it used to use the BloodStreamComponent.Solution as a "Stomach".
* Update StomachBehavior.cs
Somach now checks if it still contains a reagant, before transferring it.
* Added argument to IMetabolizable.Metabolize()
Added availableReagent argument to IMetabolizable.Metabolize(), This ensures that this function does not over-metabolize a reagant, which can happen if tickTime*metabolismRate is larger than the available reagant
* Revert "Stomach now only transfers non-empty solutions."
This reverts commit 2a51e2d87e6e17ab76b48e5316ce501ec05ac061.
* Renamed _updateInterval to _updateIntervalSeconds
Also modified doc comment specifying units
* Fix spelling of healthChangeAmount
Changed from healthChangeAmmount to healthChangeAmount
* Fixed comment
comment used to mention _updateInterval, which has been renamed _updateIntervalSeconds
* Fixed typo in comment
* fixed typos: reagant -> reagent
Most typos were just in comments.
* Make metabolizable classes inherit from DefaultMetabolizable
Also involved changing around IMetabolizable
* Renamed variables
metabolismAmount -> amountMetabolized
* Updated Comments in DefaultMetabolizable
Makes it clearer why DefaultMetabolizable works as it does, and that other classes depend on it.
2021-07-31 14:11:02 +10:00
|
|
|
using Content.Shared.Chemistry.Reagent;
|
2021-02-11 01:13:03 -08:00
|
|
|
using Robust.Shared.GameObjects;
|
2019-11-21 17:24:19 -05:00
|
|
|
|
2021-06-09 22:19:39 +02:00
|
|
|
namespace Content.Shared.Chemistry.Metabolizable
|
2019-11-21 17:24:19 -05:00
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Metabolism behavior for a reagent.
|
|
|
|
|
/// </summary>
|
2021-03-05 01:08:38 +01:00
|
|
|
public interface IMetabolizable
|
2019-11-21 17:24:19 -05:00
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Metabolize the attached reagent. Return the amount of reagent to be removed from the solution.
|
|
|
|
|
/// You shouldn't remove the reagent yourself to avoid invalidating the iterator of the metabolism
|
|
|
|
|
/// organ that is processing it's reagents.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="solutionEntity">The entity containing the solution.</param>
|
|
|
|
|
/// <param name="reagentId">The reagent id</param>
|
|
|
|
|
/// <param name="tickTime">The time since the last metabolism tick in seconds.</param>
|
Bug fixes for metabolisable reagents (#4385)
* HealthChangeMetabolism now scales with ticktime and metabolism rate
Both Food and Drink metabolisms scale with ticktime, Now HealthChangeMetabolism also does so.
Additionally, 'healthChange' now correctly scales with the metabolism rate, so it's description is now correct.
* LiverBehaviour now uses correct frameTime
Previously, the liver only metabolised reagants once every second, but incorrectly passes the current frameTime to the metabilism function, not 1 second.
* Stomach now only transfers non-empty solutions.
Makes debugging bloodstream bugs easier if the stomach is not constantly adding empty solution to it.
* Fixed StomachBehaviour using wrong SolutionContainerComponent
Stomach was using the first SolutionContainerComponent in the owner of the body, instead of the container in the owner of the mechanism (stomach). As a result, it used to use the BloodStreamComponent.Solution as a "Stomach".
* Update StomachBehavior.cs
Somach now checks if it still contains a reagant, before transferring it.
* Added argument to IMetabolizable.Metabolize()
Added availableReagent argument to IMetabolizable.Metabolize(), This ensures that this function does not over-metabolize a reagant, which can happen if tickTime*metabolismRate is larger than the available reagant
* Revert "Stomach now only transfers non-empty solutions."
This reverts commit 2a51e2d87e6e17ab76b48e5316ce501ec05ac061.
* Renamed _updateInterval to _updateIntervalSeconds
Also modified doc comment specifying units
* Fix spelling of healthChangeAmount
Changed from healthChangeAmmount to healthChangeAmount
* Fixed comment
comment used to mention _updateInterval, which has been renamed _updateIntervalSeconds
* Fixed typo in comment
* fixed typos: reagant -> reagent
Most typos were just in comments.
* Make metabolizable classes inherit from DefaultMetabolizable
Also involved changing around IMetabolizable
* Renamed variables
metabolismAmount -> amountMetabolized
* Updated Comments in DefaultMetabolizable
Makes it clearer why DefaultMetabolizable works as it does, and that other classes depend on it.
2021-07-31 14:11:02 +10:00
|
|
|
/// <param name="availableReagent">Reagent available to be metabolized.</param>
|
2019-11-21 17:24:19 -05:00
|
|
|
/// <returns>The amount of reagent to be removed. The metabolizing organ should handle removing the reagent.</returns>
|
Bug fixes for metabolisable reagents (#4385)
* HealthChangeMetabolism now scales with ticktime and metabolism rate
Both Food and Drink metabolisms scale with ticktime, Now HealthChangeMetabolism also does so.
Additionally, 'healthChange' now correctly scales with the metabolism rate, so it's description is now correct.
* LiverBehaviour now uses correct frameTime
Previously, the liver only metabolised reagants once every second, but incorrectly passes the current frameTime to the metabilism function, not 1 second.
* Stomach now only transfers non-empty solutions.
Makes debugging bloodstream bugs easier if the stomach is not constantly adding empty solution to it.
* Fixed StomachBehaviour using wrong SolutionContainerComponent
Stomach was using the first SolutionContainerComponent in the owner of the body, instead of the container in the owner of the mechanism (stomach). As a result, it used to use the BloodStreamComponent.Solution as a "Stomach".
* Update StomachBehavior.cs
Somach now checks if it still contains a reagant, before transferring it.
* Added argument to IMetabolizable.Metabolize()
Added availableReagent argument to IMetabolizable.Metabolize(), This ensures that this function does not over-metabolize a reagant, which can happen if tickTime*metabolismRate is larger than the available reagant
* Revert "Stomach now only transfers non-empty solutions."
This reverts commit 2a51e2d87e6e17ab76b48e5316ce501ec05ac061.
* Renamed _updateInterval to _updateIntervalSeconds
Also modified doc comment specifying units
* Fix spelling of healthChangeAmount
Changed from healthChangeAmmount to healthChangeAmount
* Fixed comment
comment used to mention _updateInterval, which has been renamed _updateIntervalSeconds
* Fixed typo in comment
* fixed typos: reagant -> reagent
Most typos were just in comments.
* Make metabolizable classes inherit from DefaultMetabolizable
Also involved changing around IMetabolizable
* Renamed variables
metabolismAmount -> amountMetabolized
* Updated Comments in DefaultMetabolizable
Makes it clearer why DefaultMetabolizable works as it does, and that other classes depend on it.
2021-07-31 14:11:02 +10:00
|
|
|
ReagentUnit Metabolize(IEntity solutionEntity, string reagentId, float tickTime, ReagentUnit availableReagent);
|
2019-11-21 17:24:19 -05:00
|
|
|
}
|
|
|
|
|
}
|