Solution normalizer (#227)
* dropper * add stabilizer * fuck, now * Update CP14SolutionNormalizerComponent.cs
@@ -0,0 +1,40 @@
|
||||
|
||||
using Content.Shared.FixedPoint;
|
||||
using Robust.Shared.Audio;
|
||||
|
||||
namespace Content.Server._CP14.Alchemy;
|
||||
|
||||
/// <summary>
|
||||
/// gradually rounds down all reagents in the specified solution
|
||||
/// </summary>
|
||||
[RegisterComponent, Access(typeof(CP14SolutionNormalizerSystem))]
|
||||
public sealed partial class CP14SolutionNormalizerComponent : Component
|
||||
{
|
||||
[DataField(required: true)]
|
||||
public string Solution = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// will round down any reagent in solution until it is divisible by this value
|
||||
/// </summary>
|
||||
[DataField]
|
||||
public float Factor = 0.25f;
|
||||
|
||||
/// <summary>
|
||||
/// the reagent will flow gradually by the specified number until it becomes normalized
|
||||
/// </summary>
|
||||
[DataField]
|
||||
public FixedPoint2 LeakageQuantity = 0.05f;
|
||||
|
||||
[DataField]
|
||||
public TimeSpan UpdateFrequency = TimeSpan.FromSeconds(4f);
|
||||
|
||||
[DataField]
|
||||
public TimeSpan NextUpdateTime = TimeSpan.Zero;
|
||||
|
||||
[DataField]
|
||||
public SoundSpecifier NormalizeSound = new SoundPathSpecifier("/Audio/Ambience/Objects/drain.ogg")
|
||||
{
|
||||
Params = AudioParams.Default.WithVariation(0.03f)
|
||||
};
|
||||
}
|
||||
|
||||
67
Content.Server/_CP14/Alchemy/CP14SolutionNormalizerSystem.cs
Normal file
@@ -0,0 +1,67 @@
|
||||
using Content.Shared.Chemistry.Components.SolutionManager;
|
||||
using Content.Shared.Chemistry.EntitySystems;
|
||||
using Content.Shared.Chemistry.Reagent;
|
||||
using Content.Shared.FixedPoint;
|
||||
using Robust.Shared.Audio.Systems;
|
||||
using Robust.Shared.Timing;
|
||||
|
||||
namespace Content.Server._CP14.Alchemy;
|
||||
|
||||
public sealed partial class CP14SolutionNormalizerSystem : EntitySystem
|
||||
{
|
||||
[Dependency] private readonly SharedAudioSystem _audio = default!;
|
||||
[Dependency] private readonly IGameTiming _timing = default!;
|
||||
[Dependency] private readonly SharedSolutionContainerSystem _solutionContainer = default!;
|
||||
|
||||
public override void Update(float frameTime)
|
||||
{
|
||||
base.Update(frameTime);
|
||||
|
||||
var query = EntityQueryEnumerator<CP14SolutionNormalizerComponent, SolutionContainerManagerComponent>();
|
||||
|
||||
while (query.MoveNext(out var uid, out var normalizer, out var containerManager))
|
||||
{
|
||||
if (_timing.CurTime <= normalizer.NextUpdateTime)
|
||||
continue;
|
||||
|
||||
normalizer.NextUpdateTime = _timing.CurTime + normalizer.UpdateFrequency;
|
||||
|
||||
var solutionManager = new Entity<SolutionContainerManagerComponent?>(uid, containerManager);
|
||||
|
||||
if (!_solutionContainer.TryGetSolution(solutionManager,
|
||||
normalizer.Solution,
|
||||
out var solutionEnt,
|
||||
out var solution))
|
||||
continue;
|
||||
|
||||
if (solution.Volume == 0)
|
||||
continue;
|
||||
|
||||
Dictionary<ReagentId, FixedPoint2> affect = new();
|
||||
foreach (var (id, quantity) in solution.Contents)
|
||||
{
|
||||
FixedPoint2 roundedQuantity = Math.Floor((float) quantity / normalizer.Factor) * normalizer.Factor;
|
||||
|
||||
var leakQuantity = quantity - roundedQuantity;
|
||||
|
||||
if (leakQuantity == 0) continue;
|
||||
|
||||
if (quantity - normalizer.LeakageQuantity < roundedQuantity)
|
||||
affect.Add(id, leakQuantity);
|
||||
else
|
||||
affect.Add(id, normalizer.LeakageQuantity);
|
||||
}
|
||||
|
||||
if (affect.Count > 0)
|
||||
{
|
||||
//Telegraphy
|
||||
_audio.PlayPvs(normalizer.NormalizeSound, uid);
|
||||
|
||||
foreach (var (id, count) in affect)
|
||||
{
|
||||
_solutionContainer.RemoveReagent(solutionEnt.Value, id, count);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -16,7 +16,7 @@ public abstract class SharedInjectorSystem : EntitySystem
|
||||
/// <summary>
|
||||
/// Default transfer amounts for the set-transfer verb.
|
||||
/// </summary>
|
||||
public static readonly FixedPoint2[] TransferAmounts = { 1, 5, 10, 15 };
|
||||
public static readonly FixedPoint2[] TransferAmounts = {0.25f, 1, 5, 10, 15};//{ 1, 5, 10, 15 }; // CP14 0.25 needed
|
||||
|
||||
[Dependency] protected readonly SharedPopupSystem Popup = default!;
|
||||
[Dependency] protected readonly SharedSolutionContainerSystem SolutionContainers = default!;
|
||||
|
||||
@@ -264,6 +264,7 @@
|
||||
name: dropper
|
||||
parent: BaseItem
|
||||
description: Used to transfer small amounts of chemical solution between containers.
|
||||
noSpawn: true
|
||||
id: Dropper
|
||||
components:
|
||||
- type: Sprite
|
||||
@@ -307,6 +308,7 @@
|
||||
name: borgdropper
|
||||
parent: Dropper
|
||||
description: Used to transfer small amounts of chemical solution between containers. Extended for use by medical borgs.
|
||||
noSpawn: true
|
||||
id: BorgDropper
|
||||
components:
|
||||
- type: Sprite
|
||||
|
||||
@@ -46,7 +46,7 @@
|
||||
ignoreMobs: true
|
||||
minTransferAmount: 10
|
||||
maxTransferAmount: 100
|
||||
transferAmount: 50
|
||||
transferAmount: 15
|
||||
toggleState: 1 # draw
|
||||
- type: UserInterface
|
||||
interfaces:
|
||||
@@ -153,4 +153,54 @@
|
||||
- 0,0,1,1
|
||||
- type: CP14Mortar
|
||||
solution: mortar
|
||||
containerId: storagebase
|
||||
containerId: storagebase
|
||||
|
||||
- type: entity
|
||||
parent: BaseItem
|
||||
id: CP14Dropper
|
||||
name: dropper
|
||||
description: Small dropper for managing very small values of liquids
|
||||
components:
|
||||
- type: MixableSolution
|
||||
solution: vial
|
||||
- type: FitsInDispenser
|
||||
solution: vial
|
||||
- type: RefillableSolution
|
||||
solution: vial
|
||||
- type: DrainableSolution
|
||||
solution: vial
|
||||
- type: ExaminableSolution
|
||||
solution: vial
|
||||
- type: DrawableSolution
|
||||
solution: vial
|
||||
- type: InjectableSolution
|
||||
solution: vial
|
||||
- type: SolutionItemStatus
|
||||
solution: vial
|
||||
- type: SolutionContainerManager
|
||||
solutions:
|
||||
vial:
|
||||
maxVol: 2
|
||||
- type: UserInterface
|
||||
interfaces:
|
||||
enum.TransferAmountUiKey.Key:
|
||||
type: TransferAmountBoundUserInterface
|
||||
- type: Appearance
|
||||
- type: Injector
|
||||
solutionName: vial
|
||||
injectOnly: false
|
||||
ignoreMobs: true
|
||||
minTransferAmount: 0.25
|
||||
maxTransferAmount: 1
|
||||
transferAmount: 0.25
|
||||
toggleState: 1 # draw
|
||||
- type: Sprite
|
||||
sprite: _CP14/Objects/Specific/Alchemy/dropper.rsi
|
||||
layers:
|
||||
- state: dropper
|
||||
- state: liq-1
|
||||
map: ["enum.SolutionContainerLayers.Fill"]
|
||||
visible: false
|
||||
- type: SolutionContainerVisuals
|
||||
maxFillLevels: 2
|
||||
fillBaseName: liq-
|
||||
@@ -3,6 +3,7 @@
|
||||
parent: BaseStructure
|
||||
abstract: true
|
||||
components:
|
||||
- type: InteractionOutline
|
||||
- type: Fixtures
|
||||
fixtures:
|
||||
fix1:
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
- type: entity
|
||||
id: CP14AlchemyNormalizer
|
||||
parent: BaseStructureDynamic
|
||||
name: solution stabilizer
|
||||
description: An alchemical device that removes fine precipitates from solutions, and stabilizes it for further work
|
||||
placement:
|
||||
mode: PlaceFree
|
||||
components:
|
||||
# TODO: energy consuming (magic or fireplace)
|
||||
- type: InteractionOutline
|
||||
- type: Sprite
|
||||
drawdepth: Items
|
||||
noRot: true
|
||||
offset: 0, 0.2
|
||||
sprite: _CP14/Structures/Specific/Alchemy/normalizer.rsi
|
||||
layers:
|
||||
- state: rotate_back
|
||||
- state: liq-1
|
||||
map: ["enum.SolutionContainerLayers.Fill"]
|
||||
visible: false
|
||||
- state: base
|
||||
- state: rotate_front
|
||||
state: base
|
||||
- type: Fixtures
|
||||
fixtures:
|
||||
fix1:
|
||||
shape:
|
||||
!type:PhysShapeAabb
|
||||
bounds: "-0.25,-0.25,0.25,0.25"
|
||||
density: 125
|
||||
mask:
|
||||
- TabletopMachineMask
|
||||
- type: SolutionContainerManager
|
||||
solutions:
|
||||
normalizer:
|
||||
maxVol: 50
|
||||
- type: DrainableSolution
|
||||
solution: normalizer
|
||||
- type: ExaminableSolution
|
||||
solution: normalizer
|
||||
- type: MixableSolution
|
||||
solution: normalizer
|
||||
- type: RefillableSolution
|
||||
solution: normalizer
|
||||
- type: DrawableSolution
|
||||
solution: normalizer
|
||||
- type: DumpableSolution
|
||||
solution: normalizer
|
||||
- type: CP14SolutionNormalizer
|
||||
solution: normalizer
|
||||
- type: Appearance
|
||||
- type: SolutionContainerVisuals
|
||||
maxFillLevels: 5
|
||||
fillBaseName: liq-
|
||||
|
After Width: | Height: | Size: 257 B |
|
After Width: | Height: | Size: 117 B |
|
After Width: | Height: | Size: 119 B |
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"version": 1,
|
||||
"size": {
|
||||
"x": 32,
|
||||
"y": 32
|
||||
},
|
||||
"license": "All rights reserved for the CrystallPunk14 project only",
|
||||
"copyright": "Created by TheShuEd (Github) for CrystallPunk14",
|
||||
"states": [
|
||||
{
|
||||
"name": "dropper"
|
||||
},
|
||||
{
|
||||
"name": "liq-1"
|
||||
},
|
||||
{
|
||||
"name": "liq-2"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
After Width: | Height: | Size: 726 B |
|
After Width: | Height: | Size: 146 B |
|
After Width: | Height: | Size: 158 B |
|
After Width: | Height: | Size: 167 B |
|
After Width: | Height: | Size: 197 B |
|
After Width: | Height: | Size: 227 B |
@@ -0,0 +1,51 @@
|
||||
{
|
||||
"version": 1,
|
||||
"license": "All rights reserved for the CrystallPunk14 project only",
|
||||
"copyright": "Created by TheShuEd for CrystallPunk14",
|
||||
"size": {
|
||||
"x": 32,
|
||||
"y": 32
|
||||
},
|
||||
"states": [
|
||||
{
|
||||
"name": "base"
|
||||
},
|
||||
{
|
||||
"name": "liq-1"
|
||||
},
|
||||
{
|
||||
"name": "liq-2"
|
||||
},
|
||||
{
|
||||
"name": "liq-3"
|
||||
},
|
||||
{
|
||||
"name": "liq-4"
|
||||
},
|
||||
{
|
||||
"name": "liq-5"
|
||||
},
|
||||
{
|
||||
"name": "rotate_back",
|
||||
"delays": [
|
||||
[
|
||||
0.2,
|
||||
0.2,
|
||||
0.2,
|
||||
0.2
|
||||
]
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "rotate_front",
|
||||
"delays": [
|
||||
[
|
||||
0.2,
|
||||
0.2,
|
||||
0.2,
|
||||
0.2
|
||||
]
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
After Width: | Height: | Size: 527 B |
|
After Width: | Height: | Size: 413 B |