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

Task core components #860

Merged
merged 7 commits into from
May 16, 2024
Merged

Conversation

royfalk
Copy link
Contributor

@royfalk royfalk commented May 7, 2024

This is part of the lib component tasks.
This commit introduces Component, EnergyConsumer, EnergyContainer and Reactor.
These are not yet connected to the engine. Please focus on reviewing the classes themselves, as they are fairly major.

Please answer the following:

Code Changes:

Issues:

  • Because I'm pulling changes by files, there are a few things that are going to be used in future PRs.

Add unit tests. 
Remove UnitCsvFactory reliance on VSFileSystem for better separation of concerns. Game doesn't build because unit tests require VSFileSystem and that pulls in half the game with it.
As this is imported from the original lib component branch by file, some stuff here is for future commits.
@royfalk royfalk self-assigned this May 7, 2024
use of designated initializers requires at least '/std:c++20'

class Component
{
protected:
Copy link
Member

Choose a reason for hiding this comment

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

just to note, we should put public information first, then protected, then private. This helps with ABI compatibility, not that we're really concerned about that right now.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For some reason I assumed the reverse. I'll fix this here, though I can't promise for all of my work.

Copy link
Member

Choose a reason for hiding this comment

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

Changing things changes the offsets. Keeping public data first keeps the offsets to it the same, and new public goes at the end, pushing the protected and private data further away from the zero point.

If we really wanted a public binary ABI then we'd look at doing another method (what Qt does), but it's not really important just good habit for when it is.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So, I dug deeper and while most agree on public/protected/private order, fields/constructors/methods is less so.
Since most of the code is fields/constructors/methods, I'll stick with that but reverse the visibility as I go along as these are already not consistent.


#include "energy_consumer.h"

double EnergyConsumer::simulation_atom_var = 0.1;
Copy link
Member

Choose a reason for hiding this comment

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

could we get some comments on why we're having another simulation_atom_var?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure if you want this in the code or just here - the issue is one of encapsulation. With the work done on the various libraries - resource, components, damage, it's become clear that we need much better separation of concerns.
simulation_atom_var is pervasive throughout the game. However, I need a version of it for consumers. This was my solution.
Ideally, I'd like to create a new library - core. It should have some important constants and the vector class. Maybe with Resource class as well. However, I prefer to finish lib component before tackling something else.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think this has the potential to cause a lot of confusion, having two (or more) different instantiations of simulation_atom_var in different scopes. But I suppose we can leave it for now. Approving.

Copy link
Member

Choose a reason for hiding this comment

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

@royfalk thanks for the explanation; it'd probably be good to have some documentation about it in the code; but not going to require it for this PR to go through. Would you please file a follow-up PR with a small comment about it?

Copy link
Member

Choose a reason for hiding this comment

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

I do like your idea of the follow-on to have a core library that way too, BTW, and certainly agree we need to take a calculated, stepped approach to getting there.

Copy link
Member

@BenjamenMeyer BenjamenMeyer left a comment

Choose a reason for hiding this comment

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

few comments for consideration; overall I like where its going but I'll need to take another more detailed pass too

Reverse order of visibility in EnergyConsumer.
Make visibility modifiers explicit in EnergyContainer and Reactor.
@royfalk
Copy link
Contributor Author

royfalk commented May 12, 2024

If no one has any more comments and my answers satisfy, it is ready for merge.

@stephengtuggy
Copy link
Contributor

@BenjamenMeyer did you still want to review this PR in more detail? Or is it ready for merge?

@BenjamenMeyer
Copy link
Member

I'll try to take a look tonight

@royfalk royfalk merged commit b34ad92 into vegastrike:master May 16, 2024
30 of 31 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants