def info_operation(self, op):
        print("Aframe info")
        aframe = server.world.get_object(op[0].id)
        self.lcount = 0

        raw_materials = []
        for item in self.character.contains:
            if item.type[0] == str(self.materials):
                raw_materials.append(item)
                self.lcount = self.lcount + 1
            if self.lcount == 3:
                break
        else:
            print("No materials in inventory for A frame")
            self.irrelevant()
            return

        chunk_loc = Location(aframe())
        chunk_loc.position = Point3D([0, 0, 0])

        count = self.lcount
        res = Oplist()
        # loops through raw_materials and places 3 lumber
        # in inventory infront of user
        offset = Vector3D(0, 0, 0)
        while (count > 0):
            tar = raw_materials.pop()
            # length of the lumber obtained
            lumberlength = tar.location.bbox.high_corner[2] - \
                           tar.location.bbox.low_corner[2]
            lumberheight = tar.location.bbox.high_corner[1] - \
                           tar.location.bbox.low_corner[1]
            # rough length to position lumber
            lumber_length = lumberlength / 4

            if count == 3:
                # left component
                chunk_loc.orientation = Quaternion([.653, 0.27, .27, .653])
            if count == 2:
                # right component
                chunk_loc.orientation = Quaternion([.653, -0.27, -.27, .653])
                offset = Vector3D(lumber_length, 0, 0)
                chunk_loc.position = chunk_loc.position + offset
            if count == 1:
                # bottom component
                chunk_loc.position = Point3D([0, 0, 0])  # self.pos
                # .707 is sin(.5) which is needed for a 90 degree rotation
                chunk_loc.orientation = Quaternion([.707, 0, .707, 0])
                offset = Vector3D(-(1.5 * lumber_length), 0, (2.5 * lumber_length))
                chunk_loc.position = chunk_loc.position + offset

            move = Operation("move", Entity(tar.id, location=chunk_loc,
                                            mode="fixed"), to=tar)
            res.append(move)
            count = count - 1

        self.progress = 1
        self.irrelevant()
        return res
Esempio n. 2
0
    def _create_initial_mod(self):
        print("no existing mod")
        y = self.character.location.position.y + 1.0
        modmap = {'height': y,
                  'shape': Polygon([[-0.7, -0.7],
                                    [-1.0, 0.0],
                                    [-0.7, 0.7],
                                    [0.0, 1.0],
                                    [0.7, 0.7],
                                    [1.0, 0.0],
                                    [0.7, -0.7],
                                    [0.0, -1.0]]).as_data(),
                  'type': 'levelmod'}
        area_map = {'shape': modmap['shape'],
                    'layer': 7}

        mod_loc = Location(self.character.location.parent)
        mod_loc.velocity = Vector3D()
        mod_loc.position = self.pos

        mod_create = Operation("create",
                               Entity(name="motte",
                                      type="path",
                                      location=mod_loc,
                                      terrainmod=modmap,
                                      area=area_map),
                               to=self.target())
        res = Oplist()
        res.append(mod_create)
        res.append(self.next_tick(0.75))
        return res
Esempio n. 3
0
    def _create_initial_mod(self):
        y = self.character.location.position.y + 1.0
        mod_path = Line([[self.pos.x, self.pos.z]])
        modmap = {
            'height': y,
            'shape': {
                'points': [[-1.0, -1.0], [-1.0, 1.0], [1.0, 1.0], [1.0, -1.0]],
                'type': 'polygon'
            },
            'type': 'levelmod'
        }
        area_map = {'shape': modmap['shape'], 'layer': 7}
        line_map = mod_path.as_data()

        mod_loc = Location(self.character.location.parent)
        mod_loc.velocity = Vector3D()
        mod_loc.position = self.pos

        mod_create = Operation("create",
                               Entity(name="wall",
                                      type="path",
                                      line=line_map,
                                      location=mod_loc,
                                      terrainmod=modmap,
                                      area=area_map),
                               to=self.target())
        res = Oplist()
        res.append(mod_create)
        res.append(self.next_tick(0.75))
        return res
    def tick_operation(self, op):
        """ Op handler for regular tick op """
        target = self.target()
        if not target:
            # print "Target is no more"
            self.irrelevant()
            return

        self.rate = 0.5 / 0.75
        self.progress += 1

        if not target:
            print("Target is no more")
            self.irrelevant()
            return

        if self.progress < 1:
            # print "Not done yet"
            return self.next_tick(1.75)

        self.progress = 0

        chunk_loc = Location(self.character.location.parent)
        chunk_loc.position = self.pos
        lumberh = 0  # lumberheight
        lumberl = 0  # lumberlength
        res = Oplist()
        lcount = 0
        # makes sure we have 3 lumber to construct A frame
        for item in self.character.contains:
            if item.type[0] == str(self.materials):
                lcount = lcount + 1
                lumberl = item.location.bbox.high_corner[2] - \
                          item.location.bbox.low_corner[2]
                lumberh = item.location.bbox.high_corner[1] - \
                          item.location.bbox.low_corner[1]

            if lcount == 3:
                break
        else:
            print("No materials in inventory for A frame")
            self.irrelevant()
            return

        bbox1 = [
            -lumberl / 2, -lumberl / 2, -lumberh / 2, lumberl / 2, lumberl / 2,
            lumberh / 2
        ]
        # bbox of a frame
        create = Operation("create",
                           Entity(name="A_Frame",
                                  type="construction",
                                  bbox=bbox1,
                                  location=chunk_loc),
                           to=target)
        create.set_serialno(0)
        res.append(create)
        res.append(self.next_tick(1.75))
        return res
Esempio n. 5
0
    def sow_operation(self, op):
        """ Op handler for sow op which activates this task """

        if len(op) < 1:
            sys.stderr.write("Fish task has no target in sow op")

        # FIXME Use weak references, once we have them
        self.target = server.world.get_object(op[0].id)
        self.tool = op.to

        self.pos = Point3D(op[0].pos)

        # self.character.contains is a list of entities inside the player's inventory

        bait = 0

        for item in self.character.contains:
            if item.type[0] in self.baitlist:
                bait = item
                # self.character.contains.remove(item)
                break
        else:
            print("No bait in inventory")
            self.irrelevant()
            return

        if "ocean" not in self.target().type:
            print("Can fish only in the ocean")
            self.irrelevant()
            return

        self.bait = weakref.ref(bait)
        self.progress = 0.5

        res = Oplist()

        float_loc = Location(self.character.location.parent)
        # This is <server.Entity object at 0xb161b90>

        float_loc.position = self.pos

        bait_vector = Vector3D(0, -0.5, -0)
        bait_loc = float_loc.copy()
        bait_loc.position = bait_loc.position + bait_vector

        res = Operation("create",
                        Entity(name="bobber",
                               parent="bobber",
                               location=float_loc),
                        to=self.target())
        res = res + Operation(
            "move", Entity(bait.id, location=bait_loc), to=bait)
        res = res + Operation("create",
                              Entity(parent="fishing_hook",
                                     location=Location(bait, Point3D(0, 0,
                                                                     0))),
                              to=bait)
        return res
