Remove random reaction system (#1345)

* wow

* d
This commit is contained in:
Red
2025-06-01 15:01:32 +03:00
committed by GitHub
parent 759e7c73d9
commit a99f2fcd50
11 changed files with 38 additions and 139 deletions

View File

@@ -26,27 +26,6 @@
<!-- Products will be added as children here -->
</BoxContainer>
</BoxContainer>
<!-- CP14 random reactions begin -->
<!--<BoxContainer Name="RandomVariations"
Orientation="Vertical"
VerticalExpand="True"
VerticalAlignment="Center"
HorizontalAlignment="Center">
<controls:SplitBar MinHeight="10">
</controls:SplitBar>
<Label Name="RandomVariationsLabel"
Text="{Loc 'cp14-guidebook-random-variations-title'}"
Visible="False"
HorizontalAlignment="Center"
FontColorOverride="#1e6651" />
<BoxContainer Orientation="Vertical" HorizontalExpand="True" VerticalAlignment="Center">
<BoxContainer Name="RandomProductsContainer" HorizontalAlignment="Center" VerticalAlignment="Center" Orientation="Vertical">
~1~ Random products will be added as children here @1@
</BoxContainer>
</BoxContainer>
</BoxContainer>-->
<!-- CP14 random reactions end -->
</BoxContainer>
<PanelContainer StyleClasses="LowDivider" Margin="0 5 0 5" />
</BoxContainer>

View File

@@ -37,7 +37,7 @@ public sealed partial class GuideReagentReaction : BoxContainer, ISearchableCont
Container container = ReactantsContainer;
SetReagents(prototype.Reactants, ref container, protoMan);
Container productContainer = ProductsContainer;
var products = new Dictionary<string, FixedPoint2>(prototype._products); // CP14 random reactions
var products = new Dictionary<string, FixedPoint2>(prototype.Products);
foreach (var (reagent, reactantProto) in prototype.Reactants)
{
if (reactantProto.Catalyst)
@@ -45,14 +45,6 @@ public sealed partial class GuideReagentReaction : BoxContainer, ISearchableCont
}
SetReagents(products, ref productContainer, protoMan, false);
// CP14 random reagents begin
if (prototype.Cp14RandomProducts.Count > 0)
{
var randomProducts = new Dictionary<string, FixedPoint2>(prototype.Cp14RandomProducts[prototype.Cp14RandomProductIndex]);
SetReagents(randomProducts, ref productContainer, protoMan, false);
}
// CP14 random reagents end
var mixingCategories = new List<MixingCategoryPrototype>();
if (prototype.MixingCategories != null)
{

View File

@@ -1,26 +0,0 @@
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);
}
}
}

View File

@@ -51,42 +51,11 @@ namespace Content.Shared.Chemistry.Reaction
[DataField("requiredMixerCategories")]
public List<ProtoId<MixingCategoryPrototype>>? MixingCategories;
// CP14 random reactions begin
/// <summary>
/// Reagents created when the reaction occurs.
/// </summary>
[DataField("products", customTypeSerializer:typeof(PrototypeIdDictionarySerializer<FixedPoint2, ReagentPrototype>))]
public Dictionary<string, FixedPoint2> _products = new(); // CP14 random reactions
public Dictionary<string, FixedPoint2> Products
{
get {
if (Cp14RandomProducts.Count == 0)
return _products;
// New dict because we don't want to modify original products dict
Dictionary<string, FixedPoint2> res = new(_products);
foreach (var product in Cp14RandomProducts[Cp14RandomProductIndex])
{
if (res.ContainsKey(product.Key))
res[product.Key] += product.Value;
else
res[product.Key] = product.Value;
}
return res;
}
set {
_products = value;
}
}
public int Cp14RandomProductIndex = 0;
/// <summary>
/// Random reagents groups, one of which will be selected at the roundstart and will be used as a reaction product.
/// </summary>
[DataField("cp14RandomProducts")]
public List<Dictionary<string, FixedPoint2>> Cp14RandomProducts = new();
// CP14 random reactions end
public Dictionary<string, FixedPoint2> Products = new();
/// <summary>
/// Effects to be triggered when the reaction occurs.

View File

@@ -10,9 +10,7 @@
amount: 1
products:
CP14EssencePoison: 0.5
cp14RandomProducts:
- CP14EssenceWater: 0.5
- CP14EssenceEarth: 0.5
CP14EssenceEarth: 0.5
# Admixture: By adding raw precursor to a potion with target solutions, we can reduce the amount of empty solution by modifying the target solutions.

View File

