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

Refactor & fix bugs. #29

Merged
merged 1 commit into from
Sep 15, 2021
Merged

Refactor & fix bugs. #29

merged 1 commit into from
Sep 15, 2021

Conversation

knightofiam
Copy link
Member

Player:

  • Fix some player state machine bugs preventing player from transitioning to
    the correct state due to having multiple valid triggers, which in turn is
    caused by not being specific enough when specifying trigger conditions
    during state machine initialization. This reduces strange bugs where the
    player gets stuck in a specific state or won't take a valid action like
    reading a sign, or the player doesn't respond to a specific valid input.

  • Fix tile dropdown bug that was occurring, for example, when standing
    on top of arrow signs, MoveAndSlide is detecting a collision between
    the player and sign, but the player's Area2D animation collider rect
    is not actually overlapping the sign tile, and the reported
    collision point when converted to a tile cell coordinate confirms
    this. Do not drop down when there is no actual tile being
    intersected, even if a collision is being reported. Perhaps in the
    future there could be a one tile cell margin added to detect overlap
    to account for the player being very close to the tile..

  • Remove player idle back animation delay when finished reading a sign, at
    least for now. It looked a bit awkward when finished reading a sign from too
    far off center.

Editor / Scenes:

  • Simplify main scene by combining upper & lower cliffs to reduce level
    complexity and duplication by almost 50%. Merge lower cliffs into upper
    cliffs and rename upper cliffs to cliffs.

  • Restructure the ground colliders to make them more reliable & way less
    buggy.

  • Reorganize & rename many nodes in Godot editor for simplicity & readability,
    which was made possible by the merging of upper and lower cliffs.

  • Reorganize the 10 waterfall sections so that section 1 is the very top and
    section 10 is the very bottom, respectively, which is a much more intuitive
    layout.

  • Lock some nodes in the editor to prevent them from being accidentally
    modified.

Tiles:

  • Heavily rework tile intersection code in Tools.cs to improve accuracy and
    eliminate bugs. Allow units per tile aka cell size to vary from 1 to 16 for
    precise placement of tiles without affecting collision and overlap
    detection.

  • Greatly simplify player updates in Cliff.cs for detecting both cliff
    enclosing & ice intersection code.

Signals:

  • Move ground detection signal callbacks for the player from Cliffs.cs to
    Player.cs which greatly simplifies everything, including not having to add
    duplicate callbacks in both classes.

  • Block more signals while changing player's animation-based collision shape
    to prevent signal callbacks from being triggered more than they should be.
    This is an ongoing workaround for
    Changing node parent produces Area2D/3D signal duplicates godotengine/godot#14578 "Changing node parent
    produces Area2D/3D signal duplicates".

  • Don't block sign signals anymore because it causes problems with reading the
    sign because it doesn't consistently detect the player is in the sign, and
    it's working fine without the blocking.

  • Improve naming of some signal callback methods.

Player.cs refactoring:

  • Remove the use of delta from Player.cs, where it mainly a hack; awaiting a
    certain amount of idle frames has been more efficient.

  • Add more private convenience methods for energy meter management to simplify
    the code & increase readability.

  • Add more private convenience methods for sign reading management to simplify
    the code & increase readability.

  • Make fields whose value changes in async methods volatile to prevent the
    wrong value from being read, causing hard to track down bugs.

General refactoring:

  • Move more GetNode calls into _Ready methods and assign them to fields for
    efficiency, code simplicity, readability, & less possibilities for bugs.

Tools:

  • Don't throw an exception in Tools when checking if any arrow key is pressed
    except the specified one, when the specified input is invalid; just return
    false to decrease game crashes.

Extensions:

  • Add a string extension method for allowing the use of the null coalescing
    operator to work with empty strings, which greatly simplifies
    string-handling code, e.g., when using the ternary operator to return
    strings from methods.

Cleanup:

  • Remove unused & obsolete classes.
  • Remove unused & obsolete methods.
  • Remove outdated & unnecessary comments.
  • Suppress unnecessary compiler warnings with comments for increased readability.
  • Remove obsolete compiler warning suppression comments.
  • Rename some outdated variables for increased clarity on their purpose.
  • Rename some methods for simplicity.
  • Reorganize order of some fields for increased readability>
  • Remove obsolete formatter-disabling tags for code blocks.
  • Add formatter-disabling tags where necessary.
  • Add some TODO's.
  • Improve many log messages.
  • Improve code formatting.

