Browse Source

added Entity.initializeEntity()

Dave Schuyler 22 years ago
parent
commit
72c594b362

+ 2 - 1
direct/src/level/DistributedEntity.py

@@ -8,6 +8,7 @@ class DistributedEntity(DistributedObject.DistributedObject, Entity.Entity):
 
 
     def __init__(self, cr):
     def __init__(self, cr):
         DistributedObject.DistributedObject.__init__(self, cr)
         DistributedObject.DistributedObject.__init__(self, cr)
+        Entity.Entity.__init__(self)
 
 
     def generateInit(self):
     def generateInit(self):
         DistributedEntity.notify.debug('generateInit')
         DistributedEntity.notify.debug('generateInit')
@@ -31,7 +32,7 @@ class DistributedEntity(DistributedObject.DistributedObject, Entity.Entity):
 
 
         # ask our level obj for our spec data
         # ask our level obj for our spec data
         level = toonbase.tcr.doId2do[self.levelDoId]
         level = toonbase.tcr.doId2do[self.levelDoId]
-        Entity.Entity.__init__(self, level, self.entId)
+        self.initializeEntity(level, self.entId)
 
 
         DistributedObject.DistributedObject.announceGenerate(self)
         DistributedObject.DistributedObject.announceGenerate(self)
 
 

+ 2 - 2
direct/src/level/DistributedInteractiveEntity.py

@@ -22,7 +22,7 @@ class DistributedInteractiveEntity(DistributedEntity.DistributedEntity):
         DistributedEntity.DistributedEntity.__init__(self, cr)
         DistributedEntity.DistributedEntity.__init__(self, cr)
         assert(self.debugPrint("__init()"))
         assert(self.debugPrint("__init()"))
 
 
-        self.fsm = FSM.FSM('Distribu, levelDoId, entIdtedInteractiveEntity',
+        self.fsm = FSM.FSM('DistributedInteractiveEntity',
                            [State.State('off',
                            [State.State('off',
                                         self.enterOff,
                                         self.enterOff,
                                         self.exitOff,
                                         self.exitOff,
@@ -46,7 +46,7 @@ class DistributedInteractiveEntity(DistributedEntity.DistributedEntity):
         
         
     def generate(self):
     def generate(self):
         """generate(self)
         """generate(self)
-        This method is called when the DistributedEntity is reintroduced
+        This method is called when the DistributedEntity is introduced
         to the world, either for the first time or from the cache.
         to the world, either for the first time or from the cache.
         """
         """
         assert(self.debugPrint("generate()"))
         assert(self.debugPrint("generate()"))

+ 3 - 3
direct/src/level/DistributedInteractiveEntityAI.py

@@ -72,9 +72,9 @@ class DistributedInteractiveEntityAI(DistributedEntityAI.DistributedEntityAI):
         return [self.fsm.getCurrentState().getName(),
         return [self.fsm.getCurrentState().getName(),
                 globalClockDelta.getRealNetworkTime()]
                 globalClockDelta.getRealNetworkTime()]
     
     
-    def getOwnerDoId(self):
-        assert(self.debugPrint("getOwnerDoId() returning: %s"%(self.ownerDoId,)))
-        return self.ownerDoId
+    #def getOwnerDoId(self):
+    #    assert(self.debugPrint("getOwnerDoId() returning: %s"%(self.ownerDoId,)))
+    #    return self.ownerDoId
     
     
     def requestInteract(self):
     def requestInteract(self):
         assert(self.debugPrint("requestInteract()"))
         assert(self.debugPrint("requestInteract()"))

+ 9 - 1
direct/src/level/Entity.py

@@ -16,7 +16,15 @@ class Entity:
         ('comment', str, 0),
         ('comment', str, 0),
         )
         )
 
 
-    def __init__(self, level, entId, attribs=None):
+    def __init__(self, level=None, entId=None, attribs=None):
+        if level is not None and entId is not None:
+            self.initializeEntity(level, entId, attribs)
+        else:
+            self.level = level
+            self.entId = entId
+            self.attribs = Entity.Attribs
+
+    def initializeEntity(self, level, entId, attribs=None):
         self.level = level
         self.level = level
         self.entId = entId
         self.entId = entId