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
Beispiel #2
0
    def delete_operation(self, op):
        res = Oplist()

        # Restore status if it's zero.
        if self.has_prop_float("status"):
            res += Operation("set", Entity(self.id, status=1.0), to=self.id)

        # Respawn in a spawn area
        respawn_alias = self.get_prop_string("_respawning")
        if respawn_alias:
            respawn_entity = server.get_alias_entity(respawn_alias)
            if respawn_entity:
                pos = Spawner.get_spawn_pos(respawn_entity)
                if pos:
                    location = Location()
                    location.pos = pos
                    # Randomize orientation
                    rotation = random.random() * math.pi * 2
                    location.orientation = physics.Quaternion(physics.Vector3D(0, 1, 0), rotation)
                    location.parent = respawn_entity.location.parent
                    # Emit a sight of this entity being defeated
                    res += Operation("sight", Operation("defeated", Entity(self.id)))
                    res += Operation("move", Entity(self.id, location=location), to=self.id)
                    res += Operation("imaginary", Entity(description="You were killed and will be respawned."), to=self.id, from_=self.id)
                    return server.OPERATION_BLOCKED, res
Beispiel #3
0
 def face(self, other):
     vector = distance_to(self.entity.location, other.location)
     vector.y = 0
     if vector.sqr_mag() < 0.1:
         return
     vector = vector.unit_vector()
     newloc = Location(self.entity.location.parent)
     newloc.orientation = Quaternion(Vector3D(0, 0, 1), vector, Vector3D(0, 1, 0))
     return Operation("move", Entity(self.entity.id, location=newloc))
Beispiel #4
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.pos = 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

        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
Beispiel #6
0
 def face(self, other):
     vector = distance_to(self.entity.location, other.location)
     vector.y = 0
     if vector.sqr_mag() < 0.1:
         return
     vector = vector.unit_vector()
     newloc = Location(self.entity.location.parent)
     newloc.orientation = Quaternion(Vector3D(0, 0, 1), vector,
                                     Vector3D(0, 1, 0))
     return Operation("move", Entity(self.entity.id, location=newloc))
Beispiel #7
0
 def face(self, other):
     """ Turn to face that another character, ensuring that
         we are facing the character we are hitting """
     vector = distance_to(self.character.location, other.location)
     vector.y = 0
     if vector.sqr_mag() < 0.1:
         return
     vector = vector.unit_vector()
     newloc = Location(self.character.location.parent)
     newloc.orientation = Quaternion(Vector3D(1, 0, 0), vector)
     return Operation("move", Entity(self.character.id, location=newloc))
Beispiel #8
0
 def face(self, other):
     """ Turn to face that another character, ensuring that
         we are facing the character we are hitting """
     vector = distance_to(self.character.location, other.location)
     vector.y = 0
     if vector.sqr_mag() < 0.1:
         return
     vector = vector.unit_vector()
     newloc = Location(self.character.location.parent)
     newloc.orientation = Quaternion(Vector3D(1, 0, 0), vector)
     return Operation("move", Entity(self.character.id, location=newloc))
Beispiel #9
0
    def tick_operation(self, op):
        """ Op handler for regular tick op """
        # print "Raise.tick"

        if self.target() is None:
            # print "Target is no more"
            self.irrelevant()
            return
        if not self.target().location.parent:
            # Not withstanding famous quotes to the contrary, in these
            # system we can not move the world no matter how large a lever
            # or firm a place to stand we have.
            self.irrelevant()
            return

        distance = distance_to(self.character.location, self.target().location)
        # Check we are not too far away from the object to interact with it
        # This calculation is imprecise as it sums the square radii, but
        # its usually close enough.
        d = distance.sqr_mag()
        r = self.character.location.bbox.square_bounding_radius() + \
            self.target().location.bbox.square_bounding_radius()
        if d > r:
            return self.next_tick(1)
        if d < const.epsilon:
            # print "Going nowhere"
            return self.next_tick(1)
        # print "DISTANCE ", distance, distance.is_valid()
        axis = distance.cross(Vector3D(0, 1, 0))
        # If distance is zero, axis becomes zero
        # print "DISTANCE ", distance, distance.is_valid(), axis, axis.is_valid()
        # If axis is zero, the quaternion contains NaNs.
        rotation = Quaternion(axis, -0.05)
        # print "ROT ", rotation, rotation.is_valid()
        if self.target().location.orientation.is_valid():
            # print "VALID"
            rotation = self.target().location.orientation * rotation

        # print "NEW_ROT", rotation, rotation.is_valid()
        target_location = Location(self.target().location.parent,
                                   self.target().location.position)
        target_location.orientation = rotation
        move = Operation("move",
                         Entity(self.target().id, location=target_location),
                         to=self.target())
        res = Oplist()
        res.append(move)

        res.append(self.next_tick(0.5))

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

        if self.target() is None:
            # print "Target is no more"
            self.irrelevant()
            return
        if not self.target().location.parent:
            # Not withstanding famous quotes to the contrary, in these
            # system we can not move the world no matter how large a lever
            # or firm a place to stand we have.
            self.irrelevant()
            return

        distance = distance_to(self.character.location, self.target().location)
        # Check we are not too far away from the object to interact with it
        # This calculation is imprecise as it sums the square radii, but
        # its usually close enough.
        d = distance.sqr_mag()
        r = self.character.location.bbox.square_bounding_radius() + \
            self.target().location.bbox.square_bounding_radius()
        if d > r:
            return self.next_tick(1);
        if d < const.epsilon:
            # print "Going nowhere"
            return self.next_tick(1);
        # print "DISTANCE ", distance, distance.is_valid()
        axis = distance.cross(Vector3D(0, 1, 0))
        # If distance is zero, axis becomes zero
        # print "DISTANCE ", distance, distance.is_valid(), axis, axis.is_valid()
        # If axis is zero, the quaternion contains NaNs.
        rotation = Quaternion(axis, -0.05)
        # print "ROT ", rotation, rotation.is_valid()
        if self.target().location.orientation.is_valid():
            # print "VALID"
            rotation = self.target().location.orientation * rotation

        # print "NEW_ROT", rotation, rotation.is_valid()
        target_location = Location(self.target().location.parent,
                                   self.target().location.position)
        target_location.orientation = rotation
        move = Operation("move", Entity(self.target().id,
                                        location=target_location), to=self.target())
        res = Oplist()
        res.append(move)

        res.append(self.next_tick(0.5))

        return res
