def maybe_commander(self, entity): if self.world.commander.eid != entity.eid: return gpos = entity.grid_position block = self.world.grid.standing_on_block( AABB.from_player_coords(entity.position)) if block is None: return if self.world.commander.last_block is not None and self.world.commander.last_block == block: return self.world.commander.last_block = block lpos = self.world.commander.last_possition in_nodes = self.world.navgrid.graph.has_node(block.coords) gs = GridSpace(self.world.grid, block=block) msg = "P in nm %s nm nodes %d\n" % \ (in_nodes, self.world.navgrid.graph.node_count) msg += "gs_stand %s\n" % str(gs.bb_stand) msg += str(block) + '\n' msg += str(block.grid_bounding_box) try: msg += "\nsucessors %s" % str(self.world.navgrid.graph.get_succ(block.coords)) except: pass if lpos is not None: gsl = GridSpace(self.world.grid, coords=lpos) if gsl.can_stand_on: pass else: gsl = GridSpace( self.world.grid, coords=(lpos[0], lpos[1] - 1, lpos[2])) if gsl.can_stand_on: lpos = gsl.coords if not(gsl.bb_stand is None or gs.bb_stand is None): msg += "\ncost from %s to %s %s\n" % \ (lpos, block.coords, self.world.navgrid.graph.get_edge(lpos, block.coords)) msg += "last stand %s now stand %s from %s to %s\n" % \ (gsl.can_stand_on, gs.can_stand_on, gsl.bb_stand, gs.bb_stand) if gsl.can_go_between(gs, debug=True): msg += "can go True with cost %s\n" % gsl.edge_cost else: msg += "can go False\n" msg += "can stand between %s intersection %s" % ( gsl.can_stand_between(gs, debug=True), gsl.intersection) log.msg(msg) self.world.commander.last_possition = gpos