def MakeLOGPAC(self): ''' Create a generic supply LOGPAC ''' out = sandbox_entity(template='LOGPAC', sim=self) out['OPORD'] = OPORD(out,out) out['OPORD']['SERVICE AND SUPPORT']['MATERIEL']['SUPPLY']['minimum'] = 0.01 return out
def AsEntity(self, uid): ''' Return ta pointer regardless of whether uid is a pointer or an integer. ''' if type(uid) == type(sandbox_entity()): return uid # Look for the correct unit in the master OOB for i in range(len(self.OOB)): if self.OOB[i]['uid'] == uid: return self.OOB[i] # All else failed, return none. return None
def LoadSide(self, doc, node): '''! \brief Load a side and all associated information into the simulator. ''' # Color name self.sides[doc.Get(node,'name').upper()] = doc.Get(node,'color') # OOB oob = doc.Get(node,'OOB') # Make sure that there is a OOB node in the side node if oob != '': for unit in doc.Get(oob,'unit', True): # CASE 1: The unit must be imported if doc.Get(unit, 'import'): name = doc.Get(unit, 'import').replace('/','.') # Form a correct path path = os.path.join(self.OS['savepath'], doc.Get(node,'name'), name, 'current.xml') # Read in the unit's description if os.path.exists(path): udoc = sandboXML(read=path) x = udoc.Get(udoc.root, 'unit') # Look for a template definition x = sandbox_entity(sim=self,template=udoc.Get(x,'template')) del udoc else: raise SandboxException('UnitDescriptionNotFound',path) # CASE 2: The units must be loaded from this file else: # Add Side information doc.AddField('side', doc.Get(node,'name').upper(), unit) # Build unit from template x = sandbox_entity(sim=self,template=doc.Get(unit,'template')) # Read in the state data x.fromXML(doc, unit) # Add to world self.AddEntity(x)
def MakeConvoy(self): ''' Make a generic convoy. TODO: right now, this is just a pair of HMVEEs (placeholder) ''' return sandbox_entity(template='US-light-scout-section', sim=self)