Prettier window breaking (#2368)
* Put the damage in the windows * add crack overlays * Window cracking * glass related sounds * let's use a valid state * run optipng on these for posterity * Examine damage descriptions * add "Constructible" to dictionary * Downmix stereo effects to mono * breaking and knocking * Add shard etc. sprites * shard inhands * more sprite wrangling * Expand destructiblecomponent drop system + implement it for windows * Shard descriptions * Random sprite component * no nullbabby * Random destroysounds * random offset on destructible drops * fix fucked yaml * sound collections * random pitch for knocking * Localization * hascomponent * better spawnondestroy * missed one
This commit is contained in:
@@ -1,11 +1,15 @@
|
||||
using System.Collections.Generic;
|
||||
using Content.Shared.Audio;
|
||||
using Content.Shared.GameObjects.Components.Damage;
|
||||
using Robust.Server.GameObjects.EntitySystems;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.GameObjects.Systems;
|
||||
using Robust.Shared.Interfaces.GameObjects;
|
||||
using Robust.Shared.Interfaces.Random;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Serialization;
|
||||
using Robust.Shared.ViewVariables;
|
||||
using Logger = Robust.Shared.Log.Logger;
|
||||
|
||||
namespace Content.Server.GameObjects.Components.Damage
|
||||
{
|
||||
@@ -16,12 +20,19 @@ namespace Content.Server.GameObjects.Components.Damage
|
||||
[ComponentReference(typeof(IDamageableComponent))]
|
||||
public abstract class RuinableComponent : DamageableComponent
|
||||
{
|
||||
[Dependency] private IRobustRandom _random = default!;
|
||||
/// <summary>
|
||||
/// Sound played upon destruction.
|
||||
/// </summary>
|
||||
[ViewVariables]
|
||||
protected string DestroySound { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Used instead of <see cref="DestroySound"/> if specified.
|
||||
/// </summary>
|
||||
[ViewVariables]
|
||||
protected string DestroySoundCollection { get; private set; }
|
||||
|
||||
public override List<DamageState> SupportedDamageStates =>
|
||||
new List<DamageState> {DamageState.Alive, DamageState.Dead};
|
||||
|
||||
@@ -44,6 +55,7 @@ namespace Content.Server.GameObjects.Components.Damage
|
||||
() => Thresholds.TryGetValue(DamageState.Dead, out var value) ? value : (int?) null);
|
||||
|
||||
serializer.DataField(this, ruinable => ruinable.DestroySound, "destroySound", string.Empty);
|
||||
serializer.DataField(this, ruinable => ruinable.DestroySoundCollection, "destroySoundCollection", string.Empty);
|
||||
}
|
||||
|
||||
protected override void EnterState(DamageState state)
|
||||
@@ -65,10 +77,24 @@ namespace Content.Server.GameObjects.Components.Damage
|
||||
{
|
||||
CurrentState = DamageState.Dead;
|
||||
|
||||
if (!Owner.Deleted && DestroySound != string.Empty)
|
||||
if (!Owner.Deleted)
|
||||
{
|
||||
var pos = Owner.Transform.Coordinates;
|
||||
EntitySystem.Get<AudioSystem>().PlayAtCoords(DestroySound, pos);
|
||||
string sound = string.Empty;
|
||||
if (DestroySoundCollection != string.Empty)
|
||||
{
|
||||
sound = AudioHelpers.GetRandomFileFromSoundCollection(DestroySoundCollection);
|
||||
|
||||
}
|
||||
else if (DestroySound != string.Empty)
|
||||
{
|
||||
sound = DestroySound;
|
||||
}
|
||||
if (sound != string.Empty)
|
||||
{
|
||||
Logger.Debug("Playing destruction sound");
|
||||
EntitySystem.Get<AudioSystem>().PlayAtCoords(sound, pos, AudioHelpers.WithVariation(0.125f));
|
||||
}
|
||||
}
|
||||
|
||||
DestructionBehavior();
|
||||
|
||||
Reference in New Issue
Block a user