Reactive 3.0 (#5443)

* probably scrapping this

* reimpl old behavior

* misc fixes and initial yaml

* works basically first try
This commit is contained in:
mirrorcult
2021-11-22 02:17:35 -07:00
committed by GitHub
parent 8b47d0f43f
commit e40c9bc427
17 changed files with 152 additions and 71 deletions

View File

@@ -23,15 +23,6 @@ namespace Content.Shared.Chemistry.Reagent
[DataDefinition]
public class ReagentPrototype : IPrototype, IInheritingPrototype
{
[DataField("metabolisms", serverOnly: true, customTypeSerializer: typeof(PrototypeIdDictionarySerializer<ReagentEffectsEntry, MetabolismGroupPrototype>))]
public Dictionary<string, ReagentEffectsEntry>? Metabolisms = null;
[DataField("tileReactions", serverOnly: true)]
private readonly List<ITileReaction> _tileReactions = new(0);
[DataField("plantMetabolism", serverOnly: true)]
private readonly List<ReagentEffect> _plantMetabolism = new(0);
[ViewVariables]
[DataField("id", required: true)]
public string ID { get; } = default!;
@@ -64,9 +55,17 @@ namespace Content.Shared.Chemistry.Reagent
[DataField("spritePath")]
public string SpriteReplacementPath { get; } = string.Empty;
//List of metabolism effects this reagent has, should really only be used server-side.
public IReadOnlyList<ITileReaction> TileReactions => _tileReactions;
public IReadOnlyList<ReagentEffect> PlantMetabolism => _plantMetabolism;
[DataField("metabolisms", serverOnly: true, customTypeSerializer: typeof(PrototypeIdDictionarySerializer<ReagentEffectsEntry, MetabolismGroupPrototype>))]
public Dictionary<string, ReagentEffectsEntry>? Metabolisms = null;
[DataField("reactiveEffects", serverOnly: true, customTypeSerializer:typeof(PrototypeIdDictionarySerializer<ReactiveReagentEffectEntry, ReactiveGroupPrototype>))]
public Dictionary<string, ReactiveReagentEffectEntry>? ReactiveEffects = null;
[DataField("tileReactions", serverOnly: true)]
public readonly List<ITileReaction> TileReactions = new(0);
[DataField("plantMetabolism", serverOnly: true)]
public readonly List<ReagentEffect> PlantMetabolisms = new(0);
/// <summary>
/// If the substance color is too dark we user a lighter version to make the text color readable when the user examines a solution.
@@ -93,7 +92,7 @@ namespace Content.Shared.Chemistry.Reagent
if (tile.Tile.IsEmpty)
return removed;
foreach (var reaction in _tileReactions)
foreach (var reaction in TileReactions)
{
removed += reaction.TileReact(tile, this, reactVolume - removed);
@@ -115,7 +114,7 @@ namespace Content.Shared.Chemistry.Reagent
var entMan = IoCManager.Resolve<IEntityManager>();
var random = IoCManager.Resolve<IRobustRandom>();
var args = new ReagentEffectArgs(plantHolder.Value, null, solution, this, amount.Quantity, entMan, null);
foreach (var plantMetabolizable in _plantMetabolism)
foreach (var plantMetabolizable in PlantMetabolisms)
{
if (!plantMetabolizable.ShouldApply(args, random))
continue;
@@ -140,4 +139,14 @@ namespace Content.Shared.Chemistry.Reagent
[DataField("effects", required: true)]
public ReagentEffect[] Effects = default!;
}
[DataDefinition]
public class ReactiveReagentEffectEntry
{
[DataField("methods", required: true)]
public HashSet<ReactionMethod> Methods = default!;
[DataField("effects", required: true)]
public ReagentEffect[] Effects = default!;
}
}