Skip to content

Commit

Permalink
[Fix] Mass Bug Fix (#130)
Browse files Browse the repository at this point in the history
* 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
- space-wizards/space-station-14#28084
- space-wizards/space-station-14#28282
- Actually fixed PirateRadioSpawnRule heisentest (with a bandaid) (I
cancel if it's 0)
- Simple-Station/Einstein-Engines#1263

---

# Changelog

<!--
You can add an author after the `:cl:` to change the name that appears
in the changelog (ex: `:cl: Death`)
Leaving it blank will default to your GitHub display name
This includes all available types for the changelog
-->

:cl:
- 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 <[email protected]>
(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: space-wizards/RobustToolbox@a4ea5a4

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 <[email protected]>
(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 <[email protected]>
Co-authored-by: SimpleStation Changelogs <[email protected]>
Co-authored-by: Pieter-Jan Briers <[email protected]>
Co-authored-by: themias <[email protected]>
  • Loading branch information
5 people authored Nov 24, 2024
1 parent ec0cbe6 commit 2fd69f5
Show file tree
Hide file tree
Showing 42 changed files with 428 additions and 358 deletions.
2 changes: 1 addition & 1 deletion Content.Client/Arcade/BlockGameMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ private Control SetupGameGrid(Texture panelTex)
{
PanelOverride = back,
HorizontalExpand = true,
SizeFlagsStretchRatio = 60
SizeFlagsStretchRatio = 34.25f
};
var backgroundPanel = new PanelContainer
{
Expand Down
49 changes: 33 additions & 16 deletions Content.Client/Buckle/BuckleSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,41 @@ public override void Initialize()
{
base.Initialize();

SubscribeLocalEvent<BuckleComponent, ComponentHandleState>(OnHandleState);
SubscribeLocalEvent<BuckleComponent, AppearanceChangeEvent>(OnAppearanceChange);
SubscribeLocalEvent<StrapComponent, MoveEvent>(OnStrapMoveEvent);
SubscribeLocalEvent<BuckleComponent, BuckledEvent>(OnBuckledEvent);
SubscribeLocalEvent<BuckleComponent, UnbuckledEvent>(OnUnbuckledEvent);
}

/// <summary>
/// Is the strap entity already rotated north? Lower the draw depth of the buckled entity.
/// </summary>
private void OnBuckledEvent(Entity<BuckleComponent> ent, ref BuckledEvent args)
{
if (!TryComp<SpriteComponent>(args.Strap, out var strapSprite) ||
!TryComp<SpriteComponent>(ent.Owner, out var buckledSprite))
return;

if (Transform(args.Strap.Owner).LocalRotation.GetCardinalDir() == Direction.North)
{
ent.Comp.OriginalDrawDepth ??= buckledSprite.DrawDepth;
buckledSprite.DrawDepth = strapSprite.DrawDepth - 1;
}
}

/// <summary>
/// Was the draw depth of the buckled entity lowered? Reset it upon unbuckling.
/// </summary>
private void OnUnbuckledEvent(Entity<BuckleComponent> ent, ref UnbuckledEvent args)
{
if (!TryComp<SpriteComponent>(ent.Owner, out var buckledSprite))
return;

if (ent.Comp.OriginalDrawDepth.HasValue)
{
buckledSprite.DrawDepth = ent.Comp.OriginalDrawDepth.Value;
ent.Comp.OriginalDrawDepth = null;
}
}

private void OnStrapMoveEvent(EntityUid uid, StrapComponent component, ref MoveEvent args)
Expand Down Expand Up @@ -57,21 +89,6 @@ private void OnStrapMoveEvent(EntityUid uid, StrapComponent component, ref MoveE
}
}

private void OnHandleState(Entity<BuckleComponent> ent, ref ComponentHandleState args)
{
if (args.Current is not BuckleState state)
return;

ent.Comp.DontCollide = state.DontCollide;
ent.Comp.BuckleTime = state.BuckleTime;
var strapUid = EnsureEntity<BuckleComponent>(state.BuckledTo, ent);

SetBuckledTo(ent, strapUid == null ? null : new (strapUid.Value, null));

var (uid, component) = ent;

}

private void OnAppearanceChange(EntityUid uid, BuckleComponent component, ref AppearanceChangeEvent args)
{
if (!TryComp<RotationVisualsComponent>(uid, out var rotVisuals)
Expand Down
3 changes: 3 additions & 0 deletions Content.Client/Jittering/JitteringSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ private void OnAnimationCompleted(EntityUid uid, JitteringComponent jittering, A
if(args.Key != _jitterAnimationKey)
return;

if (!args.Finished)
return;

if (TryComp(uid, out AnimationPlayerComponent? animationPlayer)
&& TryComp(uid, out SpriteComponent? sprite))
_animationPlayer.Play(uid, animationPlayer, GetAnimation(jittering, sprite), _jitterAnimationKey);
Expand Down
3 changes: 3 additions & 0 deletions Content.Client/Light/EntitySystems/LightBehaviorSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ public override void Initialize()

private void OnBehaviorAnimationCompleted(EntityUid uid, LightBehaviourComponent component, AnimationCompletedEvent args)
{
if (!args.Finished)
return;

var container = component.Animations.FirstOrDefault(x => x.FullKey == args.Key);

if (container == null)
Expand Down
3 changes: 3 additions & 0 deletions Content.Client/Light/EntitySystems/RotatingLightSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ private void OnAfterAutoHandleState(EntityUid uid, RotatingLightComponent comp,

private void OnAnimationComplete(EntityUid uid, RotatingLightComponent comp, AnimationCompletedEvent args)
{
if (!args.Finished)
return;

PlayAnimation(uid, comp);
}

Expand Down
4 changes: 2 additions & 2 deletions Content.Client/Salvage/UI/SalvageMagnetBoundUserInterface.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ public SalvageMagnetBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner
protected override void Open()
{
base.Open();
_window = new OfferingWindow();

_window = this.CreateWindow<OfferingWindow>(); // WD EDIT
_window.Title = Loc.GetString("salvage-magnet-window-title");
_window.OnClose += Close;
_window.OpenCenteredLeft();
}

Expand Down
37 changes: 6 additions & 31 deletions Content.Client/_White/Animations/WaddleAnimationSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,7 @@ public sealed class WaddleAnimationSystem : SharedWaddleAnimationSystem

public override void Initialize()
{
SubscribeLocalEvent<WaddleAnimationComponent, AnimationCompletedEvent>(OnAnimationCompleted);

SubscribeAllEvent<StartedWaddlingEvent>(ev => PlayAnimation(GetEntity(ev.User)));
SubscribeAllEvent<StoppedWaddlingEvent>(ev => StopAnimation(GetEntity(ev.User)));
}

protected override void PlayAnimation(EntityUid uid)
Expand All @@ -40,7 +37,6 @@ protected override void PlayAnimation(EntityUid uid)
var len = mover.Sprinting ? component.AnimationLength * component.RunAnimationLengthMultiplier : component.AnimationLength;

component.LastStep = !component.LastStep;
component.IsCurrentlyWaddling = true;

var animation = new Animation()
{
Expand All @@ -54,9 +50,9 @@ protected override void PlayAnimation(EntityUid uid)
InterpolationMode = AnimationInterpolationMode.Linear,
KeyFrames =
{
new AnimationTrackProperty.KeyFrame(Angle.FromDegrees(0), 0),
new AnimationTrackProperty.KeyFrame(Angle.FromDegrees(tumbleIntensity), len/3),
new AnimationTrackProperty.KeyFrame(Angle.FromDegrees(0), len/3),
new(Angle.FromDegrees(0), 0),
new(Angle.FromDegrees(tumbleIntensity), len/3),
new(Angle.FromDegrees(0), len/3),
}
},
new AnimationTrackComponentProperty()
Expand All @@ -66,35 +62,14 @@ protected override void PlayAnimation(EntityUid uid)
InterpolationMode = AnimationInterpolationMode.Linear,
KeyFrames =
{
new AnimationTrackProperty.KeyFrame(new Vector2(), 0),
new AnimationTrackProperty.KeyFrame(component.HopIntensity, len/3),
new AnimationTrackProperty.KeyFrame(new Vector2(), len/3),
new(new Vector2(), 0),
new(component.HopIntensity, len/3),
new(new Vector2(), len/3),
}
}
}
};

_animation.Play(uid, animation, component.KeyName);
}

protected override void StopAnimation(EntityUid uid)
{
if (!TryComp<WaddleAnimationComponent>(uid, out var component)
|| !TryComp<SpriteComponent>(uid, out var sprite))
return;

_animation.Stop(uid, component.KeyName);

sprite.Offset = new Vector2();
sprite.Rotation = Angle.FromDegrees(0);
component.IsCurrentlyWaddling = false;
}

private void OnAnimationCompleted(EntityUid uid, WaddleAnimationComponent component, AnimationCompletedEvent args)
{
if (args.Key != component.KeyName)
return;

PlayAnimation(uid);
}
}
4 changes: 2 additions & 2 deletions Content.Server/Arcade/BlockGame/BlockGame.Ui.cs
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ private void InputTick(float frameTime)
/// <param name="message">The message to broadcase to all players/spectators.</param>
private void SendMessage(BoundUserInterfaceMessage message)
{
_uiSystem.ServerSendUiMessage(_entityManager.GetEntity(message.Entity), BlockGameUiKey.Key, message);
_uiSystem.ServerSendUiMessage(_owner, BlockGameUiKey.Key, message);
}

/// <summary>
Expand All @@ -167,7 +167,7 @@ private void SendMessage(BoundUserInterfaceMessage message)
/// <param name="actor">The target recipient.</param>
private void SendMessage(BoundUserInterfaceMessage message, EntityUid actor)
{
_uiSystem.ServerSendUiMessage(_entityManager.GetEntity(message.Entity), BlockGameUiKey.Key, message, actor);
_uiSystem.ServerSendUiMessage(_owner, BlockGameUiKey.Key, message, actor);
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public sealed partial class WelderRefinableComponent : Component
public float RefineTime = 2f;

[DataField]
public float RefineFuel;
public float RefineFuel = 1f; // WD EDIT

[DataField]
public ProtoId<ToolQualityPrototype> QualityNeeded = "Welding";
Expand Down
3 changes: 2 additions & 1 deletion Content.Server/Disposal/Tube/DisposalTubeSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -340,14 +340,15 @@ private void UpdateAnchored(EntityUid uid, DisposalTubeComponent component, bool
{
if (!Resolve(target, ref targetTube))
return null;

var oppositeDirection = nextDirection.GetOpposite();

var xform = Transform(target);
if (!TryComp<MapGridComponent>(xform.GridUid, out var grid))
return null;

var position = xform.Coordinates;
var entities = _mapSystem.GetInDir(target, grid, position, nextDirection);
var entities = _mapSystem.GetInDir((EntityUid) xform.GridUid, grid, position, nextDirection);

foreach (var entity in entities)
{
Expand Down
15 changes: 6 additions & 9 deletions Content.Server/Disposal/Unit/EntitySystems/DisposableSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,13 @@ public void ExitDisposals(EntityUid uid, DisposalHolderComponent? holder = null,

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.
Expand Down Expand Up @@ -164,11 +166,13 @@ public bool EnterTube(EntityUid holderUid, EntityUid toUid, DisposalHolderCompon
{
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);
Expand All @@ -193,6 +197,7 @@ public bool EnterTube(EntityUid holderUid, EntityUid toUid, DisposalHolderCompon
holder.PreviousTube = holder.CurrentTube;
holder.PreviousDirection = holder.CurrentDirection;
}

holder.CurrentTube = toUid;
var ev = new GetDisposalsNextDirectionEvent(holder);
RaiseLocalEvent(toUid, ref ev);
Expand All @@ -212,9 +217,7 @@ public bool EnterTube(EntityUid holderUid, EntityUid toUid, DisposalHolderCompon
if (holder.CurrentDirection != holder.PreviousDirection)
{
foreach (var ent in holder.Container.ContainedEntities)
{
_damageable.TryChangeDamage(ent, to.DamageOnTurn);
}
_audio.PlayPvs(to.ClangSound, toUid);
}

Expand All @@ -225,9 +228,7 @@ 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)
Expand All @@ -236,9 +237,7 @@ private void UpdateComp(EntityUid uid, DisposalHolderComponent holder, float fra
{
var time = frameTime;
if (time > holder.TimeLeft)
{
time = holder.TimeLeft;
}

holder.TimeLeft -= time;
frameTime -= time;
Expand Down Expand Up @@ -268,17 +267,15 @@ private void UpdateComp(EntityUid uid, DisposalHolderComponent holder, float fra

// Find next tube
var nextTube = _disposalTubeSystem.NextTubeFor(currentTube, holder.CurrentDirection);
if (!EntityManager.EntityExists(nextTube))
if (!EntityManager.EntityExists(nextTube))
{
ExitDisposals(uid, holder);
break;
}

// Perform remainder of entry process
if (!EnterTube(uid, nextTube!.Value, holder))
{
break;
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,7 @@ public bool TryFlush(EntityUid uid, SharedDisposalUnitComponent component)
return false;

var coords = xform.Coordinates;
var entry = _sharedMapSystem.GetLocal(uid, grid, coords)
var entry = _sharedMapSystem.GetLocal((EntityUid) xform.GridUid, grid, coords)
.FirstOrDefault(HasComp<DisposalEntryComponent>);

if (entry == default || component is not DisposalUnitComponent sDisposals)
Expand Down
Loading

0 comments on commit 2fd69f5

Please sign in to comment.