Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- '''rcw_cadgen early module for kick it level generation
- Created on 19.02.2011
- @author: RoadCrewWorker
- '''
- import os, stat
- class BodyLibrary:
- '''Enum class to facilitate finding and selecting geometry'''
- Player_Start_Location = 3
- Particle_Generator = 2
- #Planes
- Plane_Boundary = 398
- Plane_Rain=707
- Plane_Sun=709
- Plane_Water=510
- #Cubes
- Cube_1m_A = 645
- Cube_1m_B = 646
- Cube_1m_C = 647
- Cube_1m_D = 648
- Cube_1m_E = 649
- Cube_1m_F = 650
- Cube_1m_G = 651
- Cube_1m_H = 652
- Cube_1m_I = 653
- Cube_Unbeveled = 657
- Cube_Wall = 728
- Cube_Mostly_Transparent = 708
- #Rings
- Ring_Blocky=699
- Ring_Jagged=701
- Rings_Hollow_Yellow=460
- Rings_Hollow_Wriggle=461
- Rings_Hollow_Chopped=462
- #Throbbers
- Throbber_Hex = 702
- Throbber_Ribbon = 721
- Throbber_Ribbon2 = 722
- Throbber_Ribbon3 = 724
- Throbber_Cube = 723
- #ScorePlates
- ScorePlate_10 = 335
- ScorePlate_20 = 336
- ScorePlate_30 = 337
- ScorePlate_50 = 338
- ScorePlate_100 = 339
- #Enemies
- Enemy_Ding = 684
- Enemy_Hyposphere = 685
- Enemy_Bow_Roller = 686
- Enemy_Phalanx = 692
- Enemy_FanBlade = 694
- Enemy_Flange = 695
- Enemy_Smoothsquid = 696
- Enemy_PlusSign = 697
- Enemy_Bumblebee = 700
- Enemy_PlusSign2 = 718
- Enemy_Cylinder_Triad = 719
- Enemy_Radial_Centipede2 = 720
- Enemy_HexFlowy = 754
- Enemy_bumblebee2 = 755
- #Lights
- Data_Ring=371
- Data_Wall_1000m=384
- Data_Red_Bars_128m=440
- #Various
- Multitentacle = 730
- Sphere_1m = 659
- Sphere_tendrils = 732
- Tube = 756
- Tube_Passable = 757
- Dragon = 759
- Prism_1m_Hexagonal = 705
- S_Shape = 637
- Dna_Element = 607
- Tunnel2=452
- Icosahedron=478
- Monolith_Small=599
- Flat_Bar_Yellow=643
- Flat_Bar_Orange=644
- Tentacle_A=751
- X_Struts=735
- class Entity(object):
- '''An abstract entity defining its own coordinate space, movement or color overlay'''
- def __init__(self):
- '''Constructor'''
- #Appearance
- self.Color = [255, 255, 255]
- self.Transparency = 0.0
- self.SpawnDistance = 0
- #Defines own subspace
- self.Position = [0.0, 0.0, 0.0]
- self.Scale = [1.0, 1.0, 1.0]
- self.Rotation = [0.0, 0.0, 0.0]
- #Animation
- self.Velocity = [0.0, 0.0, 0.0]
- self.RotationVelocity = [0.0, 0.0, 0.0]
- self.Origin = [0.0, 0.0, 0.0]
- def setSeconds(self, seconds):
- self.Position[2] = (129.0 - seconds) * 1595.2
- class Body(Entity):
- '''An actual kick it geometry object that can be written into a level file. Used by other meta objects.'''
- def __init__(self, type, time):
- Entity.__init__(self)
- self.setSeconds(time)
- self.PieceType = type
- self.Unkissable = 0
- self.Shootable = 0
- self.ThrobberType = 0
- self.Behaviors = 0
- self.AnimationSpeed = 0 #common, 6 for enemies
- self.LightingData = 1028.051 #common, 1000002 for enemies
- self.Alpha = 50 #common
- self.Bright = 0 #common
- self.KissType = 0 #common
- self.WeaponType = 0 #common
- self.SeekTargetType = 0 #common
- self.WeaponPeriod = 0.0 #common
- self.SeekTargetAcceleration = 0.0 #common
- def SerializeData(self):
- data = [ 'OBJ', \
- self.Rotation[0], self.Rotation[1], self.Rotation[2], \
- self.Position[0], self.Position[1], self.Position[2], \
- 0, self.PieceType, 0, 0, 0, 0, 0, 0, 0, self.Unkissable, \
- self.Scale[0], self.Scale[1], self.Scale[2], \
- self.Color[0], self.Color[1], self.Color[2], \
- self.RotationVelocity[0], self.RotationVelocity[1], self.RotationVelocity[2], \
- self.Velocity[0], self.Velocity[1], self.Velocity[2], \
- self.Origin[0], self.Origin[1], self.Origin[2], \
- self.Shootable, self.Transparency, self.Alpha, self.Bright, self.SpawnDistance, self.LightingData, \
- self.KissType, self.WeaponPeriod, self.SeekTargetAcceleration, self.Behaviors, self.ThrobberType, \
- self.WeaponType, self.SeekTargetType, self.AnimationSpeed]
- data.extend([0]*43)
- data.append('END')
- return data
- class Level(object):
- def __init__(self):
- self.Entities = []
- self.Skycube = 26
- self.Ambient = 0
- self.TimeLimit = 6;
- self.TimeLeft = 999999;
- self.Gravity = 2;
- self.FogStart = 5000;
- self.FogEnd = 9000;
- self.FogColor = [102, 183, 255];
- #Legacy
- self.ClipFar = 30000
- def SerializeString(self):
- data = [self.TimeLimit, self.TimeLeft, 0, self.Gravity, \
- self.FogStart, self.FogEnd, self.FogColor[0], self.FogColor[1], self.FogColor[2], \
- 0, 0, self.ClipFar, 0, 0, self.Skycube, self.Ambient, 0, 1001]
- data.extend([0]*44)
- self.Entities.sort(key=lambda entity: entity.Position[2], reverse=True)
- for entity in self.Entities: data.extend(entity.SerializeData())
- return ' \n'.join([str(d) for d in data])
- def storeLevel(self, filename):
- os.chmod(filename, stat.S_IWRITE) #Remove this eventually
- l = open(filename, 'w+')
- l.write(self.SerializeString())
- l.close()
- os.chmod(filename, stat.S_IREAD) #ditto
- def Add(self, entity):
- self.Entities.append(entity)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement