-
Notifications
You must be signed in to change notification settings - Fork 451
Xenowears #519
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Xenowears #519
Changes from 14 commits
d75250d
e80c764
cc5414f
a8524d7
8ab671c
28e345b
a603b30
1371b09
fc018e5
cd0bf23
6784da1
8c03e4b
719bb42
55403e7
fde7559
706ba96
bbe1ae7
019d300
37a3022
bc27467
042bb45
7e2b6dd
bd8e17f
00136a8
61c52b6
fe2e4c1
991a5f4
50aba46
657ef43
de92a82
5e1ceb2
2909755
8e25fb2
674d92e
6789498
c83e991
830a142
cb629b8
c9d15d9
a6dffca
5113905
a2d944f
adb58d8
5df91d5
dd5aabe
f9431e1
18617ff
41067af
4b95e1f
0cce9cd
dea0aaf
7e62550
34c5e0f
5e35d63
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| using Robust.Shared.Audio; | ||
| using Robust.Shared.GameStates; | ||
| using Robust.Shared.Map; | ||
|
|
||
| namespace Content.Shared.Clothing.Components; | ||
|
|
||
| /// <summary> | ||
| /// Indicates that the clothing entity emits sound when it moves. | ||
| /// </summary> | ||
| [RegisterComponent, NetworkedComponent, AutoGenerateComponentState] | ||
| public sealed partial class EmitsSoundOnMoveComponent : Component | ||
|
ShadesMars marked this conversation as resolved.
|
||
| { | ||
| [ViewVariables(VVAccess.ReadWrite)] | ||
| [DataField(required: true), AutoNetworkedField] | ||
| public SoundSpecifier SoundCollection = default!; | ||
|
|
||
| [ViewVariables(VVAccess.ReadWrite)] | ||
| [DataField("requiresGravity"), AutoNetworkedField] | ||
| public bool RequiresGravity = true; | ||
|
|
||
| [ViewVariables(VVAccess.ReadOnly)] | ||
| public EntityCoordinates LastPosition = EntityCoordinates.Invalid; | ||
|
|
||
| /// <summary> | ||
| /// The distance moved since the played sound. | ||
| /// </summary> | ||
| [ViewVariables(VVAccess.ReadOnly)] | ||
| public float SoundDistance = 0f; | ||
|
|
||
| /// <summary> | ||
| /// Whether this item is equipped in a inventory item slot. | ||
| /// </summary> | ||
| [ViewVariables(VVAccess.ReadOnly)] | ||
| public bool IsSlotValid = true; | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,99 @@ | ||
| using System.Numerics; | ||
| using Content.Shared.Clothing.Components; | ||
| using Content.Shared.Gravity; | ||
| using Content.Shared.Inventory; | ||
| using Content.Shared.Inventory.Events; | ||
| using Content.Shared.Mobs.Components; | ||
| using Content.Shared.Movement.Components; | ||
| using Robust.Shared.Audio.Systems; | ||
| using Robust.Shared.Physics.Components; | ||
| using Robust.Shared.Timing; | ||
|
|
||
| namespace Content.Shared.Clothing.Systems; | ||
|
|
||
| public sealed class EmitsSoundOnMoveSystem : EntitySystem | ||
|
ShadesMars marked this conversation as resolved.
|
||
| { | ||
| [Dependency] private readonly SharedAudioSystem _audio = default!; | ||
| [Dependency] private readonly SharedMapSystem _grid = default!; | ||
| [Dependency] private readonly SharedGravitySystem _gravity = default!; | ||
| [Dependency] private readonly IGameTiming _timing = default!; | ||
|
|
||
| private EntityQuery<InputMoverComponent> _moverQuery; | ||
| private EntityQuery<PhysicsComponent> _physicsQuery; | ||
| private EntityQuery<TransformComponent> _xformQuery; | ||
| private EntityQuery<ClothingComponent> _clothingQuery; | ||
|
|
||
| public override void Initialize() | ||
| { | ||
| _moverQuery = GetEntityQuery<InputMoverComponent>(); | ||
| _physicsQuery = GetEntityQuery<PhysicsComponent>(); | ||
| _xformQuery = GetEntityQuery<TransformComponent>(); | ||
| _clothingQuery = GetEntityQuery<ClothingComponent>(); | ||
|
|
||
| SubscribeLocalEvent<EmitsSoundOnMoveComponent, GotEquippedEvent>(OnEquipped); | ||
| SubscribeLocalEvent<EmitsSoundOnMoveComponent, GotUnequippedEvent>(OnUnequipped); | ||
| } | ||
|
|
||
| private void OnEquipped(EntityUid uid, EmitsSoundOnMoveComponent component, GotEquippedEvent args) | ||
| { | ||
| component.IsSlotValid = !args.SlotFlags.HasFlag(SlotFlags.POCKET); | ||
| } | ||
|
|
||
| private void OnUnequipped(EntityUid uid, EmitsSoundOnMoveComponent component, GotUnequippedEvent args) | ||
| { | ||
| component.IsSlotValid = true; | ||
| } | ||
|
|
||
| public override void Update(float frameTime) | ||
| { | ||
| var query = EntityQueryEnumerator<EmitsSoundOnMoveComponent>(); | ||
| while (query.MoveNext(out var uid, out var comp)) | ||
| { | ||
| UpdateSound(uid, comp); | ||
| } | ||
| query.Dispose(); | ||
| } | ||
|
|
||
| private void UpdateSound(EntityUid uid, EmitsSoundOnMoveComponent component) | ||
| { | ||
| if (!_xformQuery.TryGetComponent(uid, out var xform) || | ||
| !_physicsQuery.TryGetComponent(uid, out var physics)) | ||
| return; | ||
|
|
||
|
ShadesMars marked this conversation as resolved.
|
||
| // Space does not transmit sound | ||
| if (xform.GridUid == null) | ||
| return; | ||
|
ShadesMars marked this conversation as resolved.
Outdated
|
||
|
|
||
| if (component.RequiresGravity && _gravity.IsWeightless(uid, physics, xform)) | ||
| return; | ||
|
|
||
| var parent = xform.ParentUid; | ||
|
ShadesMars marked this conversation as resolved.
Outdated
|
||
|
|
||
| var isWorn = parent is { Valid: true } && | ||
| _clothingQuery.TryGetComponent(uid, out var clothing) | ||
| && clothing.InSlot != null | ||
| && component.IsSlotValid; | ||
| // If this entity is worn by another entity, use that entity's coordinates | ||
| var coordinates = isWorn ? Transform(parent).Coordinates : xform.Coordinates; | ||
| var distanceNeeded = (isWorn && _moverQuery.TryGetComponent(parent, out var mover) && mover.Sprinting) | ||
| ? 1.5f // The parent is a mob that is currently sprinting | ||
| : 2f; // The parent is not a mob or is not sprinting | ||
|
|
||
| if (!coordinates.TryDistance(EntityManager, component.LastPosition, out var distance) || distance > distanceNeeded) | ||
| component.SoundDistance = distanceNeeded; | ||
| else | ||
| component.SoundDistance += distance; | ||
|
|
||
| component.LastPosition = coordinates; | ||
| if (component.SoundDistance < distanceNeeded) | ||
| return; | ||
| component.SoundDistance -= distanceNeeded; | ||
|
|
||
| var sound = component.SoundCollection; | ||
| var audioParams = sound.Params | ||
| .WithVolume(sound.Params.Volume) | ||
| .WithVariation(sound.Params.Variation ?? 0f); | ||
|
|
||
| _audio.PlayPredicted(sound, uid, uid, audioParams); | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -102,14 +102,6 @@ marking-VulpTailTip-vulp = Vulpkanin tail (base) | |
| marking-VulpTailTip-vulp-tip = Vulpkanin tail (tip) | ||
| marking-VulpTailTip = Vulpkanin (tip) | ||
|
|
||
| marking-VulpTailWag-vulp_wag = Vulpkanin tail (base) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This removes a lot of existing markings, but does not provide a db migration. This can lead to unexpected errors at runtime.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It shouldn't |
||
| marking-VulpTailWag-vulp_wag-fade = Vulpkanin tail (fade) | ||
| marking-VulpTailWag = Vulpkanin (wag) | ||
|
|
||
| marking-VulpTailWagTip-vulp_wag = Vulpkanin tail (base) | ||
| marking-VulpTailWagTip-vulp_wag-tip = Vulpkanin tail (tip) | ||
| marking-VulpTailWagTip = Vulpkanin (wag, tip) | ||
|
|
||
| marking-VulpTailAlt-vulp_alt = Vulpkanin tail (base) | ||
| marking-VulpTailAlt-vulp_alt-fade = Vulpkanin tail (fade) | ||
| marking-VulpTailAlt = Vulpkanin (alt) | ||
|
|
@@ -130,29 +122,12 @@ marking-VulpTailFoxTip-fox = Fox tail (base) | |
| marking-VulpTailFoxTip-fox-tip = Fox tail (fade) | ||
| marking-VulpTailFoxTip = Vulpkanin Fox (tip) | ||
|
|
||
| marking-VulpTailFoxWag-fox_wag = Fox tail (base) | ||
| marking-VulpTailFoxWag-fox_wag-fade = Fox tail (fade) | ||
| marking-VulpTailFoxWag = Vulpkanin Fox (wag) | ||
|
|
||
| marking-VulpTailFoxWagTip-fox_wag = Fox tail (base) | ||
| marking-VulpTailFoxWagTip-fox_wag-tip = Fox tail (tip) | ||
| marking-VulpTailFoxWagTip = Vulpkanin Fox (wag, tip) | ||
|
|
||
| marking-VulpTailBushy-bushfluff = Bush tail | ||
| marking-VulpTailBushy = Vulpkanin Bush | ||
|
|
||
| marking-VulpTailBushyWag-bushfluff_wag = Bush tail | ||
| marking-VulpTailBushyWag = Vulpkanin Bush (wag) | ||
|
|
||
| marking-VulpTailCoyote-coyote = Coyote tail | ||
| marking-VulpTailCoyote = Vulpkanin Coyote | ||
|
|
||
| marking-VulpTailCoyoteWag-coyote_wag = Coyote tail | ||
| marking-VulpTailCoyoteWag = Vulpkanin Coyote (wag) | ||
|
|
||
| marking-VulpTailCorgiWag-corgi_wag = Crogi tail | ||
| marking-VulpTailCorgiWag = Vulpkanin Corgi (wag) | ||
|
|
||
| marking-VulpTailHusky-husky-inner = Husky tail (inner) | ||
| marking-VulpTailHusky-husky-outer = Husky tail (outer) | ||
| marking-VulpTailHusky = Vulpkanin Husky | ||
|
|
@@ -176,8 +151,11 @@ marking-VulpTailOtie = Vulpkanin Otie | |
| marking-VulpTailFluffy-fluffy = Fluffy tail | ||
| marking-VulpTailFluffy = Vulpkanin Fluffy | ||
|
|
||
| marking-VulpTailDalmatianWag-dalmatian_wag = Dalmatian tail | ||
| marking-VulpTailDalmatianWag = Vulpkanin Dalmatian (wag) | ||
| marking-VulpTailCorgi-corgi = Crogi tail | ||
| marking-VulpTailCorgi = Vulpkanin Corgi | ||
|
|
||
| marking-VulpTailDalmatian-dalmatian = Dalmatian tail | ||
| marking-VulpTailDalmatian = Vulpkanin Dalmatian | ||
|
|
||
|
|
||
| marking-VulpBellyCrest-belly_crest = Belly | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -280,32 +280,32 @@ | |
| state: vulp-fade | ||
|
|
||
| - type: marking | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As above, tail changes go into a separate PR |
||
| id: VulpTailTip | ||
| id: VulpTailAnimated | ||
| bodyPart: Tail | ||
| markingCategory: Tail | ||
| speciesRestriction: [Vulpkanin] | ||
| speciesRestriction: [] | ||
| sprites: | ||
| - sprite: DeltaV/Mobs/Customization/Vulpkanin/tail_markings.rsi | ||
| state: vulp | ||
| state: vulp_wag | ||
| - sprite: DeltaV/Mobs/Customization/Vulpkanin/tail_markings.rsi | ||
| state: vulp-tip | ||
| state: vulp_wag-tip #fade | ||
|
|
||
| - type: marking | ||
| id: VulpTailWag | ||
| id: VulpTailTip | ||
| bodyPart: Tail | ||
| markingCategory: Tail | ||
| speciesRestriction: [Vulpkanin] | ||
| sprites: | ||
| - sprite: DeltaV/Mobs/Customization/Vulpkanin/tail_markings.rsi | ||
| state: vulp_wag | ||
| state: vulp | ||
| - sprite: DeltaV/Mobs/Customization/Vulpkanin/tail_markings.rsi | ||
| state: vulp_wag-tip #fade | ||
| state: vulp-tip | ||
|
|
||
| - type: marking | ||
| id: VulpTailWagTip | ||
| id: VulpTailTipAnimated | ||
| bodyPart: Tail | ||
| markingCategory: Tail | ||
| speciesRestriction: [Vulpkanin] | ||
| speciesRestriction: [] | ||
| sprites: | ||
| - sprite: DeltaV/Mobs/Customization/Vulpkanin/tail_markings.rsi | ||
| state: vulp_wag | ||
|
|
@@ -357,32 +357,32 @@ | |
| state: fox-fade | ||
|
|
||
| - type: marking | ||
| id: VulpTailFoxTip | ||
| id: VulpTailFoxAnimated | ||
| bodyPart: Tail | ||
| markingCategory: Tail | ||
| speciesRestriction: [Vulpkanin] | ||
| speciesRestriction: [] | ||
| sprites: | ||
| - sprite: DeltaV/Mobs/Customization/Vulpkanin/tail_markings.rsi | ||
| state: fox | ||
| state: fox_wag | ||
| - sprite: DeltaV/Mobs/Customization/Vulpkanin/tail_markings.rsi | ||
| state: fox-tip | ||
| state: fox_wag-fade | ||
|
|
||
| - type: marking | ||
| id: VulpTailFoxWag | ||
| id: VulpTailFoxTip | ||
| bodyPart: Tail | ||
| markingCategory: Tail | ||
| speciesRestriction: [Vulpkanin] | ||
| sprites: | ||
| - sprite: DeltaV/Mobs/Customization/Vulpkanin/tail_markings.rsi | ||
| state: fox_wag | ||
| state: fox | ||
| - sprite: DeltaV/Mobs/Customization/Vulpkanin/tail_markings.rsi | ||
| state: fox_wag-fade | ||
| state: fox-tip | ||
|
|
||
| - type: marking | ||
| id: VulpTailFoxWagTip | ||
| id: VulpTailFoxTipAnimated | ||
| bodyPart: Tail | ||
| markingCategory: Tail | ||
| speciesRestriction: [Vulpkanin] | ||
| speciesRestriction: [] | ||
| sprites: | ||
| - sprite: DeltaV/Mobs/Customization/Vulpkanin/tail_markings.rsi | ||
| state: fox_wag | ||
|
|
@@ -399,10 +399,10 @@ | |
| state: bushfluff | ||
|
|
||
| - type: marking | ||
| id: VulpTailBushyWag | ||
| id: VulpTailBushyAnimated | ||
| bodyPart: Tail | ||
| markingCategory: Tail | ||
| speciesRestriction: [Vulpkanin] | ||
| speciesRestriction: [] | ||
| sprites: | ||
| - sprite: DeltaV/Mobs/Customization/Vulpkanin/tail_markings.rsi | ||
| state: bushfluff_wag | ||
|
|
@@ -417,19 +417,28 @@ | |
| state: coyote | ||
|
|
||
| - type: marking | ||
| id: VulpTailCoyoteWag | ||
| id: VulpTailCoyoteAnimated | ||
| bodyPart: Tail | ||
| markingCategory: Tail | ||
| speciesRestriction: [Vulpkanin] | ||
| speciesRestriction: [] | ||
| sprites: | ||
| - sprite: DeltaV/Mobs/Customization/Vulpkanin/tail_markings.rsi | ||
| state: coyote_wag | ||
|
|
||
| - type: marking | ||
| id: VulpTailCorgiWag | ||
| id: VulpTailCorgi | ||
| bodyPart: Tail | ||
| markingCategory: Tail | ||
| speciesRestriction: [Vulpkanin] | ||
| sprites: | ||
| - sprite: DeltaV/Mobs/Customization/Vulpkanin/tail_markings.rsi | ||
| state: corgi | ||
|
|
||
| - type: marking | ||
| id: VulpTailCorgiAnimated | ||
| bodyPart: Tail | ||
| markingCategory: Tail | ||
| speciesRestriction: [] | ||
| sprites: | ||
| - sprite: DeltaV/Mobs/Customization/Vulpkanin/tail_markings.rsi | ||
| state: corgi_wag | ||
|
|
@@ -502,10 +511,19 @@ | |
| state: fluffy | ||
|
|
||
| - type: marking | ||
| id: VulpTailDalmatianWag | ||
| id: VulpTailDalmatian | ||
| bodyPart: Tail | ||
| markingCategory: Tail | ||
| speciesRestriction: [Vulpkanin] | ||
| sprites: | ||
| - sprite: DeltaV/Mobs/Customization/Vulpkanin/tail_markings.rsi | ||
| state: dalmatian | ||
|
|
||
| - type: marking | ||
| id: VulpTailDalmatianAnimated | ||
| bodyPart: Tail | ||
| markingCategory: Tail | ||
| speciesRestriction: [] | ||
| sprites: | ||
| - sprite: DeltaV/Mobs/Customization/Vulpkanin/tail_markings.rsi | ||
| state: dalmatian_wag | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.