예제 #1
0
    def disable(self):
        """ This method is called when the object is removed from the
        scene, for instance because it left the zone.  It is balanced
        against generate(): for each generate(), there will be a
        corresponding disable().  Everything that was done in
        generate() or announceGenerate() should be undone in disable().

        After a disable(), the object might be cached in memory in case
        it will eventually reappear.  The DistributedObject should be
        prepared to receive another generate() for an object that has
        already received disable().

        Note that the above is only strictly true for *cacheable*
        objects.  Most objects are, by default, non-cacheable; you
        have to call obj.setCacheable(True) (usually in the
        constructor) to make it cacheable.  Until you do this, your
        non-cacheable object will always receive a delete() whenever
        it receives a disable(), and it will never be stored in a
        cache.
        """

        # Stop the smooth task.
        self.stopSmooth()

        # Take it out of the scene graph.
        self.detachNode()

        if self.flushTask:
            taskMgr.remove(self.flushTask)
            self.flushTask = None

        DistributedSmoothNode.disable(self)
예제 #2
0
    def announceGenerate(self):
        DistributedSmoothNode.announceGenerate(self)
        self.activateSmoothing(True, False)
        self.startSmooth()

        self.loadActor()
        self.reparentTo(render)
예제 #3
0
    def delete(self):
        # Stop the smooth task.
        self.stopSmooth()
        
        # Clean out self.model, so we don't have a circular reference.
        self.model = None

        DistributedSmoothNode.delete(self)
예제 #4
0
 def generate(self):
     DistributedSmoothNode.generate(self)
     self.name = self.uniqueName('projectile')
     self.posHprBroadcastName = self.uniqueName('projectileBroadcast')
     geom = loader.loadModel('models/smiley')
     self.geom = geom
     self.geom.reparentTo(self)
     self.startSmooth()
     self.reparentTo(render)
예제 #5
0
 def __init__(self, cr):
     self.cr = cr
     Char.Char.__init__(self)
     DistributedSmoothNode.__init__(self, cr)
     self.name = ''
     self.anim = ''
     self.chat = ''
     self.charType = ''
     self.clerk = 0
예제 #6
0
 def delete(self):
     del self.name
     del self.charType
     del self.anim
     del self.chat
     if self.clerk:
         self.wb.remove_node()
         del self.wb
     Char.Char.delete(self)
     DistributedSmoothNode.delete(self)
예제 #7
0
    def smoothPosition(self):
        """
        This function updates the position of the node to its computed
        smoothed position.  This may be overridden by a derived class
        to specialize the behavior.
        """
        DistributedSmoothNode.smoothPosition(self)

        vel = self.smoother.getSmoothForwardVelocity()
        self.setMoving(vel != 0)
예제 #8
0
    def __init__(self, cr):
        DistributedSmoothNode.__init__(self, cr)

        self.actor = None
        self.isMoving = False
        self.name = ''
        self.chat = ''
        self.nameText = None
        self.nameTextNP = None
        self.chatText = None
        self.chatTextNP = None
예제 #9
0
    def generate(self):
        """ This method is called when the object is generated: when it
        manifests for the first time on a particular client, or when it
        is pulled out of the cache after a previous manifestation.  At
        the time of this call, the object has been created, but its
        required fields have not yet been filled in. """

        # Always call up to parent class
        DistributedSmoothNode.generate(self)

        self.setPythonTag('avId', self.doId)
예제 #10
0
    def delete(self):
        try:
            self.DistributedToon_deleted
        except:
            self.DistributedToon_deleted = 1
            self.tutDone = None
            self.stopSmooth()
            Toon.Toon.delete(self)
            DistributedAvatar.delete(self)
            DistributedSmoothNode.delete(self)

        return
예제 #11
0
    def delete(self):
        """ This method is called after disable() when the object is to
        be completely removed, for instance because the other user
        logged off.  We will not expect to see this object again; it
        will not be cached.  This is stronger than disable(), and the
        object may remove any structures it needs to in order to allow
        it to be completely deleted from memory.  This balances against
        __init__(): every DistributedObject that is created will
        eventually get delete() called for it exactly once. """

        # Clean out self.model, so we don't have a circular reference.
        self.model = None

        DistributedSmoothNode.delete(self)
