predict egg cracking + refactor (#25028)

* move stuff to server and some refactoring

* update spikables to not use triggering

* add Delete bool just incase

* a new egg

* mom can we have webedit. no, we have webedit at home

---------

Co-authored-by: deltanedas <@deltanedas:kde.org>
This commit is contained in:
deltanedas
2024-02-08 06:24:24 +00:00
committed by GitHub
parent 6e91190478
commit 55dbe26019
5 changed files with 29 additions and 25 deletions

View File

@@ -1,30 +1,40 @@
namespace Content.Server.Chemistry.Components; using Content.Shared.Chemistry.EntitySystems;
using Robust.Shared.GameStates;
[RegisterComponent] namespace Content.Shared.Chemistry.Components;
[RegisterComponent, NetworkedComponent, Access(typeof(SolutionSpikerSystem))]
public sealed partial class SolutionSpikerComponent : Component public sealed partial class SolutionSpikerComponent : Component
{ {
/// <summary> /// <summary>
/// The source solution to take the reagents from in order /// The source solution to take the reagents from in order
/// to spike the other solution container. /// to spike the other solution container.
/// </summary> /// </summary>
[DataField] [DataField(required: true)]
public string SourceSolution { get; private set; } = string.Empty; public string SourceSolution = string.Empty;
/// <summary> /// <summary>
/// If spiking with this entity should ignore empty containers or not. /// If spiking with this entity should ignore empty containers or not.
/// </summary> /// </summary>
[DataField] [DataField]
public bool IgnoreEmpty { get; private set; } public bool IgnoreEmpty;
/// <summary>
/// If true, the entity is deleted after spiking.
/// This is almost certainly what you want.
/// </summary>
[DataField]
public bool Delete = true;
/// <summary> /// <summary>
/// What should pop up when spiking with this entity. /// What should pop up when spiking with this entity.
/// </summary> /// </summary>
[DataField] [DataField]
public LocId Popup { get; private set; } = "spike-solution-generic"; public LocId Popup = "spike-solution-generic";
/// <summary> /// <summary>
/// What should pop up when spiking fails because the container was empty. /// What should pop up when spiking fails because the container was empty.
/// </summary> /// </summary>
[DataField] [DataField]
public LocId PopupEmpty { get; private set; } = "spike-solution-empty-generic"; public LocId PopupEmpty = "spike-solution-empty-generic";
} }

View File

@@ -1,12 +1,9 @@
using Content.Server.Chemistry.Components; using Content.Shared.Popups;
using Content.Server.Chemistry.Containers.EntitySystems;
using Content.Server.Explosion.EntitySystems;
using Content.Server.Popups;
using Content.Shared.Chemistry.Components; using Content.Shared.Chemistry.Components;
using Content.Shared.Chemistry.Components.SolutionManager; using Content.Shared.Chemistry.Components.SolutionManager;
using Content.Shared.Interaction; using Content.Shared.Interaction;
namespace Content.Server.Chemistry.EntitySystems; namespace Content.Shared.Chemistry.EntitySystems;
/// <summary> /// <summary>
/// Entity system used to handle when solution containers are 'spiked' /// Entity system used to handle when solution containers are 'spiked'
@@ -17,11 +14,10 @@ namespace Content.Server.Chemistry.EntitySystems;
/// Examples of spikable entity interactions include pills being dropped into glasses, /// Examples of spikable entity interactions include pills being dropped into glasses,
/// eggs being cracked into bowls, and so on. /// eggs being cracked into bowls, and so on.
/// </summary> /// </summary>
public sealed class SolutionSpikableSystem : EntitySystem public sealed class SolutionSpikerSystem : EntitySystem
{ {
[Dependency] private readonly SolutionContainerSystem _solutionContainerSystem = default!; [Dependency] private readonly SharedPopupSystem _popup = default!;
[Dependency] private readonly TriggerSystem _triggerSystem = default!; [Dependency] private readonly SharedSolutionContainerSystem _solution = default!;
[Dependency] private readonly PopupSystem _popupSystem = default!;
public override void Initialize() public override void Initialize()
{ {
@@ -47,23 +43,24 @@ public sealed class SolutionSpikableSystem : EntitySystem
{ {
if (!Resolve(source, ref spikableSource, ref managerSource, false) if (!Resolve(source, ref spikableSource, ref managerSource, false)
|| !Resolve(target, ref spikableTarget, ref managerTarget, false) || !Resolve(target, ref spikableTarget, ref managerTarget, false)
|| !_solutionContainerSystem.TryGetRefillableSolution((target, spikableTarget, managerTarget), out var targetSoln, out var targetSolution) || !_solution.TryGetRefillableSolution((target, spikableTarget, managerTarget), out var targetSoln, out var targetSolution)
|| !_solutionContainerSystem.TryGetSolution((source, managerSource), spikableSource.SourceSolution, out _, out var sourceSolution)) || !_solution.TryGetSolution((source, managerSource), spikableSource.SourceSolution, out _, out var sourceSolution))
{ {
return; return;
} }
if (targetSolution.Volume == 0 && !spikableSource.IgnoreEmpty) if (targetSolution.Volume == 0 && !spikableSource.IgnoreEmpty)
{ {
_popupSystem.PopupEntity(Loc.GetString(spikableSource.PopupEmpty, ("spiked-entity", target), ("spike-entity", source)), user, user); _popup.PopupClient(Loc.GetString(spikableSource.PopupEmpty, ("spiked-entity", target), ("spike-entity", source)), user, user);
return; return;
} }
if (!_solutionContainerSystem.ForceAddSolution(targetSoln.Value, sourceSolution)) if (!_solution.ForceAddSolution(targetSoln.Value, sourceSolution))
return; return;
_popupSystem.PopupEntity(Loc.GetString(spikableSource.Popup, ("spiked-entity", target), ("spike-entity", source)), user, user); _popup.PopupClient(Loc.GetString(spikableSource.Popup, ("spiked-entity", target), ("spike-entity", source)), user, user);
sourceSolution.RemoveAllSolution(); sourceSolution.RemoveAllSolution();
_triggerSystem.Trigger(source, user); if (spikableSource.Delete)
QueueDel(source);
} }
} }

View File

@@ -30,7 +30,6 @@
sourceSolution: food sourceSolution: food
ignoreEmpty: true ignoreEmpty: true
popup: spike-solution-egg popup: spike-solution-egg
- type: DeleteOnTrigger
# egg fragile # egg fragile
- type: DamageOnHighSpeedImpact - type: DamageOnHighSpeedImpact
minimumSpeed: 0.1 minimumSpeed: 0.1

View File

@@ -118,7 +118,6 @@
- type: SolutionSpiker - type: SolutionSpiker
sourceSolution: food sourceSolution: food
ignoreEmpty: true ignoreEmpty: true
- type: DeleteOnTrigger
- type: Extractable - type: Extractable
grindableSolutionName: food grindableSolutionName: food

View File

@@ -454,7 +454,6 @@
maxVol: 20 maxVol: 20
- type: SolutionSpiker - type: SolutionSpiker
sourceSolution: food sourceSolution: food
- type: DeleteOnTrigger
- type: Extractable - type: Extractable
grindableSolutionName: food grindableSolutionName: food
- type: StaticPrice - type: StaticPrice