mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
Single ShipGroupGenerator added
This commit is contained in:
@@ -3,7 +3,7 @@ import random
|
||||
|
||||
from dcs import unitgroup
|
||||
from dcs.point import PointAction
|
||||
from dcs.unit import Vehicle
|
||||
from dcs.unit import Vehicle, Ship
|
||||
|
||||
|
||||
class GroupGenerator():
|
||||
@@ -75,3 +75,25 @@ class GroupGenerator():
|
||||
current_offset += outer_offset
|
||||
return positions
|
||||
|
||||
class ShipGroupGenerator(GroupGenerator):
|
||||
"""Abstract class for other ship generator classes"""
|
||||
def __init__(self, game, ground_object, faction):
|
||||
self.game = game
|
||||
self.go = ground_object
|
||||
self.position = ground_object.position
|
||||
self.heading = random.randint(0, 359)
|
||||
self.faction = faction
|
||||
self.vg = unitgroup.ShipGroup(self.game.next_group_id(), self.groupNamePrefix + self.go.group_identifier)
|
||||
wp = self.vg.add_waypoint(self.position, 0)
|
||||
wp.ETA_locked = True
|
||||
|
||||
def add_unit(self, unit_type, name, pos_x, pos_y, heading):
|
||||
nn = "cgroup|" + str(self.go.cp_id) + '|' + str(self.go.group_id) + '|' + str(self.go.group_identifier) + "|" + name
|
||||
|
||||
unit = Ship(self.game.next_unit_id(),
|
||||
nn, unit_type)
|
||||
unit.position.x = pos_x
|
||||
unit.position.y = pos_y
|
||||
unit.heading = heading
|
||||
self.vg.add_unit(unit)
|
||||
return unit
|
||||
|
||||
Reference in New Issue
Block a user