def dig_operation(self, op): """Digging into the pile will disperse it, making it smaller""" scale_reduction = 0.5 set_ent = Entity(self.id, scale=[1.0 - scale_reduction]) scale_prop = self.props.scale if scale_prop: if len(scale_prop) == 3: set_ent.scale = [ scale_prop[0] - scale_reduction, scale_prop[1] - scale_reduction, scale_prop[2] - scale_reduction ] else: set_ent.scale = [scale_prop[0] - scale_reduction] return Operation("set", set_ent, to=self), \ Operation("imaginary", Entity(description="You dispersed the pile."), to=op.id, from_=op.id)
def delete_operation(self, op): new_ent = Entity(parent="lumber", mass=self.props.mass, location=self.location.copy(), mode="free") # Copy scale if there is one if self.props.scale: new_ent.scale = self.props.scale create = Operation("create", new_ent, to=self.parent) # Send through parent since this entity will be destroyed once the op is handled. self.parent.send_world(create) return server.OPERATION_HANDLED