95% Done implementing C++ DNA Reader

This commit is contained in:
Loudrob 2015-03-14 19:23:50 -04:00
parent f04bb95b95
commit b3fd5e37ae
50 changed files with 48 additions and 2125 deletions

Binary file not shown.

View file

@ -6,7 +6,7 @@ from pandac.PandaModules import *
import random
import ToonInteriorColors
from toontown.dna.DNAParser import DNADoor
from toontown.dna.DNAParser import *
from toontown.hood import ZoneUtil
from toontown.toon.DistributedNPCToonBase import DistributedNPCToonBase
from toontown.toonbase.ToonBaseGlobal import *
@ -210,7 +210,7 @@ class DistributedBankInterior(DistributedObject):
doorOrigin.setScale(0.8, 0.8, 0.8)
doorOrigin.setPos(doorOrigin, 0, -0.025, 0)
doorColor = self.randomGenerator.choice(self.colors['TI_door'])
DNADoor.setupDoor(doorNP, self.interior, doorOrigin, self.dnaStore, str(self.block), doorColor)
setupDoor(doorNP, self.interior, doorOrigin, self.dnaStore, str(self.block), doorColor)
doorFrame = doorNP.find('door_*_flat')
doorFrame.wrtReparentTo(self.interior)
doorFrame.setColor(doorColor)

View file

@ -5,7 +5,7 @@ import random
from direct.distributed import DistributedObject
from direct.directnotify import DirectNotifyGlobal
import ToonInteriorColors
from toontown.dna.DNAParser import DNADoor
from toontown.dna.DNAParser import *
from toontown.hood import ZoneUtil
from toontown.toon.DistributedNPCToonBase import DistributedNPCToonBase
@ -82,7 +82,7 @@ class DistributedGagshopInterior(DistributedObject.DistributedObject):
doorOrigin.setScale(0.8, 0.8, 0.8)
doorOrigin.setPos(doorOrigin, 0, -0.025, 0)
doorColor = self.randomGenerator.choice(self.colors['TI_door'])
DNADoor.setupDoor(doorNP, self.interior, doorOrigin, self.dnaStore, str(self.block), doorColor)
setupDoor(doorNP, self.interior, doorOrigin, self.dnaStore, str(self.block), doorColor)
doorFrame = doorNP.find('door_*_flat')
doorFrame.wrtReparentTo(self.interior)
doorFrame.setColor(doorColor)

View file

@ -8,7 +8,7 @@ from pandac.PandaModules import *
from toontown.toonbase import TTLocalizer
from toontown.toonbase.ToonBaseGlobal import *
from toontown.toonbase.ToontownGlobals import *
from toontown.dna.DNAParser import DNADoor
from toontown.dna.DNAParser import *
from toontown.toon.DistributedNPCToonBase import DistributedNPCToonBase
@ -156,7 +156,7 @@ class DistributedHQInterior(DistributedObject.DistributedObject):
doorOrigin.setPos(doorOrigin, 0, -0.025, 0)
doorColor = self.randomGenerator.choice(self.colors['TI_door'])
triggerId = str(self.block) + '_' + doorOriginIndexStr
DNADoor.setupDoor(doorNP, newNodePath, doorOrigin, self.dnaStore, triggerId, doorColor)
setupDoor(doorNP, newNodePath, doorOrigin, self.dnaStore, triggerId, doorColor)
doorFrame = doorNP.find('door_*_flat')
doorFrame.setColor(doorColor)
del self.dnaStore

View file

