Skip to content

Commit

Permalink
Xenowears
Browse files Browse the repository at this point in the history
  • Loading branch information
FoxxoTrystan committed Jul 6, 2024
1 parent a6073ef commit d75250d
Show file tree
Hide file tree
Showing 32 changed files with 364 additions and 2 deletions.
35 changes: 35 additions & 0 deletions Content.Shared/Clothing/Components/EmitsSoundOnMoveComponent.cs
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
{
[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;
}
99 changes: 99 additions & 0 deletions Content.Shared/Clothing/EntitySystems/EmitsSoundOnMoveSystem.cs
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
{
[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;

// Space does not transmit sound
if (xform.GridUid == null)
return;

if (component.RequiresGravity && _gravity.IsWeightless(uid, physics, xform))
return;

var parent = xform.ParentUid;

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
Expand Up @@ -4,6 +4,7 @@

petting-success-generic = You pet {THE($target)} on {POSS-ADJ($target)} head.
petting-success-soft-floofy = You pet {THE($target)} on {POSS-ADJ($target)} soft floofy head.
petting-success-generic-others = { CAPITALIZE(THE($user)) } pets {THE($target)}.
petting-success-bingus = You pet {THE($target)} on {POSS-ADJ($target)} wrinkly little head.
petting-success-bird = You pet {THE($target)} on {POSS-ADJ($target)} cute feathery head.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
ClothingShoesColorOrange: 2
ClothingShoesColorRed: 2
ClothingShoesColorPurple: 2
ClothingsClothwarp: 4
ClothingHeadHatGreysoft: 8
ClothingHeadHatMimesoft: 3
ClothingHeadHatBluesoft: 2
Expand Down Expand Up @@ -111,6 +112,8 @@
ClothingHandsGlovesColorOrange: 2
ClothingHandsGlovesColorPurple: 2
ClothingEyesGlassesCheapSunglasses: 3
ClothingNeckOldMantle: 2
ClothingNeckUnathiMantle: 2
contrabandInventory:
ClothingMaskNeckGaiter: 2
ClothingUniformJumpsuitTacticool: 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@
ClothingShoesBootsCowboyBlack: 1
ClothingShoesBootsCowboyWhite: 1
ClothingMaskNeckGaiterRed: 2
ClothingNeckBellCollar: 2
ClothingOuterUnathiRobe: 1
emaggedInventory:
ClothingShoesBling: 1
ClothingShoesBootsCowboyFancy: 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
- type: CombatMode
- type: InteractionPopup
successChance: 1
interactSuccessString: hugging-success-generic
interactSuccessString: petting-success-generic
interactSuccessSound: /Audio/Effects/thudswoosh.ogg
messagePerceivedByOthers: hugging-success-generic-others
messagePerceivedByOthers: petting-success-generic-others
- type: MindContainer
showExamineInfo: true
- type: Input
Expand Down
22 changes: 22 additions & 0 deletions Resources/Prototypes/Entities/Clothing/Neck/mantles.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,3 +74,25 @@
sprite: Clothing/Neck/mantles/qmmantle.rsi
- type: Clothing
sprite: Clothing/Neck/mantles/qmmantle.rsi

- type: entity
parent: ClothingNeckBase
id: ClothingNeckOldMantle
name: old wrap
description: A tattered fabric wrap, faded over the years. Smells faintly of cigars.
components:
- type: Sprite
sprite: Clothing/Neck/Mantles/oldmantle.rsi
- type: Clothing
sprite: Clothing/Neck/Mantles/oldmantle.rsi

- type: entity
parent: ClothingNeckBase
id: ClothingNeckUnathiMantle
name: hide mantle
description: A rather grisly selection of cured hides and skin, sewn together to form a ragged mantle.
components:
- type: Sprite
sprite: Clothing/Neck/Mantles/unathimantle.rsi
- type: Clothing
sprite: Clothing/Neck/Mantles/unathimantle.rsi
14 changes: 14 additions & 0 deletions Resources/Prototypes/Entities/Clothing/Neck/misc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,3 +93,17 @@
- type: Construction
graph: flowerwreath
node: flowerwreath

- type: entity
parent: ClothingNeckBase
id: ClothingNeckBellCollar
name: bell collar
description: A way to inform others about your presence, or just to annoy everyone around you!
components:
- type: Sprite
sprite: Clothing/Neck/Misc/bellcollar.rsi
- type: Clothing
sprite: Clothing/Neck/Misc/bellcollar.rsi
- type: EmitsSoundOnMove
soundCollection:
collection: FootstepJester
11 changes: 11 additions & 0 deletions Resources/Prototypes/Entities/Clothing/OuterClothing/misc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -377,3 +377,14 @@
sprite: Clothing/OuterClothing/Misc/red_racoon.rsi
- type: Clothing
sprite: Clothing/OuterClothing/Misc/red_racoon.rsi

- type: entity
parent: ClothingOuterBase
id: ClothingOuterUnathiRobe
name: roughspun robes
description: A traditional Unathi garment.
components:
- type: Sprite
sprite: Clothing/OuterClothing/Misc/unathirobe.rsi
- type: Clothing
sprite: Clothing/OuterClothing/Misc/unathirobe.rsi
38 changes: 38 additions & 0 deletions Resources/Prototypes/Entities/Clothing/clothwarps.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
- type: entity
parent: Clothing
id: ClothingsClothwarp
name: clothwarps
description: A roll of treated canvas used for wrapping claws or paws.
components:
- type: Item
size: Small
storedRotation: -90
- type: Sprite
state: icon
sprite: Clothing/Shoes/Misc/clothwarp.rsi
- type: Clothing
slots:
- gloves
- FEET
sprite: Clothing/Shoes/Misc/clothwarp.rsi
- type: Construction
graph: ClothingsClothwarp
node: shoes
- type: Butcherable
butcheringType: Knife
spawned:
- id: MaterialCloth1
amount: 1
- type: Food
requiresSpecialDigestion: true
- type: SolutionContainerManager
solutions:
food:
maxVol: 10
reagents:
- ReagentId: Fiber
Quantity: 10
- type: Tag
tags:
- ClothMade
- WhitelistChameleon
24 changes: 24 additions & 0 deletions Resources/Prototypes/Loadouts/neck.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,30 @@
items:
- ClothingNeckScarfStripedZebra

- type: loadout
id: LoadoutNeckBellCollar
category: Neck
cost: 1
exclusive: true
items:
- ClothingNeckBellCollar

- type: loadout
id: LoadoutNeckOldMantle
category: Neck
cost: 1
exclusive: true
items:
- ClothingNeckOldMantle

- type: loadout
id: LoadoutNeckUnathiMantle
category: Neck
cost: 1
exclusive: true
items:
- ClothingNeckUnathiMantle

#Pride Accessories
- type: loadout
id: LoadoutItemsPrideLGBTPin
Expand Down
8 changes: 8 additions & 0 deletions Resources/Prototypes/Loadouts/shoes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -164,3 +164,11 @@
exclusive: true
items:
- ClothingShoesMiscWhite

- type: loadout
id: LoadoutShoesClothwarp
category: Shoes
cost: 1
exclusive: true
items:
- ClothingsClothwarp
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
- type: constructionGraph
id: ClothingsClothwarp
start: start
graph:
- node: start
edges:
- to: warps
steps:
- material: Cloth
amount: 2
doAfter: 1
- node: warps
entity: ClothingsClothwarp
11 changes: 11 additions & 0 deletions Resources/Prototypes/Recipes/Construction/clothing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,3 +96,14 @@
description: Comfy, yet haunted by the ghosts of ducks you fed bread to as a child.
icon: { sprite: Clothing/Shoes/Misc/duck-slippers.rsi, state: icon }
objectType: Item

- type: construction
name: clothwarps
id: ClothingsClothwarp
graph: ClothingsClothwarp
startNode: start
targetNode: warps
category: construction-category-clothing
description: A roll of treated canvas used for wrapping claws or paws.
icon: { sprite: Clothing/Shoes/Misc/clothwarp.rsi, state: icon }
objectType: Item
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.
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.
26 changes: 26 additions & 0 deletions Resources/Textures/Clothing/Neck/Misc/bellcollar.rsi/meta.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"version": 1,
"license": "CC-BY-SA-3.0",
"copyright": "Made by mnemotechnician (GitHub, Frontier) for Frontier Station 14",
"size": {
"x": 32,
"y": 32
},
"states": [
{
"name": "icon"
},
{
"name": "equipped-NECK",
"directions": 4
},
{
"name": "inhand-left",
"directions": 4
},
{
"name": "inhand-right",
"directions": 4
}
]
}
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.
18 changes: 18 additions & 0 deletions Resources/Textures/Clothing/Neck/mantles/oldmantle.rsi/meta.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"version": 1,
"license": "CC-BY-SA-3.0",
"copyright": "Taken from https://github.com/ParadiseSS13/Paradise",
"size": {
"x": 32,
"y": 32
},
"states": [
{
"name": "icon"
},
{
"name": "equipped-OUTERCLOTHING",
"directions": 4
}
]
}
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.
Loading

0 comments on commit d75250d

Please sign in to comment.