Esempio n. 1
0
    def generate_fob(self) -> None:
        category = "fob"
        obj_name = self.control_point.name
        template = random.choice(list(self.templates[category].values()))
        point = self.control_point.position
        # Pick from preset locations
        object_id = 0
        group_id = self.game.next_group_id()

        # TODO: Create only one TGO per objective, each with multiple units.
        for unit in template:
            object_id += 1

            template_point = Point(unit["offset"].x, unit["offset"].y)
            g = BuildingGroundObject(
                obj_name,
                category,
                group_id,
                object_id,
                point + template_point,
                unit["heading"],
                self.control_point,
                unit["type"],
                is_fob_structure=True,
            )
            self.control_point.connected_objectives.append(g)
Esempio n. 2
0
    def generate_strike_target_at(self, category: str,
                                  position: Point) -> None:

        obj_name = namegen.random_objective_name()
        template = random.choice(list(self.templates[category].values()))

        object_id = 0
        group_id = self.game.next_group_id()

        # TODO: Create only one TGO per objective, each with multiple units.
        for unit in template:
            object_id += 1

            template_point = Point(unit["offset"].x, unit["offset"].y)
            g = BuildingGroundObject(
                obj_name,
                category,
                group_id,
                object_id,
                position + template_point,
                unit["heading"],
                self.control_point,
                unit["type"],
            )

            self.control_point.connected_objectives.append(g)
Esempio n. 3
0
    def generate_fob(self) -> None:
        try:
            category = self.faction.building_set[
                self.faction.building_set.index('fob')]
        except IndexError:
            logging.exception("Faction has no fob buildings defined")
            return

        obj_name = self.control_point.name
        template = random.choice(list(self.templates[category].values()))
        point = self.control_point.position
        # Pick from preset locations
        object_id = 0
        group_id = self.game.next_group_id()

        # TODO: Create only one TGO per objective, each with multiple units.
        for unit in template:
            object_id += 1

            template_point = Point(unit["offset"].x, unit["offset"].y)
            g = BuildingGroundObject(obj_name,
                                     category,
                                     group_id,
                                     object_id,
                                     point + template_point,
                                     unit["heading"],
                                     self.control_point,
                                     unit["type"],
                                     airbase_group=True)
            self.control_point.connected_objectives.append(g)
Esempio n. 4
0
    def generate_ground_point(self) -> None:
        try:
            category = random.choice(self.faction.building_set)
        except IndexError:
            logging.exception("Faction has no buildings defined")
            return

        obj_name = namegen.random_objective_name()
        template = random.choice(list(self.templates[category].values()))

        if category == "oil":
            location_type = LocationType.OffshoreStrikeTarget
        else:
            location_type = LocationType.StrikeTarget

        # Pick from preset locations
        point = self.location_finder.location_for(location_type)
        if point is None:
            return

        object_id = 0
        group_id = self.game.next_group_id()

        # TODO: Create only one TGO per objective, each with multiple units.
        for unit in template:
            object_id += 1

            template_point = Point(unit["offset"].x, unit["offset"].y)
            g = BuildingGroundObject(obj_name, category, group_id, object_id,
                                     point + template_point, unit["heading"],
                                     self.control_point, unit["type"])

            self.control_point.connected_objectives.append(g)
Esempio n. 5
0
    def generate_tgo_for_scenery(self, scenery: SceneryGroup) -> None:
        # Special Handling for scenery Objects based on trigger zones
        g = BuildingGroundObject(
            namegen.random_objective_name(),
            scenery.category,
            scenery.position,
            Heading.from_degrees(0),
            self.control_point,
        )
        ground_group = TheaterGroup(
            self.game.next_group_id(),
            scenery.zone_def.name,
            PointWithHeading.from_point(scenery.position,
                                        Heading.from_degrees(0)),
            [],
            g,
        )
        g.groups.append(ground_group)
        # Each nested trigger zone is a target/building/unit for an objective.
        for zone in scenery.zones:
            scenery_unit = SceneryUnit(
                zone.id,
                zone.name,
                dcs.statics.Fortification.White_Flag,
                PointWithHeading.from_point(zone.position,
                                            Heading.from_degrees(0)),
                g,
            )
            scenery_unit.zone = zone
            ground_group.units.append(scenery_unit)

        self.control_point.connected_objectives.append(g)
Esempio n. 6
0
 def create_ground_object(
     self,
     name: str,
     position: PointWithHeading,
     control_point: ControlPoint,
 ) -> BuildingGroundObject:
     return BuildingGroundObject(
         name,
         self.category,
         position,
         position.heading,
         control_point,
         self.category == "fob",
     )