mirror of
https://github.com/dcs-liberation/dcs_liberation.git
synced 2025-11-10 14:22:26 +00:00
Single ShipGroupGenerator added
This commit is contained in:
parent
4ca92ea22d
commit
9087f3487d
@ -1,14 +1,10 @@
|
||||
import random
|
||||
|
||||
from gen.sam.group_generator import GroupGenerator
|
||||
from gen.sam.group_generator import ShipGroupGenerator
|
||||
|
||||
|
||||
class CarrierGroupGenerator(GroupGenerator):
|
||||
|
||||
def __init__(self, game, ground_object, faction):
|
||||
super(CarrierGroupGenerator, self).__init__(game, ground_object)
|
||||
self.faction = faction
|
||||
|
||||
class CarrierGroupGenerator(ShipGroupGenerator):
|
||||
|
||||
def generate(self):
|
||||
|
||||
# Add carrier
|
||||
|
||||
@ -1,15 +1,11 @@
|
||||
import random
|
||||
|
||||
from gen.fleet.dd_group import DDGroupGenerator
|
||||
from gen.sam.group_generator import GroupGenerator
|
||||
from gen.sam.group_generator import ShipGroupGenerator
|
||||
from dcs.ships import *
|
||||
|
||||
|
||||
class ChineseNavyGroupGenerator(GroupGenerator):
|
||||
|
||||
def __init__(self, game, ground_object, faction):
|
||||
super(ChineseNavyGroupGenerator, self).__init__(game, ground_object)
|
||||
self.faction = faction
|
||||
class ChineseNavyGroupGenerator(ShipGroupGenerator):
|
||||
|
||||
def generate(self):
|
||||
|
||||
|
||||
@ -1,40 +1,19 @@
|
||||
import random
|
||||
|
||||
from gen.sam.group_generator import GroupGenerator
|
||||
from dcs import unitgroup
|
||||
from dcs.point import PointAction
|
||||
from dcs.unit import Ship
|
||||
from gen.sam.group_generator import ShipGroupGenerator
|
||||
from dcs.ships import *
|
||||
|
||||
|
||||
class DDGroupGenerator(GroupGenerator):
|
||||
class DDGroupGenerator(ShipGroupGenerator):
|
||||
|
||||
def __init__(self, game, ground_object, faction, ddtype):
|
||||
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
|
||||
super(DDGroupGenerator, self).__init__(game, ground_object, faction, ddtype)
|
||||
self.ddtype = ddtype
|
||||
|
||||
def generate(self):
|
||||
self.add_unit(self.ddtype, "DD1", self.position.x + 500, self.position.y + 900, self.heading)
|
||||
self.add_unit(self.ddtype, "DD2", self.position.x + 500, self.position.y - 900, self.heading)
|
||||
self.get_generated_group().points[0].speed = 20
|
||||
|
||||
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
|
||||
|
||||
|
||||
|
||||
|
||||
@ -1,13 +1,9 @@
|
||||
import random
|
||||
|
||||
from gen.sam.group_generator import GroupGenerator
|
||||
from gen.sam.group_generator import ShipGroupGenerator
|
||||
|
||||
|
||||
class LHAGroupGenerator(GroupGenerator):
|
||||
|
||||
def __init__(self, game, ground_object, faction):
|
||||
super(LHAGroupGenerator, self).__init__(game, ground_object)
|
||||
self.faction = faction
|
||||
class LHAGroupGenerator(ShipGroupGenerator):
|
||||
|
||||
def generate(self):
|
||||
|
||||
|
||||
@ -1,15 +1,11 @@
|
||||
import random
|
||||
|
||||
from gen.fleet.dd_group import DDGroupGenerator
|
||||
from gen.sam.group_generator import GroupGenerator
|
||||
from gen.sam.group_generator import ShipGroupGenerator
|
||||
from dcs.ships import *
|
||||
|
||||
|
||||
class RussianNavyGroupGenerator(GroupGenerator):
|
||||
|
||||
def __init__(self, game, ground_object, faction):
|
||||
super(RussianNavyGroupGenerator, self).__init__(game, ground_object)
|
||||
self.faction = faction
|
||||
class RussianNavyGroupGenerator(ShipGroupGenerator):
|
||||
|
||||
def generate(self):
|
||||
|
||||
|
||||
@ -2,14 +2,10 @@ import random
|
||||
|
||||
from dcs.ships import Schnellboot_type_S130
|
||||
|
||||
from gen.sam.group_generator import GroupGenerator
|
||||
from gen.sam.group_generator import ShipGroupGenerator
|
||||
|
||||
|
||||
class SchnellbootGroupGenerator(GroupGenerator):
|
||||
|
||||
def __init__(self, game, ground_object, faction):
|
||||
super(SchnellbootGroupGenerator, self).__init__(game, ground_object)
|
||||
self.faction = faction
|
||||
class SchnellbootGroupGenerator(ShipGroupGenerator):
|
||||
|
||||
def generate(self):
|
||||
|
||||
|
||||
@ -11,6 +11,9 @@ from gen.fleet.ru_dd_group import RussianNavyGroupGenerator, GrishaGroupGenerato
|
||||
from gen.fleet.schnellboot import SchnellbootGroupGenerator
|
||||
from gen.fleet.uboat import UBoatGroupGenerator
|
||||
from gen.fleet.ww2lst import WW2LSTGroupGenerator
|
||||
# from dcs import unitgroup
|
||||
# from dcs.unit import Ship
|
||||
|
||||
|
||||
SHIP_MAP = {
|
||||
"SchnellbootGroupGenerator": SchnellbootGroupGenerator,
|
||||
@ -68,4 +71,27 @@ def generate_lha_group(faction:str, game, ground_object):
|
||||
"""
|
||||
generator = LHAGroupGenerator(game, ground_object, db.FACTIONS[faction])
|
||||
generator.generate()
|
||||
return generator.get_generated_group()
|
||||
return generator.get_generated_group()
|
||||
|
||||
# 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
|
||||
|
||||
@ -2,14 +2,10 @@ import random
|
||||
|
||||
from dcs.ships import Uboat_VIIC_U_flak
|
||||
|
||||
from gen.sam.group_generator import GroupGenerator
|
||||
from gen.sam.group_generator import ShipGroupGenerator
|
||||
|
||||
|
||||
class UBoatGroupGenerator(GroupGenerator):
|
||||
|
||||
def __init__(self, game, ground_object, faction):
|
||||
super(UBoatGroupGenerator, self).__init__(game, ground_object)
|
||||
self.faction = faction
|
||||
class UBoatGroupGenerator(ShipGroupGenerator):
|
||||
|
||||
def generate(self):
|
||||
|
||||
|
||||
@ -2,14 +2,10 @@ import random
|
||||
|
||||
from dcs.ships import LS_Samuel_Chase, LST_Mk_II
|
||||
|
||||
from gen.sam.group_generator import GroupGenerator
|
||||
from gen.sam.group_generator import ShipGroupGenerator
|
||||
|
||||
|
||||
class WW2LSTGroupGenerator(GroupGenerator):
|
||||
|
||||
def __init__(self, game, ground_object, faction):
|
||||
super(WW2LSTGroupGenerator, self).__init__(game, ground_object)
|
||||
self.faction = faction
|
||||
class WW2LSTGroupGenerator(ShipGroupGenerator):
|
||||
|
||||
def generate(self):
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user