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 get_liquids_at function and small stuff #392

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

estebanfer
Copy link
Contributor

I added the ENTITY_MASK enum, I didn't if name it MASK because sounds too much of a generic name, but if someone thinks it's fine then I'll change it

WATER = 0x2000,
LAVA = 0x4000,
LIQUID = 0x6000,
NONE = 0x0,
Copy link
Contributor

Choose a reason for hiding this comment

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

We use 0 as ANY, not NONE. This can be confusing, maybe just add both?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Perhaps both, it was weird to do something like (mask & ENTITY_MASK::WATER) == ENTITY_MASK::ANY

Copy link
Contributor

@Mr-Auto Mr-Auto Aug 3, 2024

Choose a reason for hiding this comment

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

I would do == 0 in that case. Or the inverse != ENTITY_MASK::WATER
Using mask to test for another mask feels weird
(and yes, i know it it's not allowed by default with enum class in C++ to just compare with integer)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it's kinda annoying that it's not possible to just do if (mask & ENTITY_MASK::WATER) and you have to do either (mask & ENTITY_MASK::WATER) == ENTITY_MASK::WATER or static_cast<uint32_t>(mask & ENTITY_MASK::WATER)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Would this be fine in aliases.hpp?

template <class T>
bool test_flags(T flags, T test_flags)
{
    return (flags & test_flags) == test_flags;
}

Copy link
Collaborator

Choose a reason for hiding this comment

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

Whatever you think makes this enum easier to use and compare is fine.

@Mr-Auto
Copy link
Contributor

Mr-Auto commented Aug 4, 2024

Btw. I'm still trying to figure out why would anyone want to know number of liquid entity/particles in a tile?
what's the use?

@estebanfer
Copy link
Contributor Author

The array is how the game mostly checks for liquid collisions (eg. Entity:is_in_liquid() uses it), it makes sense to also use it for mods, and not be checking for if every blob of liquid is colliding a hitbox

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.

3 participants