@ -2,7 +2,7 @@ from direct.distributed.DistributedObject import DistributedObject
import random
from toontown.building import ToonInteriorColors
from toontown.dna.DNAParser import DNADoor
from toontown.dna.DNAParser import *
from toontown.hood import ZoneUtil
from toontown.toon.DistributedNPCToonBase import DistributedNPCToonBase
@ -27,7 +27,7 @@ class DistributedLibraryInterior(DistributedObject):
hoodId = ZoneUtil.getCanonicalHoodId(self.zoneId)
doorColor = ToonInteriorColors.colors[hoodId]['TI_door'][0]
DNADoor.setupDoor(
setupDoor(
doorNodePath, self.interior, doorOrigin, self.cr.playGame.dnaStore,
str(self.block), doorColor)

View file

@ -6,7 +6,7 @@ from direct.distributed import DistributedObject
from direct.directnotify import DirectNotifyGlobal
from direct.actor import Actor
import ToonInteriorColors
from toontown.dna.DNAParser import DNADoor
from toontown.dna.DNAParser import *
from toontown.hood import ZoneUtil
from toontown.toon.DistributedNPCToonBase import DistributedNPCToonBase
@ -90,7 +90,7 @@ class DistributedPetshopInterior(DistributedObject.DistributedObject):
doorOrigin.setScale(0.8, 0.8, 0.8)
doorOrigin.setPos(doorOrigin, 0, -0.25, 0)
doorColor = self.randomGenerator.choice(self.colors['TI_door'])
DNADoor.setupDoor(doorNP, self.interior, doorOrigin, self.dnaStore, str(self.block), doorColor)
setupDoor(doorNP, self.interior, doorOrigin, self.dnaStore, str(self.block), doorColor)
doorFrame = doorNP.find('door_*_flat')
doorFrame.wrtReparentTo(self.interior)
doorFrame.setColor(doorColor)

View file

@ -3,7 +3,7 @@ from direct.interval.IntervalGlobal import *
from direct.distributed.ClockDelta import *
from direct.showbase import Audio3DManager
from toontown.toonbase import ToontownGlobals
from toontown.dna.DNAParser import DNADoor
from toontown.dna.DNAParser import *
import cPickle
from DistributedToonInterior import DistributedToonInterior
from direct.directnotify import DirectNotifyGlobal
@ -80,7 +80,7 @@ class DistributedToonHallInterior(DistributedToonInterior):
door_origin.setScale(0.8, 0.8, 0.8)
door_origin.setPos(door_origin, 0, -0.025, 0)
color = self.randomGenerator.choice(self.colors['TI_door'])
DNADoor.setupDoor(doorNP, self.interior, door_origin, self.dnaStore, str(self.block), color)
setupDoor(doorNP, self.interior, door_origin, self.dnaStore, str(self.block), color)
doorFrame = doorNP.find('door_*_flat')
doorFrame.wrtReparentTo(self.interior)
doorFrame.setColor(color)

View file

@ -11,7 +11,7 @@ from direct.fsm import State
from direct.interval.IntervalGlobal import *
from otp.speedchat import SpeedChatGlobals
from pandac.PandaModules import *
from toontown.dna.DNAParser import DNADoor
from toontown.dna.DNAParser import *
from toontown.hood import ZoneUtil
from toontown.toon import ToonDNA
from toontown.toon import ToonHead
@ -113,7 +113,7 @@ class DistributedToonInterior(DistributedObject.DistributedObject):
door_origin.setScale(0.8, 0.8, 0.8)
door_origin.setPos(door_origin, 0, -0.025, 0)
color = self.randomGenerator.choice(self.colors['TI_door'])
DNADoor.setupDoor(doorNP, self.interior, door_origin, self.dnaStore, str(self.block), color)
setupDoor(doorNP, self.interior, door_origin, self.dnaStore, str(self.block), color)
doorFrame = doorNP.find('door_*_flat')
doorFrame.wrtReparentTo(self.interior)
doorFrame.setColor(color)

View file

@ -78,7 +78,7 @@ class BossbotHQExterior(CogHQExterior.CogHQExterior):
visZoneId = ZoneUtil.getTrueZoneId(visZoneId, self.zoneId)
visibles = []
for i in xrange(visGroup.getNumVisibles()):
visibles.append(int(visGroup.visibles[i]))
visibles.append(int(visGroup.getVisible(i)))
visibles.append(ZoneUtil.getBranchZone(visZoneId))
self.zoneVisDict[visZoneId] = visibles

View file

@ -72,7 +72,7 @@ class CashbotHQExterior(CogHQExterior.CogHQExterior):
visZoneId = ZoneUtil.getTrueZoneId(visZoneId, self.zoneId)
visibles = []
for i in xrange(visGroup.getNumVisibles()):
visibles.append(int(visGroup.visibles[i]))
visibles.append(int(visGroup.getVisible(i)))
visibles.append(ZoneUtil.getBranchZone(visZoneId))
self.zoneVisDict[visZoneId] = visibles

View file

@ -80,7 +80,7 @@ class FactoryExterior(BattlePlace.BattlePlace):
visZoneId = ZoneUtil.getTrueZoneId(visZoneId, self.zoneId)
visibles = []
for i in xrange(visGroup.getNumVisibles()):
visibles.append(int(visGroup.visibles[i]))
visibles.append(int(visGroup.getVisible(i)))
visibles.append(ZoneUtil.getBranchZone(visZoneId))
self.zoneVisDict[visZoneId] = visibles

View file

@ -30,7 +30,7 @@ class LawbotHQExterior(CogHQExterior.CogHQExterior):
visZoneId = ZoneUtil.getTrueZoneId(visZoneId, self.zoneId)
visibles = []
for i in xrange(visGroup.getNumVisibles()):
visibles.append(int(visGroup.visibles[i]))
visibles.append(int(visGroup.getVisible(i)))
visibles.append(ZoneUtil.getBranchZone(visZoneId))
self.zoneVisDict[visZoneId] = visibles

View file

@ -26,7 +26,7 @@ class SellbotHQExterior(CogHQExterior.CogHQExterior):
visZoneId = ZoneUtil.getTrueZoneId(visZoneId, self.zoneId)
visibles = []
for i in xrange(visGroup.getNumVisibles()):
visibles.append(int(visGroup.visibles[i]))
visibles.append(int(visGroup.getVisible(i)))
visibles.append(ZoneUtil.getBranchZone(visZoneId))
self.zoneVisDict[visZoneId] = visibles

View file

@ -158,7 +158,6 @@ class PlayGame(StateData.StateData):
def unloadDnaStore(self):
if hasattr(self, 'dnaStore'):
self.dnaStore.cleanup()
del self.dnaStore
ModelPool.garbageCollect()
TexturePool.garbageCollect()

View file

@ -1,33 +0,0 @@
import DNALandmarkBuilding
import DNAError
import DNAUtil
class DNAAnimBuilding(DNALandmarkBuilding.DNALandmarkBuilding):
COMPONENT_CODE = 16
def __init__(self, name):
DNALandmarkBuilding.DNALandmarkBuilding.__init__(self, name)
self.animName = ''
def setAnim(self, anim):
self.animName = anim
def getAnim(self):
return self.animName
def makeFromDGI(self, dgi):
DNALandmarkBuilding.DNALandmarkBuilding.makeFromDGI(self, dgi)
self.animName = DNAUtil.dgiExtractString8(dgi)
def traverse(self, nodePath, dnaStorage):
node = dnaStorage.findNode(self.getCode())
if node is None:
raise DNAError.DNAError('DNAAnimBuilding code ' + self.getCode() + ' not found in dnastore')
node = node.copyTo(nodePath, 0)
node.setName(self.getName())
node.setPosHprScale(self.getPos(), self.getHpr(), self.getScale())
node.setTag('DNAAnim', self.animName)
self.setupSuitBuildingOrigin(nodePath, node)
for child in self.children:
child.traverse(nodePath, dnaStorage)
nodePath.flattenStrong()

View file

@ -1,36 +0,0 @@
import DNAProp
from DNAUtil import *
class DNAAnimProp(DNAProp.DNAProp):
COMPONENT_CODE = 14
def __init__(self, name):
DNAProp.DNAProp.__init__(self, name)
self.animName = ''
def setAnim(self, anim):
self.animName = anim
def getAnim(self):
return self.animName
def makeFromDGI(self, dgi):
DNAProp.DNAProp.makeFromDGI(self, dgi)
self.animName = dgiExtractString8(dgi)
def traverse(self, nodePath, dnaStorage):
node = None
if self.getCode() == 'DCS':
node = ModelNode(self.getName())
node.setPreserveTransform(ModelNode.PTNet)
node = nodePath.attachNewNode(node, 0)
else:
node = dnaStorage.findNode(self.getCode())
node = node.copyTo(nodePath, 0)
node.setName(self.getName())
node.setTag('DNAAnim', self.getAnim())
node.setPosHprScale(self.getPos(), self.getHpr(), self.getScale())
node.setColorScale(self.getColor(), 0)
node.flattenStrong()
for child in self.children:
child.traverse(node, dnaStorage)

View file

@ -1,34 +0,0 @@
from DNAUtil import *
class DNABattleCell:
COMPONENT_CODE = 21
def __init__(self, width, height, pos):
self.width = width
self.height = height
self.pos = pos
def setWidth(self, width):
self.width = width
def getWidth(self):
return self.width
def setHeight(self, height):
self.height = height
def getHeight(self):
return self.height
def setPos(self, pos):
self.pos = pos
def getPos(self):
return self.pos
def setWidthHeight(self, width, height):
self.width = width
self.height = height
def __str__(self):
return 'DNABattleCell width: ' + str(self.width) + ' height: ' + str(self.height) + ' pos: ' + str(self.pos)

View file

@ -1,60 +0,0 @@
from panda3d.core import LVector4f, LVector3f, DecalEffect
import DNAGroup
import DNAError
import DNAUtil
class DNACornice(DNAGroup.DNAGroup):
COMPONENT_CODE = 12
def __init__(self, name):
DNAGroup.DNAGroup.__init__(self, name)
self.code = ''
self.color = LVector4f(1, 1, 1, 1)
def setCode(self, code):
self.code = code
def getCode(self):
return self.code
def setColor(self, color):
self.color = color
def getColor(self):
return self.color
def makeFromDGI(self, dgi):
DNAGroup.DNAGroup.makeFromDGI(self, dgi)
self.code = DNAUtil.dgiExtractString8(dgi)
self.color = DNAUtil.dgiExtractColor(dgi)
def traverse(self, nodePath, dnaStorage):
pParentXScale = nodePath.getParent().getScale().getX()
parentZScale = nodePath.getScale().getZ()
node = dnaStorage.findNode(self.code)
if node is None:
raise DNAError.DNAError('DNACornice code %d not found in DNAStorage' % self.code)
nodePathA = nodePath.attachNewNode('cornice-internal', 0)
node = node.find('**/*_d')
np = node.copyTo(nodePathA, 0)
np.setPosHprScale(
LVector3f(0, 0, 0),
LVector3f(0, 0, 0),
LVector3f(1, pParentXScale/parentZScale,
pParentXScale/parentZScale))
np.setEffect(DecalEffect.make())
np.flattenStrong()
node = node.getParent().find('**/*_nd')
np = node.copyTo(nodePathA, 1)
np.setPosHprScale(
LVector3f(0, 0, 0),
LVector3f(0, 0, 0),
LVector3f(1, pParentXScale/parentZScale,
pParentXScale/parentZScale))
np.flattenStrong()
nodePathA.setPosHprScale(
LVector3f(0, 0, node.getScale().getZ()),
LVector3f(0, 0, 0),
LVector3f(1, 1, 1))
nodePathA.setColor(self.color)
nodePathA.flattenStrong()

View file

@ -1,81 +0,0 @@
from panda3d.core import LVector4f, DecalEffect, NodePath
import DNAGroup
import DNAError
import DNAUtil
class DNADoor(DNAGroup.DNAGroup):
COMPONENT_CODE = 17
def __init__(self, name):
DNAGroup.DNAGroup.__init__(self, name)
self.code = ''
self.color = LVector4f(1, 1, 1, 1)
def setCode(self, code):
self.code = code
def getCode(self):
return self.code
def setColor(self, color):
self.color = color
def getColor(self):
return self.color
@staticmethod
def setupDoor(doorNodePath, parentNode, doorOrigin, dnaStore, block, color):
doorNodePath.setPosHprScale(doorOrigin, (0, 0, 0), (0, 0, 0), (1, 1, 1))
doorNodePath.setColor(color, 0)
leftHole = doorNodePath.find('door_*_hole_left')
leftHole.flattenStrong()
leftHole.setName('doorFrameHoleLeft')
rightHole = doorNodePath.find('door_*_hole_right')
rightHole.flattenStrong()
rightHole.setName('doorFrameHoleRight')
leftDoor = doorNodePath.find('door_*_left')
leftDoor.flattenStrong()
leftDoor.setName('leftDoor')
rightDoor = doorNodePath.find('door_*_right')
rightDoor.flattenStrong()
rightDoor.setName('rightDoor')
doorFlat = doorNodePath.find('door_*_flat')
doorFlat.flattenStrong()
leftHole.wrtReparentTo(doorFlat, 0)
rightHole.wrtReparentTo(doorFlat, 0)
doorFlat.setEffect(DecalEffect.make())
rightDoor.wrtReparentTo(parentNode, 0)
leftDoor.wrtReparentTo(parentNode, 0)
rightDoor.setColor(color, 0)
leftDoor.setColor(color, 0)
leftHole.setColor((0, 0, 0, 1), 0)
rightHole.setColor((0, 0, 0, 1), 0)
doorTrigger = doorNodePath.find('door_*_trigger')
doorTrigger.setScale(2, 2, 2)
doorTrigger.wrtReparentTo(parentNode, 0)
doorTrigger.setName('door_trigger_' + block)
if not dnaStore.getDoorPosHprFromBlockNumber(block):
dnaStore.storeBlockDoor(block, doorOrigin)
doorNodePath.flattenMedium()
def makeFromDGI(self, dgi):
DNAGroup.DNAGroup.makeFromDGI(self, dgi)
self.code = DNAUtil.dgiExtractString8(dgi)
self.color = DNAUtil.dgiExtractColor(dgi)
def traverse(self, nodePath, dnaStorage):
frontNode = nodePath.find('**/*_front')
if not frontNode.getNode(0).isGeomNode():
frontNode = frontNode.find('**/+GeomNode')
frontNode.setEffect(DecalEffect.make())
node = dnaStorage.findNode(self.code)
if node is None:
raise DNAError.DNAError('DNADoor code ' + self.code + ' not found in DNAStorage')
doorNode = node.copyTo(frontNode, 0)
doorNode.flattenMedium()
block = dnaStorage.getBlock(nodePath.getName())
DNADoor.setupDoor(doorNode, nodePath, nodePath.find('**/*door_origin'), dnaStorage, block, self.getColor())

View file

@ -1,2 +0,0 @@
class DNAError(Exception):
pass

View file

@ -1,149 +0,0 @@
from panda3d.core import NodePath, DecalEffect
import DNANode
import DNAWall
import random
class DNAFlatBuilding(DNANode.DNANode):
COMPONENT_CODE = 9
currentWallHeight = 0
def __init__(self, name):
DNANode.DNANode.__init__(self, name)
self.width = 0
self.hasDoor = False
def setWidth(self, width):
self.width = width
def getWidth(self):
return self.width
def setCurrentWallHeight(self, currentWallHeight):
DNAFlatBuilding.currentWallHeight = currentWallHeight
def getCurrentWallHeight(self):
return DNAFlatBuilding.currentWallHeight
def setHasDoor(self, hasDoor):
self.hasDoor = hasDoor
def getHasDoor(self):
return self.hasDoor
def makeFromDGI(self, dgi):
DNANode.DNANode.makeFromDGI(self, dgi)
self.width = dgi.getInt16() / 100.0
self.hasDoor = dgi.getBool()
def setupSuitFlatBuilding(self, nodePath, dnaStorage):
name = self.getName()
if name[:2] != 'tb':
return
name = 'sb' + name[2:]
node = nodePath.attachNewNode(name)
node.setPosHpr(self.getPos(), self.getHpr())
numCodes = dnaStorage.getNumCatalogCodes('suit_wall')
if numCodes < 1:
return
code = dnaStorage.getCatalogCode(
'suit_wall', random.randint(0, numCodes - 1))
wallNode = dnaStorage.findNode(code)
if not wallNode:
return
wallNode = wallNode.copyTo(node, 0)
wallScale = wallNode.getScale()
wallScale.setX(self.width)
wallScale.setZ(DNAFlatBuilding.currentWallHeight)
wallNode.setScale(wallScale)
if self.getHasDoor():
wallNodePath = node.find('wall_*')
doorNode = dnaStorage.findNode('suit_door')
doorNode = doorNode.copyTo(wallNodePath, 0)
doorNode.setScale(NodePath(), (1, 1, 1))
doorNode.setPosHpr(0.5, 0, 0, 0, 0, 0)
wallNodePath.setEffect(DecalEffect.make())
node.flattenMedium()
node.stash()
def setupCogdoFlatBuilding(self, nodePath, dnaStorage):
name = self.getName()
if name[:2] != 'tb':
return
name = 'cb' + name[2:]
node = nodePath.attachNewNode(name)
node.setPosHpr(self.getPos(), self.getHpr())
numCodes = dnaStorage.getNumCatalogCodes('cogdo_wall')
if numCodes < 1:
return
code = dnaStorage.getCatalogCode(
'cogdo_wall', random.randint(0, numCodes - 1))
wallNode = dnaStorage.findNode(code)
if not wallNode:
return
wallNode = wallNode.copyTo(node, 0)
wallScale = wallNode.getScale()
wallScale.setX(self.width)
wallScale.setZ(DNAFlatBuilding.currentWallHeight)
wallNode.setScale(wallScale)
if self.getHasDoor():
wallNodePath = node.find('wall_*')
doorNode = dnaStorage.findNode('suit_door')
doorNode = doorNode.copyTo(wallNodePath, 0)
doorNode.setScale(NodePath(), (1, 1, 1))
doorNode.setPosHpr(0.5, 0, 0, 0, 0, 0)
wallNodePath.setEffect(DecalEffect.make())
node.flattenMedium()
node.stash()
def traverse(self, nodePath, dnaStorage):
DNAFlatBuilding.currentWallHeight = 0
node = nodePath.attachNewNode(self.getName())
internalNode = node.attachNewNode(self.getName() + '-internal')
scale = self.getScale()
scale.setX(self.width)
internalNode.setScale(scale)
node.setPosHpr(self.getPos(), self.getHpr())
for child in self.children:
if isinstance(child, DNAWall.DNAWall):
child.traverse(internalNode, dnaStorage)
else:
child.traverse(node, dnaStorage)
if DNAFlatBuilding.currentWallHeight == 0:
print 'empty flat building with no walls'
else:
cameraBarrier = dnaStorage.findNode('wall_camera_barrier')
if cameraBarrier is None:
raise DNAError.DNAError('DNAFlatBuilding requires that there is a wall_camera_barrier in storage')
cameraBarrier = cameraBarrier.copyTo(internalNode, 0)
cameraBarrier.setScale((1, 1, DNAFlatBuilding.currentWallHeight))
internalNode.flattenStrong()
collisionNode = node.find('**/door_*/+CollisionNode')
if not collisionNode.isEmpty():
collisionNode.setName('KnockKnockDoorSphere_' + dnaStorage.getBlock(self.getName()))
cameraBarrier.wrtReparentTo(nodePath, 0)
wallCollection = internalNode.findAllMatches('wall*')
wallHolder = node.attachNewNode('wall_holder')
wallDecal = node.attachNewNode('wall_decal')
windowCollection = internalNode.findAllMatches('**/window*')
doorCollection = internalNode.findAllMatches('**/door*')
corniceCollection = internalNode.findAllMatches('**/cornice*_d')
wallCollection.reparentTo(wallHolder)
windowCollection.reparentTo(wallDecal)
doorCollection.reparentTo(wallDecal)
corniceCollection.reparentTo(wallDecal)
for i in xrange(wallHolder.getNumChildren()):
iNode = wallHolder.getChild(i)
iNode.clearTag('DNACode')
iNode.clearTag('DNARoot')
wallHolder.flattenStrong()
wallDecal.flattenStrong()
holderChild0 = wallHolder.getChild(0)
wallDecal.getChildren().reparentTo(holderChild0)
holderChild0.reparentTo(internalNode)
holderChild0.setEffect(DecalEffect.make())
wallHolder.removeNode()
wallDecal.removeNode()
self.setupSuitFlatBuilding(nodePath, dnaStorage)
self.setupCogdoFlatBuilding(nodePath, dnaStorage)
node.flattenStrong()

View file

@ -1,14 +0,0 @@
from panda3d.core import NodePath, DecalEffect
import DNADoor
class DNAFlatDoor(DNADoor.DNADoor):
COMPONENT_CODE = 18
def traverse(self, nodePath, dnaStorage):
node = dnaStorage.findNode(self.getCode())
node = node.copyTo(nodePath, 0)
node.setScale(NodePath(), (1, 1, 1))
node.setPosHpr((0.5, 0, 0), (0, 0, 0))
node.setColor(self.getColor())
node.getNode(0).setEffect(DecalEffect.make())
node.flattenStrong()

View file

@ -1,54 +0,0 @@
from panda3d.core import PandaNode
import DNAUtil
class DNAGroup:
COMPONENT_CODE = 1
def __init__(self, name):
self.name = name
self.children = []
self.parent = None
self.visGroup = None
def add(self, child):
self.children += [child]
def remove(self, child):
self.children.remove(child)
def at(self, index):
return self.children[index]
def setParent(self, parent):
self.parent = parent
self.visGroup = parent.getVisGroup()
def getParent(self):
return self.parent
def clearParent(self):
self.parent = None
self.visGroup = None
def getVisGroup(self):
return self.visGroup
def getNumChildren(self):
return len(self.children)
def getName(self):
return self.name
def setName(self, name):
self.name = name
def makeFromDGI(self, dgi):
self.name = DNAUtil.dgiExtractString8(dgi)
DNAUtil.dgiExtractString8(dgi)
DNAUtil.dgiExtractString8(dgi)
def traverse(self, nodePath, dnaStorage):
node = PandaNode(self.name)
nodePath = nodePath.attachNewNode(node, 0)
for child in self.children:
child.traverse(nodePath, dnaStorage)

View file

@ -1,37 +0,0 @@
from panda3d.core import ModelNode
import DNAAnimProp
class DNAInteractiveProp(DNAAnimProp.DNAAnimProp):
COMPONENT_CODE = 15
def __init__(self, name):
DNAAnimProp.DNAAnimProp.__init__(self, name)
self.cellId = -1
def setCellId(self, id):
self.cellId = id
def getCellId(self):
return cellId
def makeFromDGI(self, dgi):
DNAAnimProp.DNAAnimProp.makeFromDGI(self, dgi)
self.cellId = dgi.getInt16()
def traverse(self, nodePath, dnaStorage):
node = None
if self.getCode() == 'DCS':
node = ModelNode(self.getName())
node.setPreserveTransform(ModelNode.PTNet)
node = nodePath.attachNewNode(node, 0)
else:
node = dnaStorage.findNode(self.getCode())
node = node.copyTo(nodePath, 0)
node.setName(self.getName())
node.setTag('DNAAnim', self.getAnim())
node.setTag('DNACellIndex', str(self.cellId))
node.setPosHprScale(self.getPos(), self.getHpr(), self.getScale())
node.setColorScale(self.getColor(), 0)
node.flattenStrong()
for child in self.children:
child.traverse(node, dnaStorage)

View file

@ -1,79 +0,0 @@
from panda3d.core import LVector4f
import DNANode
import DNAUtil
import DNAError
class DNALandmarkBuilding(DNANode.DNANode):
COMPONENT_CODE = 13
def __init__(self, name):
DNANode.DNANode.__init__(self, name)
self.code = ''
self.wallColor = LVector4f(1, 1, 1, 1)
self.title = ''
self.article = ''
self.buildingType = ''
self.door = None
def setArticle(self, article):
self.article = article
def getArticle(self):
return self.article
def setBuildingType(self, buildingType):
self.buildingType = buildingType
def getBuildingType(self):
return self.buildingType
def setTitle(self, title):
self.title = title
def getTitle(self):
return self.title
def getCode(self):
return self.code
def setCode(self, code):
self.code = code
def setWallColor(self, color):
self.wallColor = color
def getWallColor(self):
return self.wallColor
def setupSuitBuildingOrigin(self, nodePathA, nodePathB):
if (self.getName()[:2] == 'tb') and (self.getName()[3].isdigit()) and (self.getName().find(':') != -1):
name = self.getName()
name = 's' + name[1:]
node = nodePathB.find('**/*suit_building_origin')
if node.isEmpty():
node = nodePathA.attachNewNode(name)
node.setPosHprScale(self.getPos(), self.getHpr(), self.getScale())
else:
node.wrtReparentTo(nodePathA, 0)
node.setName(name)
def makeFromDGI(self, dgi):
DNANode.DNANode.makeFromDGI(self, dgi)
self.code = DNAUtil.dgiExtractString8(dgi)
self.wallColor = DNAUtil.dgiExtractColor(dgi)
self.title = DNAUtil.dgiExtractString8(dgi)
self.article = DNAUtil.dgiExtractString8(dgi)
self.buildingType = DNAUtil.dgiExtractString8(dgi)
def traverse(self, nodePath, dnaStorage):
node = dnaStorage.findNode(self.code)
if node is None:
raise DNAError.DNAError('DNALandmarkBuilding code ' + self.code + ' not found in DNAStorage')
npA = nodePath
nodePath = node.copyTo(nodePath, 0)
nodePath.setName(self.getName())
nodePath.setPosHprScale(self.getPos(), self.getHpr(), self.getScale())
self.setupSuitBuildingOrigin(npA, nodePath)
for child in self.children:
child.traverse(nodePath, dnaStorage)
nodePath.flattenStrong()

View file

@ -1,220 +0,0 @@
from pandac.PandaModules import *
from direct.distributed.PyDatagramIterator import PyDatagramIterator
from direct.distributed.PyDatagram import PyDatagram
from direct.stdpy.file import *
import DNAUtil
import DNAError
import DNAAnimBuilding
import DNAAnimProp
import DNACornice
import DNADoor
import DNAFlatBuilding
import DNAFlatDoor
import DNAGroup
import DNAInteractiveProp
import DNALandmarkBuilding
import DNANode
import DNAProp
import DNASign
import DNASignBaseline
import DNASignGraphic
import DNASignText
import DNAStreet
import DNAVisGroup
import DNAWall
import DNAWindows
import DNABattleCell
import DNASuitPoint
import zlib
import sys
sys.setrecursionlimit(10000)
compClassTable = {
1: DNAGroup.DNAGroup,
2: DNAVisGroup.DNAVisGroup,
3: DNANode.DNANode,
4: DNAProp.DNAProp,
5: DNASign.DNASign,
6: DNASignBaseline.DNASignBaseline,
7: DNASignText.DNASignText,
8: DNASignGraphic.DNASignGraphic,
9: DNAFlatBuilding.DNAFlatBuilding,
10: DNAWall.DNAWall,
11: DNAWindows.DNAWindows,
12: DNACornice.DNACornice,
13: DNALandmarkBuilding.DNALandmarkBuilding,
14: DNAAnimProp.DNAAnimProp,
15: DNAInteractiveProp.DNAInteractiveProp,
16: DNAAnimBuilding.DNAAnimBuilding,
17: DNADoor.DNADoor,
18: DNAFlatDoor.DNAFlatDoor,
19: DNAStreet.DNAStreet
}
childlessComps = (
7, # DNASignText
11, # DNAWindows
12, # DNACornice
17, # DNADoor
18, # DNAFlatDoor
19 # DNAStreet
)
class DNALoader:
def __init__(self):
self.dnaStorage = None
self.prop = None
def destroy(self):
del self.dnaStorage
del self.prop
def handleStorageData(self, dgi):
# Catalog Codes
numRoots = dgi.getUint16()
for _ in xrange(numRoots):
root = DNAUtil.dgiExtractString8(dgi)
numCodes = dgi.getUint8()
for i in xrange(numCodes):
code = DNAUtil.dgiExtractString8(dgi)
self.dnaStorage.storeCatalogCode(root, code)
# Textures
numTextures = dgi.getUint16()
for _ in xrange(numTextures):
code = DNAUtil.dgiExtractString8(dgi)
filename = DNAUtil.dgiExtractString8(dgi)
self.dnaStorage.storeTexture(code, loader.pdnaTexture(filename, okMissing=True))
# Fonts
numFonts = dgi.getUint16()
for _ in xrange(numFonts):
code = DNAUtil.dgiExtractString8(dgi)
filename = DNAUtil.dgiExtractString8(dgi)
self.dnaStorage.storeFont(code, loader.pdnaFont(filename))
# Nodes
self.handleNode(dgi, target = self.dnaStorage.storeNode)
self.handleNode(dgi, target = self.dnaStorage.storeHoodNode)
self.handleNode(dgi, target = self.dnaStorage.storePlaceNode)
# Blocks
numBlocks = dgi.getUint16()
for _ in xrange(numBlocks):
number = dgi.getUint8()
zone = dgi.getUint16()
title = DNAUtil.dgiExtractString8(dgi)
article = DNAUtil.dgiExtractString8(dgi)
bldgType = DNAUtil.dgiExtractString8(dgi)
self.dnaStorage.storeBlock(number, title, article, bldgType, zone)
# Suit Points
numPoints = dgi.getUint16()
for _ in xrange(numPoints):
index = dgi.getUint16()
pointType = dgi.getUint8()
x, y, z = (dgi.getInt32() / 100.0 for i in xrange(3))
graph = dgi.getUint8()
landmarkBuildingIndex = dgi.getInt8()
self.dnaStorage.storeSuitPoint(DNASuitPoint.DNASuitPoint(index, pointType, LVector3f(x, y, z), landmarkBuildingIndex))
# Suit Edges
numEdges = dgi.getUint16()
for _ in xrange(numEdges):
index = dgi.getUint16()
numPoints = dgi.getUint16()
for i in xrange(numPoints):
endPoint = dgi.getUint16()
zoneId = dgi.getUint16()
self.dnaStorage.storeSuitEdge(index, endPoint, zoneId)
# Battle Cells
numCells = dgi.getUint16()
for _ in xrange(numCells):
w = dgi.getUint8()
h = dgi.getUint8()
x, y, z = (dgi.getInt32() / 100.0 for i in xrange(3))
self.dnaStorage.storeBattleCell(DNABattleCell.DNABattleCell(w, h, LVector3f(x, y, z)))
def handleCompData(self, dgi):
while True:
propCode = dgi.getUint8()
if propCode == 255:
if self.prop == None:
raise DNAError.DNAError('Unexpected 255 found.')
prop = self.prop.getParent()
if prop is not None:
self.prop = prop
else:
assert self.prop.getName() == 'root'
elif propCode in compClassTable:
propClass = compClassTable[propCode]
if propClass.__init__.func_code.co_argcount > 1:
newComp = propClass('unnamed_comp')
else:
newComp = propClass()
if propCode == 2:
newComp.makeFromDGI(dgi, self.dnaStorage)
self.dnaStorage.storeDNAVisGroup(newComp)
else:
newComp.makeFromDGI(dgi)
else:
raise DNAError.DNAError('Invalid prop code: %d' % propCode)
if dgi.getRemainingSize():
if propCode != 255:
if self.prop is not None:
newComp.setParent(self.prop)
self.prop.add(newComp)
if propCode not in childlessComps:
self.prop = newComp
continue
break
def handleNode(self, dgi, target = None):
if target is None:
return
numNodes = dgi.getUint16()
for _ in xrange(numNodes):
code = DNAUtil.dgiExtractString8(dgi)
file = DNAUtil.dgiExtractString8(dgi)
node = DNAUtil.dgiExtractString8(dgi)
np = NodePath(loader.pdnaModel(file))
if node:
newNode = np.find('**/' + node).copyTo(NodePath())
np.removeNode()
np = newNode
np.setTag('DNACode', code)
np.setTag('DNARoot', node)
target(np, code)
def loadDNAFileBase(self, dnaStorage, file):
self.dnaStorage = dnaStorage
dnaFile = open(file, 'rb')
dnaData = dnaFile.read()
dg = PyDatagram(dnaData)
dgi = PyDatagramIterator(dg)
dnaFile.close()
header = dgi.extractBytes(5)
if header != 'PDNA\n':
raise DNAError.DNAError('Invalid header: %s' % (header))
compressed = dgi.getBool()
dgi.skipBytes(1)
if compressed:
data = dgi.getRemainingBytes()
data = zlib.decompress(data)
dg = PyDatagram(data)
dgi = PyDatagramIterator(dg)
self.handleStorageData(dgi)
self.handleCompData(dgi)
def loadDNAFile(self, dnaStorage, file):
self.loadDNAFileBase(dnaStorage, file)
nodePath = NodePath(PandaNode('dna'))
self.prop.traverse(nodePath, self.dnaStorage)
return nodePath
def loadDNAFileAI(self, dnaStorage, file):
self.loadDNAFileBase(dnaStorage, file)
return self.prop

View file

@ -1,55 +0,0 @@
from panda3d.core import LVector3f, PandaNode
import DNAGroup
class DNANode(DNAGroup.DNAGroup):
COMPONENT_CODE = 3
def __init__(self, name):
DNAGroup.DNAGroup.__init__(self, name)
self.pos = LVector3f()
self.hpr = LVector3f()
self.scale = LVector3f(1, 1, 1)
def getPos(self):
return self.pos
def setPos(self, pos):
self.pos = pos
def getHpr(self):
return self.hpr
def setHpr(self, hpr):
self.hpr = hpr
def getScale(self):
return self.scale
def setScale(self, scale):
self.scale = scale
def makeFromDGI(self, dgi):
DNAGroup.DNAGroup.makeFromDGI(self, dgi)
x = dgi.getInt32() / 100.0
y = dgi.getInt32() / 100.0
z = dgi.getInt32() / 100.0
self.pos = LVector3f(x, y, z)
h = dgi.getInt32() / 100.0
p = dgi.getInt32() / 100.0
r = dgi.getInt32() / 100.0
self.hpr = LVector3f(h, p, r)
sx = dgi.getInt16() / 100.0
sy = dgi.getInt16() / 100.0
sz = dgi.getInt16() / 100.0
self.scale = LVector3f(sx, sy, sz)
def traverse(self, nodePath, dnaStorage):
node = PandaNode(self.name)
node = nodePath.attachNewNode(node, 0)
node.setPosHprScale(self.pos, self.hpr, self.scale)
for child in self.children:
child.traverse(node, dnaStorage)
node.flattenMedium()

View file

@ -1,11 +1,6 @@
from direct.stdpy import threading
import DNALoader
from DNAStorage import DNAStorage
from DNASuitPoint import DNASuitPoint
from DNAGroup import DNAGroup
from DNAVisGroup import DNAVisGroup
from DNADoor import DNADoor
from libpandadna import *
class DNABulkLoader:
def __init__(self, storage, files):
@ -20,37 +15,44 @@ class DNABulkLoader:
del self.dnaFiles
def loadDNABulk(dnaStorage, file):
dnaLoader = DNALoader.DNALoader()
dnaLoader = DNALoader()
fileu = '../resources/' + file
fileo = 'resources/' + file
try:
dnaLoader.loadDNAFile(dnaStorage, fileu)
except:
dnaLoader.loadDNAFile(dnaStorage, fileo)
dnaLoader.destroy()
def loadDNAFile(dnaStorage, file):
print 'Reading DNA file...', file
dnaLoader = DNALoader.DNALoader()
dnaLoader = DNALoader()
fileu = '../resources/' + file
fileo = 'resources/' + file
try:
node = dnaLoader.loadDNAFile(dnaStorage, fileu)
except:
node = dnaLoader.loadDNAFile(dnaStorage, fileo)
dnaLoader.destroy()
if node.node().getNumChildren() > 0:
return node.node()
return None
def loadDNAFileAI(dnaStorage, file):
dnaLoader = DNALoader.DNALoader()
dnaLoader = DNALoader()
fileu = '../resources/' + file
fileo = 'resources/' + file
try:
data = dnaLoader.loadDNAFileAI(dnaStorage, fileu)
except:
data = dnaLoader.loadDNAFileAI(dnaStorage, fileo)
dnaLoader.destroy()
return data
def setupDoor(a, b, c, d, e, f):
try:
e = int(str(e).split('_')[0])
except:
print 'setupDoor: error parsing', e
e = 9999
DNADoor.setupDoor(a, b, c, d, e, f)

View file

@ -1,66 +0,0 @@
from panda3d.core import LVector4f, ModelNode
import DNANode
import DNAUtil
class DNAProp(DNANode.DNANode):
COMPONENT_CODE = 4
def __init__(self, name):
DNANode.DNANode.__init__(self, name)
self.code = ''
self.color = LVector4f(1, 1, 1, 1)
def getCode(self):
return self.code
def setCode(self, code):
self.code = code
def getColor(self):
return self.color
def setColor(self, color):
self.color = color
def smartFlatten(self, node):
if 'trolley' in self.name:
return
elif self.children:
node.flattenMedium()
elif 'HQTelescopeAnimatedProp' in self.name:
node.flattenMedium()
elif node.find('**/water1*').isEmpty():
node.flattenStrong()
elif not node.find('**/water').isEmpty():
water = node.find('**/water')
water.setTransparency(1)
water.setColor(1, 1, 1, 0.8)
node.flattenStrong()
elif not node.find('**/water1*').isEmpty():
water = node.find('**/water1*')
water.setTransparency(1)
water.setColorScale(1.0, 1.0, 1.0, 1.0)
water.setBin('water', 51, 1)
node.flattenStrong()
def makeFromDGI(self, dgi):
DNANode.DNANode.makeFromDGI(self, dgi)
self.code = DNAUtil.dgiExtractString8(dgi)
self.color = DNAUtil.dgiExtractColor(dgi)
def traverse(self, nodePath, dnaStorage):
if self.code == 'DCS':
node = ModelNode(self.name)
node.setPreserveTransform(ModelNode.PTNet)
node = nodePath.attachNewNode(node)
else:
node = dnaStorage.findNode(self.code)
if node is None:
return
node = node.copyTo(nodePath, 0)
node.setPosHprScale(self.pos, self.hpr, self.scale)
node.setName(self.name)
node.setColorScale(self.color, 0)
#self.smartFlatten(node)
for child in self.children:
child.traverse(node, dnaStorage)

View file

@ -1,44 +0,0 @@
from panda3d.core import LVector4f, NodePath, DecalEffect
import DNANode
import DNAUtil
class DNASign(DNANode.DNANode):
COMPONENT_CODE = 5
def __init__(self):
DNANode.DNANode.__init__(self, '')
self.code = ''
self.color = LVector4f(1, 1, 1, 1)
def getCode(self):
return self.code
def setCode(self, code):
self.code = code
def getColor(self):
return self.color
def setColor(self, color):
self.color = color
def makeFromDGI(self, dgi):
DNANode.DNANode.makeFromDGI(self, dgi)
self.code = DNAUtil.dgiExtractString8(dgi)
self.color = DNAUtil.dgiExtractColor(dgi)
def traverse(self, nodePath, dnaStorage):
sign = dnaStorage.findNode(self.code)
if not sign:
sign = NodePath(self.name)
signOrigin = nodePath.find('**/*sign_origin')
if not signOrigin:
signOrigin = nodePath
node = sign.copyTo(signOrigin)
#node.setDepthOffset(50)
node.setPosHprScale(signOrigin, self.pos, self.hpr, self.scale)
node.setPos(node, 0, -0.1, 0)
node.setColor(self.color)
for child in self.children:
child.traverse(node, dnaStorage)
node.flattenStrong()

View file

@ -1,30 +0,0 @@
from panda3d.core import BamFile, NodePath, StringStream, decompressString
import DNANode
class DNASignBaseline(DNANode.DNANode):
COMPONENT_CODE = 6
def __init__(self):
DNANode.DNANode.__init__(self, '')
self.data = ''
def makeFromDGI(self, dgi):
DNANode.DNANode.makeFromDGI(self, dgi)
self.data = dgi.getString()
if len(self.data):
self.data = decompressString(self.data)
def traverse(self, nodePath, dnaStorage):
node = nodePath.attachNewNode('baseline', 0)
node.setPosHpr(self.pos, self.hpr)
node.setPos(node, 0, -0.1, 0)
if self.data:
bf = BamFile()
ss = StringStream()
ss.setData(self.data)
bf.openRead(ss)
signText = NodePath(bf.readNode())
signText.reparentTo(node)
node.flattenStrong()
for child in self.children:
child.traverse(nodePath, dnaStorage)

View file

@ -1,62 +0,0 @@
from panda3d.core import LVector4f, DecalEffect
import DNANode
import DNAError
import DNAUtil
class DNASignGraphic(DNANode.DNANode):
COMPONENT_CODE = 8
def __init__(self, name):
DNANode.DNANode.__init__(self, name)
self.code = ''
self.color = LVector4f(1, 1, 1, 1)
self.width = 0
self.height = 0
self.bDefaultColor = True
def setCode(self, code):
self.code = code
def getCode(self):
return self.code
def setWidth(self, width):
self.width = width
def getWidth(self):
return self.width
def setHeight(self, height):
self.height = height
def getHeight(self):
return self.height
def setColor(self, color):
self.color = color
self.bDefaultColor = False
def getColor(self):
return self.Color
def makeFromDGI(self, dgi):
DNANode.DNANode.makeFromDGI(self, dgi)
self.code = DNAUtil.dgiExtractString8(dgi)
self.color = DNAUtil.dgiExtractColor(dgi)
self.width = dgi.getInt16() / 100.0
self.height = dgi.getInt16() / 100.0
self.bDefaultColor = dgi.getBool()
def traverse(self, nodePath, dnaStorage):
node = dnaStorage.findNode(self.code)
if node is None:
raise DNAError.DNAError('DNASignGraphic code ' + self.code + ' not found in storage')
node = node.copyTo(nodePath, 0)
node.setScale(self.scale)
node.setScale(node, self.getParent().scale)
node.setPosHpr(self.getParent().pos, self.getParent().hpr)
node.setPos(node, 0, -0.1, 0)
node.setColor(self.color)
node.flattenStrong()
for child in self.children:
child.traverse(node, dnaStorage)

View file

@ -1,8 +0,0 @@
import DNANode
class DNASignText(DNANode.DNANode):
COMPONENT_CODE = 7
def __init__(self):
DNANode.DNANode.__init__(self, '')
self.letters = ''

View file

@ -1,308 +0,0 @@
from pandac.PandaModules import *
from DNAError import DNAError
from DNASuitPoint import DNASuitPoint
from DNASuitPath import DNASuitPath
from DNASuitEdge import DNASuitEdge
class DNAStorage:
def __init__(self):
self.suitPoints = []
self.suitPointMap = {}
self.DNAGroups = {}
self.DNAVisGroups = []
self.suitEdges = {}
self.battleCells = []
self.nodes = {}
self.hoodNodes = {}
self.placeNodes = {}
self.fonts = {}
self.blockTitles = {}
self.blockArticles = {}
self.blockBuildingTypes = {}
self.blockDoors = {}
self.blockNumbers = []
self.blockZones = {}
self.textures = {}
self.catalogCodes = {}
def getSuitPath(self, startPoint, endPoint, minPathLen=40, maxPathLen=300):
path = DNASuitPath()
path.addPoint(startPoint)
while path.getNumPoints() < maxPathLen:
startPointIndex = startPoint.getIndex()
if startPointIndex == endPoint.getIndex():
if path.getNumPoints() >= minPathLen:
break
if startPointIndex not in self.suitEdges:
raise DNAError('Could not find DNASuitPath.')
edges = self.suitEdges[startPointIndex]
for edge in edges:
startPoint = edge.getEndPoint()
startPointType = startPoint.getPointType()
if startPointType != DNASuitPoint.FRONT_DOOR_POINT:
if startPointType != DNASuitPoint.SIDE_DOOR_POINT:
break
else:
raise DNAError('Could not find DNASuitPath.')
path.addPoint(startPoint)
return path
def getSuitEdgeTravelTime(self, startIndex, endIndex, suitWalkSpeed):
startPoint = self.suitPointMap.get(startIndex)
endPoint = self.suitPointMap.get(endIndex)
if (not startPoint) or (not endPoint):
return 0.0
distance = (endPoint.getPos()-startPoint.getPos()).length()
return distance / suitWalkSpeed
def getSuitEdgeZone(self, startIndex, endIndex):
return self.getSuitEdge(startIndex, endIndex).getZoneId()
def getAdjacentPoints(self, point):
path = DNASuitPath()
startIndex = point.getIndex()
if startIndex not in self.suitEdges:
return path
for edge in self.suitEdges[startIndex]:
path.addPoint(edge.getEndPoint())
return path
def storeSuitPoint(self, suitPoint):
if not isinstance(suitPoint, DNASuitPoint):
raise TypeError('suitPoint must be an instance of DNASuitPoint')
self.suitPoints.append(suitPoint)
self.suitPointMap[suitPoint.getIndex()] = suitPoint
def getSuitPointAtIndex(self, index):
return self.suitPoints[index]
def getSuitPointWithIndex(self, index):
return self.suitPointMap.get(index)
def resetSuitPoints(self):
self.suitPoints = []
self.suitPointMap = {}
self.suitEdges = {}
def resetTextures(self):
self.textures = {}
def resetHood(self):
self.resetBlockNumbers()
def findDNAGroup(self, node):
return self.DNAGroups[node]
def removeDNAGroup(self, dnagroup):
for node, group in self.DNAGroups.items():
if group == dnagroup:
del self.DNAGroups[node]
def resetDNAGroups(self):
self.DNAGroups = {}
def getNumDNAVisGroups(self):
return len(self.DNAVisGroups)
def getDNAVisGroupName(self, i):
return self.DNAVisGroups[i].getName()
def storeDNAVisGroup(self, group):
self.DNAVisGroups.append(group)
def storeSuitEdge(self, startIndex, endIndex, zoneId):
startPoint = self.getSuitPointWithIndex(startIndex)
endPoint = self.getSuitPointWithIndex(endIndex)
edge = DNASuitEdge(startPoint, endPoint, zoneId)
self.suitEdges.setdefault(startIndex, []).append(edge)
return edge
def getSuitEdge(self, startIndex, endIndex):
edges = self.suitEdges[startIndex]
for edge in edges:
if edge.getEndPoint().getIndex() == endIndex:
return edge
def removeBattleCell(self, cell):
self.battleCells.remove(cell)
def storeBattleCell(self, cell):
self.battleCells.append(cell)
def resetBattleCells(self):
self.battleCells = []
def findNode(self, code):
if code in self.nodes:
return self.nodes[code]
if code in self.hoodNodes:
return self.hoodNodes[code]
if code in self.placeNodes:
return self.placeNodes[code]
def resetNodes(self):
for node in self.nodes:
self.nodes[node].removeNode()
self.nodes = {}
def resetHoodNodes(self):
for node in self.hoodNodes:
self.hoodNodes[node].removeNode()
self.hoodNodes = {}
def resetPlaceNodes(self):
for node in self.placeNodes:
self.placeNodes[node].removeNode()
self.placeNodes = {}
def storeNode(self, node, code):
self.nodes[code] = node
def storeHoodNode(self, node, code):
self.hoodNodes[code] = node
def storePlaceNode(self, node, code):
self.placeNodes[code] = node
def findFont(self, code):
if code in self.fonts:
return self.fonts[code]
def resetFonts(self):
self.fonts = {}
def storeFont(self, font, code):
self.fonts[code] = font
def getBlock(self, name):
block = name[name.find(':')-2:name.find(':')]
if not block[0].isdigit():
block = block[1:]
return block
def getBlockBuildingType(self, blockNumber):
if blockNumber in self.blockBuildingTypes:
return self.blockBuildingTypes[blockNumber]
def getTitleFromBlockNumber(self, blockNumber):
if blockNumber in self.blockTitles:
return self.blockTitles[blockNumber]
return ''
def getDoorPosHprFromBlockNumber(self, blockNumber):
key = str(blockNumber)
if key in self.blockDoors:
return self.blockDoors[key]
def storeBlockDoor(self, blockNumber, door):
self.blockDoors[str(blockNumber)] = door
def storeBlockTitle(self, blockNumber, title):
self.blockTitles[blockNumber] = title
def storeBlockArticle(self, blockNumber, article):
self.blockArticles[blockNumber] = article
def storeBlockBuildingType(self, blockNumber, buildingType):
self.blockBuildingTypes[blockNumber] = buildingType
def storeBlock(self, blockNumber, title, article, bldgType, zoneId):
self.storeBlockNumber(blockNumber)
self.storeBlockTitle(blockNumber, title)
self.storeBlockArticle(blockNumber, article)
self.storeBlockBuildingType(blockNumber, bldgType)
self.storeBlockZone(blockNumber, zoneId)
def storeTexture(self, name, texture):
self.textures[name] = texture
def resetDNAVisGroups(self):
self.DNAVisGroups = []
def resetDNAVisGroupsAI(self):
self.resetDNAVisGroups()
def getNumDNAVisGroupsAI(self):
return self.getNumDNAVisGroups()
def getNumSuitPoints(self):
return len(self.suitPoints)
def getNumVisiblesInDNAVisGroup(self, i):
return self.DNAVisGroups[i].getNumVisibles()
def getVisibleName(self, i, j):
return self.DNAVisGroups[i].getVisibleName(j)
def getDNAVisGroupAI(self, i):
return self.DNAVisGroups[i]
def storeCatalogCode(self, category, code):
if not category in self.catalogCodes:
self.catalogCodes[category] = []
self.catalogCodes[category].append(code)
def getNumCatalogCodes(self, category):
if category not in self.catalogCodes:
return -1
return len(self.catalogCodes[category])
def resetCatalogCodes(self):
self.catalogCodes = {}
def getCatalogCode(self, category, index):
return self.catalogCodes[category][index]
def findTexture(self, name):
if name in self.textures:
return self.textures[name]
def discoverContinuity(self):
return 1 # TODO
def resetBlockNumbers(self):
self.blockNumbers = []
self.blockZones = {}
self.blockArticles = {}
self.resetBlockDoors()
self.blockTitles = {}
self.blockBuildingTypes = {}
def getNumBlockNumbers(self):
return len(self.blockNumbers)
def storeBlockNumber(self, blockNumber):
self.blockNumbers.append(blockNumber)
def getBlockNumberAt(self, index):
return self.blockNumbers[index]
def getZoneFromBlockNumber(self, blockNumber):
if blockNumber in self.blockZones:
return self.blockZones[blockNumber]
def storeBlockZone(self, blockNumber, zoneId):
self.blockZones[blockNumber] = zoneId
def resetBlockZones(self):
self.blockZones = {}
def resetBlockDoors(self):
self.blockDoors = {}
def cleanup(self):
self.resetBattleCells()
self.resetBlockNumbers()
self.resetDNAGroups()
self.resetDNAVisGroups()
self.resetDNAVisGroupsAI()
self.resetFonts()
self.resetHood()
self.resetHoodNodes()
self.resetNodes()
self.resetPlaceNodes()
self.resetSuitPoints()
self.resetTextures()
self.resetCatalogCodes()
ModelPool.garbageCollect()
TexturePool.garbageCollect()

View file

@ -1,121 +0,0 @@
from panda3d.core import LVector4f
import DNANode
import DNAError
import DNAUtil
class DNAStreet(DNANode.DNANode):
COMPONENT_CODE = 19
def __init__(self, name):
DNANode.DNANode.__init__(self, name)
self.code = ''
self.streetTexture = ''
self.sideWalkTexture = ''
self.curbTexture = ''
self.streetColor = LVector4f(1, 1, 1, 1)
self.sidewalkColor = LVector4f(1, 1, 1, 1)
self.curbColor = LVector4f(1, 1, 1, 1)
self.setTexCnt = 0
self.setColCnt = 0
def setCode(self, code):
self.code = code
def getCode(self):
return self.code
def setStreetTexture(self, texture):
self.streetTexture = texture
def getStreetTexture(self):
return self.streetTexture
def setSidewalkTexture(self, texture):
self.sidewalkTexture = texture
def getSidewalkTexture(self):
return self.sidewalkTexture
def setCurbTexture(self, texture):
self.curbTexture = texture
def getCurbTexture(self):
return self.curbTexture
def setStreetColor(self, color):
self.streetColor = color
def getStreetColor(self):
return self.streetColor
def setSidewalkColor(self, color):
self.SidewalkColor = color
def getSidewalkColor(self):
return self.sidewalkColor
def getCurbColor(self):
return self.curbColor
def setTextureColor(self, color):
self.Color = color
def setTexture(self, texture):
if self.setTexCnt == 0:
self.streetTexture = texture
if self.setTexCnt == 1:
self.sidewalkTexture = texture
if self.setTexCnt == 2:
self.curbTexture = texture
self.setTexCnt += 1
def setColor(self, color):
if self.setColCnt == 0:
self.streetColor = color
if self.setColCnt == 1:
self.sidewalkColor = color
if self.setColCnt == 2:
self.curbColor = color
self.setColCnt += 1
def makeFromDGI(self, dgi):
DNANode.DNANode.makeFromDGI(self, dgi)
self.code = DNAUtil.dgiExtractString8(dgi)
self.streetTexture = DNAUtil.dgiExtractString8(dgi)
self.sidewalkTexture = DNAUtil.dgiExtractString8(dgi)
self.curbTexture = DNAUtil.dgiExtractString8(dgi)
self.streetColor = DNAUtil.dgiExtractColor(dgi)
self.sideWalkColor = DNAUtil.dgiExtractColor(dgi)
self.curbColor = DNAUtil.dgiExtractColor(dgi)
def traverse(self, nodePath, dnaStorage):
node = dnaStorage.findNode(self.code)
if node is None:
raise DNAError.DNAError('DNAStreet code ' + self.code + ' not found in DNAStorage')
nodePath = node.copyTo(nodePath, 0)
node.setName(self.getName())
streetTexture = dnaStorage.findTexture(self.streetTexture)
sidewalkTexture = dnaStorage.findTexture(self.sidewalkTexture)
curbTexture = dnaStorage.findTexture(self.curbTexture)
if streetTexture is None:
raise DNAError.DNAError('street texture not found in DNAStorage : ' + self.streetTexture)
if sidewalkTexture is None:
raise DNAError.DNAError('sidewalk texture not found in DNAStorage : ' + self.sidewalkTexture)
if curbTexture is None:
raise DNAError.DNAError('curb texture not found in DNAStorage : ' + self.curbTexture)
streetNode = nodePath.find('**/*_street')
sidewalkNode = nodePath.find('**/*_sidewalk')
curbNode = nodePath.find('**/*_curb')
if not streetNode.isEmpty():
streetNode.setTexture(streetTexture, 1)
streetNode.setColorScale(self.streetColor, 0)
if not sidewalkNode.isEmpty():
sidewalkNode.setTexture(sidewalkTexture, 1)
sidewalkNode.setColorScale(self.sidewalkColor, 0)
if not curbNode.isEmpty():
curbNode.setTexture(curbTexture, 1)
curbNode.setColorScale(self.curbColor, 0)
nodePath.setPosHprScale(self.getPos(), self.getHpr(), self.getScale())
nodePath.flattenStrong()

View file

@ -1,17 +0,0 @@
class DNASuitEdge:
def __init__(self, startpt, endpt, zoneId):
self.startpt = startpt
self.endpt = endpt
self.zoneId = zoneId
def getEndPoint(self):
return self.endpt
def getStartPoint(self):
return self.startpt
def getZoneId(self):
return self.zoneId
def setZoneId(self, zoneId):
self.zoneId = zoneId

View file

@ -1,18 +0,0 @@
class DNASuitPath:
def __init__(self):
self.suitPoints = []
def getNumPoints(self):
return len(self.suitPoints)
def getPointIndex(self, pointIndex):
return self.suitPoints[pointIndex].getIndex()
def addPoint(self, point):
self.suitPoints.append(point)
def getPoint(self, pointIndex):
return self.suitPoints[pointIndex]
def reversePath(self):
self.suitPoints.reverse()

View file

@ -1,89 +0,0 @@
class DNASuitPoint:
COMPONENT_CODE = 20
STREET_POINT = 0
FRONT_DOOR_POINT = 1
SIDE_DOOR_POINT = 2
COGHQ_IN_POINT = 3
COGHQ_OUT_POINT = 4
def __init__(self, index, pointType, pos, landmarkBuildingIndex=-1):
self.index = index
self.pointType = pointType
self.pos = pos
self.graphId = 0
self.landmarkBuildingIndex = landmarkBuildingIndex
def __str__(self):
pointType = self.getPointType()
if pointType == DNASuitPoint.STREET_POINT:
pointTypeStr = 'STREET_POINT'
elif pointType == DNASuitPoint.FRONT_DOOR_POINT:
pointTypeStr = 'FRONT_DOOR_POINT'
elif pointType == DNASuitPoint.SIDE_DOOR_POINT:
pointTypeStr = 'SIDE_DOOR_POINT'
elif pointType == DNASuitPoint.COGHQ_IN_POINT:
pointTypeStr = 'COGHQ_IN_POINT'
elif pointType == DNASuitPoint.COGHQ_OUT_POINT:
pointTypeStr = 'COGHQ_OUT_POINT'
else:
pointTypeStr = '**invalid**'
return 'DNASuitPoint index: %d, pointType: %s, pos: %s' % (
self.getIndex(), pointTypeStr, self.getPos())
def setIndex(self, index):
self.index = index
def getIndex(self):
return self.index
def getGraphId(self):
return self.graphId
def getLandmarkBuildingIndex(self):
return self.landmarkBuildingIndex
def getPos(self):
return self.pos
def isTerminal(self):
return self.pointType <= 2
def setGraphId(self, id):
self.graphId = id
def setLandmarkBuildingIndex(self, index):
self.landmarkBuildingIndex = index
def setPointType(self, pointType):
if isinstance(pointType, int):
if type == DNASuitPoint.STREET_POINT:
self.pointType = DNASuitPoint.STREET_POINT
elif type == DNASuitPoint.FRONT_DOOR_POINT:
self.pointType = DNASuitPoint.FRONT_DOOR_POINT
elif pointType == DNASuitPoint.SIDE_DOOR_POINT:
self.pointType = DNASuitPoint.SIDE_DOOR_POINT
elif pointType == DNASuitPoint.COGHQ_IN_POINT:
self.pointType = DNASuitPoint.COGHQ_IN_POINT
elif pointType == DNASuitPoint.COGHQ_OUT_POINT:
self.pointType = DNASuitPoint.COGHQ_OUT_POINT
else:
raise TypeError('%i is not a valid DNASuitPointType' % pointType)
elif isinstance(pointType, str):
if type == 'STREET_POINT':
self.pointType = DNASuitPoint.STREET_POINT
elif type == 'FRONT_DOOR_POINT':
self.pointType = DNASuitPoint.FRONT_DOOR_POINT
elif pointType == 'SIDE_DOOR_POINT':
self.pointType = DNASuitPoint.SIDE_DOOR_POINT
elif pointType == 'COGHQ_IN_POINT':
self.pointType = DNASuitPoint.COGHQ_IN_POINT
elif pointType == 'COGHQ_OUT_POINT':
self.pointType = DNASuitPoint.COGHQ_OUT_POINT
else:
raise TypeError('%s is not a valid DNASuitPointType' % pointType)
def getPointType(self):
return self.pointType
def setPos(self, pos):
self.pos = pos

View file

@ -1,9 +0,0 @@
from panda3d.core import LVector4f
def dgiExtractString8(dgi):
return dgi.extractBytes(dgi.getUint8())
def dgiExtractColor(dgi):
a, b, c, d = (dgi.getUint8() / 255.0 for _ in xrange(4))
return LVector4f(a, b, c, d)

View file

@ -1,72 +0,0 @@
from panda3d.core import LVector3f
import DNAGroup
import DNABattleCell
import DNAUtil
class DNAVisGroup(DNAGroup.DNAGroup):
COMPONENT_CODE = 2
def __init__(self, name):
DNAGroup.DNAGroup.__init__(self, name)
self.visibles = []
self.suitEdges = []
self.battleCells = []
def getVisGroup(self):
return self
def addBattleCell(self, battleCell):
self.battleCells.append(battleCell)
def addSuitEdge(self, suitEdge):
self.suitEdges.append(suitEdge)
def addVisible(self, visible):
self.visibles.append(visible)
def getBattleCell(self, i):
return self.battleCells[i]
def getNumBattleCells(self):
return len(self.battleCells)
def getNumSuitEdges(self):
return len(self.suitEdges)
def getNumVisibles(self):
return len(self.visibles)
def getSuitEdge(self, i):
return self.suitEdges[i]
def getVisibleName(self, i):
return self.visibles[i]
def removeBattleCell(self, cell):
self.battleCells.remove(cell)
def removeSuitEdge(self, edge):
self.suitEdges.remove(edge)
def removeVisible(self, visible):
self.visibles.remove(visible)
def makeFromDGI(self, dgi, dnaStorage):
DNAGroup.DNAGroup.makeFromDGI(self, dgi)
numEdges = dgi.getUint16()
for _ in xrange(numEdges):
index = dgi.getUint16()
endPoint = dgi.getUint16()
self.addSuitEdge(dnaStorage.getSuitEdge(index, endPoint))
numVisibles = dgi.getUint16()
for _ in xrange(numVisibles):
self.addVisible(DNAUtil.dgiExtractString8(dgi))
numCells = dgi.getUint16()
for _ in xrange(numCells):
w = dgi.getUint8()
h = dgi.getUint8()
x, y, z = [dgi.getInt32() / 100.0 for i in xrange(3)]
self.addBattleCell(DNABattleCell.DNABattleCell(w, h, LVector3f(x, y, z)))

View file

@ -1,52 +0,0 @@
from panda3d.core import LVector4f
import DNANode
import DNAFlatBuilding
import DNAError
import DNAUtil
class DNAWall(DNANode.DNANode):
COMPONENT_CODE = 10
def __init__(self, name):
DNANode.DNANode.__init__(self, name)
self.code = ''
self.height = 10
self.color = LVector4f(1, 1, 1, 1)
def setCode(self, code):
self.code = code
def getCode(self):
return self.code
def setColor(self, color):
self.color = color
def getColor(self):
return self.color
def setHeight(self, height):
self.height = height
def getHeight(self):
return self.height
def makeFromDGI(self, dgi):
DNANode.DNANode.makeFromDGI(self, dgi)
self.code = DNAUtil.dgiExtractString8(dgi)
self.height = dgi.getInt16() / 100.0
self.color = DNAUtil.dgiExtractColor(dgi)
def traverse(self, nodePath, dnaStorage):
node = dnaStorage.findNode(self.code)
if node is None:
raise DNAError.DNAError('DNAWall code ' + self.code + ' not found in DNAStorage')
node = node.copyTo(nodePath, 0)
self.pos.setZ(DNAFlatBuilding.DNAFlatBuilding.currentWallHeight)
self.scale.setZ(self.height)
node.setPosHprScale(self.pos, self.hpr, self.scale)
node.setColor(self.color)
for child in self.children:
child.traverse(node, dnaStorage)
node.flattenStrong()
DNAFlatBuilding.DNAFlatBuilding.currentWallHeight += self.height

View file

@ -1,103 +0,0 @@
from panda3d.core import LVector4f, NodePath, DecalEffect
import DNAGroup
import DNAError
import DNAUtil
import random
class DNAWindows(DNAGroup.DNAGroup):
COMPONENT_CODE = 11
def __init__(self, name):
DNAGroup.DNAGroup.__init__(self, name)
self.code = ''
self.color = LVector4f(1, 1, 1, 1)
self.windowCount = 0
def setCode(self, code):
self.code = code
def getCode(self):
return self.code
def setColor(self, color):
self.color = color
def getColor(self):
return self.color
def setWindowCount(self, windowCount):
self.windowCount = windowCount
def getWindowCount(self):
return self.windowCount
@staticmethod
def setupWindows(parentNode, dnaStorage, code, windowCount, color, hpr,
scale):
stripped = code[:-1]
node_r = dnaStorage.findNode(stripped + 'r')
node_l = dnaStorage.findNode(stripped + 'l')
if (node_r is None) or (node_l is None):
raise DNAError.DNAError('DNAWindows code %s not found in'
'DNAStorage' % code)
def makeWindow(x, y, z, parentNode, color, scale, hpr, flip=False):
node = node_r if not flip else node_l
window = node.copyTo(parentNode, 0)
window.setColor(color)
window.setScale(NodePath(), scale)
window.setHpr(hpr)
window.setPos(x, 0, z)
window.setEffect(DecalEffect.make())
window.flattenStrong()
offset = lambda: random.random() % 0.0375
if windowCount == 1:
makeWindow(offset() + 0.5, 0, offset() + 0.5,
parentNode, color, scale, hpr)
elif windowCount == 2:
makeWindow(offset() + 0.33, 0, offset() + 0.5,
parentNode, color, scale, hpr)
makeWindow(offset() + 0.66, 0, offset() + 0.5,
parentNode, color, scale, hpr, True)
elif windowCount == 3:
makeWindow(offset() + 0.33, 0, offset() + 0.66,
parentNode, color, scale, hpr)
makeWindow(offset() + 0.66, 0, offset() + 0.66,
parentNode, color, scale, hpr, True)
makeWindow(offset() + 0.5, 0, offset() + 0.33,
parentNode, color, scale, hpr)
elif windowCount == 4:
makeWindow(offset() + 0.33, 0, offset() + 0.25,
parentNode, color, scale, hpr)
makeWindow(offset() + 0.66, 0, offset() + 0.25,
parentNode, color, scale, hpr, True)
makeWindow(offset() + 0.33, 0, offset() + 0.66,
parentNode, color, scale, hpr)
makeWindow(offset() + 0.66, 0, offset() + 0.66,
parentNode, color, scale, hpr, True)
else:
raise NotImplementedError('Invalid window count ' + str(windowCount))
def makeFromDGI(self, dgi):
DNAGroup.DNAGroup.makeFromDGI(self, dgi)
self.code = DNAUtil.dgiExtractString8(dgi)
self.color = DNAUtil.dgiExtractColor(dgi)
self.windowCount = dgi.getUint8()
def traverse(self, nodePath, dnaStorage):
if self.getWindowCount() == 0:
return
parentX = nodePath.getParent().getScale().getX()
scale = random.random() % 0.0375
if parentX <= 5.0:
scale += 1.0
elif parentX <= 10.0:
scale += 1.15
else:
scale += 1.3
hpr = (0, 0, 0)
DNAWindows.setupWindows(nodePath, dnaStorage, self.getCode(),
self.getWindowCount(), self.getColor(), hpr,
scale)

View file

@ -19,7 +19,7 @@ from toontown.hood import Place
import HouseGlobals
from toontown.building import ToonInteriorColors
from direct.showbase.MessengerGlobal import messenger
from toontown.dna.DNAParser import DNADoor
from toontown.dna.DNAParser import *
from toontown.nametag.NametagGroup import NametagGroup
from toontown.nametag.Nametag import Nametag
@ -115,7 +115,7 @@ class DistributedHouse(DistributedObject.DistributedObject):
self.randomGenerator.seed(self.doId)
houseColor = HouseGlobals.stairWood
color = Vec4(houseColor[0], houseColor[1], houseColor[2], 1)
DNADoor.setupDoor(doorNP, door_origin, door_origin, self.dnaStore, str(self.doId), color)
setupDoor(doorNP, door_origin, door_origin, self.dnaStore, str(self.doId), color)
self.__setupNamePlate()
self.__setupFloorMat()
self.__setupNametag()

View file

@ -13,7 +13,7 @@ from toontown.catalog import CatalogWallpaperItem
from toontown.catalog import CatalogFlooringItem
from toontown.catalog import CatalogMouldingItem
from toontown.catalog import CatalogWainscotingItem
from toontown.dna.DNAParser import DNADoor
from toontown.dna.DNAParser import *
WindowPlugNames = ('**/windowcut_a*', '**/windowcut_b*', '**/windowcut_c*', '**/windowcut_d*', '**/windowcut_e*', '**/windowcut_f*')
RoomNames = ('**/group2', '**/group1')
WallNames = ('ceiling*', 'wall_side_middle*', 'wall_front_middle*', 'windowcut_*')
@ -66,7 +66,7 @@ class DistributedHouseInterior(DistributedObject.DistributedObject):
doorNP = door.copyTo(door_origin)
houseColor = HouseGlobals.atticWood
color = Vec4(houseColor[0], houseColor[1], houseColor[2], 1)
DNADoor.setupDoor(doorNP, door_origin, door_origin, dnaStore, str(self.houseId), color)
setupDoor(doorNP, door_origin, door_origin, dnaStore, str(self.houseId), color)
doorFrame = doorNP.find('door_*_flat')
doorFrame.setColor(color)
self.interior.flattenMedium()

View file

@ -24,7 +24,7 @@ from toontown.chat.ChatGlobals import *
from toontown.distributed.DelayDeletable import DelayDeletable
from toontown.nametag import NametagGlobals
from toontown.nametag.NametagGlobals import *
from toontown.suit.SuitLegList import *
from libpandadna import *
from toontown.toonbase import ToontownGlobals
@ -56,7 +56,7 @@ class DistributedSuit(DistributedSuitBase.DistributedSuitBase, DelayDeletable):
self.pathState = 0
self.path = None
self.localPathState = 0
self.currentLeg = -1
self.currentLeg = 0
self.pathStartTime = 0.0
self.legList = None
self.initState = None
@ -220,7 +220,7 @@ class DistributedSuit(DistributedSuitBase.DistributedSuitBase, DelayDeletable):
self.maxPathLen = maxPathLen
self.path = None
self.pathLength = 0
self.currentLeg = -1
self.currentLeg = 0
self.legList = None
if self.maxPathLen == 0 or not self.verifySuitPlanner() or start not in self.sp.pointIndexes or end not in self.sp.pointIndexes:
return
@ -343,13 +343,13 @@ class DistributedSuit(DistributedSuitBase.DistributedSuitBase, DelayDeletable):
return Task.done
def doPathLeg(self, leg, time):
self.fsm.request(leg.getTypeName(), [leg, time])
self.fsm.request(SuitLeg.getTypeName(leg.getType()), [leg, time])
return 0
def stopPathNow(self):
name = self.taskName('move')
taskMgr.remove(name)
self.currentLeg = -1
self.currentLeg = 0
def calculateHeading(self, a, b):
xdelta = b[0] - a[0]

View file

@ -8,7 +8,7 @@ import SuitPlannerBase
import SuitBase
import SuitDialog
import SuitDNA
from SuitLegList import *
from libpandadna import *
from direct.directnotify import DirectNotifyGlobal
from toontown.battle import SuitBattleGlobals
from toontown.building import FADoorCodes
@ -364,4 +364,4 @@ class DistributedSuitAI(DistributedSuitBaseAI.DistributedSuitBaseAI):
self.sp.cogdoTakeOver(blockNumber, difficulty, self.buildingHeight)
else:
dept = SuitDNA.getSuitDept(self.dna.name)
self.sp.suitTakeOver(blockNumber, dept, difficulty, self.buildingHeight)
self.sp.suitTakeOver(blockNumber, dept, difficulty, self.buildingHeight)

View file

@ -15,7 +15,7 @@ from toontown.building import SuitBuildingGlobals
from toontown.dna.DNAParser import DNASuitPoint
from toontown.hood import ZoneUtil
from toontown.suit.SuitInvasionGlobals import IFSkelecog, IFWaiter, IFV2
from toontown.suit.SuitLegList import *
from libpandadna import *
from toontown.toon import NPCToons
from toontown.toonbase import ToontownBattleGlobals
from toontown.toonbase import ToontownGlobals

View file

@ -1,5 +1,5 @@
import SuitDNA
from SuitLegList import *
from libpandadna import *
import SuitTimings
from direct.directnotify import DirectNotifyGlobal
from direct.distributed.ClockDelta import *

View file

@ -1,225 +0,0 @@
from toontown.dna.DNAParser import DNASuitPoint
from toontown.suit import SuitTimings
from toontown.toonbase import ToontownGlobals
class SuitLeg:
TWalkFromStreet = 0
TWalkToStreet = 1
TWalk = 2
TFromSky = 3
TToSky = 4
TFromSuitBuilding = 5
TToSuitBuilding = 6
TToToonBuilding = 7
TFromCogHQ = 8
TToCogHQ = 9
TOff = 10
TypeToName = {
TWalkFromStreet: 'WalkFromStreet',
TWalkToStreet: 'WalkToStreet',
TWalk: 'Walk',
TFromSky: 'FromSky',
TToSky: 'ToSky',
TFromSuitBuilding: 'FromSuitBuilding',
TToSuitBuilding: 'ToSuitBuilding',
TToToonBuilding: 'ToToonBuilding',
TFromCogHQ: 'FromCogHQ',
TToCogHQ: 'ToCogHQ',
TOff: 'Off'
}
def __init__(self, startTime, zoneId, blockNumber, pointA, pointB, type):
self.startTime = startTime
self.zoneId = zoneId
self.blockNumber = blockNumber
self.pointA = pointA
self.pointB = pointB
self.type = type
self.posA = self.pointA.getPos()
self.posB = self.pointB.getPos()
distance = (self.posB - self.posA).length()
self.legTime = distance / ToontownGlobals.SuitWalkSpeed
self.endTime = self.startTime + self.getLegTime()
def getStartTime(self):
return self.startTime
def getZoneId(self):
return self.zoneId
def getBlockNumber(self):
return self.blockNumber
def getPointA(self):
return self.pointA
def getPointB(self):
return self.pointB
def getType(self):
return self.type
def getPosA(self):
return self.posA
def getPosB(self):
return self.posB
def getLegTime(self):
if self.type in (SuitLeg.TWalk, SuitLeg.TWalkFromStreet,
SuitLeg.TWalkToStreet):
return self.legTime
if self.type == SuitLeg.TFromSky:
return SuitTimings.fromSky
if self.type == SuitLeg.TToSky:
return SuitTimings.toSky
if self.type == SuitLeg.TFromSuitBuilding:
return SuitTimings.fromSuitBuilding
if self.type == SuitLeg.TToSuitBuilding:
return SuitTimings.toSuitBuilding
if self.type in (SuitLeg.TToToonBuilding, SuitLeg.TToCogHQ,
SuitLeg.TFromCogHQ):
return SuitTimings.toToonBuilding
return 0.0
def getEndTime(self):
return self.endTime
def getPosAtTime(self, time):
if self.type in (SuitLeg.TFromSky, SuitLeg.TFromSuitBuilding,
SuitLeg.TFromCogHQ):
return self.posA
elif self.type in (SuitLeg.TToSky, SuitLeg.TToSuitBuilding,
SuitLeg.TToToonBuilding, SuitLeg.TToCogHQ,
SuitLeg.TOff):
return self.posB
delta = self.posB - self.posA
return self.posA + (delta * (time/self.getLegTime()))
def getTypeName(self):
if self.type in SuitLeg.TypeToName:
return SuitLeg.TypeToName[self.type]
return '**invalid**'
class SuitLegList:
def __init__(self, path, dnaStore):
self.path = path
self.dnaStore = dnaStore
self.legs = []
# First, add the initial SuitLeg:
self.add(self.path.getPoint(0), self.path.getPoint(1), self.getFirstLegType())
# Next, connect each of the points in our path through SuitLegs:
for i in xrange(self.path.getNumPoints() - 1):
pointA = self.path.getPoint(i)
pointB = self.path.getPoint(i + 1)
pointTypeA = pointA.getPointType()
pointTypeB = pointB.getPointType()
legType = self.getLegType(pointTypeA, pointTypeB)
if pointTypeA == DNASuitPoint.COGHQ_OUT_POINT:
# We're going out of a door, so we'll need to insert a door
# leg before the move:
self.add(pointA, pointB, SuitLeg.TFromCogHQ)
self.add(pointA, pointB, legType)
if pointTypeB == DNASuitPoint.COGHQ_IN_POINT:
# We're going into a door, so we'll need to insert a door leg
# after the move:
self.add(pointA, pointB, SuitLeg.TToCogHQ)
# Add the last SuitLeg:
numPoints = self.path.getNumPoints()
pointA = self.path.getPoint(numPoints - 2)
pointB = self.path.getPoint(numPoints - 1)
self.add(pointA, pointB, self.getLastLegType())
# Finally, take down the suit:
self.add(pointA, pointB, SuitLeg.TOff)
def add(self, pointA, pointB, legType):
zoneId = self.dnaStore.getSuitEdgeZone(pointA.getIndex(), pointB.getIndex())
landmarkBuildingIndex = pointB.getLandmarkBuildingIndex()
if landmarkBuildingIndex == -1:
landmarkBuildingIndex = pointA.getLandmarkBuildingIndex()
startTime = 0.0
if len(self.legs) > 0:
startTime = self.legs[-1].getEndTime()
leg = SuitLeg(startTime, zoneId, landmarkBuildingIndex, pointA, pointB, legType)
self.legs.append(leg)
def getFirstLegType(self):
if self.path.getPoint(0).getPointType() == DNASuitPoint.SIDE_DOOR_POINT:
return SuitLeg.TFromSuitBuilding
else:
return SuitLeg.TFromSky
def getLegType(self, pointTypeA, pointTypeB):
if pointTypeA in (DNASuitPoint.FRONT_DOOR_POINT,
DNASuitPoint.SIDE_DOOR_POINT):
return SuitLeg.TWalkToStreet
if pointTypeB in (DNASuitPoint.FRONT_DOOR_POINT,
DNASuitPoint.SIDE_DOOR_POINT):
return SuitLeg.TWalkFromStreet
return SuitLeg.TWalk
def getLastLegType(self):
endPoint = self.path.getPoint(self.path.getNumPoints() - 1)
endPointType = endPoint.getPointType()
if endPointType == DNASuitPoint.FRONT_DOOR_POINT:
return SuitLeg.TToToonBuilding
if endPointType == DNASuitPoint.SIDE_DOOR_POINT:
return SuitLeg.TToSuitBuilding
return SuitLeg.TToSky
def getNumLegs(self):
return len(self.legs)
def getLeg(self, index):
return self.legs[index]
def getType(self, index):
return self.legs[index].getType()
def getLegTime(self, index):
return self.legs[index].getLegTime()
def getZoneId(self, index):
return self.legs[index].getZoneId()
def getBlockNumber(self, index):
return self.legs[index].getBlockNumber()
def getPointA(self, index):
return self.legs[index].getPointA()
def getPointB(self, index):
return self.legs[index].getPointB()
def getStartTime(self, index):
return self.legs[index].getStartTime()
def getLegIndexAtTime(self, time, startLegIndex):
for i, leg in enumerate(self.legs):
if leg.getEndTime() > time:
break
return i
def isPointInRange(self, point, lowTime, highTime):
legIndex = self.getLegIndexAtTime(lowTime, 0)
while legIndex < self.getNumLegs():
leg = self.legs[legIndex]
if leg.getEndTime() > highTime:
break
if (leg.pointA == point) or (leg.pointB == point):
return True
legIndex += 1
return False

View file

@ -254,7 +254,7 @@ class TownLoader(StateData.StateData):
self.zoneDict[zoneId] = groupNode
visibles = []
for i in xrange(visGroup.getNumVisibles()):
visibles.append(int(visGroup.visibles[i]))
visibles.append(int(visGroup.getVisible(i)))
visibles.append(ZoneUtil.getBranchZone(zoneId))
self.zoneVisDict[zoneId] = visibles
fadeDuration = 0.5
@ -377,4 +377,4 @@ class TownLoader(StateData.StateData):
result = None
if zoneId in self.zoneIdToInteractivePropDict:
result = self.zoneIdToInteractivePropDict[zoneId]
return result
return result