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:
@@ -1,4 +1,4 @@
|
||||
using Content.Server.Nutrition.Components;
|
||||
using Content.Server.Nutrition.Components;
|
||||
using Content.Shared.Chemistry;
|
||||
using Content.Shared.Chemistry.Metabolizable;
|
||||
using Content.Shared.Chemistry.Reagent;
|
||||
@@ -9,28 +9,27 @@ namespace Content.Server.Chemistry.Metabolism
|
||||
{
|
||||
/// <summary>
|
||||
/// Default metabolism for drink reagents. Attempts to find a ThirstComponent on the target,
|
||||
/// and to update it's thirst values.
|
||||
/// and to update it's thirst values. Inherits metabolisation rate logic from DefaultMetabolizable.
|
||||
/// </summary>
|
||||
[DataDefinition]
|
||||
public class DefaultDrink : IMetabolizable
|
||||
public class DefaultDrink : DefaultMetabolizable
|
||||
{
|
||||
//Rate of metabolism in units / second
|
||||
[DataField("rate")]
|
||||
public ReagentUnit MetabolismRate { get; set; } = ReagentUnit.New(1);
|
||||
|
||||
//How much thirst is satiated when 1u of the reagent is metabolized
|
||||
[DataField("hydrationFactor")]
|
||||
public float HydrationFactor { get; set; } = 30.0f;
|
||||
|
||||
//Remove reagent at set rate, satiate thirst if a ThirstComponent can be found
|
||||
ReagentUnit IMetabolizable.Metabolize(IEntity solutionEntity, string reagentId, float tickTime)
|
||||
public override ReagentUnit Metabolize(IEntity solutionEntity, string reagentId, float tickTime, ReagentUnit availableReagent)
|
||||
{
|
||||
var metabolismAmount = MetabolismRate * tickTime;
|
||||
// use DefaultMetabolism to determine how much reagent we should metabolize
|
||||
var amountMetabolized = base.Metabolize(solutionEntity, reagentId, tickTime, availableReagent);
|
||||
|
||||
// If metabolizing entity has a ThirstComponent, hydrate them.
|
||||
if (solutionEntity.TryGetComponent(out ThirstComponent? thirst))
|
||||
thirst.UpdateThirst(metabolismAmount.Float() * HydrationFactor);
|
||||
thirst.UpdateThirst(amountMetabolized.Float() * HydrationFactor);
|
||||
|
||||
//Return amount of reagent to be removed, remove reagent regardless of ThirstComponent presence
|
||||
return metabolismAmount;
|
||||
return amountMetabolized;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using Content.Server.Nutrition.Components;
|
||||
using Content.Server.Nutrition.Components;
|
||||
using Content.Shared.Chemistry;
|
||||
using Content.Shared.Chemistry.Metabolizable;
|
||||
using Content.Shared.Chemistry.Reagent;
|
||||
@@ -9,30 +9,30 @@ namespace Content.Server.Chemistry.Metabolism
|
||||
{
|
||||
/// <summary>
|
||||
/// Default metabolism for food reagents. Attempts to find a HungerComponent on the target,
|
||||
/// and to update it's hunger values.
|
||||
/// and to update it's hunger values. Inherits metabolisation rate logic from DefaultMetabolizable.
|
||||
/// </summary>
|
||||
[DataDefinition]
|
||||
public class DefaultFood : IMetabolizable
|
||||
public class DefaultFood : DefaultMetabolizable
|
||||
{
|
||||
/// <summary>
|
||||
/// Rate of metabolism in units / second
|
||||
/// </summary>
|
||||
[DataField("rate")] public ReagentUnit MetabolismRate { get; private set; } = ReagentUnit.New(1.0);
|
||||
|
||||
/// <summary>
|
||||
/// How much hunger is satiated when 1u of the reagent is metabolized
|
||||
/// </summary>
|
||||
[DataField("nutritionFactor")] public float NutritionFactor { get; set; } = 30.0f;
|
||||
|
||||
//Remove reagent at set rate, satiate hunger if a HungerComponent can be found
|
||||
ReagentUnit IMetabolizable.Metabolize(IEntity solutionEntity, string reagentId, float tickTime)
|
||||
{
|
||||
var metabolismAmount = MetabolismRate * tickTime;
|
||||
if (solutionEntity.TryGetComponent(out HungerComponent? hunger))
|
||||
hunger.UpdateFood(metabolismAmount.Float() * NutritionFactor);
|
||||
|
||||
//Return amount of reagent to be removed, remove reagent regardless of HungerComponent presence
|
||||
return metabolismAmount;
|
||||
//Remove reagent at set rate, satiate hunger if a HungerComponent can be found
|
||||
public override ReagentUnit Metabolize(IEntity solutionEntity, string reagentId, float tickTime, ReagentUnit availableReagent)
|
||||
{
|
||||
// use DefaultMetabolism to determine how much reagent we should metabolize
|
||||
var amountMetabolized = base.Metabolize(solutionEntity, reagentId, tickTime, availableReagent);
|
||||
|
||||
// If metabolizing entity has a HungerComponent, feed them.
|
||||
if (solutionEntity.TryGetComponent(out HungerComponent? hunger))
|
||||
hunger.UpdateFood(amountMetabolized.Float() * NutritionFactor);
|
||||
|
||||
//Return amount of reagent to be removed. Reagent is removed regardless of HungerComponent presence
|
||||
return amountMetabolized;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,16 +10,11 @@ namespace Content.Server.Chemistry.Metabolism
|
||||
{
|
||||
/// <summary>
|
||||
/// Default metabolism for medicine reagents. Attempts to find a DamageableComponent on the target,
|
||||
/// and to update its damage values.
|
||||
/// and to update its damage values. Inherits metabolisation rate logic from DefaultMetabolizable.
|
||||
/// </summary>
|
||||
[DataDefinition]
|
||||
public class HealthChangeMetabolism : IMetabolizable
|
||||
public class HealthChangeMetabolism : DefaultMetabolizable
|
||||
{
|
||||
/// <summary>
|
||||
/// How much of the reagent should be metabolized each sec.
|
||||
/// </summary>
|
||||
[DataField("rate")]
|
||||
public ReagentUnit MetabolismRate { get; set; } = ReagentUnit.New(1);
|
||||
|
||||
/// <summary>
|
||||
/// How much damage is changed when 1u of the reagent is metabolized.
|
||||
@@ -41,14 +36,23 @@ namespace Content.Server.Chemistry.Metabolism
|
||||
/// <param name="solutionEntity"></param>
|
||||
/// <param name="reagentId"></param>
|
||||
/// <param name="tickTime"></param>
|
||||
/// <param name="availableReagent">Reagent available to be metabolized.</param>
|
||||
/// <returns></returns>
|
||||
ReagentUnit IMetabolizable.Metabolize(IEntity solutionEntity, string reagentId, float tickTime)
|
||||
public override ReagentUnit Metabolize(IEntity solutionEntity, string reagentId, float tickTime, ReagentUnit availableReagent)
|
||||
{
|
||||
// use DefaultMetabolism to determine how much reagent we should metabolize
|
||||
var amountMetabolized = base.Metabolize(solutionEntity, reagentId, tickTime, availableReagent);
|
||||
|
||||
// how much does this much reagent heal for
|
||||
var healthChangeAmount = HealthChange * amountMetabolized.Float();
|
||||
|
||||
if (solutionEntity.TryGetComponent(out IDamageableComponent? health))
|
||||
{
|
||||
health.ChangeDamage(DamageType, (int)HealthChange, true);
|
||||
float decHealthChange = (float) (HealthChange - (int) HealthChange);
|
||||
_accumulatedHealth += decHealthChange;
|
||||
// Heal damage by healthChangeAmmount, rounding down to nearest integer
|
||||
health.ChangeDamage(DamageType, (int) healthChangeAmount, true);
|
||||
|
||||
// Store decimal remainder of healthChangeAmmount in _accumulatedHealth
|
||||
_accumulatedHealth += (healthChangeAmount - (int) healthChangeAmount);
|
||||
|
||||
if (_accumulatedHealth >= 1)
|
||||
{
|
||||
@@ -62,7 +66,7 @@ namespace Content.Server.Chemistry.Metabolism
|
||||
_accumulatedHealth += 1;
|
||||
}
|
||||
}
|
||||
return MetabolismRate;
|
||||
return amountMetabolized;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,6 @@ using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototy
|
||||
namespace Content.Server.Chemistry.ReagentEntityReactions
|
||||
{
|
||||
[UsedImplicitly]
|
||||
[DataDefinition]
|
||||
public class AddToSolutionReaction : ReagentEntityReaction
|
||||
{
|
||||
[DataField("reagents", true, customTypeSerializer:typeof(PrototypeIdHashSetSerializer<ReagentPrototype>))]
|
||||
|
||||
@@ -10,7 +10,6 @@ using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototy
|
||||
namespace Content.Server.Chemistry.ReagentEntityReactions
|
||||
{
|
||||
[UsedImplicitly]
|
||||
[DataDefinition]
|
||||
public class ExtinguishReaction : ReagentEntityReaction
|
||||
{
|
||||
[DataField("reagents", true, customTypeSerializer:typeof(PrototypeIdHashSetSerializer<ReagentPrototype>))]
|
||||
|
||||
@@ -10,7 +10,6 @@ using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototy
|
||||
namespace Content.Server.Chemistry.ReagentEntityReactions
|
||||
{
|
||||
[UsedImplicitly]
|
||||
[DataDefinition]
|
||||
public class FlammableReaction : ReagentEntityReaction
|
||||
{
|
||||
[DataField("reagents", true, customTypeSerializer:typeof(PrototypeIdHashSetSerializer<ReagentPrototype>))]
|
||||
|
||||
@@ -10,7 +10,6 @@ using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototy
|
||||
namespace Content.Server.Chemistry.ReagentEntityReactions
|
||||
{
|
||||
[UsedImplicitly]
|
||||
[DataDefinition]
|
||||
public class WashCreamPieReaction : ReagentEntityReaction
|
||||
{
|
||||
[DataField("reagents", true, customTypeSerializer:typeof(PrototypeIdHashSetSerializer<ReagentPrototype>))]
|
||||
|
||||
Reference in New Issue
Block a user