Repository navigation
Add ExplosionCollider component - #1195
Open
earthwise01 wants to merge 3 commits into
Open
earthwise01 wants to merge 3 commits into
earthwise01 wants to merge 3 commits into
Conversation
aonkeeper4
approved these changes
Nov 15, 2026
Comment on lines
+61
to
+72
| public static void TriggerExplosionColliders(Entity entity) { | ||
| // collect the colliding components beforehand so no side effects from their `OnCollide` will affect which components are checked | ||
| ExplosionCollider[] collidingExplosionColliders = entity.Scene.Tracker | ||
| .GetComponents<ExplosionCollider>() | ||
| .Cast<ExplosionCollider>() | ||
| .Where(c => c.OnCollide != null && c.Check(entity)) | ||
| .ToArray(); | ||
|
|
||
| foreach (ExplosionCollider explosionCollider in collidingExplosionColliders) { | ||
| explosionCollider.OnCollide(entity, entity.Center); | ||
| } | ||
| } |
Contributor
There was a problem hiding this comment.
would b nice to be able to specify the explosion center separately, e.g.
Suggested change
| public static void TriggerExplosionColliders(Entity entity) { | |
| // collect the colliding components beforehand so no side effects from their `OnCollide` will affect which components are checked | |
| ExplosionCollider[] collidingExplosionColliders = entity.Scene.Tracker | |
| .GetComponents<ExplosionCollider>() | |
| .Cast<ExplosionCollider>() | |
| .Where(c => c.OnCollide != null && c.Check(entity)) | |
| .ToArray(); | |
| foreach (ExplosionCollider explosionCollider in collidingExplosionColliders) { | |
| explosionCollider.OnCollide(entity, entity.Center); | |
| } | |
| } | |
| public static void TriggerExplosionColliders(Entity entity, Vector2? explosionCenter = null) { | |
| // collect the colliding components beforehand so no side effects from their `OnCollide` will affect which components are checked | |
| ExplosionCollider[] collidingExplosionColliders = entity.Scene.Tracker | |
| .GetComponents<ExplosionCollider>() | |
| .Cast<ExplosionCollider>() | |
| .Where(c => c.OnCollide != null && c.Check(entity)) | |
| .ToArray(); | |
| foreach (ExplosionCollider explosionCollider in collidingExplosionColliders) { | |
| explosionCollider.OnCollide(entity, explosionCenter ?? entity.Center); | |
| } | |
| } |
(would require changes to patches obviously)
Contributor
Author
There was a problem hiding this comment.
ohh true that would be very nicies
would it b too evil to make the vector2 arg not nullable and have a TriggerExplosionColliders(Entity entity) => TriggerExplosionColliders(entity, entity.Center); overload though .. depending on if i feel like doing more generics in ilpatches ..
Contributor
There was a problem hiding this comment.
afaik you shouldnt even need to do any more generics stuff, just a ldnull should work to emit a null Vector2?, but like ya idm
(edit: don't do this. Vector2? is still a value type so emitting a null reference explod s 💥 )
This branch has not been deployed
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Adds an
ExplosionCollidercomponent to allow modded entities to more easily define custom interactions with the explosions created by puffers and seekers, without each mod having to hook the relevant explosion code.Vanilla entities affected by puffer/seeker explosions (excluding players and theo crystals) have also been made to use
ExplosionCollidercomponents instead of having their interactions hardcoded.This also allows modded entities which produce similar explosions to easily handle explosion interactions (including with other modded entities!) by calling the
ExplosionCollider.TriggerExplosionCollidersmethod.