Esempio n. 6
0
    def tick_operation(self, op):

        """ Op handler for regular tick op """
        target = self.target()
        if not target:
            # print "Target is no more"
            self.irrelevant()
            return

        self.rate = 0.5 / 0.75
        self.progress += 1

        if not target:
            print("Target is no more")
            self.irrelevant()
            return

        lcount = 0  # Lumber count
        acount = 0  # A frame count
        self.gname = ""  # Gate name
        # makes sure we have 3 lumber to construct A frame
        for item in self.character.contains:
            if item.type[0] == "lumber":
                lcount = lcount + 1
            if item.type[0] == "construction":
                acount = acount + 1
            if lcount == 3:
                self.gname = "House_Gate"
                break
            if acount == 2 and lcount == 1:
                self.gname = "Basic_Gate"
                break
        else:
            print("No materials in inventory for a Gate")
            self.irrelevant()

        if self.progress < 1:
            # print "Not done yet"
            return self.next_tick(0.75)

        self.progress = 0

        chunk_loc = Location(self.character.location.parent)
        chunk_loc.position = self.pos
        chunk_loc.orientation = self.character.location.orientation
        res = Oplist()
        bbox1 = [-4, -4, -.01, 4, 4, .01]  # Needed so it can be viewed from afar
        create = Operation("create", Entity(name=self.gname,
                                            type="construction",
                                            bbox=bbox1,
                                            location=chunk_loc),
                           to=target)
        create.set_serialno(0)
        res.append(create)
        res.append(self.next_tick(1.75))
        return res
    def tick_operation(self, op):

        """ Op handler for regular tick op """
        target = self.target()
        if not target:
            # print "Target is no more"
            self.irrelevant()
            return

        self.rate = 0.5 / 0.75
        self.progress += 1

        if not target:
            print("Target is no more")
            self.irrelevant()
            return

        if self.progress < 1:
            # print "Not done yet"
            return self.next_tick(1.75)

        self.progress = 0

        chunk_loc = Location(self.character.location.parent)
        chunk_loc.position = self.pos
        lumberh = 0  # lumberheight
        lumberl = 0  # lumberlength
        res = Oplist()
        lcount = 0
        # makes sure we have 3 lumber to construct A frame
        for item in self.character.contains:
            if item.type[0] == str(self.materials):
                lcount = lcount + 1
                lumberl = item.location.bbox.high_corner[2] - \
                          item.location.bbox.low_corner[2]
                lumberh = item.location.bbox.high_corner[1] - \
                          item.location.bbox.low_corner[1]

            if lcount == 3:
                break
        else:
            print("No materials in inventory for A frame")
            self.irrelevant()
            return

        bbox1 = [-lumberl / 2, -lumberl / 2, -lumberh / 2, lumberl / 2, lumberl / 2, lumberh / 2]
        # bbox of a frame
        create = Operation("create", Entity(name="A_Frame",
                                            type="construction",
                                            bbox=bbox1, location=chunk_loc),
                           to=target)
        create.set_serialno(0)
        res.append(create)
        res.append(self.next_tick(1.75))
        return res
Esempio n. 8
0
    def tick_operation(self, op):
        """ Op handler for regular tick op """
        # print "Dig.tick"
        if self.target() is None:
            print("Target is no more")
            self.irrelevant()
            return

        world = self.target().location.parent

        material = self.target().props.name
        # print material

        if material not in Sift.materials:
            print("Not right material for earthworms")
            self.irrelevant()
            return

        old_rate = self.rate

        self.rate = 0.1 / 1.75
        self.progress += 0.1

        if old_rate < 0.01:
            self.progress = 0

        # print "%s" % self.pos

        if self.progress < 1:
            # print "Not done yet"
            return self.next_tick(1.75)

        self.progress = 0

        res = Oplist()

        self_loc = Location(self.character)
        self_loc.velocity = Vector3D()
        if hasattr(world, 'moisture'):
            moisture = 10 * world.moisture
        else:
            moisture = 1
        self_loc.position = self.pos

        quality = int(self.get_quality(self_loc.position, self.target(), moisture))
        print(quality)
        for i in range(int(quality / 2), quality):
            res = res + Operation("create", Entity(name="scrawny earthworm", parent="annelid", location=self_loc), to=self.character)
        for i in range(int((10 - quality) / 2), quality):
            res = res + Operation("create", Entity(name="juicy earthworm", parent="annelid", location=self_loc), to=self.character)

        self.irrelevant()
        return res
Esempio n. 9
0
    def tick_operation(self, op):
        """ Op handler for regular tick op """
        # print "Dig.tick"

        if self.target() is None:
            # print "Target is no more"
            self.irrelevant()
            return

        old_rate = self.rate

        self.rate = 0.1 / 1.75
        self.progress += 0.1

        if old_rate < 0.01:
            self.progress = 0

        # print "%s" % self.pos

        if self.progress < 1:
            # print "Not done yet"
            return self.next_tick(1.75)

        self.progress = 0

        surface = self.target().props.terrain.get_surface(self.pos)
        # print "SURFACE %d at %s" % (surface, self.pos)
        if surface not in Dig.materials:
            print("Not right")
            self.irrelevant()
            return

        res = Oplist()

        chunk_loc = Location(self.character.location.parent)
        chunk_loc.velocity = Vector3D()

        chunk_loc.position = self.pos

        create = Operation("create",
                           Entity(name=Dig.materials[surface],
                                  type="pile",
                                  material=Dig.materials[surface],
                                  location=chunk_loc),
                           to=self.target())
        create.set_serialno(0)
        res.append(create)

        res.append(self.next_tick(1.75))

        return res
Esempio n. 10
0
    def tick_operation(self, op):
        """ Op handler for regular tick op """
        # print "Reap.tick"

        if self.target() is None:
            # print "Target is no more"
            self.irrelevant()
            return

        if self.count == 0:
            self.count = int(self.target().props.mass)
            # print "setting target mass to ", self.count

        if not self.character.location.velocity.is_valid() or \
            self.character.location.velocity.sqr_mag() < 1 or \
            self.character.location.velocity.sqr_mag() > 10:
            self.rate = 0
            self.progress = 0
            # print "Not moving the right speed"
            return self.next_tick(1.75)

        old_rate = self.rate

        self.rate = 1.0 / 1.75
        self.progress = 0.01

        if old_rate < 0.1:
            # print "Wasn't moving right speed"
            return self.next_tick(1.75)

        surface = self.target().props.terrain.get_surface(self.character.location.position)
        if surface is not 2:
            # print "Not grass"
            return self.next_tick(1.75)

        res = Oplist()

        chunk_loc = Location(self.character.location.parent)
        chunk_loc.velocity = Vector3D()

        chunk_loc.position = self.character.location.position

        create = Operation("create",
                           Entity(name="grass",
                                  type="grass",
                                  location=chunk_loc), to=self.target())
        res.append(create)

        res.append(self.next_tick(1.75))

        return res
Esempio n. 11
0
    def tick_operation(self, op):
        """ Op handler for regular tick op """
        # print "Dig.tick"

        if self.target() is None:
            # print "Target is no more"
            self.irrelevant()
            return

        old_rate = self.rate

        self.rate = 0.1 / 1.75
        self.progress += 0.1

        if old_rate < 0.01:
            self.progress = 0

        # print "%s" % self.pos

        if self.progress < 1:
            # print "Not done yet"
            return self.next_tick(1.75)

        self.progress = 0

        surface = self.target().props.terrain.get_surface(self.pos)
        # print "SURFACE %d at %s" % (surface, self.pos)
        if surface not in Dig.materials:
            print("Not right")
            self.irrelevant()
            return

        res = Oplist()

        chunk_loc = Location(self.character.location.parent)
        chunk_loc.velocity = Vector3D()

        chunk_loc.position = self.pos

        create = Operation("create",
                           Entity(name=Dig.materials[surface],
                                  type="pile",
                                  material=Dig.materials[surface],
                                  location=chunk_loc), to=self.target())
        create.set_serialno(0)
        res.append(create)

        res.append(self.next_tick(1.75))

        return res
Esempio n. 12
0
    def tick_operation(self, op):
        """ Op handler for regular tick op """
        # print "Dragging.tick"
        self.pos = self.character.location.position
        if self.target() is None:
            # print "Target is no more"
            self.irrelevant()
            return

        if not self.target().location.parent:
            # Make sure the user dosen't use dragging on the world entity..
            self.irrelevant()
            return

        old_rate = self.rate

        self.rate = 0.5 / 0.75
        self.progress += 0.5

        if old_rate < 0.01:
            self.progress = 0

        # print "%s" % self.pos

        if self.progress < 1:
            # print "Not done yet"
            return self.next_tick(0.75)

        self.progress = 0

        res = Oplist()

        chunk_loc = Location(self.character.location.parent)
        chunk_loc.velocity = Vector3D()

        chunk_loc.position = self.pos
        # Move the entity to user's position.
        res = res + Operation("move", Entity(self.target().id,
                                             location=chunk_loc), to=self.target())
        res.append(self.next_tick(0.75))

        return res
