decline-cookies / anvil-unity-dots

Unity DOTS and ECS specific additions and extensions to Anvil
MIT License
4 stars 1 forks source link

EntityPersistentDataReader/Writer - Add helper methods #200

Closed mbaker3 closed 1 year ago

mbaker3 commented 1 year ago

Add helper methods to EntityPersistentDataReader and EntityPersistentDataWriter

What is the current behaviour?

Consumers of EPD readers/writers are not able to iterate over all of the persistent data. This is an unusual usage bust still required in some situations.

Data in an EPD implements IDisposable but it's easy for the developer to forget to dispose the elements when removing them.

What is the new behaviour?

The pass through methods to the backing collection are now exposed.

Add RemoveAndDispose to the writer to help make it easier to correctly remove EPD elements. I'm open to making this the default behaviour of Remove and instead having a RemoveWithoutDispose as a special case method that can be called. Thoughts?

What issues does this resolve?

What PRs does this depend on?

Does this introduce a breaking change?

mbaker3 commented 1 year ago

Sounds good. I just figured that because you're dealing with persistent data...which is something special. There's almost no case where you would want to remove and not dispose.