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

Misc. Refactoring of Components #1005

Merged
merged 5 commits into from
Jan 26, 2025
Merged

Misc. Refactoring of Components #1005

merged 5 commits into from
Jan 26, 2025

Conversation

royfalk
Copy link
Contributor

@royfalk royfalk commented Jan 21, 2025

What is this pull request trying to do?
As I'm working on moving hull, armor and shield code into lib_component, additional changes have also been made. I've separated these into another PR, so review will be easier.

The changes are many but very localised.

  • Move graphicOptions.InWarp to ftl_drive.Enabled(). Also support enable, disable and toggle.
  • Remove base_computer::showUnitStats. It's been replaced by python code.
  • Remove two unused parameters in DamageRandSys.
  • Remove unused parameter in Component::Load and subclasses
  • Align Cloak with other components.
  • unit_csv::UnitToMap no longer uses the original unit stats as a starting point.
  • Rename Component::Percent to Component::PercentOperational. We will have namespace collisions when we implement hull, armor and shield, as there is a Percent function there as well.
  • Standardise on Component::Load(unit_key) and Component::Upgrade(upgrade_key)
  • Fix bug in AfterburnerUpgrade::Upgrade - added __upgrades suffix twice.
  • Disabled Component::Load code related to MasterPartList. This needs a PR on its own to do right.
  • Deleted Component::unit_key. This collides with parameters and doesn't actually add worth. Components shouldn't know about the ship.
  • Fix issue in JumpDrive and other some other components, where the constructor switched two parameters around.
  • Make Resource::Percent return 0 and not -1. The game uses this in cockpit and VDU and checking every cycle is costly.
  • Resource now checks if it is destroyed (0) before repairing.

Code Changes:

Issues identified:

- Move graphicOptions.InWarp to ftl_drive.Enabled(). Also support enable, disable and toggle.
- Remove base_computer::showUnitStats. It's been replaced by python code.
- Remove two unused parameters in DamageRandSys.
- Remove unused parameter in Component::Load and subclasses
- Align Cloak with other components.
- unit_csv::UnitToMap no longer uses the original unit stats as a starting point.
- Rename Component::Percent to Component::PercentOperational. We will have namespace collisions when we implement hull, armor and shield, as there is a Percent function there as well.
- Standardise on Component::Load(unit_key) and Component::Upgrade(upgrade_key)
- Fix bug in AfterburnerUpgrade::Upgrade - added __upgrades suffix twice.
- Disabled Component::Load code related to MasterPartList. This needs a PR on its own to do right.
- Deleted Component::unit_key. This collides with parameters and doesn't actually add worth. Components shouldn't know about the ship.
- Fix issue in JumpDrive and other some other components, where the constructor switched two parameters around.
- Make Resource::Percent return 0 and not -1. The game uses this in cockpit and VDU and checking every cycle is costly.
- Resource now checks if it is destroyed (0) before repairing.
- Disable mass tests as it is disabled in Component
- Disable upgrade name, as it is partially disabled in Component
- Adjust Resource tests - new behavior doesn't allow destroyed resource to be repaired.
upgrade.Load(upgrade_string + upgrades_suffix_string);

EXPECT_EQ(afterburner.GetMass(), 0.0);
EXPECT_EQ(afterburner.thrust.MaxValue(), 10.0);
EXPECT_EQ(afterburner.speed.MaxValue(), 100.0);
EXPECT_EQ(afterburner.GetConsumption(), 2.0);

EXPECT_EQ(upgrade.GetMass(), 5.0);
//EXPECT_EQ(upgrade.GetMass(), 5.0);
Copy link
Contributor

Choose a reason for hiding this comment

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

Why are these being commented out? I don't understand

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If you look at Component.cpp, you'll see I've commented out the code to initialize name and mass of the upgrade.
I have a general idea of where I want to go with this. Right now, the game uses cargo to represent upgrades and these (volume, price, name, etc.) are stored as part of the Master Part List (MPL).
Because these are part of Cargo and not Unit Asset, we need to process two separate elements.
I'm not sure how to do that. I'm also not sure I need to.
Right now, upgrade_view takes the key and pulls data directly from the Assets and MPL.

Copy link
Contributor

Choose a reason for hiding this comment

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

So in other words, we're breaking functionality temporarily until we figure out how this should be done. I am not OK with that. At least not on master. The master branch is supposed to remain playable at all times, right?

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree here, the master should be playable at all times, so each of the issues identified should be fixed before this PR can be merged.

Saying that, this is a step in the right direction, and so I'll be play testing this branch, and as the fixes come in for the various issues identified I will continue play testing until we are sure that this branch does not introduce any new issues into master.

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 in other words, we're breaking functionality temporarily until we figure out how this should be done. I am not OK with that. At least not on master. The master branch is supposed to remain playable at all times, right?

Nope. Right now the game stores a list of Cargo items for each upgrade. I've made provisions in Component when I started development to store this information there.

Commenting it out does not impact game play as this extra copy of Cargo attributes (mass, volume, name, description, etc.) is currently not used.

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh. Okay.

RandomDamage has a chance of destroying a resource, which then cannot be repaired.
Add gitignore
Copy link
Contributor

@stephengtuggy stephengtuggy left a comment

Choose a reason for hiding this comment

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

Looks good to me

@royfalk royfalk merged commit c9a477f into master Jan 26, 2025
21 checks passed
@royfalk royfalk deleted the task_armor_3 branch January 26, 2025 17:58
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.

4 participants