Beispiel #11
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.pos = 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
Beispiel #12
0
    def info_operation(self, op):
        print("Furnishings info")
        item = server.world.get_object(op[0].id)
        chunk_loc = Location(item())
        chunk_loc.pos = 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.pos = chunk_loc.pos + 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.pos = Point3D([0, 0, 0])
            offset = Vector3D(.2, 0, -.2)
            chunk_loc.pos = chunk_loc.pos + offset
            create = Operation("create",
                               Entity(name="lumber",
                                      type="lumber",
                                      location=chunk_loc,
                                      mode="fixed"),
                               to=target)
            res.append(create)

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

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

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

            # create the seat
            chunk_loc.pos = Point3D([0, 0, 0])
            offset = Vector3D(0, .5, 0)
            lbbox = [-.3, -.3, -.1, .3, .3, .1]  # Local bbox
            chunk_loc.pos = chunk_loc.pos + 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.pos = Point3D([0, 0, 0])
            offset = Vector3D(-.3, .75, 0)
            lbbox = [-.1, -.3, -.4, .1, .3, .4]  # local bbox
            chunk_loc.pos = chunk_loc.pos + 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.pos = Point3D([0, 0, 0])
            offset = Vector3D(0, 4, 0)
            chunk_loc.pos = chunk_loc.pos + 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.pos = Point3D([0, 0, 0])
            offset = Vector3D(-2, 2, 0)
            chunk_loc.pos = chunk_loc.pos + 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.pos = Point3D([0, 0, 0])
            offset = Vector3D(2, 2, 0)
            chunk_loc.pos = chunk_loc.pos + 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.pos = Point3D([0, 0, 0])
            offset = Vector3D(-1.6, 0, 0)
            lbbox = [-.1, -1, -.1, .1, 1, 1.5]
            chunk_loc.pos = chunk_loc.pos + 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.pos = Point3D([0, 0, 0])
            offset = Vector3D(1.6, 0, 0)
            lbbox = [-.1, -1, -.1, .1, 1, 1.5]
            chunk_loc.pos = chunk_loc.pos + 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.pos = Point3D([0, 0, 0])
            offset = Vector3D(0, 0, .6)
            lbbox = [-2, -.1, -.1, 2, .1, 1.5]
            chunk_loc.pos = chunk_loc.pos + 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.pos = 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.pos = chunk_loc.pos + offset
            create = Operation("move",
                               Entity(tar.id, location=chunk_loc,
                                      mode="fixed"),
                               to=tar)
            res.append(create)
            # Top part of wall frame
            chunk_loc.pos = Point3D([0, 0, 0])
            tar = raw_materials.pop()
            offset = Vector3D(-lumberlength / 2, 0, lumberlength * .8)
            chunk_loc.pos = chunk_loc.pos + 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.pos = Point3D([0, 0, 0])
            tar = raw_materials.pop()
            offset = Vector3D((lumberlength / 2.0) * -.8, lumberlength * .8, 0)
            chunk_loc.pos = chunk_loc.pos + 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.pos = Point3D([0, 0, 0])
            tar = raw_materials.pop()
            offset = Vector3D((lumberlength / 2.0) * .8, lumberlength * .8, 0)
            chunk_loc.pos = chunk_loc.pos + 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.pos = Point3D([0, 0, 0])
            tar = raw_materials.pop()
            offset = Vector3D((lumberlength / 2.0) * -.8, lumberlength * .1, 0)
            chunk_loc.pos = chunk_loc.pos + 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.pos = chunk_loc.pos + 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.pos = Point3D([0, 0, 0])
            lbbox = [-.5, -.5, -.1, .5, .5, 6]  # local bbox
            offset = Vector3D(0, 0, 0)
            chunk_loc.pos = chunk_loc.pos + 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
Beispiel #13
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
Beispiel #14
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
Beispiel #15
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
Beispiel #16
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.pos = 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.pos = chunk_loc.pos + 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.pos = 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.pos = Point3D([0, 0, 0])
                    offset = Vector3D(0, self.lumber_length * .7, 0)
                    chunk_loc.orientation = Quaternion([.707, 0, 0, .707])
                    chunk_loc.pos = chunk_loc.pos + offset

                if count == 1:
                    # right component of gate
                    chunk_loc.pos = 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.pos = chunk_loc.pos + 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.pos = 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.pos = chunk_loc.pos + 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.pos = 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.pos = chunk_loc.pos + 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.pos = 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.pos = chunk_loc.pos + offset
            move1 = Operation("move",
                              Entity(tar.id, location=chunk_loc, mode="fixed"),
                              to=tar)
            res.append(move1)

        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