-
Notifications
You must be signed in to change notification settings - Fork 611
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
Separate crate machine from market system #2681
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looked through this - one issue and one small gripe.
I think you could fire off events from the animation system itself instead of using delegates, seems closer to ECS and less OO.
I also think the CrateMachineVisualState could be scoped outside of the component.
Looks fine skimming it, will test briefly.
Content.Server/_NF/CrateMachine/CrateMachineSystem.Animation.cs
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Put in a few small suggestions.
I would honestly recommend testing and pulling in https://github.com/new-frontiers-14/frontier-station-14/compare/rack-attack...whatston3:frontier-station-14:2025-01-20-rack-attack-suggestions?expand=1
Seems to work fine under modest tests.
Edit: The TransformSystem distance calc. is probably cleaner vs. Vector2, I'd recommend using that.
var currentDistance = CalculateDistance(compXform.Coordinates, Transform(from).Coordinates); | ||
|
||
var isTooFarAway = currentDistance > maxDistance; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
var currentDistance = CalculateDistance(compXform.Coordinates, Transform(from).Coordinates); | |
var isTooFarAway = currentDistance > maxDistance; | |
var isTooFarAway = Vector2.Distance(compXform.Coordinates.Position, Transform(from).Coordinates.Position) > maxDistance; |
Vector2 has a convenient function for this, and TransformSystem does too. I believe the snippet above should work - I also wrong a version using TransformSystem, which is even better since it'll handle weird parenting better - no false positives.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems odd to assign some conditions to variables when they're only used in an if statement but eh.
|
||
/// <summary> | ||
/// Calculates distance between two EntityCoordinates on the same grid. | ||
/// Used to check for cargo pallets around the console instead of on the grid. | ||
/// </summary> | ||
/// <param name="point1">the first point</param> | ||
/// <param name="point2">the second point</param> | ||
/// <returns></returns> | ||
private static double CalculateDistance(EntityCoordinates point1, EntityCoordinates point2) | ||
{ | ||
var xDifference = point2.X - point1.X; | ||
var yDifference = point2.Y - point1.Y; | ||
|
||
return Math.Sqrt(xDifference * xDifference + yDifference * yDifference); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/// <summary> | |
/// Calculates distance between two EntityCoordinates on the same grid. | |
/// Used to check for cargo pallets around the console instead of on the grid. | |
/// </summary> | |
/// <param name="point1">the first point</param> | |
/// <param name="point2">the second point</param> | |
/// <returns></returns> | |
private static double CalculateDistance(EntityCoordinates point1, EntityCoordinates point2) | |
{ | |
var xDifference = point2.X - point1.X; | |
var yDifference = point2.Y - point1.Y; | |
return Math.Sqrt(xDifference * xDifference + yDifference * yDifference); | |
} |
Just use Vector2.Distance.
/// </summary> | ||
public sealed partial class CrateMachineSystem | ||
{ | ||
[Dependency] private readonly IEntityManager _entityManager = default!; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[Dependency] private readonly IEntityManager _entityManager = default!; |
Shouldn't need this - why isn't this extending SharedCrateMachineSystem? EntitySystem should already has a reference in EntityManager.
/// When calling <see cref="OpenFor"/>, the machine will open the door and give a callback to the given | ||
/// <see cref="ICrateMachineDelegate"/> when it is done opening. | ||
/// </summary> | ||
public sealed partial class CrateMachineSystem |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
public sealed partial class CrateMachineSystem | |
public sealed partial class CrateMachineSystem : SharedCrateMachineSystem |
Extend the shared version, add the needed import above?
|
||
public sealed class MarketSystem : SharedMarketSystem | ||
public sealed class CrateMachineSystem: SharedCrateMachineSystem |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
public sealed class CrateMachineSystem: SharedCrateMachineSystem | |
public sealed partial class CrateMachineSystem : SharedCrateMachineSystem |
per https://learn.microsoft.com/en-us/dotnet/csharp/programming-guide/classes-and-structs/partial-classes-and-methods:
All the parts must use the partial keyword
// Stop here if we don't have a grid. | ||
if (Transform(consoleUid).GridUid == null) | ||
return; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Recommend pushing this into FindNearestUnoccupied.
using Robust.Shared.Player; | ||
using Robust.Shared.Prototypes; | ||
using static Content.Shared._NF.Market.Components.CrateMachineComponent; | ||
using CrateMachineComponent = Content.Shared._NF.CrateMachine.Components.CrateMachineComponent; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
using CrateMachineComponent = Content.Shared._NF.CrateMachine.Components.CrateMachineComponent; | |
using Content.Shared._NF.CrateMachine.Components; |
About the PR
Why / Balance
How to test
Start a round and aghost
teleport to cargo depot
sell iron ore
buy iron ore at market console
check if animation is correct and items and crate spawn correctly
check if animation closes when moving crate off the crate hole.
Media
Requirements
Breaking changes
none
Changelog