Skip to content

Commit

Permalink
Added Showers (#661)
Browse files Browse the repository at this point in the history
<!--
This is a semi-strict format, you can add/remove sections as needed but
the order/format should be kept the same
Remove these comments before submitting
-->

# Description

<!--
Explain this PR in as much detail as applicable

Some example prompts to consider:
How might this affect the game? The codebase?
What might be some alternatives to this?
How/Who does this benefit/hurt [the game/codebase]?
-->

Added in showers. A pure RP furniture item.

---

# TODO

<!--
A list of everything you have to do before this PR is "complete"
You probably won't have to complete everything before merging but it's
good to leave future references
-->

- [x] Sound effects
- [x] Wallmount
- [x] Add in Showers

---



![Display](https://github.com/user-attachments/assets/c8499c33-a9ce-4d2d-9003-ed8517afb0b9)


---

# Changelog

<!--
You can add an author after the `:cl:` to change the name that appears
in the changelog (ex: `:cl: Death`)
Leaving it blank will default to your GitHub display name
This includes all available types for the changelog
-->

:cl: Tilkku
- add: Added showers
  • Loading branch information
SleepyScarecrow authored Aug 12, 2024
1 parent f57327e commit 376b8f1
Show file tree
Hide file tree
Showing 12 changed files with 270 additions and 7 deletions.
8 changes: 8 additions & 0 deletions Content.Server/Shower/ShowerSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
using Content.Shared.Showers;

namespace Content.Server.Shower;

public sealed class ShowerSystem : SharedShowerSystem
{

}
92 changes: 92 additions & 0 deletions Content.Shared/Showers/SharedShowerSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
using Content.Shared.Interaction;
using Content.Shared.Verbs;
using Robust.Shared.Audio;
using Robust.Shared.Audio.Systems;
using Robust.Shared.Random;
using Robust.Shared.Utility;

namespace Content.Shared.Showers
{
public abstract class SharedShowerSystem : EntitySystem
{
[Dependency] private readonly IRobustRandom _random = default!;
[Dependency] private readonly SharedAppearanceSystem _appearance = default!;
[Dependency] private readonly SharedAudioSystem _audio = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<ShowerComponent, MapInitEvent>(OnMapInit);
SubscribeLocalEvent<ShowerComponent, GetVerbsEvent<AlternativeVerb>>(OnToggleShowerVerb);
SubscribeLocalEvent<ShowerComponent, ActivateInWorldEvent>(OnActivateInWorld);
}
private void OnMapInit(EntityUid uid, ShowerComponent component, MapInitEvent args)
{
if (_random.Prob(0.5f))
component.ToggleShower = true;
UpdateAppearance(uid);
}
private void OnToggleShowerVerb(EntityUid uid, ShowerComponent component, GetVerbsEvent<AlternativeVerb> args)
{
if (!args.CanInteract || !args.CanAccess || args.Hands == null)
return;

AlternativeVerb toggleVerb = new()
{
Act = () => ToggleShowerHead(uid, args.User, component)
};

if (component.ToggleShower)
{
toggleVerb.Text = Loc.GetString("shower-turn-on");
toggleVerb.Icon =
new SpriteSpecifier.Texture(new ResPath("/Textures/Interface/VerbIcons/open.svg.192dpi.png"));
}
else
{
toggleVerb.Text = Loc.GetString("shower-turn-off");
toggleVerb.Icon =
new SpriteSpecifier.Texture(new ResPath("/Textures/Interface/VerbIcons/close.svg.192dpi.png"));
}
args.Verbs.Add(toggleVerb);
}
private void OnActivateInWorld(EntityUid uid, ShowerComponent comp, ActivateInWorldEvent args)
{
if (args.Handled)
return;

args.Handled = true;
ToggleShowerHead(uid, args.User, comp);

_audio.PlayPvs(comp.EnableShowerSound, uid);
}
public void ToggleShowerHead(EntityUid uid, EntityUid? user = null, ShowerComponent? component = null, MetaDataComponent? meta = null)
{
if (!Resolve(uid, ref component))
return;

component.ToggleShower = !component.ToggleShower;

UpdateAppearance(uid, component);
}
private void UpdateAppearance(EntityUid uid, ShowerComponent? component = null)
{
if (!Resolve(uid, ref component))
return;

_appearance.SetData(uid, ShowerVisuals.ShowerVisualState, component.ToggleShower ? ShowerVisualState.On : ShowerVisualState.Off);

if (component.ToggleShower)
{
if (component.PlayingStream == null)
{
component.PlayingStream = _audio.PlayPvs(component.LoopingSound, uid, AudioParams.Default.WithLoop(true).WithMaxDistance(5)).Value.Entity;
}
}
else
{
component.PlayingStream = _audio.Stop(component.PlayingStream);
component.PlayingStream = null;
}
}
}
}
43 changes: 43 additions & 0 deletions Content.Shared/Showers/ShowerComponent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
using Robust.Shared.Audio;
using Robust.Shared.GameStates;
using Robust.Shared.Serialization;

namespace Content.Shared.Showers
{
/// <summary>
/// showers that can be enabled
/// </summary>
[RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
public sealed partial class ShowerComponent : Component
{
/// <summary>
/// Toggles shower.
/// </summary>
[DataField, AutoNetworkedField]
public bool ToggleShower;

[DataField("enableShowerSound")]
public SoundSpecifier EnableShowerSound = new SoundPathSpecifier("/Audio/Ambience/Objects/shower_enable.ogg");

public EntityUid? PlayingStream;

[DataField("loopingSound")]
public SoundSpecifier LoopingSound = new SoundPathSpecifier("/Audio/Ambience/Objects/shower_running.ogg");

}


[Serializable, NetSerializable]
public enum ShowerVisuals : byte
{
ShowerVisualState,
}

[Serializable, NetSerializable]
public enum ShowerVisualState : byte
{
Off,
On
}
}

Binary file not shown.
Binary file not shown.
2 changes: 2 additions & 0 deletions Resources/Locale/en-US/shower/shower-component.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
shower-turn-on = Turn On
shower-turn-off = Turn Off
46 changes: 46 additions & 0 deletions Resources/Prototypes/Entities/Structures/Furniture/shower.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
- type: entity
name: shower
id: Shower
description: A shower, complete with bluespace water.
placement:
mode: SnapgridCenter
snap:
- Wallmount
components:
- type: Sprite
sprite: Structures/Furniture/shower.rsi
drawdepth: WallMountedItems
layers:
- state: shower
map: ["enabled", "enum.ShowerVisualState.Off" ]
- type: Appearance
- type: Rotatable
- type: Transform
noRot: false
- type: Clickable
- type: Shower
- type: Physics
bodyType: Static
canCollide: false
- type: InteractionOutline
- type: Damageable
- type: Construction
graph: Shower
node: shower
damageContainer: Inorganic
damageModifierSet: Metallic
- type: Destructible
thresholds:
- trigger:
!type:DamageTrigger
damage: 100
behaviors:
- !type:DoActsBehavior
acts: [ "Destruction" ]
- type: GenericVisualizer
visuals:
enum.ShowerVisuals.ShowerVisualState:
ShowerVisualState.Off:
On: { state: shower_on }
Off: { state: shower }

Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
- type: constructionGraph
id: Shower
start: start
graph:
- node: start
edges:
- to: shower
completed:
- !type:SnapToGrid { }
steps:
- material: Steel
amount: 5
doAfter: 1
- node: shower
entity: Shower
edges:
- to: start
completed:
- !type:SpawnPrototype
prototype: SheetSteel1
amount: 5
- !type:EmptyAllContainers {}
- !type:DestroyEntity {}
conditions:
- !type:EntityAnchored
anchored: false
steps:
- tool: Welding
doAfter: 2
32 changes: 25 additions & 7 deletions Resources/Prototypes/Recipes/Construction/furniture.yml
Original file line number Diff line number Diff line change
Expand Up @@ -596,6 +596,24 @@
- !type:TileNotBlocked

#bathroom
- type: construction
name: shower
id: Shower
graph: Shower
startNode: start
targetNode: shower
category: construction-category-furniture
description: A shower, complete with bluespace water.
icon:
sprite: Structures/Furniture/shower.rsi
state: shower
objectType: Structure
placementMode: SnapgridCenter
canRotate: true
canBuildInImpassable: false
conditions:
- !type:TileNotBlocked

- type: construction
name: toilet
id: ToiletEmpty
Expand Down Expand Up @@ -732,7 +750,7 @@
objectType: Structure
placementMode: SnapgridCenter
canBuildInImpassable: true

- type: construction
id: CurtainsBlack
name: black curtains
Expand Down Expand Up @@ -762,7 +780,7 @@
objectType: Structure
placementMode: SnapgridCenter
canBuildInImpassable: true

- type: construction
id: CurtainsCyan
name: cyan curtains
Expand All @@ -777,7 +795,7 @@
objectType: Structure
placementMode: SnapgridCenter
canBuildInImpassable: true

- type: construction
id: CurtainsGreen
name: green curtains
Expand All @@ -792,7 +810,7 @@
objectType: Structure
placementMode: SnapgridCenter
canBuildInImpassable: true

- type: construction
id: CurtainsOrange
name: orange curtains
Expand All @@ -807,7 +825,7 @@
objectType: Structure
placementMode: SnapgridCenter
canBuildInImpassable: true

- type: construction
id: CurtainsPink
name: pink curtains
Expand All @@ -822,7 +840,7 @@
objectType: Structure
placementMode: SnapgridCenter
canBuildInImpassable: true

- type: construction
id: CurtainsPurple
name: purple curtains
Expand All @@ -837,7 +855,7 @@
objectType: Structure
placementMode: SnapgridCenter
canBuildInImpassable: true

- type: construction
id: CurtainsRed
name: red curtains
Expand Down
25 changes: 25 additions & 0 deletions Resources/Textures/Structures/Furniture/shower.rsi/meta.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"version": 1,
"license": "CC-BY-SA-3.0",
"copyright": "Made by Dakodragon, DiscordID: 56038550335922176",
"size": {
"x": 32,
"y": 32
},
"states": [
{
"name": "shower",
"directions": 4
},
{
"name": "shower_on",
"directions": 4,
"delays": [
[ 0.3, 0.3, 0.3 ],
[ 0.3, 0.3, 0.3 ],
[ 0.3, 0.3, 0.3 ],
[ 0.3, 0.3, 0.3 ]
]
}
]
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 376b8f1

Please sign in to comment.