def new_connection( self, client ): print "Newconn" self.clients.append( client ) pos, angles = (0., 1., 0.), (0., 0., 0.) new_char = Character( pos, angles ) new_player = Player( new_char, None ) new_weapon = TestWeapon( TestProjectile ) new_char.equip( new_weapon ) client.network_id = 2*self.conn_no new_char.state().entity_id = 2*self.conn_no new_player.state().entity_id = 2*self.conn_no + 1 self.conn_no += 1 print "Newconn!" return new_player.state()
def new_entity( self, data ): l, = struct.unpack( "!H", data[:2] ) cls = data[2: 2+l] print "new_ent", cls if cls == "BlockWorldState": w = World() self.append( w ) state = w.state() elif cls == "CharacterState": c = Character( (0., .1, 0.), (0., 0., 0.) ) w = TestWeapon( TestProjectile ) c.equip( w ) state = c.state() else: print "Unknown entity type" raise ValueError( "Unknown entity type" ) if state: data = state.deserialize( data[2+l:] ) return NewEntityData( data, state )