コード例 #1
0
	def act(self, action, facing_loc=None, repeating=False, force_restart=True):
		"""
		@param repeating: maps to fife, currently broken: http://github.com/fifengine/fifengine/issues/708
		@param force_restart: whether to always restart, even if action is already displayed
		"""
		if not self.has_action(action):
			action = 'idle'

		if not force_restart and self._action == action:
			return

		self._action = action

		# TODO This should not happen, this is a fix for the component introduction
		# Should be fixed as soon as we move concrete object to a component as well
		# which ensures proper initialization order for loading and initing
		if self._instance is None:
			return

		if facing_loc is None:
			facing_loc = self._instance.getFacingLocation()
		UnitClass.ensure_action_loaded(self._action_set_id, action) # lazy
		if (Fife.getVersion() >= (0, 3, 6)):
			if repeating:
				self._instance.actRepeat(action+"_"+str(self._action_set_id), facing_loc)
			else:
				self._instance.actOnce(action+"_"+str(self._action_set_id), facing_loc)
		else:
			self._instance.act(action+"_"+str(self._action_set_id), facing_loc, repeating)
		ActionChanged.broadcast(self, action)
コード例 #2
0
	def act(self, action, facing_loc=None, repeating=False, force_restart=True):
		"""
		@param repeating: maps to fife instance method actRepeat or actOnce
		@param force_restart: whether to always restart, even if action is already displayed
		"""
		if not self.has_action(action):
			action = 'idle'

		if not force_restart and self._action == action:
			return

		self._action = action

		# TODO This should not happen, this is a fix for the component introduction
		# Should be fixed as soon as we move concrete object to a component as well
		# which ensures proper initialization order for loading and initing
		if self._instance is None:
			return

		if facing_loc is None:
			facing_loc = self._instance.getFacingLocation()
		UnitClass.ensure_action_loaded(self._action_set_id, action) # lazy
		if (Fife.getVersion() >= (0, 3, 6)):
			if repeating:
				self._instance.actRepeat(action + "_" + str(self._action_set_id), facing_loc)
			else:
				self._instance.actOnce(action + "_" + str(self._action_set_id), facing_loc)
		else:
			self._instance.act(action + "_" + str(self._action_set_id), facing_loc, repeating)
		ActionChanged.broadcast(self, action)
コード例 #3
0
 def initialize(self):
     super(ColorOverlayComponent, self).initialize()
     ActionChanged.subscribe(self.update_overlay, self.instance)
     ActionChanged.broadcast(self.instance, self.instance._action)
コード例 #4
0
	def initialize(self):
		super(ColorOverlayComponent, self).initialize()
		ActionChanged.subscribe(self.update_overlay, self.instance)
		ActionChanged.broadcast(self.instance, self.instance._action)