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

Implement a way to edit the cell division order in multicellular #4499

Open
wants to merge 20 commits into
base: master
Choose a base branch
from

Conversation

Kashnox
Copy link
Contributor

@Kashnox Kashnox commented Oct 1, 2023

Brief Description of What This PR Does

This PR gives users the ability to change the order their cells are created during the early multicellular stage.

Related Issues

closes #3206

Progress Checklist

Note: before starting this checklist the PR should be marked as non-draft.

  • PR author has checked that this PR works as intended and doesn't
    break existing features:
    https://wiki.revolutionarygamesstudio.com/wiki/Testing_Checklist
    (this is important as to not waste the time of Thrive team
    members reviewing this PR)
  • Initial code review passed (this and further items should not be checked by the PR author)
  • Functionality is confirmed working by another person (see above checklist link)
  • Final code review is passed and code conforms to the
    styleguide.

Before merging all CI jobs should finish on this PR without errors, if
there are automatically detected style issues they should be fixed by
the PR author. Merging must follow our
styleguide.

…e red, and blocking the user from closing the editor while they exist. Also started showing the reproduction order on the cells while the Reproduction tab is open.
@hhyyrylainen hhyyrylainen added this to the Release 0.6.4 milestone Oct 1, 2023
@Kashnox Kashnox marked this pull request as ready for review October 7, 2023 18:31
@Kashnox Kashnox requested review from a team October 7, 2023 18:31
@Kashnox Kashnox added the review label Oct 7, 2023
/// </summary>
/// <param name="index1">The index of one of the items that should be swapped.</param>
/// <param name="index2">The index of the other item that should be swapped.</param>
public void SwapIndexes(int index1, int index2)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
public void SwapIndexes(int index1, int index2)
public void SwapIndices(int index1, int index2)

I think the plural goes like that for index.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, looking it up, indices seems to be the preference outside of North America.

@@ -222,7 +237,7 @@ public List<Hex> GetIslandHexes()
// These are all of the existing hexes, that if there are no islands will all be visited
var shouldBeVisited = ComputeHexCache();
Copy link
Member

Choose a reason for hiding this comment

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

Why is compute hex cache not given the cutoff parameter here?


protected override ActionInterferenceMode GetInterferenceModeWithGuaranteed(CombinableActionData other)
{
return ActionInterferenceMode.NoInterference;
Copy link
Member

Choose a reason for hiding this comment

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

Should this action combine with later reproduction order actions? Similarly to how multiple organelle moves in a row will combine. For example if someone moves the last cell to be the second cell and then moves the second cell to first, that could combine into one reproduction order action, right?

@@ -8,12 +8,16 @@ public partial class CellBodyPlanEditorComponent
private void OnCellAdded(HexWithData<CellTemplate> hexWithData)
{
cellDataDirty = true;

UpdateReproductionOrderList();
Copy link
Member

Choose a reason for hiding this comment

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

This should get triggered like the other updates with the cell data dirty. I think there's already a ton of systems that get updated based on the cellDataDirty variable.

@@ -565,7 +565,7 @@ protected void OnSymmetryPressed()
*/
}

/// <inheritdoc cref="HexEditorComponentBase{TEditor,TCombinedAction,TAction,THexMove}.OnHexEditorMouseEntered"/>
/// <inheritdoc cref="HexEditorComponentBase{TEditor,TCombined,TAction,THexMove,TContext}.OnHexEditorMouseEntered"/>
Copy link
Member

Choose a reason for hiding this comment

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

I think I fixed this on my branch where I fix various other things. I think I fixed this at least a bit better as I kept the right TCombinedAction name here. So maybe you can just revert this change and leave it be for a bit (I'm hopefult it won't take more than two weeks to get my changes regarding this merged)?

…e it generic so it can be reused for organelles. Also, renamed ReproductionOrder to ReproductionOrderEntry
@Kashnox
Copy link
Contributor Author

Kashnox commented Oct 21, 2023

This is ready for review again. After splitting the reproduction order handling into its own class, I ended up reworking it to be generic so it should be easy to reuse it for organelle division order too.

I still haven't implemented any combining for ReproductionOrderActions because the more I thought about it, the more complicated it seemed. I think, if we do end up adding an MP cost to reproduction order changes, we should worry about combining the actions then because we'll have a better idea of how exactly they should be combined. In the meantime, I just left a TODO comment in ReproductionOrderActionData related to it.

The Jetbrains Inspectcode is failing because of that bad reference to HexEditorComponentBase, but everything else is passing.

@Kashnox Kashnox requested a review from a team October 21, 2023 17:58
@@ -575,14 +575,14 @@ protected void OnMetaballEditorMouseEntered()
UpdateMutationPointsBar();
}

