mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-04 10:54:24 -04:00
improved setLocation handling
This commit is contained in:
parent
7e8448cff2
commit
25dd2c7217
@ -789,8 +789,6 @@ class ClientRepository(ConnectionRepository.ConnectionRepository):
|
||||
datagram.addUint32(zoneId)
|
||||
self.send(datagram)
|
||||
|
||||
|
||||
|
||||
else:
|
||||
def sendSetZoneMsg(self, zoneId, visibleZoneList=None):
|
||||
datagram = PyDatagram()
|
||||
|
@ -341,13 +341,18 @@ class DistributedObject(PandaObject):
|
||||
def addInterest(self, zoneId, note="", event=None):
|
||||
self.cr.addInterest(self.getDoId(), zoneId, note, event)
|
||||
|
||||
def b_setLocation(self, parentId, zoneId):
|
||||
self.d_setLocation(parentId, zoneId)
|
||||
self.setLocation(parentId, zoneId)
|
||||
|
||||
def d_setLocation(self, parentId, zoneId):
|
||||
self.cr.sendSetLocation(self.doId, parentId, zoneId)
|
||||
|
||||
def setLocation(self, parentId, zoneId):
|
||||
self.notify.info("setLocation: %s parentId: %s zoneId: %s" % (self.doId, parentId, zoneId))
|
||||
# The store must run first so we know the old location
|
||||
#self.cr.storeObjectLocation(self.doId, parentId, zoneId)
|
||||
self.__location = (parentId, zoneId)
|
||||
#if parentId != None and zoneId != None:
|
||||
# base.cr.sendSetLocation(self.doId, parentId, zoneId)
|
||||
|
||||
def getLocation(self):
|
||||
return self.__location
|
||||
|
@ -142,24 +142,48 @@ class DistributedObjectAI(DirectObject.DirectObject):
|
||||
def addInterest(self, zoneId, note="", event=None):
|
||||
self.air.addInterest(self.getDoId(), zoneId, note, event)
|
||||
|
||||
def setLocation(self, parentId, zoneId):
|
||||
if self.__location:
|
||||
# Make sure our parentId and/or zoneId are actually changing before doing any work
|
||||
oldParentId, oldZoneId = self.__location
|
||||
if oldParentId != parentId or oldZoneId != zoneId:
|
||||
# The store must run first so we know the old location
|
||||
def b_setLocation(self, parentId, zoneId):
|
||||
self.d_setLocation(parentId, zoneId)
|
||||
self.setLocation(parentId, zoneId)
|
||||
|
||||
def d_setLocation(self, parentId, zoneId):
|
||||
self.air.sendSetLocation(self, parentId, zoneId)
|
||||
|
||||
def setLocation(self, parentId, zoneId):
|
||||
oldParentId = self.parentId
|
||||
oldZoneId = self.zoneId
|
||||
self.zoneId = zoneId
|
||||
self.parentId = parentId
|
||||
self.air.changeDOZoneInTables(self, zoneId, oldZoneId)
|
||||
messenger.send(self.getZoneChangeEvent(), [zoneId, oldZoneId])
|
||||
# if we are not going into the quiet zone, send a 'logical' zone
|
||||
# change message
|
||||
if zoneId != DistributedObjectAI.QuietZone:
|
||||
lastLogicalZone = oldZoneId
|
||||
if oldZoneId == DistributedObjectAI.QuietZone:
|
||||
lastLogicalZone = self.lastNonQuietZone
|
||||
self.handleLogicalZoneChange(zoneId, lastLogicalZone)
|
||||
self.lastNonQuietZone = zoneId
|
||||
# self.air.storeObjectLocation(self.doId, parentId, zoneId)
|
||||
self.__location = (parentId, zoneId)
|
||||
|
||||
def getLocation(self):
|
||||
return self.__location
|
||||
|
||||
if 0: # this is untested:
|
||||
def setLocation(self, parentId, zoneId):
|
||||
# The store must run first so we know the old location
|
||||
self.air.storeObjectLocation(self.doId, parentId, zoneId)
|
||||
self.__location = (parentId, zoneId)
|
||||
|
||||
else:
|
||||
# NON OTP
|
||||
def handleZoneChange(self, newZoneId, oldZoneId):
|
||||
self.zoneId = newZoneId
|
||||
self.air.changeDOZoneInTables(self, newZoneId, oldZoneId)
|
||||
messenger.send(self.getZoneChangeEvent(), [newZoneId, oldZoneId])
|
||||
# if we are not going into the quiet zone, send a 'logical' zone change
|
||||
# message
|
||||
if newZoneId != DistributedObjectAI.QuietZone:
|
||||
lastLogicalZone = oldZoneId
|
||||
if oldZoneId == DistributedObjectAI.QuietZone:
|
||||
lastLogicalZone = self.lastNonQuietZone
|
||||
self.handleLogicalZoneChange(newZoneId, lastLogicalZone)
|
||||
self.lastNonQuietZone = newZoneId
|
||||
|
||||
def updateRequiredFields(self, dclass, di):
|
||||
dclass.receiveUpdateBroadcastRequired(self, di)
|
||||
@ -198,23 +222,6 @@ class DistributedObjectAI(DirectObject.DirectObject):
|
||||
# does not include the quiet zone.
|
||||
return 'DOLogicalChangeZone-%s' % self.doId
|
||||
|
||||
def handleZoneChange(self, newParentId, newZoneId, oldParentId, oldZoneId):
|
||||
if wantOtpServer:
|
||||
assert oldParentId == self.parentId
|
||||
##assert oldZoneId == self.zoneId
|
||||
self.parentId = newParentId
|
||||
self.zoneId = newZoneId
|
||||
self.air.changeDOZoneInTables(self, newZoneId, oldZoneId)
|
||||
messenger.send(self.getZoneChangeEvent(), [newZoneId, oldZoneId])
|
||||
# if we are not going into the quiet zone, send a 'logical' zone change
|
||||
# message
|
||||
if newZoneId != DistributedObjectAI.QuietZone:
|
||||
lastLogicalZone = oldZoneId
|
||||
if oldZoneId == DistributedObjectAI.QuietZone:
|
||||
lastLogicalZone = self.lastNonQuietZone
|
||||
self.handleLogicalZoneChange(newZoneId, lastLogicalZone)
|
||||
self.lastNonQuietZone = newZoneId
|
||||
|
||||
def handleLogicalZoneChange(self, newZoneId, oldZoneId):
|
||||
"""this function gets called as if we never go through the
|
||||
quiet zone. Note that it is called once you reach the newZone,
|
||||
|
@ -19,6 +19,9 @@ import whrandom
|
||||
from direct.task import Task
|
||||
import __builtin__
|
||||
|
||||
# Force direct and tk to be on
|
||||
base.startDirect(fWantDirect = 1, fWantTk = 1)
|
||||
|
||||
visualizeZones = base.config.GetBool("visualize-zones", 0)
|
||||
dnaDirectory = Filename.expandFrom(base.config.GetString("dna-directory", "$TTMODELS/src/dna"))
|
||||
fUseCVS = base.config.GetBool("level-editor-use-cvs", 1)
|
||||
@ -217,9 +220,10 @@ except NameError:
|
||||
__builtin__.DNASTORE = DNASTORE = DNAStorage()
|
||||
|
||||
# Load the generic storage files
|
||||
loadDNAFile(DNASTORE, 'dna/storage.dna', CSDefault, 1)
|
||||
loadDNAFile(DNASTORE, 'phase_4/dna/storage.dna', CSDefault, 1)
|
||||
loadDNAFile(DNASTORE, 'phase_5/dna/storage_town.dna', CSDefault, 1)
|
||||
loadDNAFile(DNASTORE, 'phase_5.5/dna/storage_estate.dna', CSDefault, 1)
|
||||
# loadDNAFile(DNASTORE, 'phase_5.5/dna/storage_estate.dna', CSDefault, 1)
|
||||
# loadDNAFile(DNASTORE, 'phase_5.5/dna/storage_house_interior.dna', CSDefault, 1)
|
||||
# Load all the neighborhood specific storage files
|
||||
if 'TT' in hoods:
|
||||
@ -749,7 +753,7 @@ class LevelEditor(NodePath, PandaObject):
|
||||
t = direct.camera.lerpPosHpr(pos, hpr, 1.0, blendType = 'easeInOut',
|
||||
task = 'manipulateCamera')
|
||||
# Note, if this dies an unatural death, this could screw things up
|
||||
t.uponDeath = self.switchToDriveMode
|
||||
# t.uponDeath = self.switchToDriveMode
|
||||
|
||||
def switchToDriveMode(self,state):
|
||||
""" Disable direct camera manipulation and enable player drive mode """
|
||||
@ -4104,6 +4108,9 @@ class LevelStyleManager:
|
||||
# Create top level node for new menu
|
||||
newMenu = hidden.attachNewNode(dnaType + 'Menu')
|
||||
# Compute angle per item
|
||||
if numItems == 0:
|
||||
angle = 0.0
|
||||
else:
|
||||
angle = deg2Rad(360.0/numItems)
|
||||
aspectRatio = direct.dr.getWidth()/float(direct.dr.getHeight())
|
||||
# Add items
|
||||
|
Loading…
x
Reference in New Issue
Block a user