Esempio n. 13
0
    def tick_operation(self, op):
        """ Op handler for regular tick op """
        # print "Dig.tick"
        if self.target() is None:
            print("Target is no more")
            self.irrelevant()
            return

        world = self.target().location.parent

        material = self.target().props.name
        # print material

        if material not in Sift.materials:
            print("Not right material for earthworms")
            self.irrelevant()
            return

        old_rate = self.rate

        self.rate = 0.1 / 1.75
        self.progress += 0.1

        if old_rate < 0.01:
            self.progress = 0

        # print "%s" % self.pos

        if self.progress < 1:
            # print "Not done yet"
            return self.next_tick(1.75)

        self.progress = 0

        res = Oplist()

        self_loc = Location(self.character)
        self_loc.velocity = Vector3D()
        if hasattr(world, 'moisture'):
            moisture = 10 * world.moisture
        else:
            moisture = 1
        self_loc.position = self.pos

        quality = int(
            self.get_quality(self_loc.position, self.target(), moisture))
        print(quality)
        for i in range(int(quality / 2), quality):
            res = res + Operation("create",
                                  Entity(name="scrawny earthworm",
                                         parent="annelid",
                                         location=self_loc),
                                  to=self.character)
        for i in range(int((10 - quality) / 2), quality):
            res = res + Operation("create",
                                  Entity(name="juicy earthworm",
                                         parent="annelid",
                                         location=self_loc),
                                  to=self.character)

        self.irrelevant()
        return res
Esempio n. 14
0
    def tick_operation(self, op):
        """ Op handler for regular tick op """
        # print "Trenching.tick"

        target = self.target()
        if not target:
            # print "Target is no more"
            self.irrelevant()
            return

        # FIXME We are overriding the position specified above?
        self.pos = self.character.location.position

        old_rate = self.rate
        self.rate = 0.5 / 0.75
        self.progress += 0.5

        if old_rate < 0.01:
            self.progress = 0

        # print "%s" % self.pos

        if self.progress < 1:
            # print "Not done yet"
            return self.next_tick(0.75)

        self.progress = 0

        res = Oplist()

        chunk_loc = Location(self.character.location.parent)
        chunk_loc.velocity = Vector3D()

        chunk_loc.position = self.pos

        if not hasattr(self, 'terrain_mod'):
            mods = target.terrain.find_mods(self.pos)
            if len(mods) == 0:
                # There is no terrain mod where we are digging,
                # so we check if it is in the materials , and if so create
                # a trench
                surface = target.terrain.get_surface(self.pos)
                # print "SURFACE %d at %s" % (surface, self.pos)
                if surface not in Trenching.materials:
                    # print "Not in material"
                    self.irrelevant()
                    return
                self.surface = surface

                y = self.character.location.position.y - 1.0
                modmap = {
                    'height': y,
                    'shape': {
                        'points': [[-1.0, -1.0], [-1.0, 1.0], [1.0, 1.0],
                                   [1.0, -1.0]],
                        'type':
                        'polygon'
                    },
                    'type': 'levelmod'
                }
                trenches_create = Operation("create",
                                            Entity(name="trenches",
                                                   type="path",
                                                   location=chunk_loc,
                                                   terrainmod=modmap),
                                            to=target)
                res.append(trenches_create)
            else:
                for mod in mods:
                    if not hasattr(mod, 'name') or mod.name != 'trenches':
                        # print "%s is no good" % mod.id
                        continue
                    # print "%s looks good" % mod.id
                    mod.terrainmod.height -= 1.0
                    # We have modified the attribute in place, so must send an update op to propagate
                    res.append(Operation("update", to=mod.id))
                    break
            # self.terrain_mod = "moddy_mod_mod"

        create = Operation("create",
                           Entity(name=Trenching.materials[self.surface],
                                  type="pile",
                                  material=Trenching.materials[self.surface],
                                  location=chunk_loc),
                           to=target)
        res.append(create)

        res.append(self.next_tick(0.75))

        return res
Esempio n. 15
0
    def tick_operation(self, op):
        """ Op handler for regular tick op """
        # print "Delve.tick"

        if self.target() is None:
            # print "Target is no more"
            self.irrelevant()
            return

        old_rate = self.rate

        self.rate = 0.5 / 0.75
        self.progress += 0.5

        if old_rate < 0.01:
            self.progress = 0

        # print "%s" % self.pos

        if self.progress < 1:
            # print "Not done yet"
            return self.next_tick(0.75)

        self.progress = 0

        res = Oplist()

        chunk_loc = Location(self.character.location.parent)
        chunk_loc.velocity = Vector3D()

        chunk_loc.position = self.pos

        if not hasattr(self, 'terrain_mod'):
            mods = self.target().props.terrain.find_mods(self.pos)
            if len(mods) == 0:
                # There is no terrain mod where we are digging,
                # so we check if it is rock, and if so create
                # a quarry
                surface = self.target().props.terrain.get_surface(self.pos)
                # print "SURFACE %d at %s" % (surface, self.pos)
                if surface not in Delve.materials:
                    print("Not rock")
                    self.irrelevant()
                    return
                self.surface = surface

                y = self.character.location.position.y + 1.0
                modmap = {
                    'height': y,
                    'shape': {
                        'points': [[-1.0, -1.0],
                                   [-1.0, 1.0],
                                   [1.0, 1.0],
                                   [1.0, -1.0]],
                        'type': 'polygon'
                    },
                    'type': 'levelmod'
                }
                quarry_create = Operation("create",
                                          Entity(name="quarry",
                                                 type="path",
                                                 location=chunk_loc,
                                                 terrainmod=modmap),
                                          to=self.target())
                res.append(quarry_create)
            else:
                print(mods)
                for mod in mods:
                    if not hasattr(mod, 'name') or mod.name != 'quarry':
                        print("%s is no good" % mod.id)
                        continue
                    print("%s looks good" % mod.id)
                    print(mod.terrainmod)
                    mod.terrainmod.height -= 2.0
                    # We have modified the attribute in place, so must send an update op to propagate
                    res.append(Operation("update", to=mod.id))
                    break
            # self.terrain_mod = "moddy_mod_mod"

        create = Operation("create",
                           Entity(name=Delve.materials[self.surface],
                                  type=Delve.materials[self.surface],
                                  location=chunk_loc), to=self.target())
        res.append(create)

        res.append(self.next_tick(0.75))

        return res
