thesadrogue / TheSadRogue.Integration

An integration library between SadConsole and GoRogue
MIT License
8 stars 5 forks source link

All IDs for RogulikeEntities Currently 0 #29

Closed Chris3606 closed 3 years ago

Chris3606 commented 3 years ago

Issue

The current implementation of RogueLikeEntity never assigns to the ID field; so it is always 0. This is a critical performance issue because it means that operations for RogueLikeMap.Entities become O(n) instead of the intended O(1).

Proposed Solution

This is fixed implicitly if the proposed solution in #26 is implemented, as the way GoRogue.GameFramework.GameObject implements idGenerator solves this. So one way to fix it would be to simply implement #26.

A minimal solution would involve adding ID = GoRogue.GlobalRandom.DefaultRNG.NextUInt(); to the constructor(s) of RogueLikeEntity. It isn't as flexible as the solution described above, but prevents the efficiency loss.