cleaner way of adding a faction parameter

to the groupgenerator constructor
This commit is contained in:
David Pierron
2020-10-27 10:06:22 +01:00
parent a465dde32f
commit 14a3279b2c
2 changed files with 5 additions and 2 deletions

View File

@@ -9,6 +9,10 @@ class GenericSamGroupGenerator(GroupGenerator):
"""
This is the base for all SAM group generators
"""
def __init__(self, game, ground_object, faction):
self.faction = faction
super(GenericSamGroupGenerator, self).__init__(game, ground_object)
@property
def groupNamePrefix(self) -> str:

View File

@@ -8,12 +8,11 @@ from dcs.unit import Vehicle
class GroupGenerator():
def __init__(self, game, ground_object, faction = None): # faction is not mandatory because some subclasses do not use it
def __init__(self, game, ground_object):
self.game = game
self.go = ground_object
self.position = ground_object.position
self.heading = random.randint(0, 359)
self.faction = faction
self.vg = unitgroup.VehicleGroup(self.game.next_group_id(), self.groupNamePrefix + self.go.group_identifier)
wp = self.vg.add_waypoint(self.position, PointAction.OffRoad, 0)
wp.ETA_locked = True