removed TryGetSound + made some SoundSpecifier datafields required
This commit is contained in:
@@ -17,7 +17,7 @@ namespace Content.Server.Storage.Components
|
||||
[RegisterComponent]
|
||||
public class CursedEntityStorageComponent : EntityStorageComponent
|
||||
{
|
||||
[Dependency] private readonly IRobustRandom _robustRandom = default!;
|
||||
[Dependency] private readonly IRobustRandom _robustRandom = default!;
|
||||
|
||||
public override string Name => "CursedEntityStorage";
|
||||
|
||||
@@ -42,7 +42,7 @@ namespace Content.Server.Storage.Components
|
||||
|
||||
var locker = lockerEnt.GetComponent<EntityStorageComponent>();
|
||||
|
||||
if(locker.Open)
|
||||
if (locker.Open)
|
||||
locker.TryCloseStorage(Owner);
|
||||
|
||||
foreach (var entity in Contents.ContainedEntities.ToArray())
|
||||
@@ -51,10 +51,8 @@ namespace Content.Server.Storage.Components
|
||||
locker.Insert(entity);
|
||||
}
|
||||
|
||||
if(_cursedSound.TryGetSound(out var cursedSound))
|
||||
SoundSystem.Play(Filter.Pvs(Owner), cursedSound, Owner, AudioHelpers.WithVariation(0.125f));
|
||||
if(_cursedLockerSound.TryGetSound(out var cursedLockerSound))
|
||||
SoundSystem.Play(Filter.Pvs(lockerEnt), cursedLockerSound, lockerEnt, AudioHelpers.WithVariation(0.125f));
|
||||
SoundSystem.Play(Filter.Pvs(Owner), _cursedSound.GetSound(), Owner, AudioHelpers.WithVariation(0.125f));
|
||||
SoundSystem.Play(Filter.Pvs(lockerEnt), _cursedLockerSound.GetSound(), lockerEnt, AudioHelpers.WithVariation(0.125f));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -226,8 +226,7 @@ namespace Content.Server.Storage.Components
|
||||
}
|
||||
|
||||
ModifyComponents();
|
||||
if(_closeSound.TryGetSound(out var closeSound))
|
||||
SoundSystem.Play(Filter.Pvs(Owner), closeSound, Owner);
|
||||
SoundSystem.Play(Filter.Pvs(Owner), _closeSound.GetSound(), Owner);
|
||||
_lastInternalOpenAttempt = default;
|
||||
}
|
||||
|
||||
@@ -236,8 +235,7 @@ namespace Content.Server.Storage.Components
|
||||
Open = true;
|
||||
EmptyContents();
|
||||
ModifyComponents();
|
||||
if(_openSound.TryGetSound(out var openSound))
|
||||
SoundSystem.Play(Filter.Pvs(Owner), openSound, Owner);
|
||||
SoundSystem.Play(Filter.Pvs(Owner), _openSound.GetSound(), Owner);
|
||||
}
|
||||
|
||||
private void UpdateAppearance()
|
||||
|
||||
@@ -1,18 +1,11 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Content.Server.DoAfter;
|
||||
using Content.Server.Hands.Components;
|
||||
using Content.Server.Items;
|
||||
using Content.Server.Placeable;
|
||||
using Content.Shared.Acts;
|
||||
using Content.Shared.Audio;
|
||||
using Content.Shared.Interaction;
|
||||
using Content.Shared.Interaction.Helpers;
|
||||
using Content.Shared.Item;
|
||||
using Content.Shared.Notification;
|
||||
using Content.Shared.Notification.Managers;
|
||||
using Content.Shared.Sound;
|
||||
using Content.Shared.Storage;
|
||||
@@ -31,6 +24,11 @@ using Robust.Shared.Player;
|
||||
using Robust.Shared.Players;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
using Robust.Shared.ViewVariables;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Content.Server.Storage.Components
|
||||
{
|
||||
@@ -66,7 +64,7 @@ namespace Content.Server.Storage.Components
|
||||
public readonly HashSet<IPlayerSession> SubscribedSessions = new();
|
||||
|
||||
[DataField("storageSoundCollection")]
|
||||
public SoundSpecifier StorageSoundCollection { get; set; } = default!;
|
||||
public SoundSpecifier StorageSoundCollection { get; set; } = new SoundCollectionSpecifier("storageRustle");
|
||||
|
||||
[ViewVariables]
|
||||
public override IReadOnlyList<IEntity>? StoredEntities => _storage?.ContainedEntities;
|
||||
@@ -389,79 +387,79 @@ namespace Content.Server.Storage.Components
|
||||
switch (message)
|
||||
{
|
||||
case RemoveEntityMessage remove:
|
||||
{
|
||||
EnsureInitialCalculated();
|
||||
|
||||
var player = session.AttachedEntity;
|
||||
|
||||
if (player == null)
|
||||
{
|
||||
EnsureInitialCalculated();
|
||||
|
||||
var player = session.AttachedEntity;
|
||||
|
||||
if (player == null)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
var ownerTransform = Owner.Transform;
|
||||
var playerTransform = player.Transform;
|
||||
|
||||
if (!playerTransform.Coordinates.InRange(Owner.EntityManager, ownerTransform.Coordinates, 2) ||
|
||||
!ownerTransform.IsMapTransform &&
|
||||
!playerTransform.ContainsEntity(ownerTransform))
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
var entity = Owner.EntityManager.GetEntity(remove.EntityUid);
|
||||
|
||||
if (entity == null || _storage?.Contains(entity) == false)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
var item = entity.GetComponent<ItemComponent>();
|
||||
if (item == null ||
|
||||
!player.TryGetComponent(out HandsComponent? hands))
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
if (!hands.CanPutInHand(item))
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
hands.PutInHand(item);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
var ownerTransform = Owner.Transform;
|
||||
var playerTransform = player.Transform;
|
||||
|
||||
if (!playerTransform.Coordinates.InRange(Owner.EntityManager, ownerTransform.Coordinates, 2) ||
|
||||
!ownerTransform.IsMapTransform &&
|
||||
!playerTransform.ContainsEntity(ownerTransform))
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
var entity = Owner.EntityManager.GetEntity(remove.EntityUid);
|
||||
|
||||
if (entity == null || _storage?.Contains(entity) == false)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
var item = entity.GetComponent<ItemComponent>();
|
||||
if (item == null ||
|
||||
!player.TryGetComponent(out HandsComponent? hands))
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
if (!hands.CanPutInHand(item))
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
hands.PutInHand(item);
|
||||
|
||||
break;
|
||||
}
|
||||
case InsertEntityMessage _:
|
||||
{
|
||||
EnsureInitialCalculated();
|
||||
|
||||
var player = session.AttachedEntity;
|
||||
|
||||
if (player == null)
|
||||
{
|
||||
EnsureInitialCalculated();
|
||||
|
||||
var player = session.AttachedEntity;
|
||||
|
||||
if (player == null)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
if (!player.InRangeUnobstructed(Owner, popup: true))
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
PlayerInsertHeldEntity(player);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
if (!player.InRangeUnobstructed(Owner, popup: true))
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
PlayerInsertHeldEntity(player);
|
||||
|
||||
break;
|
||||
}
|
||||
case CloseStorageUIMessage _:
|
||||
{
|
||||
if (session is not IPlayerSession playerSession)
|
||||
{
|
||||
if (session is not IPlayerSession playerSession)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
UnsubscribeSession(playerSession);
|
||||
break;
|
||||
}
|
||||
|
||||
UnsubscribeSession(playerSession);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -511,7 +509,7 @@ namespace Content.Server.Storage.Components
|
||||
|
||||
// Pick up all entities in a radius around the clicked location.
|
||||
// The last half of the if is because carpets exist and this is terrible
|
||||
if(_areaInsert && (eventArgs.Target == null || !eventArgs.Target.HasComponent<SharedItemComponent>()))
|
||||
if (_areaInsert && (eventArgs.Target == null || !eventArgs.Target.HasComponent<SharedItemComponent>()))
|
||||
{
|
||||
var validStorables = new List<IEntity>();
|
||||
foreach (var entity in IoCManager.Resolve<IEntityLookup>().GetEntitiesInRange(eventArgs.ClickLocation, 1))
|
||||
@@ -556,7 +554,7 @@ namespace Content.Server.Storage.Components
|
||||
}
|
||||
|
||||
// If we picked up atleast one thing, play a sound and do a cool animation!
|
||||
if (successfullyInserted.Count>0)
|
||||
if (successfullyInserted.Count > 0)
|
||||
{
|
||||
PlaySoundCollection();
|
||||
SendNetworkMessage(
|
||||
@@ -569,7 +567,7 @@ namespace Content.Server.Storage.Components
|
||||
return true;
|
||||
}
|
||||
// Pick up the clicked entity
|
||||
else if(_quickInsert)
|
||||
else if (_quickInsert)
|
||||
{
|
||||
if (eventArgs.Target == null
|
||||
|| !eventArgs.Target.Transform.IsMapTransform
|
||||
@@ -577,7 +575,7 @@ namespace Content.Server.Storage.Components
|
||||
|| !eventArgs.Target.HasComponent<SharedItemComponent>())
|
||||
return false;
|
||||
var position = eventArgs.Target.Transform.Coordinates;
|
||||
if(PlayerInsertEntityInWorld(eventArgs.User, eventArgs.Target))
|
||||
if (PlayerInsertEntityInWorld(eventArgs.User, eventArgs.Target))
|
||||
{
|
||||
SendNetworkMessage(new AnimateInsertingEntitiesMessage(
|
||||
new List<EntityUid>() { eventArgs.Target.Uid },
|
||||
@@ -631,9 +629,7 @@ namespace Content.Server.Storage.Components
|
||||
|
||||
private void PlaySoundCollection()
|
||||
{
|
||||
// TODO this doesn't compile or work
|
||||
if(StorageSoundCollection?.TryGetSound(out var sound))
|
||||
SoundSystem.Play(Filter.Pvs(Owner), sound, Owner, AudioParams.Default);
|
||||
SoundSystem.Play(Filter.Pvs(Owner), StorageSoundCollection.GetSound(), Owner, AudioParams.Default);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using Content.Shared.Sound;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
@@ -23,7 +23,7 @@ namespace Content.Server.Storage.Components
|
||||
/// <summary>
|
||||
/// A sound to play when the items are spawned. For example, gift boxes being unwrapped.
|
||||
/// </summary>
|
||||
[DataField("sound")]
|
||||
[DataField("sound", required: true)]
|
||||
public SoundSpecifier? Sound = null;
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user