Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mass Engine Update #1220

Open
wants to merge 41 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
a502d18
Fix silver crate name.
sleepyyapril Nov 14, 2024
6e1533e
Engine update!
sleepyyapril Nov 14, 2024
37ec395
Update submodule to 228.0.0 (#29947)
metalgearsloth Jul 13, 2024
a655da9
FabricateActionEvent use EntProtoId
sleepyyapril Nov 14, 2024
f9b85b3
Wait, few too many versions ahead lmao.
sleepyyapril Nov 14, 2024
a399409
Merge branch 'Simple-Station:master' into engine-update
sleepyyapril Nov 14, 2024
9712601
229.0.0
sleepyyapril Nov 14, 2024
6fc2f07
Merge branch 'engine-update' of https://github.com/sleepyyapril/Einst…
sleepyyapril Nov 14, 2024
10c9179
Wake better
sleepyyapril Nov 14, 2024
2861960
v230.0.0
sleepyyapril Nov 14, 2024
c80b52d
Use EntProtoId
sleepyyapril Nov 14, 2024
80b0d2d
More EntProtoId
sleepyyapril Nov 14, 2024
276d248
v230.2.0
sleepyyapril Nov 14, 2024
1741356
Partial buckling refactor (#29031)
ElectroJr Jun 19, 2024
c89af12
Revert "Partial buckling refactor (#29031)"
sleepyyapril Nov 14, 2024
1b1fb43
Merge branch 'master' into engine-update
sleepyyapril Nov 14, 2024
0133da8
Code cleanup: Dirty(Comp) (#26238)
Tayrtahn Mar 20, 2024
5fd6b68
aaaaaaaaa
VMSolidus Nov 15, 2024
1e0b373
Add StorageInteractionTest (#28541)
ElectroJr Jun 3, 2024
38b8b3f
Fix storage UI interactions (#28291)
ElectroJr May 26, 2024
736538e
Update SharedSingerSystem.cs
ElectroJr Jun 19, 2024
9150547
Alerts Refactor
EmoGarbage404 May 24, 2024
d6d2aeb
Partial buckling refactor (#29031)
ElectroJr Jun 19, 2024
a556466
Fix silliness, need more errors to fix...
sleepyyapril Nov 15, 2024
bee97d1
Fix usage of BuckleChangeEvent
sleepyyapril Nov 15, 2024
68b9755
Use Unbuckled
sleepyyapril Nov 15, 2024
3edbaac
AlertType usage...
sleepyyapril Nov 15, 2024
d2ebd0f
BuckledChangeEvent murder!
sleepyyapril Nov 15, 2024
cc0ce1e
Mood system updates
sleepyyapril Nov 15, 2024
cae442f
Fix yaml
sleepyyapril Nov 15, 2024
238d176
Prevent ghosts from spawning on terminating maps/grids (#28099)
Tayrtahn May 20, 2024
2230a2c
Fix unbuckling others when clicking on the strap entity (#29998)
ShadowCommander Sep 18, 2024
42c62ce
Fix unbuckling others when clicking on the strap entity (#29998)
ShadowCommander Aug 25, 2024
fe67113
Test!
sleepyyapril Nov 15, 2024
bd43299
...buckled?
sleepyyapril Nov 15, 2024
5e682c0
sigh.
sleepyyapril Nov 15, 2024
5a8b36a
What.
sleepyyapril Nov 15, 2024
85ce424
Fix unbuckling others when clicking on the strap entity (#29998)
metalgearsloth Sep 22, 2024
3323706
Buckling an entity requires a do-after (#29621)
Plykiya Aug 9, 2024
df5dbf2
Yeah
sleepyyapril Nov 15, 2024
3b0d51d
Replace IClickAlert with events (#30728)
EmoGarbage404 Aug 7, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Content.Client/Alerts/ClientAlertsSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ private void OnPlayerDetached(EntityUid uid, AlertsComponent component, LocalPla
ClearAlerts?.Invoke(this, EventArgs.Empty);
}

public void AlertClicked(AlertType alertType)
public void AlertClicked(ProtoId<AlertPrototype> alertType)
{
RaiseNetworkEvent(new ClickAlertEvent(alertType));
RaisePredictiveEvent(new ClickAlertEvent(alertType));
}
}
50 changes: 29 additions & 21 deletions Content.Client/Buckle/BuckleSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Content.Shared.Buckle.Components;
using Content.Shared.Rotation;
using Robust.Client.GameObjects;
using Robust.Shared.GameStates;

namespace Content.Client.Buckle;

Expand All @@ -14,37 +15,44 @@ public override void Initialize()
{
base.Initialize();

SubscribeLocalEvent<BuckleComponent, AfterAutoHandleStateEvent>(OnBuckleAfterAutoHandleState);
SubscribeLocalEvent<BuckleComponent, AppearanceChangeEvent>(OnAppearanceChange);
SubscribeLocalEvent<StrapComponent, MoveEvent>(OnStrapMoveEvent);
}

private void OnBuckleAfterAutoHandleState(EntityUid uid, BuckleComponent component, ref AfterAutoHandleStateEvent args)
private void OnStrapMoveEvent(EntityUid uid, StrapComponent component, ref MoveEvent args)
{
ActionBlocker.UpdateCanMove(uid);
// I'm moving this to the client-side system, but for the sake of posterity let's keep this comment:
// > This is mega cursed. Please somebody save me from Mr Buckle's wild ride

if (!TryComp<SpriteComponent>(uid, out var ownerSprite))
// The nice thing is its still true, this is quite cursed, though maybe not omega cursed anymore.
// This code is garbage, it doesn't work with rotated viewports. I need to finally get around to reworking
// sprite rendering for entity layers & direction dependent sorting.

if (args.NewRotation == args.OldRotation)
return;

// Adjust draw depth when the chair faces north so that the seat back is drawn over the player.
// Reset the draw depth when rotated in any other direction.
// TODO when ECSing, make this a visualizer
// This code was written before rotatable viewports were introduced, so hard-coding Direction.North
// and comparing it against LocalRotation now breaks this in other rotations. This is a FIXME, but
// better to get it working for most people before we look at a more permanent solution.
if (component is { Buckled: true, LastEntityBuckledTo: { } } &&
Transform(component.LastEntityBuckledTo.Value).LocalRotation.GetCardinalDir() == Direction.North &&
TryComp<SpriteComponent>(component.LastEntityBuckledTo, out var buckledSprite))
{
component.OriginalDrawDepth ??= ownerSprite.DrawDepth;
ownerSprite.DrawDepth = buckledSprite.DrawDepth - 1;
if (!TryComp<SpriteComponent>(uid, out var strapSprite))
return;
}

// If here, we're not turning north and should restore the saved draw depth.
if (component.OriginalDrawDepth.HasValue)
var isNorth = Transform(uid).LocalRotation.GetCardinalDir() == Direction.North;
foreach (var buckledEntity in component.BuckledEntities)
{
ownerSprite.DrawDepth = component.OriginalDrawDepth.Value;
component.OriginalDrawDepth = null;
if (!TryComp<BuckleComponent>(buckledEntity, out var buckle))
continue;

if (!TryComp<SpriteComponent>(buckledEntity, out var buckledSprite))
continue;

if (isNorth)
{
buckle.OriginalDrawDepth ??= buckledSprite.DrawDepth;
buckledSprite.DrawDepth = strapSprite.DrawDepth - 1;
}
else if (buckle.OriginalDrawDepth.HasValue)
{
buckledSprite.DrawDepth = buckle.OriginalDrawDepth.Value;
buckle.OriginalDrawDepth = null;
}
}
}

Expand Down
4 changes: 2 additions & 2 deletions Content.Client/Movement/Systems/WaddleAnimationSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public override void Initialize()
SubscribeLocalEvent<WaddleAnimationComponent, AnimationCompletedEvent>(OnAnimationCompleted);
SubscribeLocalEvent<WaddleAnimationComponent, StunnedEvent>(OnStunned);
SubscribeLocalEvent<WaddleAnimationComponent, KnockedDownEvent>(OnKnockedDown);
SubscribeLocalEvent<WaddleAnimationComponent, BuckleChangeEvent>(OnBuckleChange);
SubscribeLocalEvent<WaddleAnimationComponent, BuckledEvent>(OnBuckled);
}

private void OnMovementInput(EntityUid entity, WaddleAnimationComponent component, MoveInputEvent args)
Expand Down Expand Up @@ -148,7 +148,7 @@ private void OnKnockedDown(EntityUid uid, WaddleAnimationComponent component, Kn
StopWaddling(uid, component);
}

private void OnBuckleChange(EntityUid uid, WaddleAnimationComponent component, BuckleChangeEvent args)
private void OnBuckled(EntityUid uid, WaddleAnimationComponent component, BuckledEvent args)
{
StopWaddling(uid, component);
}
Expand Down
3 changes: 1 addition & 2 deletions Content.Client/Revenant/RevenantSystem.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using Content.Client.Alerts;
using Content.Shared.Alert;
using Content.Shared.Revenant;
using Content.Shared.Revenant.Components;
using Robust.Client.GameObjects;
Expand Down Expand Up @@ -42,7 +41,7 @@ private void OnAppearanceChange(EntityUid uid, RevenantComponent component, ref

private void OnUpdateAlert(Entity<RevenantComponent> ent, ref UpdateAlertSpriteEvent args)
{
if (args.Alert.AlertType != AlertType.Essence)
if (args.Alert.ID != ent.Comp.EssenceAlert)
return;

var sprite = args.SpriteViewEnt.Comp;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using Robust.Client.Player;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controllers;
using Robust.Shared.Prototypes;

namespace Content.Client.UserInterface.Systems.Alerts;

Expand Down Expand Up @@ -43,7 +44,7 @@ private void OnScreenLoad()
SyncAlerts();
}

private void OnAlertPressed(object? sender, AlertType e)
private void OnAlertPressed(object? sender, ProtoId<AlertPrototype> e)
{
_alertsSystem?.AlertClicked(e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.XAML;
using Robust.Shared.Input;
using Robust.Shared.Prototypes;

namespace Content.Client.UserInterface.Systems.Alerts.Widgets;

Expand All @@ -21,8 +22,10 @@ public AlertsUI()
RobustXamlLoader.Load(this);
}

public void SyncControls(AlertsSystem alertsSystem, AlertOrderPrototype? alertOrderPrototype,
IReadOnlyDictionary<AlertKey, AlertState> alertStates)
public void SyncControls(AlertsSystem alertsSystem,
AlertOrderPrototype? alertOrderPrototype,
IReadOnlyDictionary<AlertKey,
AlertState> alertStates)
{
// remove any controls with keys no longer present
if (SyncRemoveControls(alertStates))
Expand All @@ -46,7 +49,7 @@ public void ClearAllControls()
_alertControls.Clear();
}

public event EventHandler<AlertType>? AlertPressed;
public event EventHandler<ProtoId<AlertPrototype>>? AlertPressed;

private bool SyncRemoveControls(IReadOnlyDictionary<AlertKey, AlertState> alertStates)
{
Expand Down Expand Up @@ -88,7 +91,7 @@ private void SyncUpdateControls(AlertsSystem alertsSystem, AlertOrderPrototype?
}

if (_alertControls.TryGetValue(newAlert.AlertKey, out var existingAlertControl) &&
existingAlertControl.Alert.AlertType == newAlert.AlertType)
existingAlertControl.Alert.ID == newAlert.ID)
{
// key is the same, simply update the existing control severity / cooldown
existingAlertControl.SetSeverity(alertState.Severity);
Expand Down Expand Up @@ -155,6 +158,6 @@ private void AlertControlPressed(BaseButton.ButtonEventArgs args)
if (args.Event.Function != EngineKeyFunctions.UIClick)
return;

AlertPressed?.Invoke(this, control.Alert.AlertType);
AlertPressed?.Invoke(this, control.Alert.ID);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

namespace Content.Client.UserInterface.Systems.Storage.Controls;

public sealed class ItemGridPiece : Control
public sealed class ItemGridPiece : Control, IEntityControl
{
private readonly IEntityManager _entityManager;
private readonly StorageUIController _storageController;
Expand Down Expand Up @@ -287,6 +287,8 @@ public static Vector2 GetCenterOffset(Entity<ItemComponent?> entity, ItemStorage
var actualSize = new Vector2(boxSize.X + 1, boxSize.Y + 1);
return actualSize * new Vector2i(8, 8);
}

public EntityUid? UiEntity => Entity;
}

public enum ItemGridPieceMarks
Expand Down
6 changes: 3 additions & 3 deletions Content.Client/Weather/WeatherSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,9 @@ protected override void Run(EntityUid uid, WeatherData weather, WeatherPrototype
comp.Occlusion = occlusion;
}

protected override bool SetState(WeatherState state, WeatherComponent comp, WeatherData weather, WeatherPrototype weatherProto)
protected override bool SetState(EntityUid uid, WeatherState state, WeatherComponent comp, WeatherData weather, WeatherPrototype weatherProto)
{
if (!base.SetState(state, comp, weather, weatherProto))
if (!base.SetState(uid, state, comp, weather, weatherProto))
return false;

if (!Timing.IsFirstTimePredicted)
Expand Down Expand Up @@ -164,7 +164,7 @@ private void OnWeatherHandleState(EntityUid uid, WeatherComponent component, ref
continue;

// New weather
StartWeather(component, ProtoMan.Index<WeatherPrototype>(proto), weather.EndTime);
StartWeather(uid, component, ProtoMan.Index<WeatherPrototype>(proto), weather.EndTime);
}
}
}
56 changes: 56 additions & 0 deletions Content.IntegrationTests/Tests/Buckle/BuckleDragTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
using Content.IntegrationTests.Tests.Interaction;
using Content.Shared.Buckle;
using Content.Shared.Buckle.Components;
using Content.Shared.Input;
using Content.Shared.Movement.Pulling.Components;

namespace Content.IntegrationTests.Tests.Buckle;

public sealed class BuckleDragTest : InteractionTest
{
// Check that dragging a buckled player unbuckles them.
[Test]
public async Task BucklePullTest()
{
var urist = await SpawnTarget("MobHuman");
var sUrist = ToServer(urist);
await SpawnTarget("Chair");

var buckle = Comp<BuckleComponent>(urist);
var strap = Comp<StrapComponent>(Target);
var puller = Comp<PullerComponent>(Player);
var pullable = Comp<PullableComponent>(urist);

#pragma warning disable RA0002
buckle.Delay = TimeSpan.Zero;
#pragma warning restore RA0002

// Initially not buckled to the chair and not pulling anything
Assert.That(buckle.Buckled, Is.False);
Assert.That(buckle.BuckledTo, Is.Null);
Assert.That(strap.BuckledEntities, Is.Empty);
Assert.That(puller.Pulling, Is.Null);
Assert.That(pullable.Puller, Is.Null);
Assert.That(pullable.BeingPulled, Is.False);

// Strap the human to the chair
Assert.That(Server.System<SharedBuckleSystem>().TryBuckle(sUrist, SPlayer, STarget.Value));
await RunTicks(5);
Assert.That(buckle.Buckled, Is.True);
Assert.That(buckle.BuckledTo, Is.EqualTo(STarget));
Assert.That(strap.BuckledEntities, Is.EquivalentTo(new[]{sUrist}));
Assert.That(puller.Pulling, Is.Null);
Assert.That(pullable.Puller, Is.Null);
Assert.That(pullable.BeingPulled, Is.False);

// Start pulling, and thus unbuckle them
await PressKey(ContentKeyFunctions.TryPullObject, cursorEntity:urist);
await RunTicks(5);
Assert.That(buckle.Buckled, Is.False);
Assert.That(buckle.BuckledTo, Is.Null);
Assert.That(strap.BuckledEntities, Is.Empty);
Assert.That(puller.Pulling, Is.EqualTo(sUrist));
Assert.That(pullable.Puller, Is.EqualTo(SPlayer));
Assert.That(pullable.BeingPulled, Is.True);
}
}
108 changes: 108 additions & 0 deletions Content.IntegrationTests/Tests/Buckle/BuckleTest.Interact.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
using Content.Shared.Buckle;
using Content.Shared.Buckle.Components;
using Content.Shared.Interaction;
using Robust.Server.GameObjects;
using Robust.Shared.GameObjects;
using Robust.Shared.Map;

namespace Content.IntegrationTests.Tests.Buckle;

public sealed partial class BuckleTest
{
[Test]
public async Task BuckleInteractUnbuckleOther()
{
await using var pair = await PoolManager.GetServerClient();
var server = pair.Server;

var entMan = server.ResolveDependency<IServerEntityManager>();
var buckleSystem = entMan.System<SharedBuckleSystem>();

EntityUid user = default;
EntityUid victim = default;
EntityUid chair = default;
BuckleComponent buckle = null;
StrapComponent strap = null;

await server.WaitAssertion(() =>
{
user = entMan.SpawnEntity(BuckleDummyId, MapCoordinates.Nullspace);
victim = entMan.SpawnEntity(BuckleDummyId, MapCoordinates.Nullspace);
chair = entMan.SpawnEntity(StrapDummyId, MapCoordinates.Nullspace);

Assert.That(entMan.TryGetComponent(victim, out buckle));
Assert.That(entMan.TryGetComponent(chair, out strap));

#pragma warning disable RA0002
buckle.Delay = TimeSpan.Zero;
#pragma warning restore RA0002

// Buckle victim to chair
Assert.That(buckleSystem.TryBuckle(victim, user, chair, buckle));
Assert.Multiple(() =>
{
Assert.That(buckle.BuckledTo, Is.EqualTo(chair), "Victim did not get buckled to the chair.");
Assert.That(buckle.Buckled, "Victim is not buckled.");
Assert.That(strap.BuckledEntities, Does.Contain(victim), "Chair does not have victim buckled to it.");
});

// InteractHand with chair to unbuckle victim
entMan.EventBus.RaiseLocalEvent(chair, new InteractHandEvent(user, chair));
Assert.Multiple(() =>
{
Assert.That(buckle.BuckledTo, Is.Null);
Assert.That(buckle.Buckled, Is.False);
Assert.That(strap.BuckledEntities, Does.Not.Contain(victim));
});
});

await pair.CleanReturnAsync();
}

[Test]
public async Task BuckleInteractBuckleUnbuckleSelf()
{
await using var pair = await PoolManager.GetServerClient();
var server = pair.Server;

var entMan = server.ResolveDependency<IServerEntityManager>();

EntityUid user = default;
EntityUid chair = default;
BuckleComponent buckle = null;
StrapComponent strap = null;

await server.WaitAssertion(() =>
{
user = entMan.SpawnEntity(BuckleDummyId, MapCoordinates.Nullspace);
chair = entMan.SpawnEntity(StrapDummyId, MapCoordinates.Nullspace);

Assert.That(entMan.TryGetComponent(user, out buckle));
Assert.That(entMan.TryGetComponent(chair, out strap));

#pragma warning disable RA0002
buckle.Delay = TimeSpan.Zero;
#pragma warning restore RA0002

// Buckle user to chair
entMan.EventBus.RaiseLocalEvent(chair, new InteractHandEvent(user, chair));
Assert.Multiple(() =>
{
Assert.That(buckle.BuckledTo, Is.EqualTo(chair), "Victim did not get buckled to the chair.");
Assert.That(buckle.Buckled, "Victim is not buckled.");
Assert.That(strap.BuckledEntities, Does.Contain(user), "Chair does not have victim buckled to it.");
});

// InteractHand with chair to unbuckle
entMan.EventBus.RaiseLocalEvent(chair, new InteractHandEvent(user, chair));
Assert.Multiple(() =>
{
Assert.That(buckle.BuckledTo, Is.Null);
Assert.That(buckle.Buckled, Is.False);
Assert.That(strap.BuckledEntities, Does.Not.Contain(user));
});
});

await pair.CleanReturnAsync();
}
}
Loading
Loading