Vega strike Python Modules doc  0.5.1
Documentation of the " Modules " folder of Vega strike
 All Data Structures Namespaces Files Functions Variables
Environment Class Reference
Inheritance diagram for Environment:

Public Member Functions

def CreateUnit
 
def __init__
 
def Execute
 
def AlwaysExecute
 
def ApplyEventualEnvironment
 

Data Fields

 iter
 
 num_un
 

Detailed Description

Definition at line 7 of file car_lib.py.

Constructor & Destructor Documentation

def __init__ (   self,
  numcar,
  numspec 
)

Definition at line 14 of file car_lib.py.

14 
15  def __init__ (self,numcar, numspec):
16  Director.Mission.__init__(self)
17  print 'initing'
18  self.iter=0
19  self.num_un=0
20  for i in range(numcar):
21  self.CreateUnit ("porsche")
22  for i in range(numspec):
self.CreateUnit ("car")

Member Function Documentation

def AlwaysExecute (   self)

Definition at line 31 of file car_lib.py.

References car_lib.isCar().

31 
32  def AlwaysExecute(self):
33  self.EventualExecute()
34  iter = VS.getUnitList ()
35  un = iter.current()
36  playa = VS.getPlayer()
37  while (un):
38  if (isCar(un)):
39  self.ApplyPerFrameEnvironment (un,playa)
40  iter.advance()
un = iter.current()
def ApplyEventualEnvironment (   self,
  un,
  playa 
)

Definition at line 41 of file car_lib.py.

41 
42  def ApplyEventualEnvironment(self,un,playa):
43  if (playa):
44  if (playa!=un):
45  posdiff = playa.Position()[2]-un.Position()[2]
46  if ((posdiff*(2*(posdiff>0)-1))>1500):
47  R = un.GetOrientation ()[2]
48 
49  if (posdiff*R[2]<0):
50  pos=(un.Position()[0],0,playa.Position()[2]+4000*(2*(R[2]<0)-1),)
51  un.SetCurPosition (pos)
52  print "repositioning"
53 # def ApplyPerFrameEnvironment (self,un,playa):
54  pos = un.Position()
55  vel = un.GetVelocity()
56  if (pos[1]!=0):
57  pos=(pos[0],0,pos[2])
58  un.SetCurPosition(pos)
59  if (vel[1]!=0):
60  vel = (vel[0],0,vel[2])
61  un.SetVelocity(vel)
62  if (vel[0]!=0):
63  vel = (0,vel[1],vel[2])
64  un.SetVelocity(vel)
def CreateUnit (   self,
  name 
)

Definition at line 8 of file car_lib.py.

References Environment.num_un.

8 
9  def CreateUnit (self, name):
10  evenodd= (2*(self.num_un %2) - 1)
11  x_coord = -evenodd * 30
12  un = VS.launch ("traffic",name,"neutral", "unit","modules/traffic.py",1,1,(x_coord,0,self.num_un*100),'')
13  un.SetOrientation ((0,1,0),(0,0,evenodd))
self.num_un+=1
def Execute (   self)

Definition at line 23 of file car_lib.py.

References Environment.ApplyEventualEnvironment(), car_lib.isCar(), and Environment.iter.

23 
24  def Execute(self):
25  un = VS.getUnit (self.iter)
26  if (un):
27  if (isCar(un)):
28  self.ApplyEventualEnvironment (un,VS.getPlayer())
29  self.iter+=1
30  else:
self.iter=0

Field Documentation

iter

Definition at line 17 of file car_lib.py.

num_un

Definition at line 18 of file car_lib.py.


The documentation for this class was generated from the following file: