Medical items sound support + sounds (#6871)

This commit is contained in:
Leeroy
2022-02-27 10:02:00 +03:00
committed by GitHub
parent fc667f8f44
commit fb858ab514
10 changed files with 65 additions and 10 deletions

View File

@@ -1,6 +1,7 @@
using System.Threading;
using Content.Shared.Damage;
using Content.Shared.Damage.Prototypes;
using Content.Shared.Sound;
using Robust.Shared.GameObjects;
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
@@ -42,5 +43,17 @@ namespace Content.Server.Medical.Components
public float Delay = 3f;
public CancellationTokenSource? CancelToken = null;
/// <summary>
/// Sound played on healing begin
/// </summary>
[DataField("healingBeginSound")]
public SoundSpecifier? HealingBeginSound = null;
/// <summary>
/// Sound played on healing end
/// </summary>
[DataField("healingEndSound")]
public SoundSpecifier? HealingEndSound = null;
}
}

View File

@@ -4,12 +4,13 @@ using Content.Server.Body.Systems;
using Content.Server.DoAfter;
using Content.Server.Medical.Components;
using Content.Server.Stack;
using Content.Shared.ActionBlocker;
using Content.Shared.Audio;
using Content.Shared.Damage;
using Content.Shared.Database;
using Content.Shared.Interaction;
using Content.Shared.Interaction.Helpers;
using Content.Shared.Stacks;
using Robust.Shared.Audio;
using Robust.Shared.Player;
namespace Content.Server.Medical;
@@ -56,6 +57,11 @@ public sealed class HealingSystem : EntitySystem
_logs.Add(LogType.Healed, $"{EntityManager.ToPrettyString(args.User):user} healed {EntityManager.ToPrettyString(uid):target} for {healed.Total:damage} damage");
else
_logs.Add(LogType.Healed, $"{EntityManager.ToPrettyString(args.User):user} healed themselves for {healed.Total:damage} damage");
if (args.Component.HealingEndSound != null)
{
SoundSystem.Play(Filter.Pvs(uid, entityManager:EntityManager), args.Component.HealingEndSound.GetSound(), uid, AudioHelpers.WithVariation(0.125f).WithVolume(-5f));
}
}
private static void OnHealingCancelled(HealingCancelledEvent ev)
@@ -68,7 +74,7 @@ public sealed class HealingSystem : EntitySystem
if (args.Handled) return;
args.Handled = true;
Heal(args.User, args.User, component);
Heal(uid, args.User, args.User, component);
}
private void OnHealingAfterInteract(EntityUid uid, HealingComponent component, AfterInteractEvent args)
@@ -76,10 +82,10 @@ public sealed class HealingSystem : EntitySystem
if (args.Handled || !args.CanReach || args.Target == null) return;
args.Handled = true;
Heal(args.User, args.Target.Value, component);
Heal(uid, args.User, args.Target.Value, component);
}
private void Heal(EntityUid user, EntityUid target, HealingComponent component)
private void Heal(EntityUid uid, EntityUid user, EntityUid target, HealingComponent component)
{
if (component.CancelToken != null)
{
@@ -105,6 +111,11 @@ public sealed class HealingSystem : EntitySystem
component.CancelToken = new CancellationTokenSource();
if (component.HealingBeginSound != null)
{
SoundSystem.Play(Filter.Pvs(uid, entityManager:EntityManager), component.HealingBeginSound.GetSound(), uid, AudioHelpers.WithVariation(0.125f).WithVolume(-5f));
}
_doAfter.DoAfter(new DoAfterEventArgs(user, component.Delay, component.CancelToken.Token, target)
{
BreakOnUserMove = true,

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,10 @@
The following sounds were used from freesound:
herbertboland - heavyskirtmovement.wav - CC BY 3.0
vinrax - cloth-sounds.mp3 - CC BY-NC 3.0
lordvanye - skintouching.wav - CC0 1.0
Additional sound effects from https://www.zapsplat.com
foley-cloth-denim-rip-003.mp3 -
zapsplat_food_bottle_golden_syrup_cap_open_then_close.mp3

Binary file not shown.

Binary file not shown.

View File

@@ -1,23 +1,36 @@
- type: entity
parent: BaseItem
id: BaseHealingItem
abstract: true
components:
- type: Sprite
sprite: Objects/Specific/Medical/medical.rsi
- type: Item
sprite: Objects/Specific/Medical/medical.rsi
HeldPrefix: ointment
- type: entity
name: ointment
description: Used to treat those nasty burns.
parent: BaseItem
parent: BaseHealingItem
id: Ointment
components:
- type: Tag
tags:
- Ointment
- type: Sprite
sprite: Objects/Specific/Medical/medical.rsi
state: ointment
- type: Item
sprite: Objects/Specific/Medical/medical.rsi
HeldPrefix: ointment
- type: Healing
damageContainer: Biological
damage:
groups:
Burn: -10 # 5 for each type in the group
healingBeginSound:
path: "/Audio/Items/Medical/ointment_begin.ogg"
healingEndSound:
path: "/Audio/Items/Medical/ointment_end.ogg"
- type: Stack
stackType: Ointment
max: 5
@@ -26,7 +39,7 @@
- type: entity
name: bruise pack
description: A therapeutic gel pack and bandages designed to treat blunt-force trauma.
parent: Ointment
parent: BaseHealingItem
id: Brutepack
components:
- type: Tag
@@ -40,13 +53,17 @@
groups:
Brute: -15 # 5 for each type in the group
bloodlossModifier: -3 # a little bit of bloodloss healing.
healingBeginSound:
path: "/Audio/Items/Medical/brutepack_begin.ogg"
healingEndSound:
path: "/Audio/Items/Medical/brutepack_end.ogg"
- type: Stack
stackType: Brutepack
- type: entity
name: roll of gauze
description: Some sterile gauze to wrap around bloody stumps.
parent: Ointment
parent: BaseHealingItem
id: Gauze
components:
- type: Tag
@@ -61,6 +78,10 @@
Slash: -2.5
Piercing: -2.5
bloodlossModifier: -10
healingBeginSound:
path: "/Audio/Items/Medical/brutepack_begin.ogg"
healingEndSound:
path: "/Audio/Items/Medical/brutepack_end.ogg"
- type: Stack
stackType: Gauze