mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-04 10:54:24 -04:00
support for distributed parent tokens as strings
This commit is contained in:
parent
65a3c30dea
commit
af09aed6ea
@ -4,6 +4,7 @@ from ShowBaseGlobal import *
|
|||||||
from PandaModules import NodePath
|
from PandaModules import NodePath
|
||||||
import DistributedObject
|
import DistributedObject
|
||||||
import Task
|
import Task
|
||||||
|
import types
|
||||||
|
|
||||||
class DistributedNode(DistributedObject.DistributedObject, NodePath):
|
class DistributedNode(DistributedObject.DistributedObject, NodePath):
|
||||||
"""Distributed Node class:"""
|
"""Distributed Node class:"""
|
||||||
@ -13,6 +14,7 @@ class DistributedNode(DistributedObject.DistributedObject, NodePath):
|
|||||||
self.DistributedNode_initialized
|
self.DistributedNode_initialized
|
||||||
except:
|
except:
|
||||||
self.DistributedNode_initialized = 1
|
self.DistributedNode_initialized = 1
|
||||||
|
self.gotStringParentToken = 0
|
||||||
DistributedObject.DistributedObject.__init__(self, cr)
|
DistributedObject.DistributedObject.__init__(self, cr)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@ -31,6 +33,7 @@ class DistributedNode(DistributedObject.DistributedObject, NodePath):
|
|||||||
|
|
||||||
def generate(self):
|
def generate(self):
|
||||||
DistributedObject.DistributedObject.generate(self)
|
DistributedObject.DistributedObject.generate(self)
|
||||||
|
self.gotStringParentToken = 0
|
||||||
|
|
||||||
def __cmp__(self, other):
|
def __cmp__(self, other):
|
||||||
# DistributedNode inherits from NodePath, which inherits a
|
# DistributedNode inherits from NodePath, which inherits a
|
||||||
@ -47,15 +50,36 @@ class DistributedNode(DistributedObject.DistributedObject, NodePath):
|
|||||||
### setParent ###
|
### setParent ###
|
||||||
|
|
||||||
def b_setParent(self, parentToken):
|
def b_setParent(self, parentToken):
|
||||||
|
if type(parentToken) == types.StringType:
|
||||||
|
self.setParentStr(parentToken)
|
||||||
|
else:
|
||||||
self.setParent(parentToken)
|
self.setParent(parentToken)
|
||||||
# it's important to call the local setParent first.
|
# it's important to call the local setParent first.
|
||||||
self.d_setParent(parentToken)
|
self.d_setParent(parentToken)
|
||||||
|
|
||||||
def d_setParent(self, parentToken):
|
def d_setParent(self, parentToken):
|
||||||
|
if type(parentToken) == types.StringType:
|
||||||
|
self.sendUpdate("setParentStr", [parentToken])
|
||||||
|
else:
|
||||||
self.sendUpdate("setParent", [parentToken])
|
self.sendUpdate("setParent", [parentToken])
|
||||||
|
|
||||||
|
def setParentStr(self, parentTokenStr):
|
||||||
|
print 'setParentStr: %s' % parentTokenStr
|
||||||
|
print 'isGenerated: %s' % self.isGenerated()
|
||||||
|
self.do_setParent(parentTokenStr)
|
||||||
|
if len(parentTokenStr) > 0:
|
||||||
|
self.gotStringParentToken = 1
|
||||||
|
|
||||||
def setParent(self, parentToken):
|
def setParent(self, parentToken):
|
||||||
|
print 'setParent: %s' % parentToken
|
||||||
|
print 'isGenerated: %s' % self.isGenerated()
|
||||||
|
# if we are not yet generated and we just got a parent token
|
||||||
|
# as a string, ignore whatever value comes in here
|
||||||
|
justGotRequiredParentAsStr = ((not self.isGenerated()) and
|
||||||
|
self.gotStringParentToken)
|
||||||
|
if not justGotRequiredParentAsStr:
|
||||||
self.do_setParent(parentToken)
|
self.do_setParent(parentToken)
|
||||||
|
self.gotStringParentToken = 0
|
||||||
|
|
||||||
def do_setParent(self, parentToken):
|
def do_setParent(self, parentToken):
|
||||||
"""do_setParent(self, int parentToken)
|
"""do_setParent(self, int parentToken)
|
||||||
|
@ -12,8 +12,10 @@ class DistributedNodeAI(DistributedObjectAI.DistributedObjectAI):
|
|||||||
### setParent ###
|
### setParent ###
|
||||||
|
|
||||||
def d_setParent(self, parentString):
|
def d_setParent(self, parentString):
|
||||||
|
if type(parentString) == type(''):
|
||||||
|
self.sendUpdate("setParentStr", [parentString])
|
||||||
|
else:
|
||||||
self.sendUpdate("setParent", [parentString])
|
self.sendUpdate("setParent", [parentString])
|
||||||
return None
|
|
||||||
|
|
||||||
def setParent(self, parentString):
|
def setParent(self, parentString):
|
||||||
pass
|
pass
|
||||||
|
Loading…
x
Reference in New Issue
Block a user