Revert 'Revert 'Solution Entities'' (#23168)

This commit is contained in:
TemporalOroboros
2023-12-29 04:47:43 -08:00
committed by GitHub
parent 93e1af2f8d
commit d23c8d5c19
180 changed files with 3541 additions and 2956 deletions

View File

@@ -1,4 +1,4 @@
using Content.Shared.Chemistry.EntitySystems;
using Content.Server.Chemistry.Containers.EntitySystems;
using Content.Shared.Chemistry.Reagent;
using JetBrains.Annotations;
using Robust.Shared.Prototypes;
@@ -17,12 +17,11 @@ namespace Content.Server.Chemistry.ReagentEffects
return;
// TODO see if this is correct
if (!EntitySystem.Get<SolutionContainerSystem>()
.TryGetSolution(args.SolutionEntity, _solution, out var solutionContainer))
var solutionContainerSystem = args.EntityManager.System<SolutionContainerSystem>();
if (!solutionContainerSystem.TryGetSolution(args.SolutionEntity, _solution, out var solutionContainer))
return;
if (EntitySystem.Get<SolutionContainerSystem>()
.TryAddReagent(args.SolutionEntity, solutionContainer, args.Reagent.ID, args.Quantity, out var accepted))
if (solutionContainerSystem.TryAddReagent(solutionContainer.Value, args.Reagent.ID, args.Quantity, out var accepted))
args.Source?.RemoveReagent(args.Reagent.ID, accepted);
}

View File

@@ -10,13 +10,13 @@ public sealed partial class AdjustAlert : ReagentEffect
[DataField("alertType", required: true)]
public AlertType Type;
[DataField("clear")]
[DataField]
public bool Clear;
[DataField("cooldown")]
[DataField]
public bool Cooldown;
[DataField("time")]
[DataField]
public float Time;
//JUSTIFICATION: This just changes some visuals, doesn't need to be documented.

View File

