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

Separate crate machine from market system #2681

Merged
merged 15 commits into from
Jan 31, 2025
Merged

Separate crate machine from market system #2681

merged 15 commits into from
Jan 31, 2025

Conversation

GreaseMonk
Copy link
Contributor

About the PR

  • Crate machine now separated from market system
  • Added MarketItemSpawnerComponent for spawning market items and moved ItemsToSpawn to it.
  • No change in code other than splitting up code and adding more documentation

Why / Balance

  • Allows crate machine to be used in other systems and makes it a reusable entity

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

Copy link
Contributor

@whatston3 whatston3 left a 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.

Copy link
Contributor

@whatston3 whatston3 left a 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.

/// 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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
public sealed partial class CrateMachineSystem
public sealed partial class CrateMachineSystem : SharedCrateMachineSystem

Extend the shared version, add the needed import above?

Copy link
Contributor Author

@GreaseMonk GreaseMonk Jan 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will add it, however it will add another cleanup warning, but i do agree for readability is best to add it
image


public sealed class MarketSystem : SharedMarketSystem
public sealed class CrateMachineSystem: SharedCrateMachineSystem
Copy link
Contributor

@whatston3 whatston3 Jan 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

strange my IDE is saying it can safely be removed
image

@whatston3 whatston3 added the S: Awaiting Changes This PR has changes that need to be made before merging label Jan 21, 2025
@GreaseMonk
Copy link
Contributor Author

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.

Thank you for the review. I've updated the code to match your suggestions and comments.
Should be ready for another review, or, approval- up to you.

@GreaseMonk GreaseMonk added S: Needs Review This PR is awaiting reviews and removed S: Awaiting Changes This PR has changes that need to be made before merging labels Jan 27, 2025
@dvir001 dvir001 self-requested a review January 27, 2025 15:10
Copy link
Contributor

@dvir001 dvir001 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Marking as good to go, waiting for @whatston3 to confirm if needed.

@whatston3 whatston3 dismissed their stale review January 28, 2025 14:51

Changes made.

Copy link
Contributor

@whatston3 whatston3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few cleanup suggestions - "ChildClass : ParentClass" is pretty much the norm. Not sure exactly what configuration's setting that up for the IDE offhand, if there's a style guide config in the workspace.

Really minor stuff, and yes, sorry, I was wrong about the Client side MarketSystem.

@whatston3
Copy link
Contributor

Changes are really minor, just going to batch commit them and it's an approval from my side.

@whatston3 whatston3 removed the S: Needs Review This PR is awaiting reviews label Jan 30, 2025
@dvir001 dvir001 self-requested a review January 31, 2025 18:08
@github-actions github-actions bot added the S: Needs Review This PR is awaiting reviews label Jan 31, 2025
Copy link
Contributor

@dvir001 dvir001 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not broken it seems

@whatston3 whatston3 merged commit 0730649 into master Jan 31, 2025
13 checks passed
@GreaseMonk GreaseMonk deleted the rack-attack branch February 5, 2025 07:42
percent-temp-percent pushed a commit to Corvax-Frontier/Frontier that referenced this pull request Feb 24, 2025
* Split crate machine

* Move namespace for visual layers

* Replace with event

* Use Vector2.Distance

* Remove CalculateDistance

* Update CrateMachineSystem.cs

* Update CrateMachineSystem.cs

* Use partial

* Update FindNearestUnoccupied

* Update MarketSystem.CrateMachine.cs

* Update CrateMachineSystem.cs

* Update CrateMachineSystem.cs

* Client CrateMachineSystem: not partial, colon spacing

---------

Co-authored-by: Whatstone <[email protected]>
Co-authored-by: Dvir <[email protected]>
percent-temp-percent pushed a commit to Corvax-Frontier/Frontier that referenced this pull request Mar 1, 2025
* Split crate machine

* Move namespace for visual layers

* Replace with event

* Use Vector2.Distance

* Remove CalculateDistance

* Update CrateMachineSystem.cs

* Update CrateMachineSystem.cs

* Use partial

* Update FindNearestUnoccupied

* Update MarketSystem.CrateMachine.cs

* Update CrateMachineSystem.cs

* Update CrateMachineSystem.cs

* Client CrateMachineSystem: not partial, colon spacing

---------

Co-authored-by: Whatstone <[email protected]>
Co-authored-by: Dvir <[email protected]>
percent-temp-percent pushed a commit to Corvax-Frontier/Frontier that referenced this pull request Mar 3, 2025
* Split crate machine

* Move namespace for visual layers

* Replace with event

* Use Vector2.Distance

* Remove CalculateDistance

* Update CrateMachineSystem.cs

* Update CrateMachineSystem.cs

* Use partial

* Update FindNearestUnoccupied

* Update MarketSystem.CrateMachine.cs

* Update CrateMachineSystem.cs

* Update CrateMachineSystem.cs

* Client CrateMachineSystem: not partial, colon spacing

---------

Co-authored-by: Whatstone <[email protected]>
Co-authored-by: Dvir <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants