Files
crystall-punk-14/Content.Server/_CP14/Alchemy/EntitySystems/CP14RandomReagentReactionsSystem.cs
c4llv07e df6dbd2ac7 Add reaction randomization. (#308)
* Add random products datafield to the reaciton prototype.

One of the items in the list will be used as additional products as a
result of the reaction and will be persistent per round.

Resolves #245

* Another try

Add getter and setter for the reaction products field and
add random products there.

* There is no such product as CP14BasicEffectHealHeat

* Try to visualize random products in the guidebook

* experimental recipes

* fix

* file restructurization

* Guidebook alchemy update

* Update Alchemy.xml

* fix

* Update mixing_simple.yml

---------

Co-authored-by: Ed <96445749+TheShuEd@users.noreply.github.com>
2024-08-19 18:04:12 +03:00

27 lines
813 B
C#

using Content.Server.GameTicking.Events;
using Content.Shared.Chemistry.Reaction;
using Robust.Shared.Prototypes;
using Robust.Shared.Random;
namespace Content.Server._CP14.Alchemy.EntitySystems;
public sealed class CP14RandomReagentReactionsSystem : EntitySystem
{
[Dependency] private readonly IPrototypeManager _proto = default!;
[Dependency] private readonly IRobustRandom _random = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<RoundStartingEvent>(OnRoundStart);
}
private void OnRoundStart(RoundStartingEvent ev)
{
foreach (var reaction in _proto.EnumeratePrototypes<ReactionPrototype>())
{
reaction.Cp14RandomProductIndex = _random.Next(reaction.Cp14RandomProducts.Count);
}
}
}