Uniquely and consistently identifying deployed entities?Solved
https://pastebin.com/zgCxQiS0

So basically, when I deploy an item, I'd like to be able to check if it was a codelock or a keylock, and if so, put all that information - kind (CodeLock/KeyLock), who put it down, and the timestamp - into the cache/stored data. Then, every minute or so, the plugin will go through all the codelocks/keylocks on the server, and based on the settings (time to decay), it will unlock those that have exceeded the maximum amount of minutes between the timestamp (which gets updated every time someone succesfully accesses the container / opens the door with the lock on) and the current timestamp.
I haven't even started on the cache/data/config yet, before all that, I just want to make sure I can get consistent results. I thought InstanceID might be it. Apparently it's not. I wanted to see what the InstanceID of the Deployer object was. Instantly after dealing with it, in the "test" section, its InstanceID won't show up later in the foreach statement.

Is my only option basically taking the Vector3 position of the entity and use that as a Hash key for the cache/stored data? What would that key look as plain text when JSON-ised to stored? Position is the only thing that I can think of that would stay consistent at all times, even when removed/placed again. Let me know if you got better ideas, thanks!
I believe the *.net.ID is what you are looking for.
5e13a8d5b2bc5.jpg Wulf
I believe the *.net.ID is what you are looking for.

Thanks so much! I'm gonna give it a go.

Also, I seem to be a little bit confused about what Deployers and Deployables are. I assumed they inherited after whatever entity was deployed, like CodeLock / KeyLock, but apparently they're children of HeldEntities. The statement (deployer is CodeLock || deployer is KeyLock) will never return true and the IDE made me aware of this. I've been digging in the API/decompiling just to see what the relationship between the Deployer and the entity that was deployed is - how do I obtain it? I need to be able to check its type/prefab name to decide whether it's a key/code lock.

Does deploying stuff have more to do with items/inventories than entities?

Thank you!

EDIT: I know I can just check the argument entity (which is supposed to be one of the prefabs on the list - doors, boxes etc) and its slots - but will that information be instantly available at the moment the OnItemDeployed is called?

I'm not that familiar with that aspect, sorry.
Okay I figured it out. The solution was staring me right in the face: the hook is called right AFTER the item has been deployed, so by the time I execute the code, I can just take the entity straight from the slot:

        void OnItemDeployed(Deployer deployer, BaseEntity entity)
        {
            if (deployTargetNames.Contains(entity.ShortPrefabName))
            {
                //let's get the entity that was just put in the slot. is it null?
                BaseEntity lockEntity = entity.GetSlot(deployer.GetDeployable().slot);

                if (lockEntity != null)
                {
                    if (lockEntity is CodeLock || lockEntity is KeyLock)
                    {
                        uint lockNetId = lockEntity.net.ID;
                        Vector3 lockPos = lockEntity.transform.position;
                        BasePlayer placer = deployer.GetOwnerPlayer();

                        PrintWarning($"New {lockEntity.GetType()} with ID {lockNetId.ToString()} placed on {entity.ShortPrefabName} at {lockPos.x}, {lockPos.y}, {lockPos.z} by {placer.displayName} (userID {placer.UserIDString})");
                    }
                }
            }
        }​
Locked automatically