示例#1
0
	def __init__(self, sequence, \
			id, subtype, name, \
			size, \
			posx, posy, posz, \
			velx, vely, velz, \
			contains, \
			order_types, \
			order_number, \
			modify_time, \
			*args, **kw):
		Describable.__init__(self, sequence)

		self.length = \
			4 + 4 + \
			4 + len(name) + \
			8 + 3*8 + 3*8 + \
			4 + len(contains)*4 + \
			4 + len(order_types)*4 + \
			4 + 8 + 8

		self.id           = id
		self._subtype     = subtype
		self.name         = name
		self.size         = size
		self.pos          = (posx, posy, posz)
		self.vel          = (velx, vely, velz)
		self.contains     = contains
		self.order_types  = order_types
		self.order_number = order_number
		self.modify_time  = modify_time

		if self.__class__ == Object:
			try:
				if kw.has_key('force'):
					cls = kw['force']
				else:
					cls = descriptions()[subtype]
				self.__class__ = cls

				if len(args) > 0:
					self.__init__(sequence, \
									id, subtype, name, \
									size, \
									posx, posy, posz, \
									velx, vely, velz, \
									contains, \
									order_types, \
									order_number, \
									modify_time, *args)
			except KeyError, e:
				raise DescriptionError(sequence, subtype)
示例#2
0
	def __init__(self, sequence, \
			id, subtype, name, \
			desc, \
			parent, \
			contains, \
			modify_time, \
			*args, **kw):
		Describable.__init__(self, sequence)

		self.length = \
			4 + 4 + \
			4 + len(name) + \
			4 + len(desc) + \
			4 + \
			4 + len(contains)*4 + \
			8 + 16

		self.id           = id
		self._subtype     = subtype
		self.name         = name
		self.desc         = desc
		self.parent       = parent
		self.contains     = contains
		self.modify_time  = modify_time

		if self.__class__ == Object:
			try:
				if kw.has_key('force'):
					cls = kw['force']
					del kw['force']
				else:
					from ObjectDesc import descriptions
					cls = descriptions()[subtype]

				self.__class__ = cls
				if len(args) > 0:
					self.__init__(sequence, \
									id, subtype, name, \
									desc, \
									parent, \
									contains, \
									modify_time, \
									*args)

			except KeyError, e:
				raise DescriptionError(sequence, subtype)