Esempio n. 1
0
def do_cave_junk(img):
    sb = STRUCTURE.prefixed('cave_junk') \
            .mesh(meshes.front(1, 1, 1)) \
            .shape(structure.solid(1, 1, 1)) \
            .layer(1)
    for i in range(3):
        sb.new(str(i)).image(img.extract((i, 0)))
Esempio n. 2
0
def do_dungeon_entrance(image):
    sb = STRUCTURE.child() \
            .shape(structure.solid(1, 1, 1)) \
            .mesh(meshes.front(1, 1, 1)) \
            .image(image) \
            .layer(1) \
            .light((16, 16, 16), (96, 48, 48), 50)
    sb.new('dungeon_entrance')
    sb.new('dungeon_exit')
Esempio n. 3
0
def do_pillar(image, kind, desc):
    s = STRUCTURE.new('pillar/' + kind) \
            .shape(structure.solid(1, 1, 2)) \
            .mesh(meshes.solid(1, 1, 2)) \
            .image(image) \
            .layer(1)
    i = ITEM.from_structure(s, name=kind + '_pillar').display_name(desc + ' Pillar')
    r = RECIPE.from_item(i) \
            .station('anvil') \
            .input(kind, 5)
Esempio n. 4
0
def do_sign(image):
    s = STRUCTURE.new('sign') \
            .shape(structure.solid(1, 1, 1)) \
            .mesh(meshes.solid(1, 1, 1)) \
            .image(image) \
            .layer(1)
    i = ITEM.from_structure(s).display_name('Sign')
    r = RECIPE.from_item(i) \
            .station('anvil') \
            .input('wood', 5)
Esempio n. 5
0
def do_teleporter(image):
    s = STRUCTURE.new('teleporter') \
            .shape(structure.solid(1, 1, 1)) \
            .mesh(meshes.front(1, 1, 1)) \
            .image(image) \
            .layer(1) \
            .light((16, 16, 16), (48, 48, 96), 50)
    i = ITEM.from_structure(s).display_name('Teleporter')
    r = RECIPE.from_item(i) \
            .station('anvil') \
            .input('crystal', 50)
Esempio n. 6
0
def do_ward(image):
    s = STRUCTURE.new('ward') \
            .shape(structure.solid(1, 1, 1)) \
            .mesh(meshes.solid(1, 1, 1)) \
            .image(image) \
            .layer(1) \
            .light((16, 16, 32), (48, 48, 96), 50)
    i = ITEM.from_structure(s, extract_offset=(0, 10)).display_name('Ward')
    r = RECIPE.from_item(i) \
            .station('anvil') \
            .input('wood', 10) \
            .input('crystal', 1)