Esempio n. 16
0
    def tick_operation(self, op):

        """ Op handler for regular tick op """
        target = self.target()
        if not target:
            # print "Target is no more"
            self.irrelevant()
            return

        self.rate = 0.5 / 0.75
        self.progress += 1

        if not target:
            print("Target is no more")
            self.irrelevant()
            return

        if self.progress < 1:
            # print "Not done yet"
            return self.next_tick(0.75)

        self.progress = 0

        chunk_loc = Location(self.character.location.parent)
        chunk_loc.position = self.pos

        chunk_loc.orientation = self.character.location.orientation
        res = Oplist()
        acount = 0  # A frame count
        lcount = 0  # lumber count
        wcount = 0  # wood count
        ccount = 0  # campfire count
        bcount = 0  # boulder count
        self.fname = ""  # furnishing name
        lumberwidth = 0
        # makes sure we have the right amount of material
        for item in self.character.contains:
            if item.type[0] == "lumber":
                lcount = lcount + 1
                lumberwidth = item.location.bbox.high_corner[2] - item.location.bbox.low_corner[2]
            if item.type[0] == "wood":
                wcount = wcount + 1
            if item.type[0] == "campfire":
                ccount = ccount + 1
            if item.type[0] == "boulder":
                bcount = bcount + 1
            if item.type[0] == "construction":
                acount = acount + 1

        print(str(lcount))
        print(str(wcount))
        if lcount == 1 and wcount == 3:
            self.fname = "Table"
        elif lcount == 4 and wcount == 2:
            self.fname = "Chair"
        elif lcount == 0 and wcount == 5:
            self.fname = "Floor"
        elif lcount == 0 and wcount == 4:
            self.fname = "Siding"
        elif ccount == 1 and bcount == 4:
            self.fname = "Fireplace"
        elif lcount == 3 and wcount == 5:
            self.fname = "Roof"
        elif wcount == 0 and lcount == 5:
            self.fname = "Wallframe"
        else:
            print("No materials in inventory for Furnishings 1")
            self.irrelevant()
            return

        bbox1 = [-1, -1, -1, 1, 1, 1]  # cube bbox so the ojects can be viewed from afar.  Relatively close fit
        if (self.fname == "Floor"):  # If floor make different bbox which is thing so it can be walked over
            bbox1 = [-2, -2, -.01, 2, 2, .01]
        if (self.fname == "Wallframe"):  # If wall frame make bbox based upon the 2 aframes used
            bbox1 = [-lumberwidth, -.5, -lumberwidth, 0, .5, lumberwidth]
        if (self.fname == "Siding"):
            bbox1 = [-3, -.1, -3, 3, .1, 3]
        create = Operation("create", Entity(name=self.fname, type="construction", bbox=bbox1, location=chunk_loc), to=target)
        create.set_serialno(0)
        res.append(create)
        res.append(self.next_tick(1.75))
        return res
Esempio n. 17
0
    def tick_operation(self, op):
        """ Op handler for regular tick op """
        # print "Trenching.tick"

        target = self.target()
        if not target:
            # print "Target is no more"
            self.irrelevant()
            return

        # FIXME We are overriding the position specified above?
        self.pos = self.character.location.position

        old_rate = self.rate
        self.rate = 0.5 / 0.75
        self.progress += 0.5

        if old_rate < 0.01:
            self.progress = 0

        # print "%s" % self.pos

        if self.progress < 1:
            # print "Not done yet"
            return self.next_tick(0.75)

        self.progress = 0

        res = Oplist()

        chunk_loc = Location(self.character.location.parent)
        chunk_loc.velocity = Vector3D()

        chunk_loc.position = self.pos

        if not hasattr(self, 'terrain_mod'):
            mods = target.terrain.find_mods(self.pos)
            if len(mods) == 0:
                # There is no terrain mod where we are digging,
                # so we check if it is in the materials , and if so create
                # a trench
                surface = target.terrain.get_surface(self.pos)
                # print "SURFACE %d at %s" % (surface, self.pos)
                if surface not in Trenching.materials:
                    # print "Not in material"
                    self.irrelevant()
                    return
                self.surface = surface

                y = self.character.location.position.y - 1.0
                modmap = {
                    'height': y,
                    'shape': {
                        'points': [[-1.0, -1.0],
                                   [-1.0, 1.0],
                                   [1.0, 1.0],
                                   [1.0, -1.0]],
                        'type': 'polygon'
                    },
                    'type': 'levelmod'
                }
                trenches_create = Operation("create",
                                            Entity(name="trenches",
                                                   type="path",
                                                   location=chunk_loc,
                                                   terrainmod=modmap),
                                            to=target)
                res.append(trenches_create)
            else:
                for mod in mods:
                    if not hasattr(mod, 'name') or mod.name != 'trenches':
                        # print "%s is no good" % mod.id
                        continue
                    # print "%s looks good" % mod.id
                    mod.terrainmod.height -= 1.0
                    # We have modified the attribute in place, so must send an update op to propagate
                    res.append(Operation("update", to=mod.id))
                    break
            # self.terrain_mod = "moddy_mod_mod"

        create = Operation("create",
                           Entity(name=Trenching.materials[self.surface],
                                  type="pile",
                                  material=Trenching.materials[self.surface],
                                  location=chunk_loc), to=target)
        res.append(create)

        res.append(self.next_tick(0.75))

        return res
Esempio n. 18
0
    def tick_operation(self, op):
        """ Op handler for regular tick op """
        target = self.target()
        if not target:
            # print "Target is no more"
            self.irrelevant()
            return

        self.rate = 0.5 / 0.75
        self.progress += 1

        if not target:
            print("Target is no more")
            self.irrelevant()
            return

        if self.progress < 1:
            # print "Not done yet"
            return self.next_tick(0.75)

        self.progress = 0

        chunk_loc = Location(self.character.location.parent)
        chunk_loc.position = self.pos

        chunk_loc.orientation = self.character.location.orientation
        res = Oplist()
        acount = 0  # A frame count
        lcount = 0  # lumber count
        wcount = 0  # wood count
        ccount = 0  # campfire count
        bcount = 0  # boulder count
        self.fname = ""  # furnishing name
        lumberwidth = 0
        # makes sure we have the right amount of material
        for item in self.character.contains:
            if item.type[0] == "lumber":
                lcount = lcount + 1
                lumberwidth = item.location.bbox.high_corner[
                    2] - item.location.bbox.low_corner[2]
            if item.type[0] == "wood":
                wcount = wcount + 1
            if item.type[0] == "campfire":
                ccount = ccount + 1
            if item.type[0] == "boulder":
                bcount = bcount + 1
            if item.type[0] == "construction":
                acount = acount + 1

        print(str(lcount))
        print(str(wcount))
        if lcount == 1 and wcount == 3:
            self.fname = "Table"
        elif lcount == 4 and wcount == 2:
            self.fname = "Chair"
        elif lcount == 0 and wcount == 5:
            self.fname = "Floor"
        elif lcount == 0 and wcount == 4:
            self.fname = "Siding"
        elif ccount == 1 and bcount == 4:
            self.fname = "Fireplace"
        elif lcount == 3 and wcount == 5:
            self.fname = "Roof"
        elif wcount == 0 and lcount == 5:
            self.fname = "Wallframe"
        else:
            print("No materials in inventory for Furnishings 1")
            self.irrelevant()
            return

        bbox1 = [
            -1, -1, -1, 1, 1, 1
        ]  # cube bbox so the ojects can be viewed from afar.  Relatively close fit
        if (
                self.fname == "Floor"
        ):  # If floor make different bbox which is thing so it can be walked over
            bbox1 = [-2, -2, -.01, 2, 2, .01]
        if (self.fname == "Wallframe"
            ):  # If wall frame make bbox based upon the 2 aframes used
            bbox1 = [-lumberwidth, -.5, -lumberwidth, 0, .5, lumberwidth]
        if (self.fname == "Siding"):
            bbox1 = [-3, -.1, -3, 3, .1, 3]
        create = Operation("create",
                           Entity(name=self.fname,
                                  type="construction",
                                  bbox=bbox1,
                                  location=chunk_loc),
                           to=target)
        create.set_serialno(0)
        res.append(create)
        res.append(self.next_tick(1.75))
        return res
