def announceGenerate(self): DistributedEntity.announceGenerate(self) self.barrelRoot = self.attachNewNode('barrelRoot') barrel = self.getModelNP() barrel.setScale(self.barrelScale) barrel.reparentTo(self.barrelRoot) barrel.setHpr(180, 0, 0) lblBg = barrel.find('**/gagLabelDCS') lblBg.setColor(0.15, 0.15, 0.1) self.gagNode = barrel.attachNewNode('gagNode') self.gagNode.setPosHpr(0.0, -2.62, 4.0, 0, 0, 0) self.gagNode.setColorScale(0.7, 0.7, 0.6, 1) self.gagModel = loader.loadModel('phase_4/models/props/icecream.bam') self.gagModel.reparentTo(self.gagNode) self.gagModel.find('**/p1_2').clearBillboard() self.gagModel.setScale(0.6) self.gagModel.setPos(0, -0.1, -0.1 - 0.6) self.addSound( 'empty', 'phase_4/audio/sfx/MG_sfx_travel_game_square_no_vote_1.ogg') self.addSound('giveLaff', 'phase_4/audio/sfx/SZ_DD_treasure.ogg') self.addSound('start', 'phase_4/audio/sfx/MG_pairing_match.ogg') UseableObject.load(self)
def disable(self): self.height = None self.raiseSpeed = None self.stompSpeed = None self.scale = None self.moveDir = None DistributedEntity.disable(self)
def __init__(self, cr): DistributedEntity.__init__(self, cr) self.height = 1.0 self.raiseSpeed = 1 self.stompSpeed = 1 self.scale = Vec3(1) self.moveDir = Vec3.up()
def setEntityState(self, state): DistributedEntity.setEntityState(self, state) if state == self.StateDown: self.clearSequence() self.setPos(self.cEntity.getOrigin()) self.playSound("stomp") base.emitShake(self, 0.5) elif state == self.StateUp: self.stopSound("raise") self.clearSequence() self.setPos(self.cEntity.getOrigin() + self.getUpPosition()) elif state == self.StateStomp: self.setSequence( LerpPosInterval( self, self.height / self.stompSpeed, self.cEntity.getOrigin(), self.cEntity.getOrigin() + self.getUpPosition())) elif state == self.StateRaise: self.loopSound("raise") self.setSequence( LerpPosInterval( self, self.height / self.raiseSpeed, self.cEntity.getOrigin() + self.getUpPosition(), self.cEntity.getOrigin()))
def __init__(self, cr): DistributedEntity.__init__(self, cr) self.gagId = 0 self.pickupState = 0 self.collNode = None self.pickupSound = None self.gagMdl = None
def __init__(self, cr): DistributedEntity.__init__(self, cr) self.buttons = [] self.text = TextNode("keypad-text") self.text.setFont(loader.loadFont("models/fonts/DS-DIGI.TTF")) self.text.setTextColor((0, 0, 0, 1)) self.text.setAlign(TextNode.ACenter) self.textNP = None
def disable(self): self.ignore(self.thebldg.uniqueName('prepareElevator')) self.elev.cleanup() del self.elev if self.thebldg: if self.thebldg.elevators: self.thebldg.elevators[self.index] = None DistributedEntity.disable(self) DistributedElevator.disable(self)
def announceGenerate(self): DistributedEntity.announceGenerate(self) self.elev = Elevator( base.bspLoader.getEntityValueInt(self.entnum, "type")) self.elev.elevatorMdl.setPos(self.cEntity.getOrigin()) self.elev.elevatorMdl.setHpr(self.cEntity.getAngles()) DistributedElevator.announceGenerate(self)
def setupPhysics(self): shape = BulletSphereShape(1.0) bnode = BulletGhostNode(self.uniqueName('codeNumberPhys')) bnode.addShape(shape) bnode.setIntoCollideMask(CIGlobals.EventGroup) DistributedEntity.setupPhysics(self, bnode, True) self.stopWaterCheck() self.acceptOnce('enter' + self.uniqueName('codeNumberPhys'), self.__handlePickup)
def disable(self): DistributedEntity.disable(self) DistributedNode.disable(self) self.ignoreAll() if self.animTrack: self.animTrack.pause() self.animTrack = None return
def generate(self): DistributedEntity.generate(self) sph = BulletSphereShape(1.0) gn = BulletGhostNode(self.uniqueName("pickupGhost")) print gn.getName() gn.addShape(sph) self.collNode = self.attachNewNode(gn) self.pickupSound = base.loadSfx(self.PickupSoundPath)
def __init__(self, cr): DistributedEntity.__init__(self, cr) self.assign(NodePath(ModelNode('ambientGeneric'))) self.node().setPreserveTransform(ModelNode.PTLocal) self.sndFile = "" self.looping = False self.volume = 1.0 self.numWildcardSounds = 0
def disable(self): self.ignore('enter' + self.uniqueName('codeNumberPhys')) self.number = None if self.emblemFloat: self.emblemFloat.finish() self.emblemFloat = None if self.emblem: self.emblem.removeNode() self.emblem = None DistributedEntity.disable(self)
def __init__(self, cr): DistributedEntity.__init__(self, cr) UseableObject.__init__(self) self.barrel = None self.gagModel = None self.gagNode = None self.barrelScale = 0.5 self.pulseIval = None self.hasPhysGeom = False self.underneathSelf = True
def announceGenerate(self): DistributedEntity.announceGenerate(self) self.addSound("press", "sound/buttons/blip1.wav") self.addSound("denied", "sound/buttons/button2.wav") self.addSound("access", "sound/buttons/button3.wav") PhysicsUtils.makeBulletCollFromPandaColl(self.getModelNP()) for np in self.getModelNP().findAllMatches("**/trigger_*"): btn = KeypadButton(self, np) self.buttons.append(btn) self.setEffect(LightingOriginEffect.make((0, 0.1, 0)))
def announceGenerate(self): DistributedEntity.announceGenerate(self) self.getModelNP().find("**/shaft").setSy(self.height / 16.0) self.optimizeModel() self.enableModelCollisions() if self.scale.length() >= 5: self.addSound("stomp", self.BigStompSoundPath) else: self.addSound("stomp", self.SmallStompSoundPath) self.addSound("raise", self.RaiseSoundPath)
def __init__(self, cr): DistributedEntity.__init__(self, cr) UseableObject.__init__(self) self.gagId = 0 self.pickupState = 0 self.cost = 0 self.collNode = None self.pickupSound = None self.gagMdl = None self.hasPhysGeom = True self.underneathSelf = True self.infoText = None
def delete(self): if self.gagMdl: self.gagMdl.removeNode() self.gagMdl = None if self.bodyNP: self.ignore("rayenter" + self.bodyNP.getName()) self.ignore("rayexit" + self.bodyNP.getName()) self.ignore("enter" + self.bodyNP.getName()) UseableObject.removeNode(self) self.pickupSound = None self.pickupState = None self.gagId = None self.cost = None DistributedEntity.delete(self)
def delete(self): if self.gagMdl: self.gagMdl.removeNode() self.gagMdl = None if self.collNode: self.ignore("enter" + self.collNode.getName()) if self.pickupState == 1: base.physicsWorld.remove(self.collNode.node()) self.collNode.removeNode() self.collNode = None self.pickupSound = None self.pickupState = None self.gagId = None DistributedEntity.delete(self)
def announceGenerate(self): DistributedEntity.announceGenerate(self) DistributedNode.announceGenerate(self) self.build() # Build collisions self.collSphere = BulletCylinderShape(self.radius, self.height, ZUp) self.collNode = BulletRigidBodyNode(self.uniqueName('barrelSphere')) self.collNode.setKinematic(True) self.collNode.addShape(self.collSphere, TransformState.makePos(Point3(0, 0, self.height / 2))) self.collNode.setIntoCollideMask(WallGroup) self.collNodePath = self.attachNewNode(self.collNode) base.physicsWorld.attach(self.collNodePath.node()) self.accept('enter' + self.collNodePath.getName(), self.__handleCollision) self.reparentTo(render)
def setModel(self, model, animating): DistributedEntity.setModel(self, model, animating) loader.loadModel("models/cage.bam").find("**/collisions").reparentTo( self.getModelNP()) self.optimizeModel() self.getModelNP().postFlatten() self.enableModelCollisions() self.getModelNP().find("**/collisions").setCollideMask( CIGlobals.UseableGroup | CIGlobals.WallGroup) self.getModelNP().find("**/collisions").setPythonTag( 'useableObject', self) self.doorHinge = self.getModelNP().controlJoint( None, "modelRoot", "Bone") self.doorHinge.setPos(self.GateBoneOrigin) self.doorHinge.setHpr(self.ClosedAngles) self.addSound("door", "phase_5/audio/sfx/CHQ_SOS_cage_door.ogg")
def __init__(self, cr): DistributedEntity.__init__(self, cr) DistributedNode.__init__(self, cr) NodePath.__init__(self, 'restock_barrel') self.grabSfx = None self.rejectSfx = None self.grabSoundPath = 'phase_4/audio/sfx/SZ_DD_treasure.ogg' self.rejectSoundPath = 'phase_4/audio/sfx/ring_miss.ogg' self.animTrack = None self.barrelScale = 0.5 self.radius = 1.5 self.height = 4.275 self.playSoundForRemoteToons = 1 self.barrel = None self.gagNode = None self.gagModel = None # Collision nodes self.collSphere = None self.collNode = None self.collNodePath = None
def announceGenerate(self): DistributedEntity.announceGenerate(self) self.addSound("pickup", "sound/items/jellybean_pickup.ogg") import random color = random.choice(self.Colors) self.getModelNP().setColorScale(color, 1) from direct.interval.IntervalGlobal import LerpHprInterval self.rot = LerpHprInterval(self.getModelNP(), 1.0, (360, 0, 0), (0, 0, 0)) self.rot.loop() from src.coginvasion.globals import CIGlobals from panda3d.bullet import BulletSphereShape, BulletGhostNode sph = BulletSphereShape(0.5) body = BulletGhostNode(self.uniqueName('jellybean-trigger')) body.addShape(sph) body.setIntoCollideMask(CIGlobals.EventGroup) self.setupPhysics(body, True) self.acceptOnce('enter' + self.uniqueName('jellybean-trigger'), self.__enterJellybeanTrigger)
def delete(self): self.gagNode.removeNode() self.barrel.removeNode() base.physicsWorld.remove(self.collNode) self.collNodePath.removeNode() del self.barrel del self.gagNode del self.grabSfx del self.rejectSfx del self.grabSoundPath del self.rejectSoundPath del self.animTrack del self.barrelScale del self.radius del self.height del self.playSoundForRemoteToons del self.gagModel del self.collNode del self.collNodePath del self.collSphere DistributedNode.delete(self) DistributedEntity.delete(self)
def announceGenerate(self): DistributedEntity.announceGenerate(self) cm = CardMaker('emblemCard') cm.setFrame(-0.5, 0.5, 0, 1) cm.setHasUvs(True) cm.setUvRange((0, 0), (1, 1)) self.emblem = self.attachNewNode(cm.generate()) self.emblem.setAttrib(BloomAttrib.make(False)) self.emblem.setBSPMaterial('phase_5/maps/quest_scroll_emblem.mat', 1) self.emblem.setBillboardAxis() self.emblem.setTransparency(True) self.emblem.setScale(2) self.emblemFloat = Sequence( LerpPosInterval(self.emblem, 1.0, (0, 0, 0.5), (0, 0, 0), blendType='easeInOut'), LerpPosInterval(self.emblem, 1.0, (0, 0, 0), (0, 0, 0.5), blendType='easeInOut')) self.emblemFloat.loop() self.setupPhysics() self.reparentTo(render)
def setEntityState(self, state): DistributedEntity.setEntityState(self, state) self.clearSequence() if state == self.StateEmpty: self.setColorScale(0.5, 0.5, 0.5, 1.0) self.playSound('empty') self.stopSound('start') self.stopSound('giveLaff') elif state == self.StateAvailable: self.setColorScale(1, 1, 1, 1) elif state == self.StateGiving: self.setSequence( Sequence( SoundInterval(self.getSound('start'), duration=self.getSound('start').length() / 2.0), Func( self.setSequence, SoundInterval( self.getSound('giveLaff'), duration=self.getSound('giveLaff').length() / 4.0), True)))
def announceGenerate(self): DistributedEntity.announceGenerate(self) if self.soundHasWildcard(): from panda3d.core import VirtualFileSystem, Filename fsnd = Filename.fromOsSpecific(self.sndFile) vfs = VirtualFileSystem.getGlobalPtr() flist = vfs.scanDirectory(fsnd.getDirname()) soundFiles = [] for f in flist.getFiles(): if fnmatch.fnmatch(f.getFilename().getBasename(), fsnd.getBasename()): soundFiles.append(f.getFilename()) self.numWildcardSounds = len(soundFiles) for i in range(self.numWildcardSounds): soundfname = soundFiles[i] self.addSound("sound{0}".format(i), soundfname.getFullpath(), not self.hasSpawnFlags(self.SF_PlayEverywhere)) else: self.addSound("sound", self.sndFile, not self.hasSpawnFlags(self.SF_PlayEverywhere)) # Now that we have the sounds, reset the state in case we are currently playing self.setEntityState(self.entState)
def load(self): DistributedEntity.load(self) self.setPos(self.cEntity.getOrigin()) self.setHpr(self.cEntity.getAngles())
def disable(self): self.clearIval() DistributedEntity.disable(self)
def __init__(self, cr): DistributedEntity.__init__(self, cr) self.ival = None