def addEntity(self, ent_proxy):
     if not issubclass(ent_proxy, Entity): raise TypeError
     ent_proxy = ent_proxy()
     try:
         ent = self.entityCache.pop()
     except IndexError:
         ent = EntityProxy(world=self.world)
         ent_name = getClassName(EntityProxy) + str(self.nextId)
         ent.id = EntityBitTracker.getBit(ent_name)
         self.nextId += 1
     
     ent.oldCls = getClassName(ent_proxy)
     [ent.addComponent(comp_cls) for comp_cls in ent_proxy.database.viewvalues()]
     self.entityMask += ent.id
     self.database[ent.id] = ent
     return ent.id
Beispiel #2
0
 def addComponent(self, comp_cls):
     #comp_id = self.ComponentManager.addComponent(self.id, comp_cls)
     if not issubclass(comp_cls, Component): raise TypeError
     comp_id = ComponentBitTracker.getBit(comp_cls)
     self.database[getClassName(comp_cls).lower()] = comp_cls(
         world=self.world)
     self.compBits |= comp_id
Beispiel #3
0
    def addEntity(self, ent_proxy):
        if not issubclass(ent_proxy, Entity): raise TypeError
        ent_proxy = ent_proxy()
        try:
            ent = self.entityCache.pop()
        except IndexError:
            ent = EntityProxy(world=self.world)
            ent_name = getClassName(EntityProxy) + str(self.nextId)
            ent.id = EntityBitTracker.getBit(ent_name)
            self.nextId += 1

        ent.oldCls = getClassName(ent_proxy)
        [
            ent.addComponent(comp_cls)
            for comp_cls in ent_proxy.database.values()
        ]
        self.entityMask += ent.id
        self.database[ent.id] = ent
        return ent.id
 def addComponent(self, comp_cls):
     #comp_id = self.ComponentManager.addComponent(self.id, comp_cls)
     if not issubclass(comp_cls, Component): raise TypeError
     comp_id = ComponentBitTracker.getBit(comp_cls)
     self.database[getClassName(comp_cls).lower()] = comp_cls(world=self.world)        
     self.compBits |= comp_id
 def addComponent(self, comp_cls):
     self.database[getClassName(comp_cls)] = comp_cls
Beispiel #6
0
 def addComponent(self, comp_cls):
     self.database[getClassName(comp_cls)] = comp_cls
Beispiel #7
0
 def addManager(self, manager, priority=0):
     if not issubclass(manager, BaseManager): raise TypeError(manager)
     manager_name = getClassName(manager)
     if manager_name not in self.database.keys():
         manager_cls = manager(priority=priority, world=self)
         self.database[manager_name] = manager_cls
Beispiel #8
0
 def addManager(self, manager, priority=0):
     if not issubclass(manager, BaseManager): raise TypeError(manager)
     manager_name = getClassName(manager)
     if manager_name not in self.database.viewkeys():
         manager_cls = manager(priority=priority, world=self)
         self.database[manager_name] = manager_cls