mirror of
https://github.com/dcs-liberation/dcs_liberation.git
synced 2025-11-10 14:22:26 +00:00
This class does far too many things and the file is huge. Split it up into a few more classes.
43 lines
1.4 KiB
Python
43 lines
1.4 KiB
Python
import logging
|
|
|
|
from dcs.point import MovingPoint
|
|
from dcs.task import AttackGroup, WeaponType
|
|
|
|
from game.theater import TheaterGroundObject
|
|
from game.transfers import MultiGroupTransport
|
|
from .pydcswaypointbuilder import PydcsWaypointBuilder
|
|
|
|
|
|
class BaiIngressBuilder(PydcsWaypointBuilder):
|
|
def build(self) -> MovingPoint:
|
|
waypoint = super().build()
|
|
|
|
# TODO: Add common "UnitGroupTarget" base type.
|
|
group_names = []
|
|
target = self.package.target
|
|
if isinstance(target, TheaterGroundObject):
|
|
for group in target.groups:
|
|
group_names.append(group.name)
|
|
elif isinstance(target, MultiGroupTransport):
|
|
group_names.append(target.name)
|
|
else:
|
|
logging.error(
|
|
"Unexpected target type for BAI mission: %s",
|
|
target.__class__.__name__,
|
|
)
|
|
return waypoint
|
|
|
|
for group_name in group_names:
|
|
group = self.mission.find_group(group_name)
|
|
if group is None:
|
|
logging.error("Could not find group for BAI mission %s", group_name)
|
|
continue
|
|
|
|
task = AttackGroup(group.id, weapon_type=WeaponType.Auto)
|
|
task.params["attackQtyLimit"] = False
|
|
task.params["directionEnabled"] = False
|
|
task.params["altitudeEnabled"] = False
|
|
task.params["groupAttack"] = True
|
|
waypoint.tasks.append(task)
|
|
return waypoint
|