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

Add Hill VBL, Pit VBL and MBL to tokens #3430

Conversation

kwvanderlinde
Copy link
Collaborator

@kwvanderlinde kwvanderlinde commented Jun 3, 2022

Identify the Bug or Feature request

Addresses most of #3052 and #2730, leaving out only the Edit Token dialog changes.

Description of the Change

New features

  • Macro functions for manipulating token topology
    • getTokenHillVBL
    • getTokenPitVBL
    • getTokenMBL
    • setTokenHillVBL
    • setTokenPitVBL
    • setTokenMBL
    • transferHillVBL
    • transferPitVBL
    • transferMBL
  • Token topology is rendered in distinct colours for each topology type.
  • Color sensitivity for auto-generated topology is remembered per topology type.

Internal changes / refactorings

  • Token model now has fields for Hill VBL, Pit VBL and MBL in addition to the existing Wall VBL.
    • Token model update command setVBL has been replaced by setTopology which requires a topology type to be sent as well as the area.
  • Protobuf Token DTO has been extended to support the new fields.
  • The macro function code under Topology_Functions was refactored so that each kind of function is handled by a separate method rather than keeping all that code in a single method under an if/else chain.
  • Zone and ZoneView only expose topology via TopologyType rather than having distinct methods for each kind of topology.
  • Topology caching in ZoneView has been revamped.
    • ZoneView no longer caches the token topology Areas and instead just caches the total topology of the map plus tokens.
    • ZoneView now caches the topology Areas for each topology type instead of just the AreaTrees. This benefits the A* walker because it needs the Areas but previously had to rely on the expensive AreaTrees.
    • The cached AreaTrees are now only needed internally to ZoneView, for passing to the FoW calculations.
  • Most methods with the term "VBL" in the name now use "topology" to make clear that they are more general.

Bug fixes

  • Subtle issue in A* algorithm to only subtract token topology from total topology of the same type. Previously a
    token's Wall VBL would be subtracted from all topologies.

Possible Drawbacks

Performance may be worse in some circumstances as there are now four loops over tokens to collect the various topologies instead of one (e.g., for vision calculations and A*).

Documentation Notes

Tokens can now carry all kinds of topology (Wall VBL, Hill VBL, Pit VBL and MBL). The topology for a token can be manipulated using these macro functions:

  • getTokenVBL(id)/getTokenHillVBL(id)/getTokenPitVBL(id)/getTokenMBL(id) are used to get the Wall VBL/Hill VBL/Pit VBL/MBL of a token.
  • setTokenVBL(json, id)/setTokenHillVBL(json, id)/setTokenPitVBL(json, id)/setTokenMBL(json, id) are used to set the Wall VBL/Hill VBL/Pit VBL/MBL of a token.
  • transferVBL(direction, delete, id)/transferHillVBL(direction, delete, id)/transferPitVBL(direction, delete, id)/transferMBL(direction, delete, id) are used to copy or move topology from a map to a token or vice-versa.

When a token has a given type of topology, the effect is as if the map has that topology at the token's location. The difference is that a token's topology moves with the token, unlike the map topology. An additional difference is that a token's topology is ignored when that token is pathfinding, so that a token cannot block its own movement. The same does not hold true for vision: for example, a token carrying Pit VBL cannot see outside of its own topology.

Release Notes

  • Added Hill VBL, Pit VBL and MBL for tokens, and macro functions for interacting with them.

This change is Reviewable

New features
---
- Macro functions for manipulating token topology
  - `getTokenHillVBL`
  - `getTokenPitVBL`
  - `getTokenMBL`
  - `setTokenHillVBL`
  - `setTokenPitVBL`
  - `setTokenMBL`
  - `transferHillVBL`
  - `transferPitVBL`
  - `transferMBL`
- Token topology is rendered in distinct colours for each topology type.
- Color sensitivity for auto-generated topology is remembered per topology type.

Internal changes / refactorings
---
- Token model now has fields for Hill VBL, Pit VBL and MBL in addition to the existing Wall VBL.
  - Token model update command `setVBL` has been replaced by `setTopology` which requires a topology type to be sent as
    well as the area.
- Protobuf Token DTO has been extended to support the new fields.
- The macro function code under `Topology_Functions` was refactored so that each kind of function is handled by a
  separate method rather than keeping all that code in a single method under an if/else chain.
- `Zone` and `ZoneView` only expose topology via `TopologyType` rather than having distinct methods for each kind of
  topology.
- Topology caching in `ZoneView` has been revamped.
  - `ZoneView` no longer caches the token topology `Area`s and instead just caches the total topology of the map plus
    tokens.
  - `ZoneView` now caches the topology `Area`s for each topology type instead of just the `AreaTree`s. This benefits the
    A* walker because it needs the `Area`s but previously had to rely on the expensive `AreaTree`s.
  - The cached `AreaTree`s are now only needed internally to `ZoneView`, for passing to the FoW calculations.
- Most methods with the term "VBL" in the name now use "topology" to make clear that they are more general.

Bug fixes
---
- Subtle issue in A* algorithm to only subtract token topology from total topology of the same type. Previously a
  token's Wall VBL would be subtracted from all topologies.

VBL => topology
@kwvanderlinde
Copy link
Collaborator Author

@thelsing I'd especially love to get your feedback on the protobuf changes if possible as I've hardly worked with protobuf before. So I just made changes that work (based on testing), but I have no idea if they are good.

@Phergus Phergus requested a review from thelsing June 4, 2022 17:18
Copy link
Contributor

@Phergus Phergus left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewed 17 of 17 files at r1, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @thelsing)

@Phergus Phergus merged commit 5a15c1c into RPTools:develop Jun 4, 2022
@kwvanderlinde kwvanderlinde deleted the feature/3052/token-hill-and-pit-vbl-plus-mbl branch June 14, 2022 03:22
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.

2 participants