Solution refactor (#4407)
* Rename SolutionContainerCaps -> Capability * Move IExamine event to Chemistry System. * ECS the ISolutionChange into SolutionChangeEvent * Unify SolutionContainer into a single shared component * Replace ISolutionInteraction with SolutionContainerComponent * Move all methods from SolutionContainer to ChemistrySystem * Refactor EntitySystem calls to Dependencies * Refactor SolutionContainer to SolutionManager * Fix yamls * Fix test fails * Fix post merge issues * Fix various issues with SolutionManager * More fixes * Fix more components * Fix events not being directed * Fixes for Hypospray * Separate removal and iteration on Metabolism * Fix creampie problems * Address some of sloth's issues * Refactors for Systems * Refactored solution location * Fix tests * Address more sloth issues * Fix dependency * Fix merge conflicts * Add xmldocs for Capabilities components * Remove HasSolution/TryGetDefaultSolution and Add/Remove Drainable/Refillable * Replace Grindable/Juiceable with Extractable * Refactor field names * Fix Drainable * Fix some issues with spillable and injector * Fix issues with Grinder * Fix Beaker having duplicate solutions * Fix foaming * Address some MGS issues * Fix Uid issues * Fix errors in solution Tranfer * Fixed some extra values constant values * Cola is drinkable now
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
using System;
|
||||
using System;
|
||||
using Content.Server.Chemistry.Components;
|
||||
using Content.Server.Coordinates.Helpers;
|
||||
using Content.Shared.Audio;
|
||||
using Content.Shared.Chemistry.Components;
|
||||
using Content.Shared.Chemistry.EntitySystems;
|
||||
using Content.Shared.Chemistry.Reaction;
|
||||
using Content.Shared.Sound;
|
||||
using JetBrains.Annotations;
|
||||
@@ -87,12 +89,9 @@ namespace Content.Server.Chemistry.ReactionEffects
|
||||
IoCManager.InjectDependencies(this);
|
||||
}
|
||||
|
||||
public void React(IEntity solutionEntity, double intensity)
|
||||
public void React(Solution solution, IEntity solutionEntity, double intensity)
|
||||
{
|
||||
if (!solutionEntity.TryGetComponent(out SolutionContainerComponent? contents))
|
||||
return;
|
||||
|
||||
var solution = contents.SplitSolution(contents.MaxVolume);
|
||||
var splitSolution = EntitySystem.Get<SolutionContainerSystem>().SplitSolution(solutionEntity.Uid, solution, solution.MaxVolume);
|
||||
// We take the square root so it becomes harder to reach higher amount values
|
||||
var amount = (int) Math.Round(_rangeConstant + _rangeMultiplier*Math.Sqrt(intensity));
|
||||
amount = Math.Min(amount, _maxRange);
|
||||
@@ -115,7 +114,7 @@ namespace Content.Server.Chemistry.ReactionEffects
|
||||
solutionFraction = amount * (1 - _reagentMaxConcentrationFactor) / _reagentDilutionStart +
|
||||
_reagentMaxConcentrationFactor;
|
||||
}
|
||||
solution.RemoveSolution(solution.TotalVolume * solutionFraction);
|
||||
splitSolution.RemoveSolution(splitSolution.TotalVolume * solutionFraction);
|
||||
}
|
||||
|
||||
if (!_mapManager.TryFindGridAt(solutionEntity.Transform.MapPosition, out var grid)) return;
|
||||
@@ -133,7 +132,7 @@ namespace Content.Server.Chemistry.ReactionEffects
|
||||
return;
|
||||
}
|
||||
|
||||
areaEffectComponent.TryAddSolution(solution);
|
||||
areaEffectComponent.TryAddSolution(splitSolution);
|
||||
areaEffectComponent.Start(amount, _duration, _spreadDelay, _removeDelay);
|
||||
|
||||
SoundSystem.Play(Filter.Pvs(solutionEntity), _sound.GetSound(), solutionEntity, AudioHelpers.WithVariation(0.125f));
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
using System;
|
||||
using Content.Server.Chemistry.Components;
|
||||
using Content.Server.Explosion;
|
||||
using Content.Shared.Chemistry.Components;
|
||||
using Content.Shared.Chemistry.Components.SolutionManager;
|
||||
using Content.Shared.Chemistry.Reaction;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
@@ -26,12 +28,11 @@ namespace Content.Server.Chemistry.ReactionEffects
|
||||
/// </summary>
|
||||
[DataField("maxScale")] private float _maxScale = 1;
|
||||
|
||||
public void React(IEntity? solutionEntity, double intensity)
|
||||
public void React(Solution solution, IEntity solutionEntity, double intensity)
|
||||
{
|
||||
var floatIntensity = (float) intensity;
|
||||
if (solutionEntity == null)
|
||||
return;
|
||||
if (!solutionEntity.HasComponent<SolutionContainerComponent>())
|
||||
|
||||
if (!solutionEntity.HasComponent<SolutionContainerManagerComponent>())
|
||||
return;
|
||||
|
||||
//Handle scaling
|
||||
|
||||
Reference in New Issue
Block a user