2019-12-30 00:00:16 -06:00
|
|
|
from . import Entity, BasicEntities
|
2022-12-16 18:40:57 -06:00
|
|
|
from panda3d.core import NodePath
|
2019-11-02 17:27:54 -05:00
|
|
|
from direct.directnotify import DirectNotifyGlobal
|
|
|
|
|
|
|
|
class LocatorEntity(Entity.Entity, NodePath):
|
|
|
|
notify = DirectNotifyGlobal.directNotify.newCategory('LocatorEntity')
|
|
|
|
|
|
|
|
def __init__(self, level, entId):
|
|
|
|
node = hidden.attachNewNode('LocatorEntity-%s' % entId)
|
|
|
|
NodePath.__init__(self, node)
|
|
|
|
Entity.Entity.__init__(self, level, entId)
|
|
|
|
self.doReparent()
|
|
|
|
|
|
|
|
def destroy(self):
|
|
|
|
Entity.Entity.destroy(self)
|
|
|
|
self.removeNode()
|
|
|
|
|
|
|
|
def getNodePath(self):
|
|
|
|
return self
|
|
|
|
|
|
|
|
def doReparent(self):
|
|
|
|
if self.searchPath != '':
|
|
|
|
parent = self.level.geom.find(self.searchPath)
|
|
|
|
if parent.isEmpty():
|
|
|
|
LocatorEntity.notify.warning("could not find '%s'" % self.searchPath)
|
|
|
|
self.reparentTo(hidden)
|
|
|
|
else:
|
|
|
|
self.reparentTo(parent)
|
|
|
|
|
|
|
|
if __dev__:
|
|
|
|
|
|
|
|
def attribChanged(self, attrib, value):
|
|
|
|
self.doReparent()
|