-
Notifications
You must be signed in to change notification settings - Fork 88
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'refs/remotes/wizards/master'
- Loading branch information
Showing
9 changed files
with
112 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 0 additions & 11 deletions
11
Content.Shared/Chemistry/Components/BlockSolutionAccessComponent.cs
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
Content.Shared/Fluids/Components/SpillWhenWornComponent.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
using Robust.Shared.GameStates; | ||
|
||
namespace Content.Shared.Fluids.Components; | ||
|
||
/// <summary> | ||
/// This entity will spill its contained solution onto the wearer when worn, and its | ||
/// (empty) contents will be inaccessible while still worn. | ||
/// </summary> | ||
[RegisterComponent] | ||
[NetworkedComponent, AutoGenerateComponentState] | ||
public sealed partial class SpillWhenWornComponent : Component | ||
{ | ||
/// <summary> | ||
/// Name of the solution to spill. | ||
/// </summary> | ||
[DataField] | ||
public string Solution = "default"; | ||
|
||
/// <summary> | ||
/// Tracks if this item is currently being worn. | ||
/// </summary> | ||
[DataField, AutoNetworkedField] | ||
public bool IsWorn; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
Content.Shared/Fluids/EntitySystems/SpillWhenWornSystem.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
using Content.Shared.Chemistry.EntitySystems; | ||
using Content.Shared.Clothing; | ||
using Content.Shared.Fluids.Components; | ||
|
||
namespace Content.Shared.Fluids.EntitySystems; | ||
|
||
/// <inheritdoc cref="SpillWhenWornComponent"/> | ||
public sealed class SpillWhenWornSystem : EntitySystem | ||
{ | ||
[Dependency] private readonly SharedSolutionContainerSystem _solutionContainer = default!; | ||
[Dependency] private readonly SharedPuddleSystem _puddle = default!; | ||
|
||
public override void Initialize() | ||
{ | ||
base.Initialize(); | ||
|
||
SubscribeLocalEvent<SpillWhenWornComponent, ClothingGotEquippedEvent>(OnGotEquipped); | ||
SubscribeLocalEvent<SpillWhenWornComponent, ClothingGotUnequippedEvent>(OnGotUnequipped); | ||
SubscribeLocalEvent<SpillWhenWornComponent, SolutionAccessAttemptEvent>(OnSolutionAccessAttempt); | ||
} | ||
|
||
private void OnGotEquipped(Entity<SpillWhenWornComponent> ent, ref ClothingGotEquippedEvent args) | ||
{ | ||
if (_solutionContainer.TryGetSolution(ent.Owner, ent.Comp.Solution, out var soln, out var solution) | ||
&& solution.Volume > 0) | ||
{ | ||
// Spill all solution on the player | ||
var drainedSolution = _solutionContainer.Drain(ent.Owner, soln.Value, solution.Volume); | ||
_puddle.TrySplashSpillAt(ent.Owner, Transform(args.Wearer).Coordinates, drainedSolution, out _); | ||
} | ||
|
||
// Flag as worn after draining, otherwise we'll block ourself from accessing! | ||
ent.Comp.IsWorn = true; | ||
Dirty(ent); | ||
} | ||
|
||
private void OnGotUnequipped(Entity<SpillWhenWornComponent> ent, ref ClothingGotUnequippedEvent args) | ||
{ | ||
ent.Comp.IsWorn = false; | ||
Dirty(ent); | ||
} | ||
|
||
private void OnSolutionAccessAttempt(Entity<SpillWhenWornComponent> ent, ref SolutionAccessAttemptEvent args) | ||
{ | ||
// If we're not being worn right now, we don't care | ||
if (!ent.Comp.IsWorn) | ||
return; | ||
|
||
// Make sure it's the right solution | ||
if (ent.Comp.Solution != args.SolutionName) | ||
return; | ||
|
||
args.Cancelled = true; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -59,3 +59,4 @@ | |
- type: GuideHelp | ||
guides: | ||
- Medical Doctor | ||
- type: PowerSwitch |