コード例 #1
0
 def __init__(self, xml, validate=True):
     self.Name = ""
     self.Position = Position2D(None, validate=False)
     if validate:
         LoadingHelpers.checkAttribExist(xml, "name")
         self.Name = xml.get("name")
         self.Position = Position2D(xml, validate)
コード例 #2
0
    def __init__(self, xml, obj_classes, check_valid=True):
        LoadingHelpers.checkAttribExist(xml, "name")
        self.Name = xml.get("name")
        self.Position = Position2D(
            xml.find("position")) if xml.find("position") is not None else None
        self.Shape = Shape2D(
            xml.find("shape")) if xml.find("shape") is not None else None
        self.Tags = [l.text for l in xml.find("tags").findall("tag")
                     ] if xml.find("tags") is not None else []

        self.Color = Color(
            xml.find("color")) if xml.find("color") is not None else None

        if xml.get("class"):  # merge info with class
            other = copy.deepcopy(
                [c for c in obj_classes if c.Name == xml.get("class")][0])
            # self is prioritary
            self.Position = self.Position if self.Position is not None else other.Position
            self.Shape = self.Shape if self.Shape is not None else other.Shape
            self.Color = self.Color if self.Color is not None else other.Color
            self.Tags += other.Tags

            self.Marker = copy.deepcopy(other.Marker)
            if xml.find("marker") is not None:
                self.Marker.merge(xml.find("marker"))
        else:
            self.Marker = Marker(
                xml.find("marker")) if xml.find("marker") is not None else None

        if check_valid is True:
            self.check_valid(
            )  # disabled when manually creating a class through code
        print self.Tags  #TODO remove
コード例 #3
0
ファイル: map_classes.py プロジェクト: mouhandiaye/coupe18
 def __init__(self, initdict):
     LoadingHelpers.checkKeysExist(initdict, "position", "marker")
     super(Waypoint, self).__init__({
         "position":
         Position2D(initdict["position"]),
         "marker":
         MarkerRViz(initdict["marker"])
     })
コード例 #4
0
ファイル: map_classes.py プロジェクト: mouhandiaye/coupe18
 def __init__(self, initdict):
     LoadingHelpers.checkKeysExist(initdict, "position", "shape", "marker",
                                   "properties")
     super(Zone, self).__init__({
         "position":
         Position2D(initdict["position"]),
         "shape":
         Shape2D(initdict["shape"]),
         "marker":
         MarkerRViz(initdict["marker"]),
         "properties":
         DictManager(initdict["properties"])
     })
コード例 #5
0
ファイル: map_classes.py プロジェクト: mouhandiaye/coupe18
 def __init__(self, initdict):
     LoadingHelpers.checkKeysExist(initdict, "position", "shape", "marker",
                                   "chest", "trajectory")
     super(Entity, self).__init__({
         "position":
         Position2D(initdict["position"]),
         "shape":
         Shape2D(initdict["shape"]),
         "marker":
         MarkerRViz(initdict["marker"]),
         "chest":
         None,  # TODO Implement
         "trajectory":
         Trajectory(initdict["trajectory"])
     })
コード例 #6
0
    def __init__(self, xml):
        LoadingHelpers.checkAttribExist(xml, "type")
        LoadingHelpers.checkChildExist(xml, "position", "marker", "color")
        self.Name = "terrain"
        self.Position = Position2D(xml.find("position"))
        self.Shape = Shape2D(xml)
        self.Marker = Marker(xml.find("marker"))
        self.Color = Color(xml.find("color"))

        self.Layers = [Layer(l) for l in xml.findall("layer")]

        # Copy walls from other layers (includes)
        for layer in self.Layers:
            for include in layer.Includes:
                for l in self.Layers:
                    if l.Name == include:
                        for w in l.Walls:
                            layer.Walls.append(copy.deepcopy(w))
コード例 #7
0
ファイル: map_classes.py プロジェクト: mouhandiaye/coupe18
 def __init__(self, initdict):
     LoadingHelpers.checkKeysExist(initdict, "position", "shape")
     super(Wall, self).__init__({
         "position": Position2D(initdict["position"]),
         "shape": Shape2D(initdict["shape"])
     })
コード例 #8
0
 def __init__(self, xml):
     LoadingHelpers.checkAttribExist(xml, "name")
     LoadingHelpers.checkChildExist(xml, "position", "shape")
     self.Name = xml.get("name")
     self.Position = Position2D(xml.find("position"))
     self.Shape = Shape2D(xml.find("shape"))