-using System.Linq;
-using Content.Server.Disposal.Unit.Components;
using Content.Server.Disposal.Unit.EntitySystems;
-using Content.Shared.Construction.Components;
-using Content.Shared.Popups;
+using Content.Shared.Damage;
using Robust.Shared.Audio;
using Robust.Shared.Containers;
-namespace Content.Server.Disposal.Tube.Components
+namespace Content.Server.Disposal.Tube.Components;
+
+[RegisterComponent]
+[Access(typeof(DisposalTubeSystem), typeof(DisposableSystem))]
+public sealed partial class DisposalTubeComponent : Component
{
- [RegisterComponent]
- [Access(typeof(DisposalTubeSystem), typeof(DisposableSystem))]
- public sealed partial class DisposalTubeComponent : Component
- {
- [DataField("containerId")] public string ContainerId { get; set; } = "DisposalTube";
+ [DataField]
+ public string ContainerId = "DisposalTube";
- public static readonly TimeSpan ClangDelay = TimeSpan.FromSeconds(0.5);
- public TimeSpan LastClang;
+ [ViewVariables]
+ public bool Connected;
- public bool Connected;
- [DataField("clangSound")] public SoundSpecifier ClangSound = new SoundPathSpecifier("/Audio/Effects/clang.ogg");
+ [DataField]
+ public SoundSpecifier ClangSound = new SoundPathSpecifier("/Audio/Effects/clang.ogg");
- /// <summary>
- /// Container of entities that are currently inside this tube
- /// </summary>
- [ViewVariables]
- [Access(typeof(DisposalTubeSystem), typeof(DisposableSystem))]
- public Container Contents { get; set; } = default!;
- }
+ /// <summary>
+ /// Container of entities that are currently inside this tube
+ /// </summary>
+ [ViewVariables]
+ public Container Contents = default!;
+
+ /// <summary>
+ /// Damage dealt to containing entities on every turn
+ /// </summary>
+ [DataField, ViewVariables(VVAccess.ReadWrite)]
+ public DamageSpecifier DamageOnTurn = new()
+ {
+ DamageDict = new()
+ {
+ { "Blunt", 1.0 },
+ }
+ };
}
using Content.Server.Disposal.Tube.Components;
using Content.Server.Disposal.Unit.Components;
using Content.Shared.Body.Components;
-using Content.Shared.Disposal.Components;
+using Content.Shared.Damage;
using Content.Shared.Item;
-using JetBrains.Annotations;
+using Robust.Server.GameObjects;
+using Robust.Shared.Audio;
using Robust.Shared.Containers;
-using Robust.Shared.Map;
+using Robust.Shared.Map.Components;
using Robust.Shared.Physics.Components;
using Robust.Shared.Physics.Systems;
{
public sealed class DisposableSystem : EntitySystem
{
- [Dependency] private readonly IMapManager _mapManager = default!;
- [Dependency] private readonly DisposalUnitSystem _disposalUnitSystem = default!;
- [Dependency] private readonly DisposalTubeSystem _disposalTubeSystem = default!;
- [Dependency] private readonly AtmosphereSystem _atmosphereSystem = default!;
- [Dependency] private readonly SharedPhysicsSystem _physicsSystem = default!;
- [Dependency] private readonly SharedContainerSystem _containerSystem = default!;
- [Dependency] private readonly SharedTransformSystem _xformSystem = default!;
+ [Dependency] private readonly DisposalUnitSystem _disposalUnit = default!;
+ [Dependency] private readonly DisposalTubeSystem _disposalTube = default!;
+ [Dependency] private readonly AtmosphereSystem _atmosphere = default!;
+ [Dependency] private readonly SharedPhysicsSystem _physics = default!;
+ [Dependency] private readonly SharedContainerSystem _container = default!;
+ [Dependency] private readonly SharedTransformSystem _transform = default!;
+ [Dependency] private readonly MapSystem _map = default!;
+ [Dependency] private readonly DamageableSystem _damageable = default!;
+ [Dependency] private readonly SharedAudioSystem _audio = default!;
public override void Initialize()
{
private void OnComponentStartup(EntityUid uid, DisposalHolderComponent holder, ComponentStartup args)
{
- holder.Container = _containerSystem.EnsureContainer<Container>(uid, nameof(DisposalHolderComponent));
+ holder.Container = _container.EnsureContainer<Container>(uid, nameof(DisposalHolderComponent));
}
public bool TryInsert(EntityUid uid, EntityUid toInsert, DisposalHolderComponent? holder = null)
return false;
if (TryComp<PhysicsComponent>(toInsert, out var physBody))
- _physicsSystem.SetCanCollide(toInsert, false, body: physBody);
+ _physics.SetCanCollide(toInsert, false, body: physBody);
return true;
}
if (!Resolve(uid, ref holder))
return false;
- if (!_containerSystem.CanInsert(toInsert, holder.Container))
+ if (!_container.CanInsert(toInsert, holder.Container))
{
return false;
}
EntityUid? disposalId = null;
DisposalUnitComponent? duc = null;
- if (_mapManager.TryGetGrid(holderTransform.GridUid, out var grid))
+ var gridUid = holderTransform.GridUid;
+ if (TryComp<MapGridComponent>(gridUid, out var grid))
{
- foreach (var contentUid in grid.GetLocal(holderTransform.Coordinates))
+ var ducQuery = GetEntityQuery<DisposalUnitComponent>();
+ foreach (var contentUid in _map.GetLocal(gridUid.Value, grid, holderTransform.Coordinates))
{
- if (EntityManager.TryGetComponent(contentUid, out duc))
+ if (ducQuery.TryGetComponent(contentUid, out duc))
{
disposalId = contentUid;
break;
}
}
+ var physQuery = GetEntityQuery<PhysicsComponent>();
+ var metaQuery = GetEntityQuery<MetaDataComponent>();
+ var transformQuery = GetEntityQuery<TransformComponent>();
foreach (var entity in holder.Container.ContainedEntities.ToArray())
{
RemComp<BeingDisposedComponent>(entity);
- var meta = MetaData(entity);
+ var meta = metaQuery.GetComponent(entity);
holder.Container.Remove(entity, EntityManager, meta: meta, reparent: false, force: true);
- var xform = Transform(entity);
+ var xform = transformQuery.GetComponent(entity);
if (xform.ParentUid != uid)
continue;
if (duc != null)
duc.Container.Insert(entity, EntityManager, xform, meta: meta);
else
- _xformSystem.AttachToGridOrMap(entity, xform);
+ _transform.AttachToGridOrMap(entity, xform);
- if (EntityManager.TryGetComponent(entity, out PhysicsComponent? physics))
+ if (physQuery.TryGetComponent(entity, out var physics))
{
- _physicsSystem.WakeBody(entity, body: physics);
+ _physics.WakeBody(entity, body: physics);
}
}
if (disposalId != null && duc != null)
{
- _disposalUnitSystem.TryEjectContents(disposalId.Value, duc);
+ _disposalUnit.TryEjectContents(disposalId.Value, duc);
}
- if (_atmosphereSystem.GetContainingMixture(uid, false, true) is { } environment)
+ if (_atmosphere.GetContainingMixture(uid, false, true) is { } environment)
{
- _atmosphereSystem.Merge(environment, holder.Air);
+ _atmosphere.Merge(environment, holder.Air);
holder.Air.Clear();
}
ExitDisposals(holderUid, holder, holderTransform);
return false;
}
+
+ // damage entities on turns and play sound
+ if (holder.CurrentDirection != holder.PreviousDirection)
+ {
+ foreach (var ent in holder.Container.ContainedEntities)
+ {
+ _damageable.TryChangeDamage(ent, to.DamageOnTurn);
+ }
+ _audio.PlayPvs(to.ClangSound, toUid, AudioParams.Default.WithVolume(-5f));
+ }
+
return true;
}
var newPosition = destination * progress;
// This is some supreme shit code.
- _xformSystem.SetCoordinates(uid, origin.Offset(newPosition).WithEntityId(currentTube));
+ _transform.SetCoordinates(uid, origin.Offset(newPosition).WithEntityId(currentTube));
continue;
}
Comp<DisposalTubeComponent>(currentTube).Contents.Remove(uid, reparent: false, force: true);
// Find next tube
- var nextTube = _disposalTubeSystem.NextTubeFor(currentTube, holder.CurrentDirection);
+ var nextTube = _disposalTube.NextTubeFor(currentTube, holder.CurrentDirection);
if (!EntityManager.EntityExists(nextTube))
{
ExitDisposals(uid, holder);