@@ -10,9 +10,7 @@
amount: 1
products:
CP14EssenceAir: 0.5
cp14RandomProducts:
- CP14EssenceWater: 0.5
- CP14EssenceLife: 0.5
CP14EssenceWater: 0.5
# Admixture: By adding raw precursor to a potion with target solutions, we can reduce the amount of empty solution by modifying the target solutions.

View File

@@ -10,9 +10,7 @@
amount: 1
products:
CP14EssenceMagic: 0.5
cp14RandomProducts:
- CP14EssenceWater: 0.5
- CP14EssenceLife: 0.5
CP14EssenceWater: 0.5
# Admixture: By adding raw precursor to a potion with target solutions, we can reduce the amount of empty solution by modifying the target solutions.

View File

@@ -10,9 +10,7 @@
amount: 1
products:
CP14EssenceFire: 0.5
cp14RandomProducts:
- CP14EssenceLife: 0.5
- CP14EssenceMotion: 0.5
CP14EssenceMotion: 0.5
# Admixture: By adding raw precursor to a potion with target solutions, we can reduce the amount of empty solution by modifying the target solutions.

View File

@@ -10,9 +10,7 @@
amount: 1
products:
CP14EssenceCrystal: 0.5
cp14RandomProducts:
- CP14EssenceOrder: 0.5
- CP14EssenceChaos: 0.5
CP14EssenceOrder: 0.5
# Admixture: By adding raw precursor to a potion with target solutions, we can reduce the amount of empty solution by modifying the target solutions.

View File

@@ -10,41 +10,38 @@
amount: 1
products:
CP14EssenceLight: 0.5
cp14RandomProducts:
- CP14EssenceWater: 0.5
- CP14EssenceEarth: 0.5
CP14EssenceEarth: 0.5
# Admixture: By adding raw precursor to a potion with target solutions, we can reduce the amount of empty solution by modifying the target solutions.
# Idea: Full randomness
- type: reaction
id: CP14LumiMushroomAdmixture
minTemp: 500
reactants:
CP14LumiMushroom:
amount: 1
CP14BasicEffectEmpty:
amount: 1
cp14RandomProducts:
- CP14BasicEffectHealBrute: 2
- CP14BasicEffectDamageBrute: 2
- CP14BasicEffectHealHeat: 2
- CP14BasicEffectDamageHeat: 2
- CP14BasicEffectHealCold: 2
- CP14BasicEffectDamageCold: 2
- CP14BasicEffectHealPoison: 2
- CP14BasicEffectDamagePoison: 2
- CP14BasicEffectHealAirloss: 2
- CP14BasicEffectDamageAirloss: 2
- CP14BasicEffectBloodRestore: 2
- CP14BasicEffectBloodAbsorption: 2
- CP14BasicEffectSatiateHunger: 2
- CP14BasicEffectSatiateThirst: 2
- CP14BasicEffectHealMana: 2
- CP14BasicEffectDamageMana: 2
- CP14BasicEffectSpeedUp: 2
- CP14BasicEffectSpeedDown: 2
- CP14BasicEffectSleep: 2
- CP14BasicEffectUnsleep: 2
#- type: reaction
# id: CP14LumiMushroomAdmixture
# minTemp: 500
# reactants:
# CP14LumiMushroom:
# amount: 1
# CP14BasicEffectEmpty:
# amount: 1
# cp14RandomProducts:
# - CP14BasicEffectHealBrute: 2
# - CP14BasicEffectDamageBrute: 2
# - CP14BasicEffectHealHeat: 2
# - CP14BasicEffectDamageHeat: 2
# - CP14BasicEffectHealCold: 2
# - CP14BasicEffectDamageCold: 2
# - CP14BasicEffectHealPoison: 2
# - CP14BasicEffectDamagePoison: 2
# - CP14BasicEffectHealAirloss: 2
# - CP14BasicEffectDamageAirloss: 2
# - CP14BasicEffectBloodRestore: 2
# - CP14BasicEffectBloodAbsorption: 2
# - CP14BasicEffectSatiateHunger: 2
# - CP14BasicEffectSatiateThirst: 2
# - CP14BasicEffectHealMana: 2
# - CP14BasicEffectDamageMana: 2
# - CP14BasicEffectSpeedUp: 2
# - CP14BasicEffectSpeedDown: 2
# - CP14BasicEffectSleep: 2
# - CP14BasicEffectUnsleep: 2

View File

@@ -10,9 +10,7 @@
amount: 1
products:
CP14EssenceEarth: 0.5
cp14RandomProducts:
- CP14EssenceOrder: 0.5
- CP14EssenceChaos: 0.5
CP14EssenceOrder: 0.5
# Admixture: By adding raw precursor to a potion with target solutions, we can reduce the amount of empty solution by modifying the target solutions.