Merge branch 'master' into replace-sounds-with-sound-specifier

# Conflicts:
#	Content.Server/Hands/Components/HandsComponent.cs
#	Content.Server/Light/Components/ExpendableLightComponent.cs
#	Content.Shared/Light/Component/SharedExpendableLightComponent.cs
This commit is contained in:
Galactic Chimp
2021-07-31 13:16:03 +02:00
105 changed files with 1483 additions and 1319 deletions

View File

@@ -1,11 +1,13 @@
using Content.Shared.Chemistry.Reagent;
using Content.Shared.Chemistry.Reagent;
using Robust.Shared.GameObjects;
using Robust.Shared.Serialization.Manager.Attributes;
namespace Content.Shared.Chemistry.Metabolizable
{
/// <summary>
/// Default metabolism for reagents. Metabolizes the reagent with no effects
/// Default metabolization for reagents. Returns the amount of reagents metabolized without applying effects.
/// Metabolizes reagents at a constant rate, limited by how much is available. Other classes are derived from
/// this class, so that they do not need their own metabolization quantity calculation.
/// </summary>
[DataDefinition]
public class DefaultMetabolizable : IMetabolizable
@@ -13,12 +15,22 @@ namespace Content.Shared.Chemistry.Metabolizable
/// <summary>
/// Rate of metabolism in units / second
/// </summary>
[DataField("rate")]
public double MetabolismRate { get; set; } = 1;
[DataField("rate")] public ReagentUnit MetabolismRate { get; set; } = ReagentUnit.New(1);
ReagentUnit IMetabolizable.Metabolize(IEntity solutionEntity, string reagentId, float tickTime)
public virtual ReagentUnit Metabolize(IEntity solutionEntity, string reagentId, float tickTime, ReagentUnit availableReagent)
{
return ReagentUnit.New(MetabolismRate * tickTime);
// How much reagent should we metabolize
// The default behaviour is to metabolize at a constant rate, independent of the quantity of reagents.
var amountMetabolized = MetabolismRate * tickTime;
// is that much reagent actually available?
if (availableReagent < amountMetabolized)
{
return availableReagent;
}
return amountMetabolized;
}
}
}

View File

@@ -1,4 +1,4 @@
using Content.Shared.Chemistry.Reagent;
using Content.Shared.Chemistry.Reagent;
using Robust.Shared.GameObjects;
namespace Content.Shared.Chemistry.Metabolizable
@@ -16,7 +16,8 @@ namespace Content.Shared.Chemistry.Metabolizable
/// <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>
/// <param name="availableReagent">Reagent available to be metabolized.</param>
/// <returns>The amount of reagent to be removed. The metabolizing organ should handle removing the reagent.</returns>
ReagentUnit Metabolize(IEntity solutionEntity, string reagentId, float tickTime);
ReagentUnit Metabolize(IEntity solutionEntity, string reagentId, float tickTime, ReagentUnit availableReagent);
}
}

View File

@@ -12,7 +12,7 @@ namespace Content.Shared.Chemistry.Reagent
Ingestion,
}
[DataDefinition]
[ImplicitDataDefinitionForInheritors]
public abstract class ReagentEntityReaction
{
[ViewVariables]