@@ -1,5 +1,4 @@
using Content.Shared.Body.Prototypes;
using Content.Shared.Chemistry.EntitySystems;
using Content.Shared.Chemistry.Reagent;
using Content.Shared.FixedPoint;
using JetBrains.Annotations;
@@ -14,7 +13,7 @@ namespace Content.Server.Chemistry.ReagentEffects
/// <summary>
/// The reagent ID to remove. Only one of this and <see cref="Group"/> should be active.
/// </summary>
[DataField("reagent", customTypeSerializer:typeof(PrototypeIdSerializer<ReagentPrototype>))]
[DataField(customTypeSerializer: typeof(PrototypeIdSerializer<ReagentPrototype>))]
public string? Reagent = null;
// TODO use ReagentId
@@ -22,41 +21,39 @@ namespace Content.Server.Chemistry.ReagentEffects
/// The metabolism group to remove, if the reagent satisfies any.
/// Only one of this and <see cref="Reagent"/> should be active.
/// </summary>
[DataField("group", customTypeSerializer:typeof(PrototypeIdSerializer<MetabolismGroupPrototype>))]
[DataField(customTypeSerializer: typeof(PrototypeIdSerializer<MetabolismGroupPrototype>))]
public string? Group = null;
[DataField("amount", required: true)]
[DataField(required: true)]
public FixedPoint2 Amount = default!;
public override void Effect(ReagentEffectArgs args)
{
if (args.Source != null)
if (args.Source == null)
return;
var amount = Amount;
amount *= args.Scale;
if (Reagent != null)
{
var solutionSys = args.EntityManager.EntitySysManager.GetEntitySystem<SolutionContainerSystem>();
var amount = Amount;
amount *= args.Scale;
if (Reagent != null)
if (amount < 0 && args.Source.ContainsPrototype(Reagent))
args.Source.RemoveReagent(Reagent, -amount);
if (amount > 0)
args.Source.AddReagent(Reagent, amount);
}
else if (Group != null)
{
var prototypeMan = IoCManager.Resolve<IPrototypeManager>();
foreach (var quant in args.Source.Contents.ToArray())
{
if (amount < 0 && args.Source.ContainsPrototype(Reagent))
solutionSys.RemoveReagent(args.SolutionEntity, args.Source, Reagent, -amount);
if (amount > 0)
solutionSys.TryAddReagent(args.SolutionEntity, args.Source, Reagent, amount, out _);
}
else if (Group != null)
{
var prototypeMan = IoCManager.Resolve<IPrototypeManager>();
foreach (var quant in args.Source.Contents.ToArray())
var proto = prototypeMan.Index<ReagentPrototype>(quant.Reagent.Prototype);
if (proto.Metabolisms != null && proto.Metabolisms.ContainsKey(Group))
{
var proto = prototypeMan.Index<ReagentPrototype>(quant.Reagent.Prototype);
if (proto.Metabolisms != null && proto.Metabolisms.ContainsKey(Group))
{
if (amount < 0)
solutionSys.RemoveReagent(args.SolutionEntity, args.Source, quant.Reagent, amount);
if (amount > 0)
solutionSys.TryAddReagent(args.SolutionEntity, args.Source, quant.Reagent, amount, out _);
}
if (amount < 0)
args.Source.RemoveReagent(quant.Reagent, amount);
if (amount > 0)
args.Source.AddReagent(quant.Reagent, amount);
}
}
}

View File

@@ -7,7 +7,7 @@ namespace Content.Server.Chemistry.ReagentEffects
{
public sealed partial class AdjustTemperature : ReagentEffect
{
[DataField("amount")]
[DataField]
public float Amount;
protected override string? ReagentEffectGuidebookText(IPrototypeManager prototype, IEntitySystemManager entSys)

View File

@@ -1,9 +1,7 @@
using Content.Shared.Chemistry.Reagent;
using Robust.Shared.Prototypes;
using Robust.Shared.Configuration;
using Content.Server.Zombies;
using Content.Shared.Chemistry.Reagent;
using Robust.Shared.Configuration;
using Robust.Shared.Prototypes;
namespace Content.Server.Chemistry.ReagentEffects;

View File

@@ -1,6 +1,6 @@
using Content.Server.Body.Systems;
using Content.Shared.Chemistry.Reagent;
using JetBrains.Annotations;
using Content.Server.Body.Systems;
using Robust.Shared.Prototypes;
namespace Content.Server.Chemistry.ReactionEffects
@@ -11,7 +11,7 @@ namespace Content.Server.Chemistry.ReactionEffects
[UsedImplicitly]
public sealed partial class ChemCleanBloodstream : ReagentEffect
{
[DataField("cleanseRate")]
[DataField]
public float CleanseRate = 3.0f;
protected override string? ReagentEffectGuidebookText(IPrototypeManager prototype, IEntitySystemManager entSys)

View File

@@ -15,7 +15,7 @@ namespace Content.Server.Chemistry.ReagentEffects
/// <summary>
/// How much eye damage to add.
/// </summary>
[DataField("amount")]
[DataField]
public int Amount = -1;
protected override string? ReagentEffectGuidebookText(IPrototypeManager prototype, IEntitySystemManager entSys)

View File

@@ -1,5 +1,5 @@
using Content.Shared.Chemistry.Reagent;
using Content.Server.Medical;
using Content.Shared.Chemistry.Reagent;
using JetBrains.Annotations;
using Robust.Shared.Prototypes;
@@ -12,10 +12,10 @@ namespace Content.Server.Chemistry.ReagentEffects
public sealed partial class ChemVomit : ReagentEffect
{
/// How many units of thirst to add each time we vomit
[DataField("thirstAmount")]
[DataField]
public float ThirstAmount = -8f;
/// How many units of hunger to add each time we vomit
[DataField("hungerAmount")]
[DataField]
public float HungerAmount = -8f;
protected override string? ReagentEffectGuidebookText(IPrototypeManager prototype, IEntitySystemManager entSys)

View File

@@ -8,13 +8,13 @@ namespace Content.Server.Chemistry.ReagentEffects;
public sealed partial class CreateGas : ReagentEffect
{
[DataField("gas", required: true)]
[DataField(required: true)]
public Gas Gas = default!;
/// <summary>
/// For each unit consumed, how many moles of gas should be created?
/// </summary>
[DataField("multiplier")]
[DataField]
public float Multiplier = 3f;
public override bool ShouldLog => true;

View File

@@ -1,14 +1,13 @@
using Content.Shared.Chemistry.Reagent;
using Robust.Shared.Prototypes;
using Robust.Shared.Configuration;
using Content.Server.Zombies;
using Content.Shared.Chemistry.Reagent;
using Robust.Shared.Configuration;
using Robust.Shared.Prototypes;
namespace Content.Server.Chemistry.ReagentEffects;
public sealed partial class CureZombieInfection : ReagentEffect
{
[DataField("innoculate")]
[DataField]
public bool Innoculate;
protected override string? ReagentEffectGuidebookText(IPrototypeManager prototype, IEntitySystemManager entSys)

View File

@@ -9,13 +9,13 @@ public sealed partial class Drunk : ReagentEffect
/// <summary>
/// BoozePower is how long each metabolism cycle will make the drunk effect last for.
/// </summary>
[DataField("boozePower")]
[DataField]
public float BoozePower = 3f;
/// <summary>
/// Whether speech should be slurred.
/// </summary>
[DataField("slurSpeech")]
[DataField]
public bool SlurSpeech = true;
protected override string? ReagentEffectGuidebookText(IPrototypeManager prototype, IEntitySystemManager entSys)

View File

@@ -6,14 +6,14 @@ namespace Content.Server.Chemistry.ReagentEffects;
public sealed partial class Electrocute : ReagentEffect
{
[DataField("electrocuteTime")] public int ElectrocuteTime = 2;
[DataField] public int ElectrocuteTime = 2;
[DataField("electrocuteDamageScale")] public int ElectrocuteDamageScale = 5;
[DataField] public int ElectrocuteDamageScale = 5;
/// <remarks>
/// true - refresh electrocute time, false - accumulate electrocute time
/// </remarks>
[DataField("refresh")] public bool Refresh = true;
[DataField] public bool Refresh = true;
protected override string? ReagentEffectGuidebookText(IPrototypeManager prototype, IEntitySystemManager entSys)
=> Loc.GetString("reagent-effect-guidebook-electrocute", ("chance", Probability), ("time", ElectrocuteTime));

View File

@@ -16,7 +16,7 @@ public sealed partial class Emote : ReagentEffect
[DataField("emote", customTypeSerializer: typeof(PrototypeIdSerializer<EmotePrototype>))]
public string? EmoteId;
[DataField("showInChat")]
[DataField]
public bool ShowInChat;
// JUSTIFICATION: Emoting is flavor, so same reason popup messages are not in here.

View File

@@ -10,7 +10,7 @@ namespace Content.Server.Chemistry.ReagentEffects
[UsedImplicitly]
public sealed partial class FlammableReaction : ReagentEffect
{
[DataField("multiplier")]
[DataField]
public float Multiplier = 0.05f;
public override bool ShouldLog => true;

View File

@@ -1,5 +1,3 @@
using System.Linq;
using System.Text.Json.Serialization;
using Content.Shared.Chemistry.Reagent;
using Content.Shared.Damage;
using Content.Shared.Damage.Prototypes;
@@ -7,6 +5,8 @@ using Content.Shared.FixedPoint;
using Content.Shared.Localizations;
using JetBrains.Annotations;
using Robust.Shared.Prototypes;
using System.Linq;
using System.Text.Json.Serialization;
namespace Content.Server.Chemistry.ReagentEffects
{
@@ -19,19 +19,19 @@ namespace Content.Server.Chemistry.ReagentEffects
/// <summary>
/// Damage to apply every metabolism cycle. Damage Ignores resistances.
/// </summary>
[DataField(required: true)]
[JsonPropertyName("damage")]
[DataField("damage", required: true)]
public DamageSpecifier Damage = default!;
/// <summary>
/// Should this effect scale the damage by the amount of chemical in the solution?
/// Useful for touch reactions, like styptic powder or acid.
/// </summary>
[DataField]
[JsonPropertyName("scaleByQuantity")]
[DataField("scaleByQuantity")]
public bool ScaleByQuantity;
[DataField("ignoreResistances")]
[DataField]
[JsonPropertyName("ignoreResistances")]
public bool IgnoreResistances = true;

View File

@@ -7,10 +7,10 @@ namespace Content.Server.Chemistry.ReagentEffects;
public sealed partial class ModifyBleedAmount : ReagentEffect
{
[DataField("scaled")]
[DataField]
public bool Scaled = false;
[DataField("amount")]
[DataField]
public float Amount = -1.0f;
protected override string? ReagentEffectGuidebookText(IPrototypeManager prototype, IEntitySystemManager entSys)

View File

@@ -8,10 +8,10 @@ namespace Content.Server.Chemistry.ReagentEffects;
public sealed partial class ModifyBloodLevel : ReagentEffect
{
[DataField("scaled")]
[DataField]
public bool Scaled = false;
[DataField("amount")]
[DataField]
public FixedPoint2 Amount = 1.0f;
protected override string? ReagentEffectGuidebookText(IPrototypeManager prototype, IEntitySystemManager entSys)

View File

@@ -15,19 +15,19 @@ namespace Content.Server.Chemistry.ReagentEffects
/// <summary>
/// How much the entities' walk speed is multiplied by.
/// </summary>
[DataField("walkSpeedModifier")]
[DataField]
public float WalkSpeedModifier { get; set; } = 1;
/// <summary>
/// How much the entities' run speed is multiplied by.
/// </summary>
[DataField("sprintSpeedModifier")]
[DataField]
public float SprintSpeedModifier { get; set; } = 1;
/// <summary>
/// How long the modifier applies (in seconds) when metabolized.
/// </summary>
[DataField("statusLifetime")]
[DataField]
public float StatusLifetime = 2f;
protected override string? ReagentEffectGuidebookText(IPrototypeManager prototype, IEntitySystemManager entSys)

View File

@@ -7,7 +7,7 @@ namespace Content.Server.Chemistry.ReagentEffects;
public sealed partial class Oxygenate : ReagentEffect
{
[DataField("factor")]
[DataField]
public float Factor = 1f;
// JUSTIFICATION: This is internal magic that players never directly interact with.

View File

@@ -1,17 +1,17 @@
using Content.Shared.Chemistry.Reagent;
using Content.Server.Stunnable;
using Content.Shared.Chemistry.Reagent;
using Robust.Shared.Prototypes;
namespace Content.Server.Chemistry.ReagentEffects;
public sealed partial class Paralyze : ReagentEffect
{
[DataField("paralyzeTime")] public double ParalyzeTime = 2;
[DataField] public double ParalyzeTime = 2;
/// <remarks>
/// true - refresh paralyze time, false - accumulate paralyze time
/// </remarks>
[DataField("refresh")] public bool Refresh = true;
[DataField] public bool Refresh = true;
protected override string? ReagentEffectGuidebookText(IPrototypeManager prototype, IEntitySystemManager entSys)
=> Loc.GetString("reagent-effect-guidebook-paralyze",

View File

@@ -1,16 +1,19 @@
using System.Diagnostics.CodeAnalysis;
using Content.Server.Botany.Components;
using Content.Server.Botany.Components;
using Content.Shared.Chemistry.Reagent;
using Robust.Shared.Prototypes;
using Robust.Shared.Random;
using System.Diagnostics.CodeAnalysis;
namespace Content.Server.Chemistry.ReagentEffects.PlantMetabolism
{
[ImplicitDataDefinitionForInheritors]
public abstract partial class PlantAdjustAttribute : ReagentEffect
{
[DataField("amount")] public float Amount { get; protected set; } = 1;
[DataField("prob")] public float Prob { get; protected set; } = 1; // = (80);
[DataField]
public float Amount { get; protected set; } = 1;
[DataField]
public float Prob { get; protected set; } = 1; // = (80);
/// <summary>
/// Checks if the plant holder can metabolize the reagent or not. Checks if it has an alive plant by default.

View File

@@ -11,13 +11,13 @@ namespace Content.Server.Chemistry.ReagentEffects.PlantMetabolism
[DataDefinition]
public sealed partial class RobustHarvest : ReagentEffect
{
[DataField("potencyLimit")]
[DataField]
public int PotencyLimit = 50;
[DataField("potencyIncrease")]
[DataField]
public int PotencyIncrease = 3;
[DataField("potencySeedlessThreshold")]
[DataField]
public int PotencySeedlessThreshold = 30;
public override void Effect(ReagentEffectArgs args)

View File

@@ -8,13 +8,13 @@ namespace Content.Server.Chemistry.ReagentEffects
{
public sealed partial class PopupMessage : ReagentEffect
{
[DataField("messages", required: true)]
[DataField(required: true)]
public string[] Messages = default!;
[DataField("type")]
[DataField]
public PopupRecipients Type = PopupRecipients.Local;
[DataField("visualType")]
[DataField]
public PopupType VisualType = PopupType.Small;
// JUSTIFICATION: This is purely cosmetic.

View File

@@ -17,25 +17,25 @@ namespace Content.Server.Chemistry.ReagentEffects.StatusEffects
[UsedImplicitly]
public sealed partial class GenericStatusEffect : ReagentEffect
{
[DataField("key", required: true)]
[DataField(required: true)]
public string Key = default!;
[DataField("component")]
[DataField]
public string Component = String.Empty;
[DataField("time")]
[DataField]
public float Time = 2.0f;
/// <remarks>
/// true - refresh status effect time, false - accumulate status effect time
/// </remarks>
[DataField("refresh")]
[DataField]
public bool Refresh = true;
/// <summary>
/// Should this effect add the status effect, remove time from it, or set its cooldown?
/// </summary>
[DataField("type")]
[DataField]
public StatusEffectMetabolismType Type = StatusEffectMetabolismType.Add;
public override void Effect(ReagentEffectArgs args)

View File

@@ -11,19 +11,19 @@ namespace Content.Server.Chemistry.ReagentEffects.StatusEffects
/// </summary>
public sealed partial class Jitter : ReagentEffect
{
[DataField("amplitude")]
[DataField]
public float Amplitude = 10.0f;
[DataField("frequency")]
[DataField]
public float Frequency = 4.0f;
[DataField("time")]
[DataField]
public float Time = 2.0f;
/// <remarks>
/// true - refresh jitter time, false - accumulate jitter time
/// </remarks>
[DataField("refresh")]
[DataField]
public bool Refresh = true;
public override void Effect(ReagentEffectArgs args)