VoxelEngine/Objects/Identifiable.py

16 lines
338 B
Python
Raw Permalink Normal View History

2020-11-08 10:20:23 +01:00
from multiprocessing import Semaphore
creatingID = Semaphore()
class Identifiable:
lastID: int = 0
def __init__(self):
creatingID.acquire()
self.lastID += 1
self.id = self.lastID
creatingID.release()
def __eq__(self, other):
return self.id == other.id and type(self) == type(other)