예제 #12
0
 def smoothPosition(self):
     """ This gets called when the position update
     has been received.  It determines whether
     to animate the object or not. """
     DistributedSmoothNode.smoothPosition(self)
     if not self.isLocal():
         if self.smoother.getSmoothForwardVelocity() or self.smoother.getSmoothRotationalVelocity():
             if self.isMoving == False:
                 self.actor.loop("run")
                 self.isMoving = True
         else:
             if self.isMoving == True:
                 self.actor.stop()
                 self.actor.pose("walk", 5)
                 self.isMoving = False
예제 #13
0
    def __init__(self, cr, playerId = None):
        DistributedSmoothNode.__init__(self,cr)
        # you have to initialize NodePath.__init__() here because it is
        # not called in DistributedSmoothNode.__init__()
        NodePath.__init__(self, 'avatar')

        self.playerId = playerId

        self.setTag('paintType', 'avatar')

        # This point is in the middle of the avatar, for determining
        # paint normals and such.
        self.center = self.attachNewNode('center')
        self.center.setZ(0.5)

        self.lastPaintPoint = None
        self.paintDirty = False
        self.flushTask = None
        self.p = None
        self.tex = None

        # A dictionary of player -> count, showing the number of
        # pixels that each player has painted onto this avatar.
        self.players = {}

        self.actor = None
        self.nametag = None
        self.moving = False

        # This is true if this avatar represents the "local avatar",
        # the player at the keyboard, as opposed to a remote player.
        self.localAvatar = False

        # Create an "into" collision sphere so it becomes tangible.
        cs = CollisionSphere(0, 0, 0.5, 0.5)
        cnode = CollisionNode('cnode')
        cnode.addSolid(cs)
        self.cnp = self.attachNewNode(cnode)
        self.cnp.setCollideMask(Globals.AvatarBit)
예제 #14
0
    def announceGenerate(self):
        """ This method is called after generate(), after all of the
        required fields have been filled in.  At the time of this call,
        the distributed object is ready for use. """

        DistributedSmoothNode.announceGenerate(self)

        # We can activate smoothing on this avatar as soon as it's
        # generated.
        self.activateSmoothing(True, False)

        # We also need to start the smooth task, which computes the
        # new smoothed position every frame.  Let's keep this task
        # running as long as the avatar is generated.
        self.startSmooth()

        # Get a pointer to the associated TagPlayer object.  Since
        # there's no guarantee of order between the time TagPlayer and
        # TagAvatar are generated, we might have to wait for it.  The
        # RelatedObjectManager can do that for us.
        self.cr.relatedObjectMgr.requestObjects(
            [self.playerId], allCallback = self.manifestAvatar)
예제 #15
0
    def __init__(self, cr):
        try:
            self.DistributedToon_initialized
            return
        except:
            self.DistributedToon_initialized = 1

        Toon.Toon.__init__(self, cr)
        DistributedAvatar.__init__(self, cr)
        DistributedSmoothNode.__init__(self, cr)
        self.questManager = QuestManager.QuestManager()
        self.token = -1
        self.ghost = 0
        self.puInventory = []
        self.equippedPU = -1
        self.backpackId = None
        self.backpack = None
        self.animState2animId = {}
        self.battleMeter = None
        for index in range(len(self.animFSM.getStates())):
            self.animState2animId[self.animFSM.getStates()[index].getName()] = index

        self.animId2animState = {v:k for k, v in self.animState2animId.items()}
        self.initAmmo = []
        self.initGagIds = []
        self.headMeter = None
        self.firstTimeChangingHP = True
        self.gagBPData = []
        self.quests = []
        self.tier = None
        self.questHistory = None
        self.busy = 1
        self.friends = None
        self.tutDone = 0
        self.hoodsDiscovered = []
        self.teleportAccess = []
        self.lastHood = 0
        return
예제 #16
0
    def disable(self):
        # Take it out of the scene graph.
        self.detachNode()

        DistributedSmoothNode.disable(self)
 def __init__(self, cr):
     Avatar.__init__(self)
     DistributedSmoothNode.__init__(self, cr)
예제 #18
0
 def delete(self):
     self.mickey = None
     DistributedSmoothNode.delete(self)
 def delete(self):
     Suit.delete(self)
     DistributedAvatar.delete(self)
     DistributedSmoothNode.delete(self)
