Plays rustle sound when inserting or opening a backpack. (#2890)
* SoundCollection * Works * Applied review * Waah * Working * e * Adjust sound collection serialization Co-authored-by: Metal Gear Sloth <metalgearsloth@gmail.com>
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Content.Server.GameObjects.EntitySystems.DoAfter;
|
using Content.Server.GameObjects.EntitySystems.DoAfter;
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
#nullable enable
|
#nullable enable
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Content.Server.GameObjects.Components.GUI;
|
using Content.Server.GameObjects.Components.GUI;
|
||||||
using Content.Server.Interfaces.GameObjects.Components.Items;
|
using Content.Server.Interfaces.GameObjects.Components.Items;
|
||||||
|
using Content.Shared.Audio;
|
||||||
using Content.Shared.GameObjects.Components.Storage;
|
using Content.Shared.GameObjects.Components.Storage;
|
||||||
using Content.Shared.GameObjects.EntitySystems;
|
using Content.Shared.GameObjects.EntitySystems;
|
||||||
using Content.Shared.Interfaces;
|
using Content.Shared.Interfaces;
|
||||||
@@ -13,16 +14,22 @@ using Content.Shared.Utility;
|
|||||||
using Robust.Server.GameObjects;
|
using Robust.Server.GameObjects;
|
||||||
using Robust.Server.GameObjects.Components.Container;
|
using Robust.Server.GameObjects.Components.Container;
|
||||||
using Robust.Server.GameObjects.EntitySystemMessages;
|
using Robust.Server.GameObjects.EntitySystemMessages;
|
||||||
|
using Robust.Server.GameObjects.EntitySystems;
|
||||||
using Robust.Server.Interfaces.Player;
|
using Robust.Server.Interfaces.Player;
|
||||||
using Robust.Server.Player;
|
using Robust.Server.Player;
|
||||||
|
using Robust.Shared.Audio;
|
||||||
using Robust.Shared.Enums;
|
using Robust.Shared.Enums;
|
||||||
using Robust.Shared.GameObjects;
|
using Robust.Shared.GameObjects;
|
||||||
|
using Robust.Shared.GameObjects.Systems;
|
||||||
using Robust.Shared.Interfaces.GameObjects;
|
using Robust.Shared.Interfaces.GameObjects;
|
||||||
using Robust.Shared.Interfaces.Map;
|
using Robust.Shared.Interfaces.Map;
|
||||||
using Robust.Shared.Interfaces.Network;
|
using Robust.Shared.Interfaces.Network;
|
||||||
|
using Robust.Shared.Interfaces.Random;
|
||||||
using Robust.Shared.IoC;
|
using Robust.Shared.IoC;
|
||||||
using Robust.Shared.Log;
|
using Robust.Shared.Log;
|
||||||
using Robust.Shared.Players;
|
using Robust.Shared.Players;
|
||||||
|
using Robust.Shared.Prototypes;
|
||||||
|
using Robust.Shared.Random;
|
||||||
using Robust.Shared.Serialization;
|
using Robust.Shared.Serialization;
|
||||||
using Robust.Shared.ViewVariables;
|
using Robust.Shared.ViewVariables;
|
||||||
|
|
||||||
@@ -46,6 +53,8 @@ namespace Content.Server.GameObjects.Components.Items.Storage
|
|||||||
private int _storageCapacityMax;
|
private int _storageCapacityMax;
|
||||||
public readonly HashSet<IPlayerSession> SubscribedSessions = new();
|
public readonly HashSet<IPlayerSession> SubscribedSessions = new();
|
||||||
|
|
||||||
|
public string? StorageSoundCollection { get; set; }
|
||||||
|
|
||||||
[ViewVariables]
|
[ViewVariables]
|
||||||
public override IReadOnlyList<IEntity>? StoredEntities => _storage?.ContainedEntities;
|
public override IReadOnlyList<IEntity>? StoredEntities => _storage?.ContainedEntities;
|
||||||
|
|
||||||
@@ -135,6 +144,7 @@ namespace Content.Server.GameObjects.Components.Items.Storage
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PlaySoundCollection(StorageSoundCollection);
|
||||||
EnsureInitialCalculated();
|
EnsureInitialCalculated();
|
||||||
|
|
||||||
Logger.DebugS(LoggerName, $"Storage (UID {Owner.Uid}) had entity (UID {message.Entity.Uid}) inserted into it.");
|
Logger.DebugS(LoggerName, $"Storage (UID {Owner.Uid}) had entity (UID {message.Entity.Uid}) inserted into it.");
|
||||||
@@ -207,6 +217,7 @@ namespace Content.Server.GameObjects.Components.Items.Storage
|
|||||||
/// <param name="entity">The entity to open the UI for</param>
|
/// <param name="entity">The entity to open the UI for</param>
|
||||||
public void OpenStorageUI(IEntity entity)
|
public void OpenStorageUI(IEntity entity)
|
||||||
{
|
{
|
||||||
|
PlaySoundCollection(StorageSoundCollection);
|
||||||
EnsureInitialCalculated();
|
EnsureInitialCalculated();
|
||||||
|
|
||||||
var userSession = entity.GetComponent<BasicActorComponent>().playerSession;
|
var userSession = entity.GetComponent<BasicActorComponent>().playerSession;
|
||||||
@@ -331,6 +342,7 @@ namespace Content.Server.GameObjects.Components.Items.Storage
|
|||||||
|
|
||||||
serializer.DataField(ref _storageCapacityMax, "capacity", 10000);
|
serializer.DataField(ref _storageCapacityMax, "capacity", 10000);
|
||||||
serializer.DataField(ref _occludesLight, "occludesLight", true);
|
serializer.DataField(ref _occludesLight, "occludesLight", true);
|
||||||
|
serializer.DataField(this, x => x.StorageSoundCollection, "storageSoundCollection", string.Empty);
|
||||||
//serializer.DataField(ref StorageUsed, "used", 0);
|
//serializer.DataField(ref StorageUsed, "used", 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -494,5 +506,17 @@ namespace Content.Server.GameObjects.Components.Items.Storage
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void PlaySoundCollection(string? name)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(name))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var file = AudioHelpers.GetRandomFileFromSoundCollection(name);
|
||||||
|
EntitySystem.Get<AudioSystem>()
|
||||||
|
.PlayFromEntity(file, Owner, AudioParams.Default);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
BIN
Resources/Audio/Effects/rustle1.ogg
Normal file
BIN
Resources/Audio/Effects/rustle1.ogg
Normal file
Binary file not shown.
BIN
Resources/Audio/Effects/rustle2.ogg
Normal file
BIN
Resources/Audio/Effects/rustle2.ogg
Normal file
Binary file not shown.
BIN
Resources/Audio/Effects/rustle3.ogg
Normal file
BIN
Resources/Audio/Effects/rustle3.ogg
Normal file
Binary file not shown.
BIN
Resources/Audio/Effects/rustle4.ogg
Normal file
BIN
Resources/Audio/Effects/rustle4.ogg
Normal file
Binary file not shown.
BIN
Resources/Audio/Effects/rustle5.ogg
Normal file
BIN
Resources/Audio/Effects/rustle5.ogg
Normal file
Binary file not shown.
@@ -15,6 +15,7 @@
|
|||||||
sprite: Clothing/Back/Backpacks/backpack.rsi
|
sprite: Clothing/Back/Backpacks/backpack.rsi
|
||||||
- type: Storage
|
- type: Storage
|
||||||
capacity: 100
|
capacity: 100
|
||||||
|
storageSoundCollection : storageRustle
|
||||||
|
|
||||||
- type: entity
|
- type: entity
|
||||||
parent: ClothingBackpack
|
parent: ClothingBackpack
|
||||||
|
|||||||
@@ -15,7 +15,8 @@
|
|||||||
- back
|
- back
|
||||||
- type: Storage
|
- type: Storage
|
||||||
capacity: 100
|
capacity: 100
|
||||||
|
storageSoundCollection : storageRustle
|
||||||
|
|
||||||
- type: entity
|
- type: entity
|
||||||
parent: ClothingBackpackDuffel
|
parent: ClothingBackpackDuffel
|
||||||
id: ClothingBackpackDuffelEngineering
|
id: ClothingBackpackDuffelEngineering
|
||||||
|
|||||||
@@ -15,7 +15,8 @@
|
|||||||
sprite: Clothing/Back/Satchels/satchel.rsi
|
sprite: Clothing/Back/Satchels/satchel.rsi
|
||||||
- type: Storage
|
- type: Storage
|
||||||
capacity: 100
|
capacity: 100
|
||||||
|
storageSoundCollection : storageRustle
|
||||||
|
|
||||||
- type: entity
|
- type: entity
|
||||||
parent: ClothingBackpackSatchel
|
parent: ClothingBackpackSatchel
|
||||||
id: ClothingBackpackSatchelEngineering
|
id: ClothingBackpackSatchelEngineering
|
||||||
|
|||||||
8
Resources/Prototypes/SoundCollections/storage_rustle.yml
Normal file
8
Resources/Prototypes/SoundCollections/storage_rustle.yml
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
- type: soundCollection
|
||||||
|
id: storageRustle
|
||||||
|
files:
|
||||||
|
- /Audio/Effects/rustle1.ogg
|
||||||
|
- /Audio/Effects/rustle2.ogg
|
||||||
|
- /Audio/Effects/rustle3.ogg
|
||||||
|
- /Audio/Effects/rustle4.ogg
|
||||||
|
- /Audio/Effects/rustle5.ogg
|
||||||
Reference in New Issue
Block a user