from UnityEngine import *

import Objective

class FlightGroup:
	def __init__(self, name, shipType, total, wave, factionName):
		self.go = GameObject("fg - %s" % name)
		self.fg = self.go.AddComponent("FlightGroup")
		self.fg.shipType = Resources.Load(shipType)
		self.fg.groupName = name
		self.fg.totalCraft = total
		self.fg.waveSize = wave
		self.fg.faction = Resources.Load(factionName)

	def startPosition(self, venue, delay, pos):
		self.go.transform.position = pos
		venue.flightGroups.Add(self.fg)
		self.fg.originationVenue = venue
		if delay > 0:
			self.fg.initialDelay = delay
		else:
			self.fg.indigenous = True
		return self

	def addObjective(self, flightgroup, percent, state):
		obj = Objective()
		obj.percent = percent
		obj.flightGroup = flightgroup
		obj.state = state
		self.fg.objectives.Add(obj)
		return self

	def playerControlled(self):
		self.fg.playerController = Resources.Load("Player")
		return self