Esempio n. 19
0
    def info_operation(self, op):
        print("Furnishings info")
        item = server.world.get_object(op[0].id)
        chunk_loc = Location(item())
        chunk_loc.position = Point3D([0, 0, 0])
        res = Oplist()
        target = self.target()
        raw_materials = []
        raw_materials1 = []  # holders campfire
        raw_materials2 = []  # temp holder for aframes to be moved
        acount = 0  # A frame count
        lcount = 0  # Lumber count
        wcount = 0  # Wood count
        bcount = 0  # Boulder count
        ccount = 0  # Campfire count
        for item in self.character.contains:
            if item.type[0] == "lumber":
                raw_materials.append(item)
                lcount = lcount + 1
            if item.type[0] == "wood":
                raw_materials.append(item)
                wcount = wcount + 1
            if item.type[0] == "campfire":
                raw_materials1.append(item)
                ccount = ccount + 1
            if item.type[0] == "boulder":
                raw_materials.append(item)
                bcount = bcount + 1
            if item.type[0] == "construction":
                raw_materials2.append(item)
                acount = acount + 1

        count = lcount + wcount + bcount
        if self.fname == "Table":
            # Making table
            while (count > 0):
                tar = raw_materials.pop()
                set = Operation("set", Entity(tar.id, status=-1), to=tar)
                res.append(set)
                count = count - 1
            # create the table
            # Table base
            lbbox = [-.2, -.2, -.5, .2, .2, .5]  # local bbox
            create = Operation("create", Entity(name="lumber", type="lumber", location=chunk_loc, bbox=lbbox, mode="fixed"), to=target)
            res.append(create)
            # create the table top
            offset = Vector3D(0, 1, 0)
            chunk_loc.position = chunk_loc.position + offset
            lbbox = [-.7, -.7, -.1, .7, .7, .1]
            create = Operation("create", Entity(name="wood", type="wood", location=chunk_loc, bbox=lbbox, mode="fixed"), to=target)
            res.append(create)
        if self.fname == "Chair":
            # Making chair
            while (count > 0):
                tar = raw_materials.pop()
                set = Operation("set", Entity(tar.id, status=-1), to=tar)
                res.append(set)
                count = count - 1
            # create the legs
            # leg 1
            chunk_loc.position = Point3D([0, 0, 0])
            offset = Vector3D(.2, 0, -.2)
            chunk_loc.position = chunk_loc.position + offset
            create = Operation("create", Entity(name="lumber", type="lumber", location=chunk_loc, mode="fixed"), to=target)
            res.append(create)

            # leg 2
            chunk_loc.position = Point3D([0, 0, 0])
            offset = Vector3D(-.2, 0, -.2)
            chunk_loc.position = chunk_loc.position + offset
            create = Operation("create", Entity(name="lumber", type="lumber", location=chunk_loc, mode="fixed"), to=target)
            res.append(create)

            # leg 3
            chunk_loc.position = Point3D([0, 0, 0])
            offset = Vector3D(-.2, 0, .2)
            chunk_loc.position = chunk_loc.position + offset
            create = Operation("create", Entity(name="lumber", type="lumber", location=chunk_loc, mode="fixed"), to=target)
            res.append(create)

            # leg 4
            chunk_loc.position = Point3D([0, 0, 0])
            offset = Vector3D(.2, 0, .2)
            chunk_loc.position = chunk_loc.position + offset
            create = Operation("create", Entity(name="lumber", type="lumber", location=chunk_loc, mode="fixed"), to=target)
            res.append(create)

            # create the seat
            chunk_loc.position = Point3D([0, 0, 0])
            offset = Vector3D(0, .5, 0)
            lbbox = [-.3, -.3, -.1, .3, .3, .1]  # Local bbox
            chunk_loc.position = chunk_loc.position + offset
            create = Operation("create", Entity(name="wood", type="wood", location=chunk_loc, bbox=lbbox, mode="fixed"), to=target)
            res.append(create)

            # create the back of the seat
            chunk_loc.position = Point3D([0, 0, 0])
            offset = Vector3D(-.3, .75, 0)
            lbbox = [-.1, -.3, -.4, .1, .3, .4]  # local bbox
            chunk_loc.position = chunk_loc.position + offset
            create = Operation("create", Entity(name="wood", type="wood", location=chunk_loc, bbox=lbbox, mode="fixed"), to=target)
            res.append(create)

        if self.fname == "Floor":
            # Making Floor
            while (count > 0):
                tar = raw_materials.pop()
                set = Operation("set", Entity(tar.id, status=-1), to=tar)
                res.append(set)
                count = count - 1
            # create the Floor, it is one large wood
            lbbox = [-2, -2, -.1, 2, 2, .1]  # local bbox
            create = Operation("create", Entity(name="wood", type="wood", location=chunk_loc, bbox=lbbox, mode="fixed"), to=target)
            res.append(create)
        if self.fname == "Siding":
            # Making wooden siding with window
            while (count > 0):
                tar = raw_materials.pop()
                set = Operation("set", Entity(tar.id, status=-1), to=tar)
                res.append(set)
                count = count - 1
            # Siding is made of 4 components so it looks like we have a window
            # Bottom part
            lbbox = [-3, -.1, -1, 3, .1, 2]
            create = Operation("create", Entity(name="wood", type="wood", location=chunk_loc, bbox=lbbox, mode="fixed"), to=target)
            res.append(create)
            # Top part
            chunk_loc.position = Point3D([0, 0, 0])
            offset = Vector3D(0, 4, 0)
            chunk_loc.position = chunk_loc.position + offset
            lbbox = [-3, -.1, -1, 3, .1, 2]
            create = Operation("create", Entity(name="wood", type="wood", location=chunk_loc, bbox=lbbox, mode="fixed"), to=target)
            res.append(create)
            # left part
            chunk_loc.position = Point3D([0, 0, 0])
            offset = Vector3D(-2, 2, 0)
            chunk_loc.position = chunk_loc.position + offset
            lbbox = [-1, -.1, -.5, 1, .1, .5]
            create = Operation("create", Entity(name="wood", type="wood", location=chunk_loc, bbox=lbbox, mode="fixed"), to=target)
            res.append(create)
            # Right part
            chunk_loc.position = Point3D([0, 0, 0])
            offset = Vector3D(2, 2, 0)
            chunk_loc.position = chunk_loc.position + offset
            lbbox = [-1, -.1, -.5, 1, .1, .5]
            create = Operation("create", Entity(name="wood", type="wood", location=chunk_loc, bbox=lbbox, mode="fixed"), to=target)
            res.append(create)
        if self.fname == "Fireplace":
            # Making Fireplace
            while (count > 0):
                tar = raw_materials.pop()
                set = Operation("set", Entity(tar.id, status=-1), to=tar)
                res.append(set)
                count = count - 1
            # Move campfire
            tar = raw_materials1.pop()
            create = Operation("move", Entity(tar.id, location=chunk_loc, mode="fixed"), to=tar)
            res.append(create)
            # make floor of fireplace
            lbbox = [-2, -1, -.1, 2, 1, .1]  # local bbox
            create = Operation("create", Entity(name="boulder", type="boulder", location=chunk_loc, bbox=lbbox, mode="fixed"), to=target)
            res.append(create)
            # make wall 1 of fireplace
            chunk_loc.position = Point3D([0, 0, 0])
            offset = Vector3D(-1.6, 0, 0)
            lbbox = [-.1, -1, -.1, .1, 1, 1.5]
            chunk_loc.position = chunk_loc.position + offset
            create = Operation("create", Entity(name="boulder", type="boulder", location=chunk_loc, bbox=lbbox, mode="fixed"), to=target)
            res.append(create)
            # make wall 2 of fireplace
            chunk_loc.position = Point3D([0, 0, 0])
            offset = Vector3D(1.6, 0, 0)
            lbbox = [-.1, -1, -.1, .1, 1, 1.5]
            chunk_loc.position = chunk_loc.position + offset
            create = Operation("create", Entity(name="boulder", type="boulder", location=chunk_loc, bbox=lbbox, mode="fixed"), to=target)
            res.append(create)
            # make back of fireplace
            chunk_loc.position = Point3D([0, 0, 0])
            offset = Vector3D(0, 0, .6)
            lbbox = [-2, -.1, -.1, 2, .1, 1.5]
            chunk_loc.position = chunk_loc.position + offset
            create = Operation("create", Entity(name="boulder", type="boulder", location=chunk_loc, bbox=lbbox, mode="fixed"), to=target)
            res.append(create)
        if self.fname == "Wallframe":
            # Bottom part of wall frame
            chunk_loc.position = Point3D([0, 0, 0])
            tar = raw_materials.pop()
            lumberlength = tar.location.bbox.high_corner[2] - tar.location.bbox.low_corner[2]
            chunk_loc.orientation = Quaternion([.5, .5, .5, .5])
            offset = Vector3D(-lumberlength / 2, 0, 0)
            chunk_loc.position = chunk_loc.position + offset
            create = Operation("move", Entity(tar.id, location=chunk_loc, mode="fixed"), to=tar)
            res.append(create)
            # Top part of wall frame
            chunk_loc.position = Point3D([0, 0, 0])
            tar = raw_materials.pop()
            offset = Vector3D(-lumberlength / 2, 0, lumberlength * .8)
            chunk_loc.position = chunk_loc.position + offset
            chunk_loc.orientation = Quaternion([.5, .5, .5, .5])
            create = Operation("move", Entity(tar.id, location=chunk_loc, mode="fixed"), to=tar)
            res.append(create)
            # Left part of wall frame
            chunk_loc.position = Point3D([0, 0, 0])
            tar = raw_materials.pop()
            offset = Vector3D((lumberlength / 2.0) * -.8, lumberlength * .8, 0)
            chunk_loc.position = chunk_loc.position + offset
            chunk_loc.orientation = Quaternion([.707, .707, 0, 0])
            create = Operation("move", Entity(tar.id, location=chunk_loc, mode="fixed"), to=tar)
            res.append(create)
            # Right part of wall frame
            chunk_loc.position = Point3D([0, 0, 0])
            tar = raw_materials.pop()
            offset = Vector3D((lumberlength / 2.0) * .8, lumberlength * .8, 0)
            chunk_loc.position = chunk_loc.position + offset
            chunk_loc.orientation = Quaternion([.707, .707, 0, 0])
            create = Operation("move", Entity(tar.id, location=chunk_loc, mode="fixed"), to=tar)
            res.append(create)
            # Center part of wall frame
            chunk_loc.position = Point3D([0, 0, 0])
            tar = raw_materials.pop()
            offset = Vector3D((lumberlength / 2.0) * -.8, lumberlength * .1, 0)
            chunk_loc.position = chunk_loc.position + offset
            chunk_loc.orientation = Quaternion([.27, .27, .65, .65])
            create = Operation("move", Entity(tar.id, location=chunk_loc, mode="fixed"), to=tar)
            res.append(create)
        if self.fname == "Roof":
            # Making the roof, roof is 1 lumber and a large wooden covering
            while (count > 0):
                tar = raw_materials.pop()
                set = Operation("set", Entity(tar.id, status=-1), to=tar)
                res.append(set)
                count = count - 1
            # create the top, it is one large wood
            lbbox = [-4, -4, -.1, 4, 4, .3]  # local bbox
            offset = Vector3D(0, 5, 0)
            chunk_loc.position = chunk_loc.position + offset
            create = Operation("create", Entity(name="wood", type="wood", location=chunk_loc, bbox=lbbox, mode="fixed"), to=target)
            res.append(create)
            # create column
            chunk_loc.position = Point3D([0, 0, 0])
            lbbox = [-.5, -.5, -.1, .5, .5, 6]  # local bbox
            offset = Vector3D(0, 0, 0)
            chunk_loc.position = chunk_loc.position + offset
            create = Operation("create", Entity(name="lumber", type="lumber", location=chunk_loc, bbox=lbbox, mode="fixed"), to=target)
            res.append(create)

        self.progress = 1
        self.irrelevant()
        return res