Player:

  - Fix some player state machine bugs preventing player from transitioning to
    the correct state due to having multiple valid triggers, which in turn is
    caused by not being specific enough when specifying trigger conditions
    during state machine initialization. This reduces strange bugs where the
    player gets stuck in a specific state or won't take a valid action like
    reading a sign, or the player doesn't respond to a specific valid input.

  - Fix tile dropdown bug that was occurring, for example, when standing
    on top of arrow signs, MoveAndSlide is detecting a collision between
    the player and sign, but the player's Area2D animation collider rect
    is not actually overlapping the sign tile, and the reported
    collision point when converted to a tile cell coordinate confirms
    this. Do not drop down when there is no actual tile being
    intersected, even if a collision is being reported. Perhaps in the
    future there could be a one tile cell margin added to detect overlap
    to account for the player being very close to the tile..

  - Remove player idle back animation delay when finished reading a sign, at
    least for now. It looked a bit awkward when finished reading a sign from too
    far off center.

Editor / Scenes:

  - Simplify main scene by combining upper & lower cliffs to reduce level
    complexity and duplication by almost 50%. Merge lower cliffs into upper
    cliffs and rename upper cliffs to cliffs.

  - Restructure the ground colliders to make them more reliable & way less
    buggy.

  - Reorganize & rename many nodes in Godot editor for simplicity & readability,
    which was made possible by the merging of upper and lower cliffs.

  - Reorganize the 10 waterfall sections so that section 1 is the very top and
    section 10 is the very bottom, respectively, which is a much more intuitive
    layout.

  - Lock some nodes in the editor to prevent them from being accidentally
    modified.

Tiles:

  - Heavily rework tile intersection code in Tools.cs to improve accuracy and
    eliminate bugs. Allow units per tile aka cell size to vary from 1 to 16 for
    precise placement of tiles without affecting collision and overlap
    detection.

  - Greatly simplify player updates in Cliff.cs for detecting both cliff
    enclosing & ice intersection code.

Signals:

  - Move ground detection signal callbacks for the player from Cliffs.cs to
    Player.cs which greatly simplifies everything, including not having to add
    duplicate callbacks in both classes.

  - Block more signals while changing player's animation-based collision shape
    to prevent signal callbacks from being triggered more than they should be.
    This is an ongoing workaround for
    godotengine/godot#14578 "Changing node parent
    produces Area2D/3D signal duplicates".

  - Don't block sign signals anymore because it causes problems with reading the
    sign because it doesn't consistently detect the player is in the sign, and
    it's working fine without the blocking.

  - Improve naming of some signal callback methods.

Player.cs refactoring:

  - Remove the use of delta from Player.cs, where it mainly a hack; awaiting a
    certain amount of idle frames has been more efficient.

  - Add more private convenience methods for energy meter management to simplify
    the code & increase readability.

  - Add more private convenience methods for sign reading management to simplify
    the code & increase readability.

  - Make fields whose value changes in async methods volatile to prevent the
    wrong value from being read, causing hard to track down bugs.

General refactoring:

  - Move more GetNode calls into _Ready methods and assign them to fields for
    efficiency, code simplicity, readability, & less possibilities for bugs.

Tools:

  - Don't throw an exception in Tools when checking if any arrow key is pressed
    except the specified one, when the specified input is invalid; just return
    false to decrease game crashes.

Extensions:

  - Add a string extension method for allowing the use of the null coalescing
    operator to work with empty strings, which greatly simplifies
    string-handling code, e.g., when using the ternary operator to return
    strings from methods.

Cleanup:

  - Remove unused & obsolete classes.
  - Remove unused & obsolete methods.
  - Remove outdated & unnecessary comments.
  - Suppress unnecessary compiler warnings with comments for increased readability.
  - Remove obsolete compiler warning suppression comments.
  - Rename some outdated variables for increased clarity on their purpose.
  - Rename some methods for simplicity.
  - Reorganize order of some fields for increased readability>
  - Remove obsolete formatter-disabling tags for code blocks.
  - Add formatter-disabling tags where necessary.
  - Add some TODO's.
  - Improve many log messages.
  - Improve code formatting.
@knightofiam knightofiam merged commit f93e698 into develop Sep 15, 2021
@knightofiam knightofiam deleted the fix-bugs-refactor branch September 15, 2021 14:34
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.

1 participant