예제 #20
0
    def __init__(self, cr):
        self.cr = cr
        DistributedSmoothNode.__init__(self, cr)
        NodePath.__init__(self, 'Mickey')
        self.name = "Mickey"
        self.anim = ""
        self.chat = ""

        self.mickey = Actor(
            "phase_3/models/char/mickey-1200.bam", {
                "neutral": "phase_3/models/char/mickey-wait.bam",
                "walk": "phase_3/models/char/mickey-walk.bam",
                "run": "phase_3/models/char/mickey-run.bam",
                "left-start": "phase_3.5/models/char/mickey-left-start.bam",
                "left": "phase_3.5/models/char/mickey-left.bam",
                "right-start": "phase_3.5/models/char/mickey-right-start.bam",
                "right": "phase_3.5/models/char/mickey-right.bam"
            })
        self.mickeyEye = self.mickey.controlJoint(None, "modelRoot",
                                                  "joint_pupilR")
        self.mickeyEye.setY(0.025)
        self.mickey.reparentTo(self)
        self.mickey.setScale(1.25)

        for bundle in self.mickey.getPartBundleDict().values():
            bundle = bundle['modelRoot'].getBundle()
            earNull = bundle.findChild('sphere3')
            if not earNull:
                earNull = bundle.findChild('*sphere3')
            earNull.clearNetTransforms()

        for bundle in self.mickey.getPartBundleDict().values():
            charNodepath = bundle['modelRoot'].partBundleNP
            bundle = bundle['modelRoot'].getBundle()
            earNull = bundle.findChild('sphere3')
            if not earNull:
                earNull = bundle.findChild('*sphere3')
            ears = charNodepath.find('**/sphere3')
            if ears.isEmpty():
                ears = charNodepath.find('**/*sphere3')
            ears.clearEffect(CharacterJointEffect.getClassType())
            earRoot = charNodepath.attachNewNode('earRoot')
            earPitch = earRoot.attachNewNode('earPitch')
            earPitch.setP(40.0)
            ears.reparentTo(earPitch)
            earNull.addNetTransform(earRoot.node())
            ears.clearMat()
            ears.node().setPreserveTransform(ModelNode.PTNone)
            ears.setP(-40.0)
            ears.flattenMedium()
            ears.setBillboardAxis()

        self.shadow = loader.loadModel("phase_3/models/props/drop_shadow.bam")
        self.shadow.setScale(0.55)
        self.shadow.flattenMedium()
        self.shadow.setBillboardAxis(4)
        try:
            self.shadowPlacer = ShadowPlacer(base.cTrav, self.shadow,
                                             base.wall_mask, base.floor_mask)
            self.shadowPlacer.on()
        except:
            pass
        self.shadow.reparentTo(self)

        cs = CollisionSphere(0, 0, 0, 2)
        cnode = CollisionNode('mickeyCNode')
        cnode.addSolid(cs)
        rs = CollisionRay(0, 0, 2, 0, 0, -1)
        rnode = CollisionNode('mickeyRNode')
        rnode.addSolid(rs)
        self.cnp = self.attachNewNode(cnode)
        self.cnp.setZ(0.75)
        self.rnp = self.attachNewNode(rnode)
예제 #21
0
    def generate(self):
        DistributedSmoothNode.generate(self)

        self.activateSmoothing(True, False)
        self.startSmooth()
예제 #22
0
 def announceGenerate(self):
     DistributedSmoothNode.announceGenerate(self)
     DistributedTargetableObject.announceGenerate(self)
 def delete(self):
     self.model = None
     DistributedSmoothNode.delete(self)
예제 #24
0
 def announceGenerate(self):
     DistributedAvatar.announceGenerate(self)
     DistributedSmoothNode.announceGenerate(self)
     self.healthLabel.setScale(1.1)
     self.deathEvent = self.uniqueName('DistributedPieTurret-death')
     self.makeTurret()
예제 #25
0
 def generate(self):
     DistributedSmoothNode.generate(self)
     DistributedTargetableObject.generate(self)
     if base.config.GetBool('create-client-coll-spheres', 0) is 1:
         self.setupDebugCollisions()
예제 #26
0
 def delete(self):
     if self.model is not None:
         self.model.removeNode()
     if self.nameTag is not None:
         self.nameTag.removeNode()
     DistributedSmoothNode.delete(self)
예제 #27
0
 def announceGenerate(self):
     DistributedSmoothNode.announceGenerate(self)
     self.reparentTo(render)
     self.d_getNameForNameTag()
 def disable(self):
     self.stopWaterCheck()
     self.stopSmooth()
     self.cleanupPhysics()
     DistributedSmoothNode.disable(self)
 def generate(self):
     DistributedSmoothNode.generate(self)