Esempio n. 20
0
    def info_operation(self, op):
        print("Gate info")
        gate = server.world.get_object(op[0].id)
        self.lcount = 0  # needs 1 lumber for basic gate
        self.acount = 0  # needs 2 a frames for basic gate
        raw_materials = []  # Holds construction
        raw_materials1 = []  # Holds lumber
        for item in self.character.contains:
            if item.type[0] == str("construction"):
                raw_materials.append(item)
                self.acount = self.acount + 1
            if item.type[0] == str("lumber"):
                raw_materials1.append(item)
                self.lcount = self.lcount + 1
            if self.acount == 2 and self.lcount == 1:
                break
            if self.lcount == 3:
                break
        else:
            print("No materials in inventory for Gate")
            self.irrelevant()
            return

        chunk_loc = Location(gate())
        chunk_loc.position = Point3D([0, 0, 0])
        res = Oplist()

        if self.gname == "Basic_Gate":
            count1 = self.lcount
            while (count1 > 0):
                tar = raw_materials1.pop()
                self.lumber_length = tar.location.bbox.high_corner[2] - \
                                     tar.location.bbox.low_corner[2]
                offset = Vector3D(self.lumber_length / 7, self.lumber_length * .63, -
                self.lumber_length / 3.5)
                chunk_loc.orientation = Quaternion([.707, 0, 0, .707])
                # Same as an Euler of (0,90 Degrees,0)
                chunk_loc.position = chunk_loc.position + offset
                move1 = Operation("move", Entity(tar.id, location=chunk_loc,
                                                 mode="fixed"), to=tar)
                res.append(move1)
                count1 = count1 - 1

            count = self.acount
            chunk_loc = Location(gate())
            chunk_loc.position = Point3D([0, 0, 0])
            # Resets
            # loops through raw_materials and places 3 lumber
            # in inventory infront of user
            offset = Vector3D(0, 0, 0)
            while (count > 0):
                tar = raw_materials.pop()

                if count == 2:
                    # left component of gate
                    chunk_loc.position = Point3D([0, 0, 0])
                    offset = Vector3D(0, self.lumber_length * .7, 0)
                    chunk_loc.orientation = Quaternion([.707, 0, 0, .707])
                    chunk_loc.position = chunk_loc.position + offset

                if count == 1:
                    # right component of gate
                    chunk_loc.position = Point3D([0, 0, 0])
                    offset = Vector3D(0,
                                      self.lumber_length * .7, (self.lumber_length / 2))
                    chunk_loc.orientation = Quaternion([.707, 0, 0, .707])
                    chunk_loc.position = chunk_loc.position + offset

                move = Operation("move", Entity(tar.id, location=chunk_loc,
                                                mode="fixed"), to=tar)
                res.append(move)
                count = count - 1

        if self.gname == "House_Gate":
            # Left leg of the house frame
            tar = raw_materials1.pop()
            chunk_loc.position = Point3D([0, 0, 0])
            self.lumber_length = tar.location.bbox.high_corner[2] - \
                                 tar.location.bbox.low_corner[2]
            offset = Vector3D(0, self.lumber_length * .8, -self.lumber_length / 4)
            chunk_loc.orientation = Quaternion([.707, .707, 0, 0])
            chunk_loc.position = chunk_loc.position + offset
            move1 = Operation("move", Entity(tar.id, location=chunk_loc,
                                             mode="fixed"), to=tar)
            res.append(move1)
            # Right Leg of the house frame
            tar = raw_materials1.pop()
            chunk_loc.position = Point3D([0, 0, 0])
            self.lumber_length = tar.location.bbox.high_corner[2] - \
                                 tar.location.bbox.low_corner[2]
            offset = Vector3D(0,
                              self.lumber_length * .8, -self.lumber_length * (3.0 / 4.0))
            chunk_loc.orientation = Quaternion([.707, .707, 0, 0])
            chunk_loc.position = chunk_loc.position + offset
            move1 = Operation("move", Entity(tar.id, location=chunk_loc,
                                             mode="fixed"), to=tar)
            res.append(move1)
            # Top of the house frame
            tar = raw_materials1.pop()
            chunk_loc.position = Point3D([0, 0, 0])
            self.lumber_length = tar.location.bbox.high_corner[2] - \
                                 tar.location.bbox.low_corner[2]
            offset = Vector3D(0, self.lumber_length * (.7, -self.lumber_length))
            chunk_loc.orientation = Quaternion([.5, .5, -.5, .5])
            # Same as (90 Degrees, 0, 90 Degrees)
            chunk_loc.position = chunk_loc.position + offset
            move1 = Operation("move", Entity(tar.id, location=chunk_loc,
                                             mode="fixed"), to=tar)
            res.append(move1)

        self.progress = 1
        self.irrelevant()
        return res
