-
-
Notifications
You must be signed in to change notification settings - Fork 595
Add cell position adjacency bonus calculations EXCEPT for GetPlayerDataSource() #6855
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
Open
IdfbAn
wants to merge
9
commits into
master
Choose a base branch
from
6764_specialization_cell_adjacency_bonus
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 4 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
082442a
Add cell position adjacency specialization bonus except for GetPlayer…
IdfbAn 1f4f8cb
Resolve JetBrains check
IdfbAn 2b2d049
Initial "solution" for adjacency specialization in GetPlayerDataSource()
IdfbAn 076e399
Revert "Initial "solution" for adjacency specialization in GetPlayerD…
IdfbAn 3d3fd0c
Use ModifiableEditorCells in GetAdjacencySpecializationBonus()
IdfbAn 4ede406
Use EditorCells instead of ModifiableEditorCells
IdfbAn 5eea89a
Removed a comment about a potential optimization
hhyyrylainen 9413a31
Hopefully resolve merge conflict
IdfbAn 4e19465
Merge branch 'master' into 6764_specialization_cell_adjacency_bonus
IdfbAn File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -141,4 +141,56 @@ public static float CalculateRotationSpeed(IReadOnlyList<HexWithData<CellTemplat | |
|
|
||
| return colonyRotation / cells.Count; | ||
| } | ||
|
|
||
| public static float GetAdjacencySpecializationBonusFromIndexAndPlan(int cellIndexInBodyPlan, | ||
| CellLayout<CellTemplate> bodyPlan) | ||
| { | ||
| var bonus = 0.0f; | ||
| var cellInBodyPlan = bodyPlan[cellIndexInBodyPlan]; | ||
|
|
||
| foreach (var cell in bodyPlan) | ||
| { | ||
| if (cellInBodyPlan.CellType == cell.CellType && cell.Position.DistanceTo(cellInBodyPlan.Position) == 1) | ||
| { | ||
| bonus += Constants.CELL_ADJACENCY_SPECIALIZATION_BONUS; | ||
| } | ||
| } | ||
|
|
||
| return 1 + bonus; | ||
| } | ||
|
|
||
| public static float GetAdjacencySpecializationBonusFromIndexAndPlan(CellTemplate? cellInBodyPlan, | ||
| IReadOnlyList<HexWithData<CellTemplate>> bodyPlan) | ||
| { | ||
| var bonus = 0.0f; | ||
|
|
||
| foreach (var cell in bodyPlan) | ||
| { | ||
| if (cellInBodyPlan!.CellType == cell.Data!.CellType | ||
| && cell.Position.DistanceTo(cellInBodyPlan.Position) == 1) | ||
| { | ||
| bonus += Constants.CELL_ADJACENCY_SPECIALIZATION_BONUS; | ||
| } | ||
| } | ||
|
|
||
| return 1 + bonus; | ||
| } | ||
|
|
||
| public static float GetAdjacencySpecializationBonusFromIndexAndPlan(int cellIndexInBodyPlan, | ||
| IndividualHexLayout<CellTemplate> bodyPlan) | ||
| { | ||
| var bonus = 0.0f; | ||
| var cellInBodyPlan = bodyPlan[cellIndexInBodyPlan]; | ||
|
|
||
| foreach (var cell in bodyPlan) | ||
| { | ||
| if (cellInBodyPlan.Data!.CellType == cell.Data!.CellType | ||
| && cell.Position.DistanceTo(cellInBodyPlan.Position) == 1) | ||
| { | ||
| bonus += Constants.CELL_ADJACENCY_SPECIALIZATION_BONUS; | ||
| } | ||
| } | ||
|
Comment on lines
+186
to
+195
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This still looks very similar to me... Like I think the code could be like: So that way there's less code repetition. |
||
|
|
||
| return 1 + bonus; | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Overall I think this is pretty good for the backend part of this feature, though the changes in this file are kind of looking very similar, so I think some of the methods here could be simplified so that they just look up some data and then call an overload. Would that be possible?
Also one slight naming thing is that you should clarify if the body plan is the gameplay or editor body plan (as your code only works for the editor body plan variant and will fail for the gameplay body plan).
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.
I'm not exactly sure what you mean by this, and I don't really see any way to simply these methods. CMIIW though, of course.
This seems a bit too important to just hide in parentheses.
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.
I mean it looks like the index method could just get the cell type from the index and then call the variant that takes in a cell template directly? I did not try to do that rewrite so I might be missing some small detail but to me that seems like a plausible code refactor.
I assumed you were aware of that... You'll want to check the differences between
ModifiableGameplayCellsandModifiableEditorCellsas I think that yeah your algorithm works for one but does not work for the other, so it should be clarified with variable naming and maybe even putting an XML comment with a warning about that that the algorithm only works for one cell layout variant.