Esempio n. 7
0
def do_wall_parts(basename, image, door_image=None, extra_parts=()):
    parts = (
            'corner/nw',
            'edge/horiz',
            'corner/ne',
            'corner/sw',
            '_/edge/horiz/copy',
            'corner/se',
            'edge/vert',
            'tee/e',
            'tee/w',
            'tee/n',
            'tee/s',
            'cross',
            # Doors are handled separately.
        )

    s = STRUCTURE.prefixed(basename) \
            .shape(solid(1, 1, 2)) \
            .layer(1)

    for j, part_name in enumerate(parts):
        if part_name.startswith('_'):
            continue
        s.new(part_name) \
                .part(models.WALL2[part_name], image.extract((j, 0), size=(1, 3)))

    for j, part_name in enumerate(extra_parts):
        x = len(parts) + (3 if door_image is not None else 0) + j
        s.new(part_name) \
                .part(models.WALL2['edge/horiz'], image.extract((x, 0), size=(1, 3)))

    if door_image is not None:
        doorway_img = image.extract((len(parts), 0), size=(3, 3))
        door_anim = door_image.sheet_to_anim((3, 3), door_image.size[0] // 3 * 4, oneshot=True)

        s.new('door/open').shape(OPEN_DOOR_SHAPE) \
                .part(models.WALL2['door'], door_anim.get_frame(-1)) \
                .part(models.WALL2['door'], doorway_img)
        s.new('door/closed').shape(CLOSED_DOOR_SHAPE) \
                .part(models.WALL2['door'], door_anim.get_frame(0)) \
                .part(models.WALL2['door'], doorway_img)

        s.new('door/opening').shape(CLOSED_DOOR_SHAPE) \
                .part(models.WALL2['door'], door_anim) \
                .part(models.WALL2['door'], doorway_img)
        s.new('door/closing').shape(CLOSED_DOOR_SHAPE) \
                .part(models.WALL2['door'], door_anim.reversed()) \
                .part(models.WALL2['door'], doorway_img)

    return s
Esempio n. 8
0
    def mk_crop(basename, display_name, index, size=(1, 1, 1), count=5):
        sx, sy, sz = size

        s = STRUCTURE.prefixed(basename) \
                .model(models.solid(*size)) \
                .shape(structure.solid(*size)) \
                .layer(1)
        for i in range(count):
            s.new(str(i)) \
                    .image(struct_sheet.extract((i, 2 * index), size=(sx, sy + sz)))

        ITEM.new(basename) \
                .display_name(display_name) \
                .icon(icon_sheet.extract((index, 0)))
Esempio n. 9
0
def do_dungeon_door(basename, img, door_anim):
    sb = STRUCTURE.prefixed(basename) \
            .shape(structure.solid(3, 1, 2)) \
            .layer(1)

    door_model = structure.Model2(meshes.front(3, 1, 2),
            ((0, 1 * TILE_SIZE, 0), (3 * TILE_SIZE, 1 * TILE_SIZE, 2 * TILE_SIZE)))

    sb.new('open') \
            .shape(OPEN_DOOR_SHAPE) \
            .part(door_model, door_anim.get_frame(-1))
    sb.new('closed').part(door_model, door_anim.get_frame(0))
    sb.new('opening').part(door_model, door_anim)
    sb.new('closing').part(door_model, door_anim.reversed())

    # The doorway needs to be drawn over top of the animated door.
    sb.mesh_part(meshes.solid(3, 1, 2), img)
Esempio n. 10
0
def init():
    sheet = load('structures/fence.png', unit=TILE_SIZE)
    parts = sheet.chop(FENCE_PARTS)

    s = STRUCTURE.prefixed('fence') \
            .model(models.front(1, 1, 1)) \
            .shape(structure.solid(1, 1, 1)) \
            .layer(1)
    for k in FENCE_PARTS.keys():
        s.new(k).image(parts[k])

    r = RECIPE.prefixed('fence') \
            .station('anvil') \
            .input('wood', 5)
    for (name, display_name, struct_name) in FENCE_ITEMS:
        i = ITEM.from_structure(s[struct_name], name=name).display_name(display_name)
        r.from_item(i)
Esempio n. 11
0
def init():
    sheet = load('structures/fence.png', unit=TILE_SIZE)
    parts = sheet.chop(FENCE_PARTS)

    s = STRUCTURE.prefixed('fence') \
            .mesh(meshes.front(1, 1, 1)) \
            .shape(structure.solid(1, 1, 1)) \
            .layer(1)
    for k in FENCE_PARTS.keys():
        s.new(k).image(parts[k])

    s_open = s.child().shape(structure.empty(1, 1, 1))
    s_open.new('gate/open').image(Image(size=(1, 2), unit=TILE_SIZE))
    s_open.new('gate/opening').image(Image(size=(1, 2), unit=TILE_SIZE))
    s_open.new('gate/closing').image(Image(size=(1, 2), unit=TILE_SIZE))

    r = RECIPE.prefixed('fence') \
            .station('anvil') \
            .input('wood', 5)
    for (name, display_name, struct_name) in FENCE_ITEMS:
        i = ITEM.from_structure(s[struct_name], name=name).display_name(display_name)
        r.from_item(i)
Esempio n. 12
0
from outpost_data.core import image2, geom, util
from outpost_data.core.builder2.base import *
from outpost_data.core.consts import *
from outpost_data.core.structure import solid, StructureDef, StructureDef2, StaticAnimDef


DEFAULT_SHAPE = solid(1, 1, 1)

class StructurePrototype(PrototypeBase):
    KIND = 'structure'
    FIELDS = (
            'image', 'model', 'shape', 'layer', 'parts',
            'light_offset', 'light_color', 'light_radius',
            'anim_frames', 'anim_framerate', 'anim_oneshot',
            )

    def instantiate(self):
        self.name = self.require('name') or '_%x' % id(self)

        shape = self.require('shape', DEFAULT_SHAPE)
        layer = self.require('layer', 0)

        if self.require_one('model', 'parts'):
            if self.require_one('image', 'anim_frames'):
                img = raw_image(self.image)
            else:
                frames = self.anim_frames
                rate = self.require('anim_framerate', default=1, reason='anim_frames')
                oneshot = self.anim_oneshot or False

                img = StaticAnimDef(self.anim_frames, self.anim_framerate, self.anim_oneshot)
Esempio n. 13
0
from outpost_data.core import image2
from outpost_data.core.builder2.base import *
from outpost_data.core.consts import *
from outpost_data.core.structure import solid, StructureDef, StaticAnimDef

DEFAULT_SHAPE = solid(1, 1, 1)


class StructurePrototype(PrototypeBase):
    KIND = 'structure'
    FIELDS = (
        'image',
        'model',
        'shape',
        'layer',
        'light_offset',
        'light_color',
        'light_radius',
        'anim_frames',
        'anim_framerate',
        'anim_oneshot',
    )

    def instantiate(self):
        self.name = self.require('name') or '_%x' % id(self)

        if self.require_one('image', 'anim_frames'):
            img = raw_image(self.image)
        else:
            frames = self.anim_frames
            rate = self.require('anim_framerate',