Revert "Solution Entities" (#23160)
Revert "Solution Entities (#21916)"
This reverts commit d75e743dd7.
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
using Content.Server.Anomaly.Effects;
|
||||
using Content.Shared.Chemistry.Components;
|
||||
using Content.Shared.Chemistry.Reagent;
|
||||
using Robust.Shared.Audio;
|
||||
using Robust.Shared.Prototypes;
|
||||
@@ -86,17 +85,10 @@ public sealed partial class ReagentProducerAnomalyComponent : Component
|
||||
/// </summary>
|
||||
[DataField, ViewVariables(VVAccess.ReadWrite)]
|
||||
public ProtoId<ReagentPrototype> ProducingReagent = "Water";
|
||||
|
||||
/// <summary>
|
||||
/// Solution name where the substance is generated
|
||||
/// </summary>
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
[DataField("solution")]
|
||||
public string SolutionName = "default";
|
||||
|
||||
/// <summary>
|
||||
/// Solution where the substance is generated
|
||||
/// </summary>
|
||||
[DataField("solutionRef")]
|
||||
public Entity<SolutionComponent>? Solution = null;
|
||||
public string Solution = "default";
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
using System.Linq;
|
||||
using Content.Server.Anomaly.Components;
|
||||
using Content.Server.Chemistry.Containers.EntitySystems;
|
||||
using Content.Shared.Anomaly.Components;
|
||||
using Content.Shared.Chemistry.Components.SolutionManager;
|
||||
using System.Linq;
|
||||
using Content.Shared.Chemistry.EntitySystems;
|
||||
|
||||
namespace Content.Server.Anomaly.Effects;
|
||||
/// <summary>
|
||||
@@ -27,40 +27,41 @@ public sealed class InjectionAnomalySystem : EntitySystem
|
||||
_injectableQuery = GetEntityQuery<InjectableSolutionComponent>();
|
||||
}
|
||||
|
||||
private void OnPulse(Entity<InjectionAnomalyComponent> entity, ref AnomalyPulseEvent args)
|
||||
private void OnPulse(EntityUid uid, InjectionAnomalyComponent component, ref AnomalyPulseEvent args)
|
||||
{
|
||||
PulseScalableEffect(entity, entity.Comp.InjectRadius, entity.Comp.MaxSolutionInjection * args.Severity);
|
||||
PulseScalableEffect(uid, component, component.InjectRadius, component.MaxSolutionInjection * args.Severity);
|
||||
}
|
||||
|
||||
private void OnSupercritical(Entity<InjectionAnomalyComponent> entity, ref AnomalySupercriticalEvent args)
|
||||
private void OnSupercritical(EntityUid uid, InjectionAnomalyComponent component, ref AnomalySupercriticalEvent args)
|
||||
{
|
||||
PulseScalableEffect(entity, entity.Comp.SuperCriticalInjectRadius, entity.Comp.SuperCriticalSolutionInjection);
|
||||
PulseScalableEffect(uid, component, component.SuperCriticalInjectRadius, component.SuperCriticalSolutionInjection);
|
||||
}
|
||||
|
||||
private void PulseScalableEffect(Entity<InjectionAnomalyComponent> entity, float injectRadius, float maxInject)
|
||||
private void PulseScalableEffect(EntityUid uid, InjectionAnomalyComponent component, float injectRadius, float maxInject)
|
||||
{
|
||||
if (!_solutionContainer.TryGetSolution(entity.Owner, entity.Comp.Solution, out _, out var sol))
|
||||
if (!_solutionContainer.TryGetSolution(uid, component.Solution, out var sol))
|
||||
return;
|
||||
|
||||
//We get all the entity in the radius into which the reagent will be injected.
|
||||
var xformQuery = GetEntityQuery<TransformComponent>();
|
||||
var xform = xformQuery.GetComponent(entity);
|
||||
var xform = xformQuery.GetComponent(uid);
|
||||
var allEnts = _lookup.GetEntitiesInRange<InjectableSolutionComponent>(xform.MapPosition, injectRadius)
|
||||
.Select(x => x.Owner).ToList();
|
||||
|
||||
//for each matching entity found
|
||||
foreach (var ent in allEnts)
|
||||
{
|
||||
if (!_solutionContainer.TryGetInjectableSolution(ent, out var injectable, out _))
|
||||
if (!_solutionContainer.TryGetInjectableSolution(ent, out var injectable))
|
||||
continue;
|
||||
|
||||
if (_injectableQuery.TryGetComponent(ent, out var injEnt))
|
||||
{
|
||||
_solutionContainer.TryTransferSolution(injectable.Value, sol, maxInject);
|
||||
var buffer = sol;
|
||||
_solutionContainer.TryTransferSolution(ent, injectable, buffer, maxInject);
|
||||
//Spawn Effect
|
||||
var uidXform = Transform(ent);
|
||||
Spawn(entity.Comp.VisualEffectPrototype, uidXform.Coordinates);
|
||||
Spawn(component.VisualEffectPrototype, uidXform.Coordinates);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
using Content.Server.Anomaly.Components;
|
||||
using Content.Server.Chemistry.Containers.EntitySystems;
|
||||
using Content.Server.Fluids.EntitySystems;
|
||||
using Content.Shared.Anomaly.Components;
|
||||
using Content.Shared.Chemistry.EntitySystems;
|
||||
using Content.Server.Fluids.EntitySystems;
|
||||
|
||||
namespace Content.Server.Anomaly.Effects;
|
||||
|
||||
@@ -19,21 +19,21 @@ public sealed class PuddleCreateAnomalySystem : EntitySystem
|
||||
SubscribeLocalEvent<PuddleCreateAnomalyComponent, AnomalySupercriticalEvent>(OnSupercritical, before: new[] { typeof(InjectionAnomalySystem) });
|
||||
}
|
||||
|
||||
private void OnPulse(Entity<PuddleCreateAnomalyComponent> entity, ref AnomalyPulseEvent args)
|
||||
private void OnPulse(EntityUid uid, PuddleCreateAnomalyComponent component, ref AnomalyPulseEvent args)
|
||||
{
|
||||
if (!_solutionContainer.TryGetSolution(entity.Owner, entity.Comp.Solution, out var sol, out _))
|
||||
if (!_solutionContainer.TryGetSolution(uid, component.Solution, out var sol))
|
||||
return;
|
||||
|
||||
var xform = Transform(entity.Owner);
|
||||
var puddleSol = _solutionContainer.SplitSolution(sol.Value, entity.Comp.MaxPuddleSize * args.Severity);
|
||||
_puddle.TrySplashSpillAt(entity.Owner, xform.Coordinates, puddleSol, out _);
|
||||
var xform = Transform(uid);
|
||||
var puddleSol = _solutionContainer.SplitSolution(uid, sol, component.MaxPuddleSize * args.Severity);
|
||||
_puddle.TrySplashSpillAt(uid, xform.Coordinates, puddleSol, out _);
|
||||
}
|
||||
private void OnSupercritical(Entity<PuddleCreateAnomalyComponent> entity, ref AnomalySupercriticalEvent args)
|
||||
private void OnSupercritical(EntityUid uid, PuddleCreateAnomalyComponent component, ref AnomalySupercriticalEvent args)
|
||||
{
|
||||
if (!_solutionContainer.TryGetSolution(entity.Owner, entity.Comp.Solution, out _, out var sol))
|
||||
if (!_solutionContainer.TryGetSolution(uid, component.Solution, out var sol))
|
||||
return;
|
||||
|
||||
var xform = Transform(entity.Owner);
|
||||
_puddle.TrySpillAt(xform.Coordinates, sol, out _);
|
||||
var buffer = sol;
|
||||
var xform = Transform(uid);
|
||||
_puddle.TrySpillAt(xform.Coordinates, buffer, out _);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
using Content.Server.Anomaly.Components;
|
||||
using Content.Server.Chemistry.Containers.EntitySystems;
|
||||
using Content.Shared.Anomaly.Components;
|
||||
using Robust.Shared.Random;
|
||||
using Content.Shared.Chemistry.Components;
|
||||
using Content.Shared.Chemistry.EntitySystems;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Content.Shared.Sprite;
|
||||
using Robust.Server.GameObjects;
|
||||
using Robust.Shared.Audio.Systems;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Random;
|
||||
|
||||
namespace Content.Server.Anomaly.Effects;
|
||||
|
||||
@@ -42,17 +42,17 @@ public sealed class ReagentProducerAnomalySystem : EntitySystem
|
||||
SubscribeLocalEvent<ReagentProducerAnomalyComponent, MapInitEvent>(OnMapInit);
|
||||
}
|
||||
|
||||
private void OnPulse(Entity<ReagentProducerAnomalyComponent> entity, ref AnomalyPulseEvent args)
|
||||
private void OnPulse(EntityUid uid, ReagentProducerAnomalyComponent component, ref AnomalyPulseEvent args)
|
||||
{
|
||||
if (_random.NextFloat(0.0f, 1.0f) > args.Stability)
|
||||
ChangeReagent(entity, args.Severity);
|
||||
ChangeReagent(uid, component, args.Severity);
|
||||
}
|
||||
|
||||
private void ChangeReagent(Entity<ReagentProducerAnomalyComponent> entity, float severity)
|
||||
private void ChangeReagent(EntityUid uid, ReagentProducerAnomalyComponent component, float severity)
|
||||
{
|
||||
var reagent = GetRandomReagentType(entity, severity);
|
||||
entity.Comp.ProducingReagent = reagent;
|
||||
_audio.PlayPvs(entity.Comp.ChangeSound, entity);
|
||||
var reagent = GetRandomReagentType(uid, component, severity);
|
||||
component.ProducingReagent = reagent;
|
||||
_audio.PlayPvs(component.ChangeSound, uid);
|
||||
}
|
||||
|
||||
//reagent realtime generation
|
||||
@@ -68,7 +68,7 @@ public sealed class ReagentProducerAnomalySystem : EntitySystem
|
||||
if (component.AccumulatedFrametime < component.UpdateInterval)
|
||||
continue;
|
||||
|
||||
if (!_solutionContainer.ResolveSolution(uid, component.SolutionName, ref component.Solution, out var producerSolution))
|
||||
if (!_solutionContainer.TryGetSolution(uid, component.Solution, out var producerSol))
|
||||
continue;
|
||||
|
||||
Solution newSol = new();
|
||||
@@ -76,7 +76,7 @@ public sealed class ReagentProducerAnomalySystem : EntitySystem
|
||||
if (anomaly.Severity >= 0.97) reagentProducingAmount *= component.SupercriticalReagentProducingModifier;
|
||||
|
||||
newSol.AddReagent(component.ProducingReagent, reagentProducingAmount);
|
||||
_solutionContainer.TryAddSolution(component.Solution.Value, newSol); //TO DO - the container is not fully filled.
|
||||
_solutionContainer.TryAddSolution(uid, producerSol, newSol); //TO DO - the container is not fully filled.
|
||||
|
||||
component.AccumulatedFrametime = 0;
|
||||
|
||||
@@ -87,7 +87,7 @@ public sealed class ReagentProducerAnomalySystem : EntitySystem
|
||||
// and nothing worked out for me. So for now it will be like this.
|
||||
if (component.NeedRecolor)
|
||||
{
|
||||
var color = producerSolution.GetColor(_prototypeManager);
|
||||
var color = producerSol.GetColor(_prototypeManager);
|
||||
_light.SetColor(uid, color);
|
||||
if (TryComp<RandomSpriteComponent>(uid, out var randomSprite))
|
||||
{
|
||||
@@ -103,9 +103,9 @@ public sealed class ReagentProducerAnomalySystem : EntitySystem
|
||||
}
|
||||
}
|
||||
|
||||
private void OnMapInit(Entity<ReagentProducerAnomalyComponent> entity, ref MapInitEvent args)
|
||||
private void OnMapInit(EntityUid uid, ReagentProducerAnomalyComponent component, MapInitEvent args)
|
||||
{
|
||||
ChangeReagent(entity, 0.1f); //MapInit Reagent 100% change
|
||||
ChangeReagent(uid, component, 0.1f); //MapInit Reagent 100% change
|
||||
}
|
||||
|
||||
// returns a random reagent based on a system of random weights.
|
||||
@@ -117,33 +117,33 @@ public sealed class ReagentProducerAnomalySystem : EntitySystem
|
||||
// After that, a random reagent in the selected category is selected.
|
||||
//
|
||||
// Such a system is made to control the danger and interest of the anomaly more.
|
||||
private string GetRandomReagentType(Entity<ReagentProducerAnomalyComponent> entity, float severity)
|
||||
private string GetRandomReagentType(EntityUid uid, ReagentProducerAnomalyComponent component, float severity)
|
||||
{
|
||||
//Category Weight Randomization
|
||||
var currentWeightDangerous = MathHelper.Lerp(entity.Comp.WeightSpreadDangerous.X, entity.Comp.WeightSpreadDangerous.Y, severity);
|
||||
var currentWeightFun = MathHelper.Lerp(entity.Comp.WeightSpreadFun.X, entity.Comp.WeightSpreadFun.Y, severity);
|
||||
var currentWeightUseful = MathHelper.Lerp(entity.Comp.WeightSpreadUseful.X, entity.Comp.WeightSpreadUseful.Y, severity);
|
||||
var currentWeightDangerous = MathHelper.Lerp(component.WeightSpreadDangerous.X, component.WeightSpreadDangerous.Y, severity);
|
||||
var currentWeightFun = MathHelper.Lerp(component.WeightSpreadFun.X, component.WeightSpreadFun.Y, severity);
|
||||
var currentWeightUseful = MathHelper.Lerp(component.WeightSpreadUseful.X, component.WeightSpreadUseful.Y, severity);
|
||||
|
||||
var sumWeight = currentWeightDangerous + currentWeightFun + currentWeightUseful;
|
||||
var rnd = _random.NextFloat(0f, sumWeight);
|
||||
//Dangerous
|
||||
if (rnd <= currentWeightDangerous && entity.Comp.DangerousChemicals.Count > 0)
|
||||
if (rnd <= currentWeightDangerous && component.DangerousChemicals.Count > 0)
|
||||
{
|
||||
var reagent = _random.Pick(entity.Comp.DangerousChemicals);
|
||||
var reagent = _random.Pick(component.DangerousChemicals);
|
||||
return reagent;
|
||||
}
|
||||
else rnd -= currentWeightDangerous;
|
||||
//Fun
|
||||
if (rnd <= currentWeightFun && entity.Comp.FunChemicals.Count > 0)
|
||||
if (rnd <= currentWeightFun && component.FunChemicals.Count > 0)
|
||||
{
|
||||
var reagent = _random.Pick(entity.Comp.FunChemicals);
|
||||
var reagent = _random.Pick(component.FunChemicals);
|
||||
return reagent;
|
||||
}
|
||||
else rnd -= currentWeightFun;
|
||||
//Useful
|
||||
if (rnd <= currentWeightUseful && entity.Comp.UsefulChemicals.Count > 0)
|
||||
if (rnd <= currentWeightUseful && component.UsefulChemicals.Count > 0)
|
||||
{
|
||||
var reagent = _random.Pick(entity.Comp.UsefulChemicals);
|
||||
var reagent = _random.Pick(component.UsefulChemicals);
|
||||
return reagent;
|
||||
}
|
||||
//We should never end up here.
|
||||
|
||||
Reference in New Issue
Block a user