/// <inheritdoc cref="HexEditorComponentBase{TEditor,TCombinedAction,TAction,THexMove}.OnHexEditorMouseExited"/>
/// <inheritdoc cref="HexEditorComponentBase{TEditor,TCombined,TAction,THexMove,TContext}.OnHexEditorMouseExited"/>
Copy link
Member

Choose a reason for hiding this comment

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

There's still changes in this file, so I think you might as well put the correct stuff here (note that due to the line length, there's a need to disable the too long line check for these few lines. You can check my open refactor PR where I did this. Or you could just revert all changes to this file. I think the CI checks will stop checking this file once you make one extra commit after the one reverting the changes in this file.

@@ -1071,6 +1085,7 @@ protected override void Dispose(bool disposing)
EditorGridPath.Dispose();
CameraFollowPath.Dispose();
IslandErrorPath.Dispose();
Camera?.Dispose();
Copy link
Member

Choose a reason for hiding this comment

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

We don't dispose Godot nodes. Only nodepaths are disposed.

/// <summary>
/// The <see cref="MicrobeCamera"/> used by this editor.
/// </summary>
public MicrobeCamera? Camera;
Copy link
Member

Choose a reason for hiding this comment

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

If this must be made public, could you at least make this a property without a public setter? That way this class state cannot be destroyed by external code swapping out the camera object.

@@ -96,6 +99,9 @@ public partial class CellBodyPlanEditorComponent :
private PackedScene microbeScene = null!;

private CellPopupMenu cellPopupMenu = null!;

private ReproductionOrderEditor<CellTemplate, EarlyMulticellularEditor, CombinedEditorAction, EditorAction,
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't this use the actual type used by the scene (EarlyMulticellularReproductionOrderEditor)? That'd simplify the long list of generic parameters defined here.

Copy link
Member

Choose a reason for hiding this comment

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

As this has an attached script of type EarlyMulticellularReproductionOrderEditor this file should be named EarlyMulticellularReproductionOrderEditor.tscn otherwise it is really hard to find what scenes are related to what script classes if they aren't named the same.

using Godot;

/// <summary>
/// Handles showing and changing the order in which hexes in a hex-based creature will be created.
Copy link
Member

Choose a reason for hiding this comment

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

I think this summary would be work better on the reproduction order editor class. This class for a single entry should have a different summary about the role this class has in the reproduction order editing process.

/// <summary>
/// When this hex will be created. 1 is the starting hex.
/// </summary>
public string Index
Copy link
Member

Choose a reason for hiding this comment

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

Why is this a string and not an int?

where THexMove : HexWithData<THex>, IActionHex
{
[Export]
public NodePath ReproductionOrderListPath = null!;
Copy link
Member

Choose a reason for hiding this comment

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

First NodePath in a class needs to be nullable to allow detecting when this object is created in the Godot editor and avoiding error conditions happening there. Editor process created class instances never get their Export variables set and don't have _Ready called on them, but do have Dispose called on them.

@hhyyrylainen
Copy link
Member

This now is blocked by the multicellular editor not being currently able to display anything related to the cells. It might take a week or two before I get around to fixing that, but after that this PR can then be finished.

@revolutionary-bot
Copy link

We are currently in feature freeze until the next release.
If your PR is not just a simple fix, then it may take until the release to get reviewed and merged.

@hhyyrylainen
Copy link
Member

There's no longer any blockers regarding this, just needs to be finished and updated to work with the latest other code changes.

@hhyyrylainen hhyyrylainen removed this from the Release 0.7.0 milestone Aug 30, 2024
@hhyyrylainen
Copy link
Member

I separately implemented a GUI for growth order changing for organelles: #5688

It has all the features like drag and drop and I think if this work is resumed it might be a good idea to do this again based on that code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: started but stuck (help wanted)
Development

Successfully merging this pull request may close these issues.

Implement a way to edit the cell division order in multicellular
3 participants