From d37da1df2e03053267542cbb8101d5bc6d9eb64c Mon Sep 17 00:00:00 2001 From: Samir Naik Date: Fri, 31 Oct 2003 23:01:47 +0000 Subject: [PATCH] *** empty log message *** --- direct/src/level/BasicEntities.py | 18 +++++++++++ direct/src/level/EntityCreator.py | 2 ++ direct/src/level/EntityCreatorAI.py | 1 + direct/src/level/EntityTypes.py | 8 +++++ direct/src/level/ModelEntity.py | 6 ++++ direct/src/level/PathEntity.py | 50 +++++++++++++++++++++++++++++ 6 files changed, 85 insertions(+) create mode 100755 direct/src/level/PathEntity.py diff --git a/direct/src/level/BasicEntities.py b/direct/src/level/BasicEntities.py index 43ec3014be..9d2deedefd 100755 --- a/direct/src/level/BasicEntities.py +++ b/direct/src/level/BasicEntities.py @@ -17,6 +17,9 @@ class NodePathAttribs: if doReparent: self.callSetters('parentEntId') + if __debug__: + self.getNodePath().setTag('entity', '1') + def setPos(self, *args): self.getNodePath().setPos(*args) def setX(self, *args): self.getNodePath().setX(*args) def setY(self, *args): self.getNodePath().setY(*args) @@ -38,6 +41,21 @@ class NodePathAttribs: self.parentEntId = parentEntId self.level.requestReparent(self, self.parentEntId) +# this is an abstract class, do not instantiate. +class NodePathSelfAttribs: + """Derive from this class to give an entity that is already a Nodepath + the behavior of a NodePathEntity, with ability to reparent and be + picked from the Direct/FactoryEditor interface""" + def initNodePathSelfAttribs(self): + if __debug__: + self.setTag('entity', '1') + self.callSetters('parentEntId') + + def setParentEntId(self, parentEntId): + self.parentEntId = parentEntId + self.level.requestReparent(self, self.parentEntId) + + class privNodePathImpl(NodePath.NodePath): def __init__(self, name): node = hidden.attachNewNode(name) diff --git a/direct/src/level/EntityCreator.py b/direct/src/level/EntityCreator.py index 314968e118..09b9c8ccfb 100755 --- a/direct/src/level/EntityCreator.py +++ b/direct/src/level/EntityCreator.py @@ -8,6 +8,7 @@ import EditMgr import LevelMgr import ZoneEntity import ModelEntity +import PathEntity # some useful constructor functions # ctor functions must take (level, entId) @@ -32,6 +33,7 @@ class EntityCreator(EntityCreatorBase.EntityCreatorBase): 'logicGate': nothing, 'model' : ModelEntity.ModelEntity, 'nodepath': BasicEntities.NodePathEntity, + 'path' : PathEntity.PathEntity, 'zone': ZoneEntity.ZoneEntity, }) diff --git a/direct/src/level/EntityCreatorAI.py b/direct/src/level/EntityCreatorAI.py index e2b1298590..d5fa38331a 100755 --- a/direct/src/level/EntityCreatorAI.py +++ b/direct/src/level/EntityCreatorAI.py @@ -50,6 +50,7 @@ class EntityCreatorAI(EntityCreatorBase.EntityCreatorBase): 'logicGate': Functor(cLE, LogicGateAI.LogicGateAI), 'model' : nothing, 'nodepath': nothing, + 'path': nothing, 'zone': Functor(cLE, ZoneEntityAI.ZoneEntityAI), }) diff --git a/direct/src/level/EntityTypes.py b/direct/src/level/EntityTypes.py index a9c1540685..5947e5415b 100755 --- a/direct/src/level/EntityTypes.py +++ b/direct/src/level/EntityTypes.py @@ -83,3 +83,11 @@ class Model(Nodepath): ('scale', 1, 'pos'), ('modelPath', None, 'bamfilename'), ) + +class Path(Nodepath): + type = 'path' + attribs = ( + ('scale', 1, 'pos'), + ('pathIndex', 0, 'int'), + ) + diff --git a/direct/src/level/ModelEntity.py b/direct/src/level/ModelEntity.py index a51596eda1..3d77e9d2fb 100755 --- a/direct/src/level/ModelEntity.py +++ b/direct/src/level/ModelEntity.py @@ -23,6 +23,12 @@ class ModelEntity(BasicEntities.NodePathEntity): if self.model: self.model.reparentTo(self) + # HACK SDN: special code for moving crate wall collisions down + # Uniquify the collision name + cNode = self.find("**/wall_collsion") + if not cNode.isEmpty(): + cNode.setZ(-1.2) + def setModelPath(self, path): self.modelPath = path self.loadModel() diff --git a/direct/src/level/PathEntity.py b/direct/src/level/PathEntity.py new file mode 100755 index 0000000000..e0ae6f6118 --- /dev/null +++ b/direct/src/level/PathEntity.py @@ -0,0 +1,50 @@ +from ToontownGlobals import * +import DirectNotifyGlobal +import BasicEntities + +class PathEntity(BasicEntities.NodePathEntity): + pathData = [ + [Vec3(10, 0, 0), + Vec3(10, 10,0), + Vec3(-10, 10, 0), + Vec3(-10, 0, 0), + ], + [Vec3(10, 5, 0), + Vec3(10, 0,0), + Vec3(-10, -5, 0), + ], + [Vec3(-8.29501342773,-9.22601318359,0.0), + Vec3(13.7590026855,-12.9730224609,0.0), + Vec3(16.7769775391,10.7899780273,0.0), + Vec3(-8.17102050781,14.1640014648,0.0), + ], + [Vec3(-47.9110107422,-6.86798095703,0.0), + Vec3(27.691986084,-5.68200683594,0.0), + Vec3(34.049987793,3.55303955078,0.0), + Vec3(-39.983001709,3.68499755859,0.0) + ], + [Vec3(1.25,21,0), + Vec3(-.2,7.9,0), + Vec3(-22.2,-12.1,0), + Vec3(-5.2,1.4,0), + ], + [Vec3(12.70, -51.9, 0.0), + Vec3(12.4, -33.0, 0.0), + Vec3(-1.16, -18.6, 0.0), + Vec3(9.27, -34.3, 0.0), + ], + ] + + def __init__(self, level, entId): + BasicEntities.NodePathEntity.__init__(self, level, entId) + self.path = self.pathData[self.pathIndex] + + def destroy(self): + BasicEntities.NodePathEntity.destroy(self) + + def setPathIndex(self, pathIndex): + self.pathIndex = pathIndex + self.path = self.pathData[self.pathIndex] + + +