Example #1
0
class Box(Object):
    layers = ["Conv", "Items", "Objects"]
    renderlayer = "Objects"
    internalsize = V(7, 7)
    gen = Generators.Building()
    exoff = V(0, -8)

    def __init__(self, coords):
        super().__init__(coords)
        self.area = Area(self.internalsize, self.gen, self)

    def update(self, pos, area, events):
        self.area.generate(area.get_power)
        self.area.update(events)

    def out_warp(self, iarea, pos, d):
        if iarea.get("Overlay", pos):
            return self.coords + d

    def in_warp(self, d):
        hb = self.area.bounds // 2
        return Coordinate(self.area, hb - d * hb)

    def mined(self):
        return Items.ObjPlaceable(self)

    @property
    def hardness(self):
        return 120 if not self.area.has_player() else 0
Example #2
0
 def get_img(self, comp):
     # FLASHBACKS
     try:
         return imgcache[comp]
     except KeyError:
         img = comp[0][0].uts[comp[0][1]].copy()
         for t, uts in comp[1:]:
             img.blit(t.uts[uts], V(0, 0))
         imgcache[comp] = img
         return img
Example #3
0
 def render(self, surf, poss, start, offset, area, player):
     ox, oy = V(0, self.off) + offset
     sx, sy = start
     for v in poss:
         vx, vy = v
         if v in self.utscache and v not in self.recache:
             surf.blit(
                 self.get_img(self.utscache[v])[3],
                 ((vx - sx) * 64 + ox, (vy - sy) * 64 + oy))
         elif self[v]:
             self.regen_uts(v, area)
             surf.blit(
                 self.get_img(self.utscache[v])[3],
                 ((vx - sx) * 64 + ox, (vy - sy) * 64 + oy))
Example #4
0
 def render(self, surf, poss, start, offset, area, player):
     ox, oy = V(0, self.off) + offset
     sx, sy = start
     rendered = set()
     if self.outobjs:
         rendered.update(self.outobjs.values())
         for v in poss:
             vx, vy = v
             if v in self.outobjs:
                 oo = self.outobjs[v]
                 oo.render(self.name, surf,
                           ((vx - sx) * 64 + ox, (vy - sy) * 64 + oy), area,
                           3)
     for v in poss:
         vx, vy = v
         o = self[v]
         if o and o.is_visible(player) and o not in rendered:
             o.render(self.name, surf,
                      ((vx - sx) * 64 + ox, (vy - sy) * 64 + oy), area, 3)
Example #5
0
 def in_warp(self, d):
     hb = self.area.bounds // 2
     return Coordinate(self.area, hb - d * hb - V(bool(d.y), bool(d.x)))
Example #6
0
 def gen_pos(self,area,pos):
     area.set_tile("MetalFloor",pos)
     if (not all(pos) or not pos.within(area.bounds-V(1,1))) and (area.bounds.x//2 in (pos.x-1,pos.x+1) or area.bounds.y//2 in (pos.y-1,pos.y+1)):
         area.spawn_new(Overlays.OneTwo,pos,pos.x-1==area.bounds.x//2 or pos.y-1==area.bounds.y//2)
Example #7
0
 def gen_pos(self,area,pos):
     area.set_tile("MetalFloor",pos)
     if (not all(pos) or not pos.within(area.bounds-V(1,1))) and (pos.x==area.bounds.x//2 or pos.y==area.bounds.y//2):
         area.spawn_new(Overlays.Arrow, pos,3 if pos.x==0 else 0 if pos.y==0 else 1 if pos.x==area.bounds.x-1 else 2)
Example #8
0
 def render(self, layer, surf, tpos, area,scale=3):
     if not self.renderlayer or self.renderlayer==layer:
         surf.blit(self.img[scale],V(*tpos)+self.moveoff+self.exoff if self.mprog or self.exoff else tpos)