mirror of
https://github.com/Sneed-Group/Poodletooth-iLand
synced 2024-12-24 04:02:40 -06:00
bouncing
This commit is contained in:
parent
7d5739c442
commit
3f37efea21
2 changed files with 6 additions and 53 deletions
|
@ -3,6 +3,7 @@ from pandac.PandaModules import CollisionPolygon
|
||||||
from otp.otpbase import OTPGlobals
|
from otp.otpbase import OTPGlobals
|
||||||
from direct.distributed.DistributedObject import DistributedObject
|
from direct.distributed.DistributedObject import DistributedObject
|
||||||
from direct.fsm import ClassicFSM, State
|
from direct.fsm import ClassicFSM, State
|
||||||
|
from toontown.toonbase import ToontownGlobals
|
||||||
|
|
||||||
class DistributedPillow(DistributedObject):
|
class DistributedPillow(DistributedObject):
|
||||||
|
|
||||||
|
@ -38,15 +39,6 @@ class DistributedPillow(DistributedObject):
|
||||||
self.wallpolys = []
|
self.wallpolys = []
|
||||||
self.npaths = []
|
self.npaths = []
|
||||||
self.np = None
|
self.np = None
|
||||||
self.fsm = ClassicFSM.ClassicFSM(
|
|
||||||
'DistributedPillow',
|
|
||||||
[
|
|
||||||
State.State('off', self.enterOff, self.exitOff,
|
|
||||||
['entering']),
|
|
||||||
State.State('bounce', self.enterBounce, self.exitBounce,
|
|
||||||
['off']),
|
|
||||||
], 'off', 'off')
|
|
||||||
self.fsm.enterInitialState()
|
|
||||||
|
|
||||||
def generate(self):
|
def generate(self):
|
||||||
DistributedObject.generate(self)
|
DistributedObject.generate(self)
|
||||||
|
@ -64,12 +56,12 @@ class DistributedPillow(DistributedObject):
|
||||||
polyNode.setFromCollideMask(OTPGlobals.FloorBitmask)
|
polyNode.setFromCollideMask(OTPGlobals.FloorBitmask)
|
||||||
polyNodePath = self.np.attachNewNode(polyNode)
|
polyNodePath = self.np.attachNewNode(polyNode)
|
||||||
self.npaths.append(polyNodePath)
|
self.npaths.append(polyNodePath)
|
||||||
self.accept("enterFloorPoly-%d" % n, self.printEntry)
|
self.accept("enterFloorPoly-%d" % n, self.gravityLow)
|
||||||
for wall in DistributedPillow.walls:
|
for wall in DistributedPillow.walls:
|
||||||
ab = DistributedPillow.points[wall[0]]
|
ab = DistributedPillow.points[wall[0]]
|
||||||
bb = DistributedPillow.points[wall[1]]
|
bb = DistributedPillow.points[wall[1]]
|
||||||
cb = Point3(bb.getX(), bb.getY(), bb.getZ() + 15)
|
cb = Point3(bb.getX(), bb.getY(), bb.getZ() + 20)
|
||||||
db = Point3(ab.getX(), ab.getY(), ab.getZ() + 15)
|
db = Point3(ab.getX(), ab.getY(), ab.getZ() + 20)
|
||||||
self.wallpolys.append(CollisionPolygon(ab, bb, cb, db))
|
self.wallpolys.append(CollisionPolygon(ab, bb, cb, db))
|
||||||
for n, p in enumerate(self.wallpolys):
|
for n, p in enumerate(self.wallpolys):
|
||||||
polyNode = CollisionNode("WallPoly-%d" % n)
|
polyNode = CollisionNode("WallPoly-%d" % n)
|
||||||
|
@ -88,28 +80,12 @@ class DistributedPillow(DistributedObject):
|
||||||
self.np = None
|
self.np = None
|
||||||
if hasattr(self, 'loader'):
|
if hasattr(self, 'loader'):
|
||||||
del self.loader
|
del self.loader
|
||||||
self.ignoreAll()
|
|
||||||
self.fsm.request('off')
|
|
||||||
|
|
||||||
def delete(self):
|
def delete(self):
|
||||||
if self.np:
|
if self.np:
|
||||||
self.np.removeNode()
|
self.np.removeNode()
|
||||||
self.np = None
|
self.np = None
|
||||||
self.ignoreAll()
|
|
||||||
DistributedObject.delete(self)
|
DistributedObject.delete(self)
|
||||||
del self.fsm
|
|
||||||
|
|
||||||
def enterOff(self):
|
def gravityLow(self, entry):
|
||||||
pass
|
base.localAvatar.controlManager.currentControls.setGravity(ToontownGlobals.GravityValue * 1.25)
|
||||||
|
|
||||||
def exitOff(self):
|
|
||||||
pass
|
|
||||||
|
|
||||||
def enterBounce(self):
|
|
||||||
pass
|
|
||||||
|
|
||||||
def exitBounce(self):
|
|
||||||
pass
|
|
||||||
|
|
||||||
def printEntry(self, entry):
|
|
||||||
print(entry)
|
|
||||||
|
|
|
@ -5,32 +5,9 @@ class DistributedPillowAI(DistributedObjectAI):
|
||||||
|
|
||||||
def __init__(self, air):
|
def __init__(self, air):
|
||||||
DistributedObjectAI.__init__(self, air)
|
DistributedObjectAI.__init__(self, air)
|
||||||
self.fsm = ClassicFSM.ClassicFSM(
|
|
||||||
'DistributedPillowAI',
|
|
||||||
[
|
|
||||||
State.State('off', self.enterOff, self.exitOff,
|
|
||||||
['bounce']),
|
|
||||||
State.State('bounce', self.enterBounce, self.exitBounce,
|
|
||||||
['off']),
|
|
||||||
], 'off', 'off')
|
|
||||||
self.fsm.enterInitialState()
|
|
||||||
|
|
||||||
def generate(self):
|
def generate(self):
|
||||||
DistributedObjectAI.generate(self)
|
DistributedObjectAI.generate(self)
|
||||||
|
|
||||||
def delete(self):
|
def delete(self):
|
||||||
self.fsm.requestFinalState()
|
|
||||||
del self.fsm
|
|
||||||
DistributedObjectAI.delete(self)
|
DistributedObjectAI.delete(self)
|
||||||
|
|
||||||
def enterOff(self):
|
|
||||||
pass
|
|
||||||
|
|
||||||
def exitOff(self):
|
|
||||||
pass
|
|
||||||
|
|
||||||
def enterBounce(self):
|
|
||||||
pass
|
|
||||||
|
|
||||||
def exitBounce(self):
|
|
||||||
pass
|
|
||||||
|
|
Loading…
Reference in a new issue