Esempio n. 21
0
    def info_operation(self, op):
        print("Furnishings info")
        item = server.world.get_object(op[0].id)
        chunk_loc = Location(item())
        chunk_loc.position = Point3D([0, 0, 0])
        res = Oplist()
        target = self.target()
        raw_materials = []
        raw_materials1 = []  # holders campfire
        raw_materials2 = []  # temp holder for aframes to be moved
        acount = 0  # A frame count
        lcount = 0  # Lumber count
        wcount = 0  # Wood count
        bcount = 0  # Boulder count
        ccount = 0  # Campfire count
        for item in self.character.contains:
            if item.type[0] == "lumber":
                raw_materials.append(item)
                lcount = lcount + 1
            if item.type[0] == "wood":
                raw_materials.append(item)
                wcount = wcount + 1
            if item.type[0] == "campfire":
                raw_materials1.append(item)
                ccount = ccount + 1
            if item.type[0] == "boulder":
                raw_materials.append(item)
                bcount = bcount + 1
            if item.type[0] == "construction":
                raw_materials2.append(item)
                acount = acount + 1

        count = lcount + wcount + bcount
        if self.fname == "Table":
            # Making table
            while (count > 0):
                tar = raw_materials.pop()
                set = Operation("set", Entity(tar.id, status=-1), to=tar)
                res.append(set)
                count = count - 1
            # create the table
            # Table base
            lbbox = [-.2, -.2, -.5, .2, .2, .5]  # local bbox
            create = Operation("create",
                               Entity(name="lumber",
                                      type="lumber",
                                      location=chunk_loc,
                                      bbox=lbbox,
                                      mode="fixed"),
                               to=target)
            res.append(create)
            # create the table top
            offset = Vector3D(0, 1, 0)
            chunk_loc.position = chunk_loc.position + offset
            lbbox = [-.7, -.7, -.1, .7, .7, .1]
            create = Operation("create",
                               Entity(name="wood",
                                      type="wood",
                                      location=chunk_loc,
                                      bbox=lbbox,
                                      mode="fixed"),
                               to=target)
            res.append(create)
        if self.fname == "Chair":
            # Making chair
            while (count > 0):
                tar = raw_materials.pop()
                set = Operation("set", Entity(tar.id, status=-1), to=tar)
                res.append(set)
                count = count - 1
            # create the legs
            # leg 1
            chunk_loc.position = Point3D([0, 0, 0])
            offset = Vector3D(.2, 0, -.2)
            chunk_loc.position = chunk_loc.position + offset
            create = Operation("create",
                               Entity(name="lumber",
                                      type="lumber",
                                      location=chunk_loc,
                                      mode="fixed"),
                               to=target)
            res.append(create)

            # leg 2
            chunk_loc.position = Point3D([0, 0, 0])
            offset = Vector3D(-.2, 0, -.2)
            chunk_loc.position = chunk_loc.position + offset
            create = Operation("create",
                               Entity(name="lumber",
                                      type="lumber",
                                      location=chunk_loc,
                                      mode="fixed"),
                               to=target)
            res.append(create)

            # leg 3
            chunk_loc.position = Point3D([0, 0, 0])
            offset = Vector3D(-.2, 0, .2)
            chunk_loc.position = chunk_loc.position + offset
            create = Operation("create",
                               Entity(name="lumber",
                                      type="lumber",
                                      location=chunk_loc,
                                      mode="fixed"),
                               to=target)
            res.append(create)

            # leg 4
            chunk_loc.position = Point3D([0, 0, 0])
            offset = Vector3D(.2, 0, .2)
            chunk_loc.position = chunk_loc.position + offset
            create = Operation("create",
                               Entity(name="lumber",
                                      type="lumber",
                                      location=chunk_loc,
                                      mode="fixed"),
                               to=target)
            res.append(create)

            # create the seat
            chunk_loc.position = Point3D([0, 0, 0])
            offset = Vector3D(0, .5, 0)
            lbbox = [-.3, -.3, -.1, .3, .3, .1]  # Local bbox
            chunk_loc.position = chunk_loc.position + offset
            create = Operation("create",
                               Entity(name="wood",
                                      type="wood",
                                      location=chunk_loc,
                                      bbox=lbbox,
                                      mode="fixed"),
                               to=target)
            res.append(create)

            # create the back of the seat
            chunk_loc.position = Point3D([0, 0, 0])
            offset = Vector3D(-.3, .75, 0)
            lbbox = [-.1, -.3, -.4, .1, .3, .4]  # local bbox
            chunk_loc.position = chunk_loc.position + offset
            create = Operation("create",
                               Entity(name="wood",
                                      type="wood",
                                      location=chunk_loc,
                                      bbox=lbbox,
                                      mode="fixed"),
                               to=target)
            res.append(create)

        if self.fname == "Floor":
            # Making Floor
            while (count > 0):
                tar = raw_materials.pop()
                set = Operation("set", Entity(tar.id, status=-1), to=tar)
                res.append(set)
                count = count - 1
            # create the Floor, it is one large wood
            lbbox = [-2, -2, -.1, 2, 2, .1]  # local bbox
            create = Operation("create",
                               Entity(name="wood",
                                      type="wood",
                                      location=chunk_loc,
                                      bbox=lbbox,
                                      mode="fixed"),
                               to=target)
            res.append(create)
        if self.fname == "Siding":
            # Making wooden siding with window
            while (count > 0):
                tar = raw_materials.pop()
                set = Operation("set", Entity(tar.id, status=-1), to=tar)
                res.append(set)
                count = count - 1
            # Siding is made of 4 components so it looks like we have a window
            # Bottom part
            lbbox = [-3, -.1, -1, 3, .1, 2]
            create = Operation("create",
                               Entity(name="wood",
                                      type="wood",
                                      location=chunk_loc,
                                      bbox=lbbox,
                                      mode="fixed"),
                               to=target)
            res.append(create)
            # Top part
            chunk_loc.position = Point3D([0, 0, 0])
            offset = Vector3D(0, 4, 0)
            chunk_loc.position = chunk_loc.position + offset
            lbbox = [-3, -.1, -1, 3, .1, 2]
            create = Operation("create",
                               Entity(name="wood",
                                      type="wood",
                                      location=chunk_loc,
                                      bbox=lbbox,
                                      mode="fixed"),
                               to=target)
            res.append(create)
            # left part
            chunk_loc.position = Point3D([0, 0, 0])
            offset = Vector3D(-2, 2, 0)
            chunk_loc.position = chunk_loc.position + offset
            lbbox = [-1, -.1, -.5, 1, .1, .5]
            create = Operation("create",
                               Entity(name="wood",
                                      type="wood",
                                      location=chunk_loc,
                                      bbox=lbbox,
                                      mode="fixed"),
                               to=target)
            res.append(create)
            # Right part
            chunk_loc.position = Point3D([0, 0, 0])
            offset = Vector3D(2, 2, 0)
            chunk_loc.position = chunk_loc.position + offset
            lbbox = [-1, -.1, -.5, 1, .1, .5]
            create = Operation("create",
                               Entity(name="wood",
                                      type="wood",
                                      location=chunk_loc,
                                      bbox=lbbox,
                                      mode="fixed"),
                               to=target)
            res.append(create)
        if self.fname == "Fireplace":
            # Making Fireplace
            while (count > 0):
                tar = raw_materials.pop()
                set = Operation("set", Entity(tar.id, status=-1), to=tar)
                res.append(set)
                count = count - 1
            # Move campfire
            tar = raw_materials1.pop()
            create = Operation("move",
                               Entity(tar.id, location=chunk_loc,
                                      mode="fixed"),
                               to=tar)
            res.append(create)
            # make floor of fireplace
            lbbox = [-2, -1, -.1, 2, 1, .1]  # local bbox
            create = Operation("create",
                               Entity(name="boulder",
                                      type="boulder",
                                      location=chunk_loc,
                                      bbox=lbbox,
                                      mode="fixed"),
                               to=target)
            res.append(create)
            # make wall 1 of fireplace
            chunk_loc.position = Point3D([0, 0, 0])
            offset = Vector3D(-1.6, 0, 0)
            lbbox = [-.1, -1, -.1, .1, 1, 1.5]
            chunk_loc.position = chunk_loc.position + offset
            create = Operation("create",
                               Entity(name="boulder",
                                      type="boulder",
                                      location=chunk_loc,
                                      bbox=lbbox,
                                      mode="fixed"),
                               to=target)
            res.append(create)
            # make wall 2 of fireplace
            chunk_loc.position = Point3D([0, 0, 0])
            offset = Vector3D(1.6, 0, 0)
            lbbox = [-.1, -1, -.1, .1, 1, 1.5]
            chunk_loc.position = chunk_loc.position + offset
            create = Operation("create",
                               Entity(name="boulder",
                                      type="boulder",
                                      location=chunk_loc,
                                      bbox=lbbox,
                                      mode="fixed"),
                               to=target)
            res.append(create)
            # make back of fireplace
            chunk_loc.position = Point3D([0, 0, 0])
            offset = Vector3D(0, 0, .6)
            lbbox = [-2, -.1, -.1, 2, .1, 1.5]
            chunk_loc.position = chunk_loc.position + offset
            create = Operation("create",
                               Entity(name="boulder",
                                      type="boulder",
                                      location=chunk_loc,
                                      bbox=lbbox,
                                      mode="fixed"),
                               to=target)
            res.append(create)
        if self.fname == "Wallframe":
            # Bottom part of wall frame
            chunk_loc.position = Point3D([0, 0, 0])
            tar = raw_materials.pop()
            lumberlength = tar.location.bbox.high_corner[
                2] - tar.location.bbox.low_corner[2]
            chunk_loc.orientation = Quaternion([.5, .5, .5, .5])
            offset = Vector3D(-lumberlength / 2, 0, 0)
            chunk_loc.position = chunk_loc.position + offset
            create = Operation("move",
                               Entity(tar.id, location=chunk_loc,
                                      mode="fixed"),
                               to=tar)
            res.append(create)
            # Top part of wall frame
            chunk_loc.position = Point3D([0, 0, 0])
            tar = raw_materials.pop()
            offset = Vector3D(-lumberlength / 2, 0, lumberlength * .8)
            chunk_loc.position = chunk_loc.position + offset
            chunk_loc.orientation = Quaternion([.5, .5, .5, .5])
            create = Operation("move",
                               Entity(tar.id, location=chunk_loc,
                                      mode="fixed"),
                               to=tar)
            res.append(create)
            # Left part of wall frame
            chunk_loc.position = Point3D([0, 0, 0])
            tar = raw_materials.pop()
            offset = Vector3D((lumberlength / 2.0) * -.8, lumberlength * .8, 0)
            chunk_loc.position = chunk_loc.position + offset
            chunk_loc.orientation = Quaternion([.707, .707, 0, 0])
            create = Operation("move",
                               Entity(tar.id, location=chunk_loc,
                                      mode="fixed"),
                               to=tar)
            res.append(create)
            # Right part of wall frame
            chunk_loc.position = Point3D([0, 0, 0])
            tar = raw_materials.pop()
            offset = Vector3D((lumberlength / 2.0) * .8, lumberlength * .8, 0)
            chunk_loc.position = chunk_loc.position + offset
            chunk_loc.orientation = Quaternion([.707, .707, 0, 0])
            create = Operation("move",
                               Entity(tar.id, location=chunk_loc,
                                      mode="fixed"),
                               to=tar)
            res.append(create)
            # Center part of wall frame
            chunk_loc.position = Point3D([0, 0, 0])
            tar = raw_materials.pop()
            offset = Vector3D((lumberlength / 2.0) * -.8, lumberlength * .1, 0)
            chunk_loc.position = chunk_loc.position + offset
            chunk_loc.orientation = Quaternion([.27, .27, .65, .65])
            create = Operation("move",
                               Entity(tar.id, location=chunk_loc,
                                      mode="fixed"),
                               to=tar)
            res.append(create)
        if self.fname == "Roof":
            # Making the roof, roof is 1 lumber and a large wooden covering
            while (count > 0):
                tar = raw_materials.pop()
                set = Operation("set", Entity(tar.id, status=-1), to=tar)
                res.append(set)
                count = count - 1
            # create the top, it is one large wood
            lbbox = [-4, -4, -.1, 4, 4, .3]  # local bbox
            offset = Vector3D(0, 5, 0)
            chunk_loc.position = chunk_loc.position + offset
            create = Operation("create",
                               Entity(name="wood",
                                      type="wood",
                                      location=chunk_loc,
                                      bbox=lbbox,
                                      mode="fixed"),
                               to=target)
            res.append(create)
            # create column
            chunk_loc.position = Point3D([0, 0, 0])
            lbbox = [-.5, -.5, -.1, .5, .5, 6]  # local bbox
            offset = Vector3D(0, 0, 0)
            chunk_loc.position = chunk_loc.position + offset
            create = Operation("create",
                               Entity(name="lumber",
                                      type="lumber",
                                      location=chunk_loc,
                                      bbox=lbbox,
                                      mode="fixed"),
                               to=target)
            res.append(create)

        self.progress = 1
        self.irrelevant()
        return res
    def info_operation(self, op):
        print("Aframe info")
        aframe = server.world.get_object(op[0].id)
        self.lcount = 0

        raw_materials = []
        for item in self.character.contains:
            if item.type[0] == str(self.materials):
                raw_materials.append(item)
                self.lcount = self.lcount + 1
            if self.lcount == 3:
                break
        else:
            print("No materials in inventory for A frame")
            self.irrelevant()
            return

        chunk_loc = Location(aframe())
        chunk_loc.position = Point3D([0, 0, 0])

        count = self.lcount
        res = Oplist()
        # loops through raw_materials and places 3 lumber
        # in inventory infront of user
        offset = Vector3D(0, 0, 0)
        while (count > 0):
            tar = raw_materials.pop()
            # length of the lumber obtained
            lumberlength = tar.location.bbox.high_corner[2] - \
                           tar.location.bbox.low_corner[2]
            lumberheight = tar.location.bbox.high_corner[1] - \
                           tar.location.bbox.low_corner[1]
            # rough length to position lumber
            lumber_length = lumberlength / 4

            if count == 3:
                # left component
                chunk_loc.orientation = Quaternion([.653, 0.27, .27, .653])
            if count == 2:
                # right component
                chunk_loc.orientation = Quaternion([.653, -0.27, -.27, .653])
                offset = Vector3D(lumber_length, 0, 0)
                chunk_loc.position = chunk_loc.position + offset
            if count == 1:
                # bottom component
                chunk_loc.position = Point3D([0, 0, 0])  # self.pos
                # .707 is sin(.5) which is needed for a 90 degree rotation
                chunk_loc.orientation = Quaternion([.707, 0, .707, 0])
                offset = Vector3D(-(1.5 * lumber_length), 0,
                                  (2.5 * lumber_length))
                chunk_loc.position = chunk_loc.position + offset

            move = Operation("move",
                             Entity(tar.id, location=chunk_loc, mode="fixed"),
                             to=tar)
            res.append(move)
            count = count - 1

        self.progress = 1
        self.irrelevant()
        return res