mirror of
https://github.com/WWhiteDreamProject/wwdpublic.git
synced 2026-04-20 23:17:43 +03:00
* Mass Bug Fixing (#1256)
<!--
This is a semi-strict format, you can add/remove sections as needed but
the order/format should be kept the same
Remove these comments before submitting
-->
# Description
<!--
Explain this PR in as much detail as applicable
Some example prompts to consider:
How might this affect the game? The codebase?
What might be some alternatives to this?
How/Who does this benefit/hurt [the game/codebase]?
-->
Mass bug fixing, for bugs related to #1220.
Feel free to link or send bugs.
Fix list:
- #1242
- #1243
- #1244
- https://github.com/space-wizards/space-station-14/pull/28084
- https://github.com/space-wizards/space-station-14/pull/28282
- Actually fixed PirateRadioSpawnRule heisentest (with a bandaid) (I
cancel if it's 0)
- https://github.com/Simple-Station/Einstein-Engines/issues/1263
---
# Changelog
<!--
You can add an author after the `🆑` to change the name that appears
in the changelog (ex: `🆑 Death`)
Leaving it blank will default to your GitHub display name
This includes all available types for the changelog
-->
🆑
- fix: Fixed chair visuals drawing depth wrongly if you sat in a
north-facing chair.
- fix: Fixed buckling doing several buckles each time you did one.
- fix: Fixed the magic mirror.
- fix: Fixed beds re-positioning you every few seconds.
- fix: Fixed E not opening containers that are in another container.
- fix: Fixed disposal systems not flushing or ejecting properly.
---------
Co-authored-by: sleepyyapril <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>
Co-authored-by: Nemanja <98561806+EmoGarbage404@users.noreply.github.com>
(cherry picked from commit 41501bd335c5e1e2e65b5d2ad040a3ae6851d4e8)
* Automatic Changelog Update (#1256)
(cherry picked from commit 9798f5363135cbe71479d0a14cf3215d01ed28f0)
* fix
* Fix animation looping bugs. (#29457)
Summary of the problem is in the corresponding engine commit: a4ea5a4620
This commit requires engine master right now.
I think #29144 is probably the most severe one, but I touched Jittering and RotatingLight too since they seemed sus too.
Fixes #29144
Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
(cherry picked from commit 8d015f5c9ff60107dccdf35fa48e1558728ff269)
* Fix arcade machines (#30376)
(cherry picked from commit e72393df712cb2f5d1b4f6b4e2dc417c5584f07a)
* fix
* fix test
* fix test
* fix test
* fix
---------
Co-authored-by: sleepyyapril <123355664+sleepyyapril@users.noreply.github.com>
Co-authored-by: SimpleStation Changelogs <simplestation14@users.noreply.github.com>
Co-authored-by: Pieter-Jan Briers <pieterjan.briers+git@gmail.com>
Co-authored-by: themias <89101928+themias@users.noreply.github.com>
283 lines
11 KiB
C#
283 lines
11 KiB
C#
using Content.Server.Atmos.EntitySystems;
|
|
using Content.Server.Disposal.Tube;
|
|
using Content.Server.Disposal.Tube.Components;
|
|
using Content.Server.Disposal.Unit.Components;
|
|
using Content.Shared.Body.Components;
|
|
using Content.Shared.Damage;
|
|
using Content.Shared.Item;
|
|
using Content.Shared.Throwing;
|
|
using Robust.Shared.Audio.Systems;
|
|
using Robust.Shared.Containers;
|
|
using Robust.Shared.Map.Components;
|
|
using Robust.Shared.Physics.Components;
|
|
using Robust.Shared.Physics.Systems;
|
|
|
|
namespace Content.Server.Disposal.Unit.EntitySystems
|
|
{
|
|
public sealed class DisposableSystem : EntitySystem
|
|
{
|
|
[Dependency] private readonly ThrowingSystem _throwing = default!;
|
|
[Dependency] private readonly AtmosphereSystem _atmosphereSystem = default!;
|
|
[Dependency] private readonly DamageableSystem _damageable = default!;
|
|
[Dependency] private readonly DisposalUnitSystem _disposalUnitSystem = default!;
|
|
[Dependency] private readonly DisposalTubeSystem _disposalTubeSystem = default!;
|
|
[Dependency] private readonly SharedAudioSystem _audio = default!;
|
|
[Dependency] private readonly SharedContainerSystem _containerSystem = default!;
|
|
[Dependency] private readonly SharedMapSystem _maps = default!;
|
|
[Dependency] private readonly SharedPhysicsSystem _physicsSystem = default!;
|
|
[Dependency] private readonly SharedTransformSystem _xformSystem = default!;
|
|
|
|
private EntityQuery<DisposalTubeComponent> _disposalTubeQuery;
|
|
private EntityQuery<DisposalUnitComponent> _disposalUnitQuery;
|
|
private EntityQuery<MetaDataComponent> _metaQuery;
|
|
private EntityQuery<PhysicsComponent> _physicsQuery;
|
|
private EntityQuery<TransformComponent> _xformQuery;
|
|
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
|
|
_disposalTubeQuery = GetEntityQuery<DisposalTubeComponent>();
|
|
_disposalUnitQuery = GetEntityQuery<DisposalUnitComponent>();
|
|
_metaQuery = GetEntityQuery<MetaDataComponent>();
|
|
_physicsQuery = GetEntityQuery<PhysicsComponent>();
|
|
_xformQuery = GetEntityQuery<TransformComponent>();
|
|
|
|
SubscribeLocalEvent<DisposalHolderComponent, ComponentStartup>(OnComponentStartup);
|
|
}
|
|
|
|
private void OnComponentStartup(EntityUid uid, DisposalHolderComponent holder, ComponentStartup args)
|
|
{
|
|
holder.Container = _containerSystem.EnsureContainer<Container>(uid, nameof(DisposalHolderComponent));
|
|
}
|
|
|
|
public bool TryInsert(EntityUid uid, EntityUid toInsert, DisposalHolderComponent? holder = null)
|
|
{
|
|
if (!Resolve(uid, ref holder))
|
|
return false;
|
|
if (!CanInsert(uid, toInsert, holder))
|
|
return false;
|
|
|
|
if (!_containerSystem.Insert(toInsert, holder.Container))
|
|
return false;
|
|
|
|
if (_physicsQuery.TryGetComponent(toInsert, out var physBody))
|
|
_physicsSystem.SetCanCollide(toInsert, false, body: physBody);
|
|
|
|
return true;
|
|
}
|
|
|
|
private bool CanInsert(EntityUid uid, EntityUid toInsert, DisposalHolderComponent? holder = null)
|
|
{
|
|
if (!Resolve(uid, ref holder))
|
|
return false;
|
|
|
|
if (!_containerSystem.CanInsert(toInsert, holder.Container))
|
|
{
|
|
return false;
|
|
}
|
|
|
|
return HasComp<ItemComponent>(toInsert) ||
|
|
HasComp<BodyComponent>(toInsert);
|
|
}
|
|
|
|
public void ExitDisposals(EntityUid uid, DisposalHolderComponent? holder = null, TransformComponent? holderTransform = null)
|
|
{
|
|
if (Terminating(uid))
|
|
return;
|
|
|
|
if (!Resolve(uid, ref holder, ref holderTransform))
|
|
return;
|
|
|
|
if (holder.IsExitingDisposals)
|
|
{
|
|
Log.Error("Tried exiting disposals twice. This should never happen.");
|
|
return;
|
|
}
|
|
|
|
holder.IsExitingDisposals = true;
|
|
|
|
// Check for a disposal unit to throw them into and then eject them from it.
|
|
// *This ejection also makes the target not collide with the unit.*
|
|
// *This is on purpose.*
|
|
|
|
EntityUid? disposalId = null;
|
|
DisposalUnitComponent? duc = null;
|
|
var gridUid = holderTransform.GridUid;
|
|
if (TryComp<MapGridComponent>(gridUid, out var grid))
|
|
{
|
|
foreach (var contentUid in _maps.GetLocal(gridUid.Value, grid, holderTransform.Coordinates))
|
|
{
|
|
if (_disposalUnitQuery.TryGetComponent(contentUid, out duc))
|
|
{
|
|
disposalId = contentUid;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
// We're purposely iterating over all the holder's children
|
|
// because the holder might have something teleported into it,
|
|
// outside the usual container insertion logic.
|
|
var children = holderTransform.ChildEnumerator;
|
|
while (children.MoveNext(out var entity))
|
|
{
|
|
RemComp<BeingDisposedComponent>(entity);
|
|
|
|
var meta = _metaQuery.GetComponent(entity);
|
|
if (holder.Container.Contains(entity))
|
|
_containerSystem.Remove((entity, null, meta), holder.Container, reparent: false, force: true);
|
|
|
|
var xform = _xformQuery.GetComponent(entity);
|
|
if (xform.ParentUid != uid)
|
|
continue;
|
|
|
|
if (duc != null)
|
|
_containerSystem.Insert((entity, xform, meta), duc.Container);
|
|
else
|
|
{
|
|
_xformSystem.AttachToGridOrMap(entity, xform);
|
|
|
|
if (holder.PreviousDirection != Direction.Invalid && _xformQuery.TryGetComponent(xform.ParentUid, out var parentXform))
|
|
{
|
|
var direction = holder.PreviousDirection.ToAngle();
|
|
direction += _xformSystem.GetWorldRotation(parentXform);
|
|
_throwing.TryThrow(entity, direction.ToWorldVec() * 3f, 10f);
|
|
}
|
|
}
|
|
}
|
|
|
|
if (disposalId != null && duc != null)
|
|
{
|
|
_disposalUnitSystem.TryEjectContents(disposalId.Value, duc);
|
|
}
|
|
|
|
if (_atmosphereSystem.GetContainingMixture(uid, false, true) is { } environment)
|
|
{
|
|
_atmosphereSystem.Merge(environment, holder.Air);
|
|
holder.Air.Clear();
|
|
}
|
|
|
|
EntityManager.DeleteEntity(uid);
|
|
}
|
|
|
|
// Note: This function will cause an ExitDisposals on any failure that does not make an ExitDisposals impossible.
|
|
public bool EnterTube(EntityUid holderUid, EntityUid toUid, DisposalHolderComponent? holder = null, TransformComponent? holderTransform = null, DisposalTubeComponent? to = null, TransformComponent? toTransform = null)
|
|
{
|
|
if (!Resolve(holderUid, ref holder, ref holderTransform))
|
|
return false;
|
|
|
|
if (holder.IsExitingDisposals)
|
|
{
|
|
Log.Error("Tried entering tube after exiting disposals. This should never happen.");
|
|
return false;
|
|
}
|
|
|
|
if (!Resolve(toUid, ref to, ref toTransform))
|
|
{
|
|
ExitDisposals(holderUid, holder, holderTransform);
|
|
return false;
|
|
}
|
|
|
|
foreach (var ent in holder.Container.ContainedEntities)
|
|
{
|
|
var comp = EnsureComp<BeingDisposedComponent>(ent);
|
|
comp.Holder = holderUid;
|
|
}
|
|
|
|
// Insert into next tube
|
|
if (!_containerSystem.Insert(holderUid, to.Contents))
|
|
{
|
|
ExitDisposals(holderUid, holder, holderTransform);
|
|
return false;
|
|
}
|
|
|
|
if (holder.CurrentTube != null)
|
|
{
|
|
holder.PreviousTube = holder.CurrentTube;
|
|
holder.PreviousDirection = holder.CurrentDirection;
|
|
}
|
|
|
|
holder.CurrentTube = toUid;
|
|
var ev = new GetDisposalsNextDirectionEvent(holder);
|
|
RaiseLocalEvent(toUid, ref ev);
|
|
holder.CurrentDirection = ev.Next;
|
|
holder.StartingTime = 0.1f;
|
|
holder.TimeLeft = 0.1f;
|
|
// Logger.InfoS("c.s.disposal.holder", $"Disposals dir {holder.CurrentDirection}");
|
|
|
|
// Invalid direction = exit now!
|
|
if (holder.CurrentDirection == Direction.Invalid)
|
|
{
|
|
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);
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
public override void Update(float frameTime)
|
|
{
|
|
var query = EntityQueryEnumerator<DisposalHolderComponent>();
|
|
while (query.MoveNext(out var uid, out var holder))
|
|
UpdateComp(uid, holder, frameTime);
|
|
}
|
|
|
|
private void UpdateComp(EntityUid uid, DisposalHolderComponent holder, float frameTime)
|
|
{
|
|
while (frameTime > 0)
|
|
{
|
|
var time = frameTime;
|
|
if (time > holder.TimeLeft)
|
|
time = holder.TimeLeft;
|
|
|
|
holder.TimeLeft -= time;
|
|
frameTime -= time;
|
|
|
|
if (!EntityManager.EntityExists(holder.CurrentTube))
|
|
{
|
|
ExitDisposals(uid, holder);
|
|
break;
|
|
}
|
|
|
|
var currentTube = holder.CurrentTube!.Value;
|
|
if (holder.TimeLeft > 0)
|
|
{
|
|
var progress = 1 - holder.TimeLeft / holder.StartingTime;
|
|
var origin = _xformQuery.GetComponent(currentTube).Coordinates;
|
|
var destination = holder.CurrentDirection.ToVec();
|
|
var newPosition = destination * progress;
|
|
|
|
// This is some supreme shit code.
|
|
_xformSystem.SetCoordinates(uid, origin.Offset(newPosition).WithEntityId(currentTube));
|
|
continue;
|
|
}
|
|
|
|
// Past this point, we are performing inter-tube transfer!
|
|
// Remove current tube content
|
|
_containerSystem.Remove(uid, _disposalTubeQuery.GetComponent(currentTube).Contents, reparent: false, force: true);
|
|
|
|
// Find next tube
|
|
var nextTube = _disposalTubeSystem.NextTubeFor(currentTube, holder.CurrentDirection);
|
|
if (!EntityManager.EntityExists(nextTube))
|
|
{
|
|
ExitDisposals(uid, holder);
|
|
break;
|
|
}
|
|
|
|
// Perform remainder of entry process
|
|
if (!EnterTube(uid, nextTube!.Value, holder))
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|