Comments (3)
i dont remember exactly what the bugs are.
but your code snippet showcases why we don't recommend that people ever use it: typing local entity = roomEntities:Get(i)
is a waste of time, and confusing for other people reading the code
from isaacdocs.
Isaac.GetRoomEntities()
will return a table that is a view of the entities in the room at the time the function was called, while Room::GetEntities()
will return a userdata that stores a raw pointer to the array in memory that stores the entities in the room. Therefore, iterating over the return value of Room::GetEntities()
will always iterate over the entities present in the room during the current logic frame, while iterating over the return value of Isaac.GetRoomEntities()
will iterate over the entities that were present at the time the function was called.
I'm not sure if the array in memory is sized in such a way that it can store the max possible amount of each entity to avoid resizes, but that's the risk when working with Room::GetEntities()
: since the userdata has a copy of the pointer to the array of entities in memory, if this pointer gets invalidated, which may happen without changing rooms (because resizes), the game may crash when iterating over the content of the userdata. With Isaac.GetRoomEntities()
, the game may crash only if you manipulate the entities inside after changing rooms (maybe also if the entity has been removed since, but I don't know when the game actually frees the memory associated with an entity, maybe it is safe).
from isaacdocs.
Ive improved the descriptions of both functions based on @amaurymaille `s post. Thank you very much for that cool explaination!
if anything other needs to be changed, please reopen the issue :)
Related commit: a877eb7
from isaacdocs.
Related Issues (20)
- Add documentation for Animation Editor Layout bug HOT 1
- Add Improved Itempool editor config file HOT 1
- Removed CollectibleType enums may be reused in new updates HOT 3
- rename ItemConfig::Foo --> ItemConfigFoo HOT 1
- PlayerEntity.SecondaryActiveItem is labelled as AB+/Rep despite the function not existing in Rep HOT 2
- Bug with EntityNPC Morph HOT 6
- EntityPlayer:ChangePlayerType documentation HOT 1
- RoomConfigRoom.Doors documentation is misleading HOT 2
- Add return type to table in docs HOT 5
- Incorrect entry order when sorting by integer enum value HOT 1
- Cookbook page with common functions and solutions HOT 1
- Use tab as search complete in addition to right arrow
- Add .IsFollower property to EntityFamiliar class HOT 1
- Add XML file validator for all xml files HOT 1
- Use decompiled variable names to check for deleted functions HOT 1
- An interactive faq to fix common installation and bug report issues HOT 2
- `<rune>` goes completely undocumented in pocketitems.xml documentation HOT 1
- `<gibs>` should be documented in entities2.xml documentation HOT 2
- Example Code for Isaac.GetPlayerTypeByName() is incorrect for Repentance HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from isaacdocs.