Getting the entity that has a known BaseEntity in its known slot?Solved
Basically, there's a CodeLock (or a KeyLock), I have its BaseEntity. It is neatly residing in the Lock slot of a certain entity - be it a door, a box, whatever. I need to find out what that entity is so I can get its prefab name.

I know how to do this in reverse: I have the door (or a box or whatever) and I need to get its lock entity? Easy.
entity.GetSlot(BaseEntity.Slot.Lock);​

Any tips would be greatly appreciated. My first plugin is nearly finished if I manage to get over this hurdle. Thanks!

(I know, I know. Too many "knowns" in the title. I didn't know how else to title it. But you know what? ... Okay I'll stop now :D)


EDIT: I can think of a dirty hack using foreach over all BaseEntities and the Where clause (so I can check if it, first, has the Lock slot, and then, whether it contains the particular entity I know - but since I am ALREADY iterating over all BaseLock entities and I'm doing this for every lock, I feel like the O(n^2) complexity is way unneccessary overhead.
...Nevermind. Once again, I found it by complete accident in another plugin.

For anyone who's wondering, it's as simple as
BaseEntity ent = lockEntityOrWhateverYouNamedIt.GetParent();​
Locked automatically