예제 #30
0
 def delete(self):
     DistributedSmoothNode.delete(self)
     DistributedTargetableObject.delete(self)
     SmoothGridChild.delete(self)
 def __init__(self, cr):
     DistributedSmoothNode.__init__(self, cr)
     PhysicsNodePath.__init__(self, ModelRoot('physEntity'))
예제 #32
0
 def setLocation(self, parentId, zoneId):
     DistributedSmoothNode.setLocation(self, parentId, zoneId)
 def generate(self):
     DistributedSmoothNode.generate(self)
     self.activateSmoothing(True, False)
     self.startSmooth()
예제 #34
0
 def disable(self):
     # remove all anims, on all parts and all lods
     self.stopSmooth()
     if (not self.isEmpty()):
         Actor.unloadAnims(self, None, None, None)
     DistributedSmoothNode.disable(self)
예제 #35
0
    def announceGenerate(self):
        DistributedSmoothNode.announceGenerate(self)

        self.reparentTo(render)
 def announceGenerate(self):
     DistributedSmoothNode.announceGenerate(self)
     self.reparentTo(base.render)
예제 #37
0
 def disable(self):
     self.stopSmooth()
     self.detachNode()
     DistributedSmoothNode.disable(self)
예제 #38
0
 def generate(self):
     DistributedSmoothNode.generate(self)
     self.activateSmoothing(True, False)
     self.startSmooth()
     self.accept('showAvId', self.__showAvId)
     self.accept('showName', self.__showName)
 def generate(self):
     DistributedAvatar.generate(self)
     DistributedSmoothNode.generate(self)
     self.startSmooth()
예제 #40
0
 def delete(self):
     DistributedSmoothNode.delete(self)
예제 #41
0
 def __init__(self, cr):
     ShadowCaster.__init__(self)
     DistributedSmoothNode.__init__(self, cr)
     NodePath.__init__(self, 'Projectile')
	def announceGenerate(self):
		DistributedAvatar.announceGenerate(self)
		DistributedSmoothNode.announceGenerate(self)
		self.healthLabel.setScale(1.1)
		self.makeTurret()
예제 #43
0
 def delete(self):
     DistributedSmoothNode.delete(self)
 def stopSmooth(self):
     DistributedSmoothNode.stopSmooth(self)
     localAvatarReachable = (hasattr(base, 'localAvatar')
                             and base.localAvatar)
     if localAvatarReachable and self.doId != base.localAvatar.doId:
         self.resetTorsoRotation()
 def announceGenerate(self):
     DistributedSmoothNode.announceGenerate(self)
     AvatarShared.announceGenerate(self)
     self.setPythonTag('avatar', self.doId)
     self.setParent(CIGlobals.SPHidden)
     self.loadAvatar()
예제 #46
0
 def disable(self):
     self.stopSmooth()
     self.ignore('showAvId')
     self.ignore('showName')
     self.detachNode()
     DistributedSmoothNode.disable(self)
 def disable(self):
     DistributedSmoothNode.disable(self)
     Avatar.disable(self)
     self.detachNode()
     return
예제 #48
0
 def __init__(self, cr):
     DistributedSmoothNode.__init__(self, cr)
     NodePath.__init__(self, "Model")
     self.model = base.loader.loadModel('smiley.egg')
     self.model.reparentTo(self)
예제 #49
0
 def wrtReparentTo(self, parent):
     DistributedSmoothNode.wrtReparentTo(self, parent)
예제 #50
0
 def generate(self):
     DistributedAvatar.generate(self)
     DistributedSmoothNode.generate(self)
     self.startSmooth()
예제 #51
0
 def wrtReparentTo(self, parent):
     DistributedSmoothNode.wrtReparentTo(self, parent)
 def disable(self):
     self.stopSmooth()
     self.model.detachNode()
     DistributedSmoothNode.disable(self)
예제 #53
0
 def __init__(self, cr):
     ShadowCaster.__init__(self)
     DistributedSmoothNode.__init__(self, cr)
     NodePath.__init__(self, "Projectile")
	def disable(self):
		self.stopSmooth()
		self.ignore('showAvId')
		self.ignore('showName')
		self.detachNode()
		DistributedSmoothNode.disable(self)