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

projectile refactoring: fixes, docs, enhancements #2295

Merged
merged 2 commits into from
Jul 3, 2024

Conversation

Arufonsu
Copy link
Contributor

  • projectile related code has been refactored, documented and commented.
  • renamed variables to follow current Intersect's naming conventions.
  • fixed variable typos.
  • removed unused variables, libraries and imports.
  • a lot of methods have been merged into one (GetProjectileOffset, GetRange, FindProjectileRotation) for better organization.
  • created AdjustPositionOnMapBoundaries methods for better organization within CheckForCollision (server and client)
  • Suppress finalization to optimize garbage collection on projectile disposal (client), this is important for performance and to prevent the finalizer from running.
  • fixes server crash due to IndexOutOfRangeException when attacking across maps and when NPCs change maps (bug: server closes when attacking entity with projectile #2287).
  • fixes projectiles not crossing map boundaries when stepping into more than one boundary (ie. diagonal crossing maps) (bug: Projectile passes through NPCs. #2291).
  • fixes server crash due to Z Dimension and Z block level issues with projectiles (bug was discovered while working on this).
  • fixes projectile issues when stepping into Z block attributes, now they are destroyed when they are supposed to (this never worked as intended).
  • Linear interpolation improvements (client): we had time as a constant, this caused the two problems: non linear movement and the object not actually reaching the target position visually, so now, linear interpolation is dinamically based on the elapsed time since the projectile was spawned. Also, The interpolation factor is now clamped to ensure that the projectile does not overshoot its target position.
  • GetProjectileLerping considers Options.Instance.Processing.ProjectileUpdateInterval in order to visually adjust projectiles according to the server update intervals
  • Pattern Matching Enhancements: specifically the use of the switch expression with pattern matching introduced in C# 8.0 and enhanced in later versions. The use of the or keyword to combine multiple patterns in a single case is a feature of these enhancements, allowing for more concise and readable code when checking for multiple conditions. (GetRange, FindProjectileRotation.

Preview

(projectiles across maps - diagonally - map edges - fixes #2287)

1.mp4

(fixes #2287)

2.1.mp4

(ZD block levels fixed for projectiles, they are actually destroyed when they should now - also doesn't crashes the server with homing nor direct projectiles anymore)
image

3.mp4

(Linear interpolation visual improvements)

4.mp4

- projectile related code has been refactored, documented and commented.
- renamed variables to follow current Intersect's naming conventions.
- fixed variable typos.
- removed unused variables, libraries and imports.
- a lot of methods have been merged into one (GetProjectileOffset, GetRange, FindProjectileRotation) for better organization.
- created AdjustPositionOnMapBoundaries methods for better organization within CheckForCollision (server and client)
- Suppress finalization to optimize garbage collection on projectile disposal (client), this is important for performance and to prevent the finalizer from running.
- fixes server crash due to IndexOutOfRangeException when attacking across maps.
- fixes projectiles not crossing map boundaries when stepping into more than one boundary (ie. diagonal crossing maps).
- fixes server crash due to Z Dimension and Z block level issues with projectiles.
- fixes projectile issues when stepping into Z block attributes, now they are destroyed when they are supposed to.
- Linear interpolation improvements (client): we had time as a constant, this caused the two problems: non linear movement and the object not actually reaching the target position visually, so now, linear interpolation is dinamically based on the elapsed time since the projectile was spawned. Also, The interpolation factor is now clamped to ensure that the projectile does not overshoot its target position.
- GetProjectileLerping considers Options.Instance.Processing.ProjectileUpdateInterval in order to visually adjust projectiles according to the server update intervals
- Pattern Matching Enhancements: specifically the use of the switch expression with pattern matching introduced in C# 8.0 and enhanced in later versions. The use of the or keyword to combine multiple patterns in a single case is a feature of these enhancements, allowing for more concise and readable code when checking for multiple conditions. (GetRange, FindProjectileRotation.
@Arufonsu Arufonsu added enhancement Minor feature addition or quality of life change chore Cleans up code, documentation or project structure without altering functionality performance Performance optimization bug fix Pull request that fixes a bug labels Jun 30, 2024
@Arufonsu Arufonsu requested a review from WeylonSantana June 30, 2024 17:50
@Arufonsu Arufonsu linked an issue Jun 30, 2024 that may be closed by this pull request
1 task
@Arufonsu Arufonsu requested a review from a team June 30, 2024 18:56
Intersect.Client/Entities/Projectiles/Projectile.cs Outdated Show resolved Hide resolved
Intersect.Client/Entities/Projectiles/Projectile.cs Outdated Show resolved Hide resolved
Intersect.Client/Entities/Projectiles/Projectile.cs Outdated Show resolved Hide resolved
Intersect.Client/Entities/Projectiles/Projectile.cs Outdated Show resolved Hide resolved
Intersect.Client/Entities/Projectiles/Projectile.cs Outdated Show resolved Hide resolved
Intersect.Server.Core/Entities/Projectile.cs Outdated Show resolved Hide resolved
Intersect.Server.Core/Entities/Projectile.cs Show resolved Hide resolved
Intersect.Server.Core/Entities/Projectile.cs Outdated Show resolved Hide resolved
Intersect.Server.Core/Entities/Projectile.cs Outdated Show resolved Hide resolved
Intersect.Server.Core/Entities/Projectile.cs Outdated Show resolved Hide resolved
@Arufonsu Arufonsu requested a review from WeylonSantana July 2, 2024 02:51
@Arufonsu Arufonsu force-pushed the refactoring/projectiles-june-2024 branch from 80ce56f to bc76e88 Compare July 2, 2024 22:14
@Arufonsu Arufonsu merged commit 4d650f0 into main Jul 3, 2024
1 check passed
@Arufonsu
Copy link
Contributor Author

Arufonsu commented Jul 3, 2024

Thanks to @WeylonSantana for reviewing, we ended up with a very clean and organized PR 🎊

cydyn pushed a commit to cydyn/Intersect-Engine that referenced this pull request Jul 3, 2024
)

* projectile refactoring: fixes, docs, enhancements

- projectile related code has been refactored, documented and commented.
- renamed variables to follow current Intersect's naming conventions.
- fixed variable typos.
- removed unused variables, libraries and imports.
- a lot of methods have been merged into one (GetProjectileOffset, GetRange, FindProjectileRotation) for better organization.
- created AdjustPositionOnMapBoundaries methods for better organization within CheckForCollision (server and client)
- Suppress finalization to optimize garbage collection on projectile disposal (client), this is important for performance and to prevent the finalizer from running.
- fixes server crash due to IndexOutOfRangeException when attacking across maps.
- fixes projectiles not crossing map boundaries when stepping into more than one boundary (ie. diagonal crossing maps).
- fixes server crash due to Z Dimension and Z block level issues with projectiles.
- fixes projectile issues when stepping into Z block attributes, now they are destroyed when they are supposed to.
- Linear interpolation improvements (client): we had time as a constant, this caused the two problems: non linear movement and the object not actually reaching the target position visually, so now, linear interpolation is dinamically based on the elapsed time since the projectile was spawned. Also, The interpolation factor is now clamped to ensure that the projectile does not overshoot its target position.
- GetProjectileLerping considers Options.Instance.Processing.ProjectileUpdateInterval in order to visually adjust projectiles according to the server update intervals
- Pattern Matching Enhancements: specifically the use of the switch expression with pattern matching introduced in C# 8.0 and enhanced in later versions. The use of the or keyword to combine multiple patterns in a single case is a feature of these enhancements, allowing for more concise and readable code when checking for multiple conditions. (GetRange, FindProjectileRotation.

* weylon's review (I)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug fix Pull request that fixes a bug chore Cleans up code, documentation or project structure without altering functionality enhancement Minor feature addition or quality of life change performance Performance optimization
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

bug: Projectile passes through NPCs. bug: server closes when attacking entity with projectile
2 participants