///<inheritdoc/> public override int GetHashCode() { int hash = 17; // Overflow is fine, just wrap unchecked { hash = (hash * 29) + PaintScheme.GetHashCode(); hash = (hash * 29) + Propulsion.GetHashCode(); hash = (hash * 29) + Damage.GetHashCode(); hash = (hash * 29) + Smoke.GetHashCode(); hash = (hash * 29) + TrailingEffects.GetHashCode(); hash = (hash * 29) + Canopy.GetHashCode(); hash = (hash * 29) + LandingLights.GetHashCode(); hash = (hash * 29) + NavigationLights.GetHashCode(); hash = (hash * 29) + AntiCollisionLights.GetHashCode(); hash = (hash * 29) + Flaming.GetHashCode(); hash = (hash * 29) + Afterburner.GetHashCode(); hash = (hash * 29) + FrozenStatus.GetHashCode(); hash = (hash * 29) + PowerPlantStatus.GetHashCode(); hash = (hash * 29) + State.GetHashCode(); hash = (hash * 29) + FormationLights.GetHashCode(); hash = (hash * 29) + SpotLights.GetHashCode(); hash = (hash * 29) + InteriorLights.GetHashCode(); } return(hash); }
public void RegisterPropulsion(Vector3 dir, Propulsion propulsion, Action action = null) { Propulsion copy = new Propulsion(propulsion); propulsions.Add(copy); copy.Start(dir, action, this); }
void SetupWheels() { wheeltransformList.Clear(); wheelcolliderList.Clear(); wheelsComponent.Clear(); wheeltransformList.Add(FL_Wheel); wheelcolliderList.Add(FL_WheelCollider); wheelsComponent.Add(FL_WheelCollider.GetComponent <Wheels>()); wheeltransformList.Add(FR_Wheel); wheelcolliderList.Add(FR_WheelCollider); wheelsComponent.Add(FR_WheelCollider.GetComponent <Wheels>()); wheeltransformList.Add(RL_Wheel); wheelcolliderList.Add(RL_WheelCollider); wheelsComponent.Add(RL_WheelCollider.GetComponent <Wheels>()); wheeltransformList.Add(RR_Wheel); wheelcolliderList.Add(RR_WheelCollider); wheelsComponent.Add(RR_WheelCollider.GetComponent <Wheels>()); for (int i = 0; i < wheelsComponent.Count; i++) { wheelsComponent[i].SetupWheelCollider(50, 25000, 2000); } //Set no traction for the drift race type if (RaceManager.instance && RaceManager.instance._raceType == RaceManager.RaceType.Drift) { traction = 0; steerHelper = 0; if (_propulsion == Propulsion.FWD) { _propulsion = Propulsion.RWD; Debug.Log("Setting propulsion to RWD for the drift race"); } } }
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { Propulsion propulsion = fieldInfo.GetValue(property.serializedObject.targetObject) as Propulsion; property.isExpanded = EditorGUI.Foldout(CustomEditorUtility.GetPropertyRect(0, position), property.isExpanded, property.name); if (property.isExpanded) { CustomEditorUtility.QuickSerializeRelativeGUI("separateAxes", property, position, 1); float w = EditorGUIUtility.labelWidth; EditorGUIUtility.labelWidth = 0.01f; if (propulsion.separateAxes) { CustomEditorUtility.QuickSerializeRelativeGUI("strengthHoriz", property, CustomEditorUtility.GetPropertyRect(2, position, 0, 0.5f, position.width)); CustomEditorUtility.QuickSerializeRelativeGUI("curveHoriz", property, CustomEditorUtility.GetPropertyRect(2, position, 0.5f, 0.5f, position.width)); CustomEditorUtility.QuickSerializeRelativeGUI("strengthVerti", property, CustomEditorUtility.GetPropertyRect(3, position, 0, 0.5f, position.width)); CustomEditorUtility.QuickSerializeRelativeGUI("curveVerti", property, CustomEditorUtility.GetPropertyRect(3, position, 0.5f, 0.5f, position.width)); } else { CustomEditorUtility.QuickSerializeRelativeGUI("strength", property, CustomEditorUtility.GetPropertyRect(2, position, 0, 0.5f, position.width)); CustomEditorUtility.QuickSerializeRelativeGUI("curve", property, CustomEditorUtility.GetPropertyRect(2, position, 0.5f, 0.5f, position.width)); } EditorGUIUtility.labelWidth = w; int start = propulsion.separateAxes ? 4 : 3; CustomEditorUtility.QuickSerializeRelativeGUI("duration", property, position, start, 0, 1, position.width); CustomEditorUtility.QuickSerializeRelativeGUI("airControl", property, position, start + 1, 0, 1, position.width); CustomEditorUtility.QuickSerializeRelativeGUI("direction", property, position, start + 2, 0, 1, position.width); CustomEditorUtility.QuickSerializeRelativeGUI("priority", property, position, start + 3, 0, 1, position.width); } property.serializedObject.ApplyModifiedProperties(); }
public NavigationTree(FighterBlackboard blackboard, Navigator navigator, Propulsion prop) { m_blackboard = blackboard; m_propulsion = prop; m_topSpeed = prop.thrust * 5; // this is just bad AddBehaviour <Behaviour>().BUpdate = GetDestinationToTarget; Selector shootOrTraverse = AddBehaviour <Selector>(); { // completely redundant //Sequence shoot = shootOrTraverse.AddBehaviour<Sequence>(); //{ // shoot.AddBehaviour<Condition>().BCanRun = TargetEnteringRange; // shoot.AddBehaviour<Behaviour>().BUpdate = TurnToTarget; //} Sequence traverse = shootOrTraverse.AddBehaviour <Sequence>(); { traverse.AddBehaviour <Behaviour>().BUpdate = Stabilize; traverse.AddBehaviour <Behaviour>().BUpdate = SetDestination; Sequence stayInFormation = traverse.AddBehaviour <Sequence>(); { stayInFormation.AddBehaviour <Condition>().BCanRun = HasWingman; stayInFormation.AddBehaviour <Behaviour>().BUpdate = VectoringThrust; } } shootOrTraverse.AddBehaviour <Behaviour>().BUpdate = CommonBehaviours.AlwaysSucceed; } AddBehaviour <Behaviour>().BUpdate = SetThrottle; }
void Start() { weaponVisuals = gameObject.transform.Find("visibleLazer").gameObject; weaponVisuals.transform.parent = gameObject.transform; weapon = (gameObject.tag == "Team1") ? new Lazer(Color.red, 20.0f, 20.0f, weaponVisuals) : new Lazer(Color.green, 20.0f, 20.0f, weaponVisuals); m_rigidbody = gameObject.AddComponent <Rigidbody>(); m_rigidbody.useGravity = false; m_propulsion = new Propulsion(m_rigidbody, gameObject, m_thrust, m_turnRate); InitializeBlackboard(); spaceManager = GameObject.FindGameObjectWithTag("SpaceManager").GetComponent <SpaceManager>(); }
public Propulsion(Propulsion copy) { this.strength = copy.strength; this.curve = copy.curve; this.duration = copy.duration; this.airControl = copy.airControl; this.direction = copy.direction; this.priority = copy.priority; this.strengthHoriz = copy.strengthHoriz; this.strengthVerti = copy.strengthVerti; this.curveHoriz = copy.curveHoriz; this.curveVerti = copy.curveVerti; this.separateAxes = copy.separateAxes; }
// private float Thrust_Ammount(float max_trust) { // } private void ActivateModule(string key, Enums.enum_movment_type movtype = Enums.enum_movment_type.none) { if (key_bindings.ContainsKey(key)) { List <KeyMapping> key_mappings = key_bindings[key] as List <KeyMapping>; foreach (KeyMapping m in key_mappings) { Propulsion p = m.module.GetComponentInChildren <Propulsion>(); if (p != null) { if (movtype != Enums.enum_movment_type.none) { if (movtype == Enums.enum_movment_type.rotation) { p.Activate(Calc_Rotation_Trust(p.Get_Calculated_Thrust(), speed_break_drag) * thrust_rotate_affect); } else if (movtype == Enums.enum_movment_type.strife) { p.Activate(Calc_Strife_Trust(p.Get_Calculated_Thrust(), speed_break_drag) * thrust_strife_affect); } else if (movtype == Enums.enum_movment_type.forward_backward) { p.Activate(Calc_forward_Trust(p.Get_Calculated_Thrust(), speed_break_drag) * thrust_forward_affect); } } else { if (m.movement_type == Enums.enum_movment_type.rotation) { p.Activate(Mathf.Abs(Calc_Rotation_Trust(p.Get_Calculated_Thrust(m.value)))); } else if (m.movement_type == Enums.enum_movment_type.strife) { p.Activate(Mathf.Abs(Calc_Strife_Trust(p.Get_Calculated_Thrust(m.value)))); } else if (m.movement_type == Enums.enum_movment_type.forward_backward) { p.Activate(p.Get_Calculated_Thrust(m.value) * Calc_Percentage_Forward()); // p.Activate(Mathf.Abs(Calc_forward_Trust(p.Get_Calculated_Thrust(m.value), Calc_Percentage_Forward()))); } else { p.Activate(p.Get_Calculated_Thrust(m.value)); } } } } } }
private void DeActivateModule(string key) { if (key_bindings.ContainsKey(key)) { List <KeyMapping> key_mappings = key_bindings[key] as List <KeyMapping>; foreach (KeyMapping m in key_mappings) { Propulsion p = m.module.GetComponentInChildren <Propulsion>(); if (p != null) { p.Deactivate(); } } } }
private Propulsion GetPropulsion(string name) { GameObject go = GameObject.Find(name); if (go != null) { Propulsion p = go.GetComponentInChildren <Propulsion>(); p.Set_PlayerObj(gameObject); return(p); } else { return(null); } }
public void Initialize() { List <Module> AllModules = new List <Module>() { Logger, Propulsion, Rotation, Navigation, Communications, Planets }; AllModules.AddRange(CustomModules); SaveState.Initialize(AllModules); Logger.Initialize(null); Propulsion.Initialize(); Rotation.Initialize(); Navigation.Initialize(); Communications.Initialize(null); Logger.Log("Initialization Complete!"); Initialized = true; }
public Propulsion Current() { if (propulsions.Count == 0) { return(null); } else { Propulsion propulsion = propulsions[0]; for (int i = 0; i < propulsions.Count; i++) { if (!(propulsions[i].priority < propulsion.priority)) { propulsion = propulsions[i]; } } return(propulsion); } }
public Vector3 Velocity() { if (propulsions.Count == 0) { return(Vector3.zero); } else { Propulsion propulsion = propulsions[0]; for (int i = 0; i < propulsions.Count; i++) { if (!(propulsions[i].priority < propulsion.priority)) { propulsion = propulsions[i]; } } //Debug.Log(propulsion.Vector); return(propulsion.Vector); } }
public Ship(IMyGridTerminalSystem gts, IMyShipController ControllerBlock, MyGridProgram Me) { if (ControllerBlock == null) { throw new ArgumentNullException("ControllerBlock"); } GridTerminalSystem = gts; this.ControllerBlock = ControllerBlock; this.Me = Me; ShipData = new ShipData(this); ShipData.Update(); Logger = new Logger(this); Propulsion = new Propulsion(this); Rotation = new Rotation(this); Planets = new Planets(this); Navigation = new Navigation(this); Communications = new CommManager(this); SaveState = new SaveState(this); EventScheduler = new EventScheduler(); CustomModules = new List <Module>(); }
public void AddKeyBinding(KeyMappingModel mapping, GameObject module) { if (!string.IsNullOrEmpty(mapping.Key)) { Propulsion p = module.GetComponent <Propulsion>(); if (p != null) { p.Set_PlayerObj(gameObject); } if (key_bindings.ContainsKey(mapping.Key)) { List <KeyMapping> mappings = key_bindings[mapping.Key] as List <KeyMapping>; KeyMapping map = ScriptableObject.CreateInstance <KeyMapping>(); map.Key = mapping.Key; map.value = mapping.value; map.movement_type = mapping.movement_type; map.module = module; Debug.Log("Updating Mapping" + mapping.Key); mappings.Add(map); } else { List <KeyMapping> mappings = new List <KeyMapping>(); KeyMapping map = ScriptableObject.CreateInstance <KeyMapping>(); map.Key = mapping.Key; map.value = mapping.value; map.movement_type = mapping.movement_type; map.module = module; Debug.Log("Adding Mapping" + mapping.Key); mappings.Add(map); key_bindings.Add(mapping.Key, mappings); } } }
public Navigator(Propulsion prop) { m_propulsion = prop; destination = prop.rigidbody.position; }
public void Start() { _seeker = GetComponent <Seeker>(); _repathTimeout = RepathTimeoutInterval; _propulsionScript = AttachedPropulsion.GetComponent <Propulsion>(); }
public void Start() { _seeker = GetComponent<Seeker>(); _repathTimeout = RepathTimeoutInterval; _propulsionScript = AttachedPropulsion.GetComponent<Propulsion>(); }
private string PropulsionToString(Propulsion propulsion) { return(propulsion.ToString()); }
private bool Allocate() { bool result = true; atmosphere = new Atmosphere(this); propulsion = new Propulsion(this); aerodynamics = new Aerodynamics(this); FCS = new FlightControlSystem(this); groundReactions = new GroundReactions(this); inertial = new Inertial(this); massBalance = new MassBalance(this); propagate = new Propagate(this); auxiliary = new Auxiliary(this); aircraft = new Aircraft(this); //output = new Output(this); input = new Input(this); groundCallback = new GroundCallback(); state = new State(this); // This must be done here, as the State // class needs valid pointers to the above model classes // Initialize models so they can communicate with each other if (!atmosphere.InitModel()) { if (log.IsErrorEnabled) { log.Error("Atmosphere model init failed"); } error += 1; } if (!FCS.InitModel()) { if (log.IsErrorEnabled) { log.Error("FCS model init failed"); } error += 2; } if (!propulsion.InitModel()) { if (log.IsErrorEnabled) { log.Error("Propulsion model init failed"); } error += 4; } if (!massBalance.InitModel()) { if (log.IsErrorEnabled) { log.Error("MassBalance model init failed"); } error += 8; } if (!aerodynamics.InitModel()) { if (log.IsErrorEnabled) { log.Error("Aerodynamics model init failed"); } error += 16; } if (!inertial.InitModel()) { if (log.IsErrorEnabled) { log.Error("Inertial model init failed"); } error += 32; } if (!groundReactions.InitModel()) { if (log.IsErrorEnabled) { log.Error("Ground Reactions model init failed"); } error += 64; } if (!aircraft.InitModel()) { if (log.IsErrorEnabled) { log.Error("Aircraft model init failed"); } error += 128; } if (!propagate.InitModel()) { if (log.IsErrorEnabled) { log.Error("Propagate model init failed"); } error += 256; } if (!auxiliary.InitModel()) { if (log.IsErrorEnabled) { log.Error("Auxiliary model init failed"); } error += 512; } if (!input.InitModel()) { if (log.IsErrorEnabled) { log.Error("Intput model init failed"); } error += 1024; } if (error > 0) { result = false; } ic = new InitialCondition(this); // Schedule a model. The second arg (the integer) is the pass number. For // instance, the atmosphere model gets executed every fifth pass it is called // by the executive. Everything else here gets executed each pass. // IC and Trim objects are NOT scheduled. Schedule(input, 1); Schedule(atmosphere, 1); Schedule(FCS, 1); Schedule(propulsion, 1); Schedule(massBalance, 1); Schedule(aerodynamics, 1); Schedule(inertial, 1); Schedule(groundReactions, 1); Schedule(aircraft, 1); Schedule(propagate, 1); Schedule(auxiliary, 1); //Schedule(output, 1); modelLoaded = false; return(result); }
public ProductBuilder SetPropulsion(Propulsion propulsion) { _product.Propulsion = propulsion; return(this); }
public void RegisterPropulsion(Propulsion propulsion, Action action = null) { RegisterPropulsion(Vector3.zero, propulsion, action); }
public Result LoadDirectory(string path) { var returnResult = new Result(string.Format("Loading object data from \"{0}\"", path)); path = PathUtil.EndWithPathSeperator(path); var subDirNames = ""; var subDirStructures = ""; var subDirBrain = ""; var subDirBody = ""; var subDirPropulsion = ""; var subDirBodyPropulsion = ""; var subDirConstruction = ""; var subDirSensor = ""; var subDirRepair = ""; var subDirTemplates = ""; var subDirWeapons = ""; var subDirEcm = ""; var subDirFeatures = ""; var subDirTexpages = ""; var subDirAssignWeapons = ""; var subDirStructureWeapons = ""; var subDirPiEs = ""; subDirNames = "messages".CombinePathWith("strings").CombinePathWith("names.txt"); subDirStructures = "stats".CombinePathWith("structures.txt"); subDirBrain = "stats".CombinePathWith("brain.txt"); subDirBody = "stats".CombinePathWith("body.txt"); subDirPropulsion = "stats".CombinePathWith("propulsion.txt"); subDirBodyPropulsion = "stats".CombinePathWith("bodypropulsionimd.txt"); subDirConstruction = "stats".CombinePathWith("construction.txt"); subDirSensor = "stats".CombinePathWith("sensor.txt"); subDirRepair = "stats".CombinePathWith("repair.txt"); subDirTemplates = "stats".CombinePathWith("templates.txt"); subDirWeapons = "stats".CombinePathWith("weapons.txt"); subDirEcm = "stats".CombinePathWith("ecm.txt"); subDirFeatures = "stats".CombinePathWith("features.txt"); subDirPiEs = "pies".CombinePathWith("", endWithPathSeparator: true); subDirTexpages = "texpages".CombinePathWith("", endWithPathSeparator: true); subDirAssignWeapons = "stats".CombinePathWith("assignweapons.txt"); subDirStructureWeapons = "stats".CombinePathWith("structureweapons.txt"); var commaFiles = new SimpleList <clsTextFile>(); var dataNames = new clsTextFile { SubDirectory = subDirNames, UniqueField = 0 }; returnResult.Add(dataNames.LoadNamesFile(path)); if (!dataNames.CalcUniqueField()) { returnResult.ProblemAdd("There are two entries for the same code in " + subDirNames + "."); } var dataStructures = new clsTextFile { SubDirectory = subDirStructures, FieldCount = 25 }; commaFiles.Add(dataStructures); var dataBrain = new clsTextFile { SubDirectory = subDirBrain, FieldCount = 9 }; commaFiles.Add(dataBrain); var dataBody = new clsTextFile { SubDirectory = subDirBody, FieldCount = 25 }; commaFiles.Add(dataBody); var dataPropulsion = new clsTextFile { SubDirectory = subDirPropulsion, FieldCount = 12 }; commaFiles.Add(dataPropulsion); var dataBodyPropulsion = new clsTextFile { SubDirectory = subDirBodyPropulsion, FieldCount = 5, UniqueField = -1 }; commaFiles.Add(dataBodyPropulsion); var dataConstruction = new clsTextFile { SubDirectory = subDirConstruction, FieldCount = 12 }; commaFiles.Add(dataConstruction); var dataSensor = new clsTextFile { SubDirectory = subDirSensor, FieldCount = 16 }; commaFiles.Add(dataSensor); var dataRepair = new clsTextFile { SubDirectory = subDirRepair, FieldCount = 14 }; commaFiles.Add(dataRepair); var dataTemplates = new clsTextFile { SubDirectory = subDirTemplates, FieldCount = 12 }; commaFiles.Add(dataTemplates); var dataEcm = new clsTextFile { SubDirectory = subDirEcm, FieldCount = 14 }; commaFiles.Add(dataEcm); var dataFeatures = new clsTextFile { SubDirectory = subDirFeatures, FieldCount = 11 }; commaFiles.Add(dataFeatures); var dataAssignWeapons = new clsTextFile { SubDirectory = subDirAssignWeapons, FieldCount = 5 }; commaFiles.Add(dataAssignWeapons); var dataWeapons = new clsTextFile { SubDirectory = subDirWeapons, FieldCount = 53 }; commaFiles.Add(dataWeapons); var dataStructureWeapons = new clsTextFile { SubDirectory = subDirStructureWeapons, FieldCount = 6 }; commaFiles.Add(dataStructureWeapons); foreach (var textFile in commaFiles) { var result = textFile.LoadCommaFile(path); returnResult.Add(result); if (!result.HasProblems) { if (textFile.CalcIsFieldCountValid()) { if (!textFile.CalcUniqueField()) { returnResult.ProblemAdd("An entry in field " + Convert.ToString(textFile.UniqueField) + " was not unique for file " + textFile.SubDirectory + "."); } } else { returnResult.ProblemAdd("There were entries with the wrong number of fields for file " + textFile.SubDirectory + "."); } } } if (returnResult.HasProblems) { return(returnResult); } //load texpages string[] texFiles = null; try { texFiles = Directory.GetFiles(path + subDirTexpages); } catch (Exception) { returnResult.WarningAdd("Unable to access texture pages."); texFiles = new string[0]; } var text = ""; Bitmap bitmap = null; foreach (var texFile in texFiles) { text = texFile; if (text.Substring(text.Length - 4, 4).ToLower() == ".png") { var result = new Result(string.Format("Loading texture page \"{0}\"", text)); if (File.Exists(text)) { SimpleResult bitmapResult = BitmapUtil.LoadBitmap(text, ref bitmap); var newPage = new clsTexturePage(); if (bitmapResult.Success) { result.Take(BitmapUtil.BitmapIsGlCompatible(bitmap)); newPage.GLTexture_Num = BitmapUtil.CreateGLTexture(bitmap, 0); } else { result.WarningAdd(bitmapResult.Problem); } var instrPos2 = text.LastIndexOf(Path.DirectorySeparatorChar); newPage.FileTitle = text.Substring(instrPos2 + 1, text.Length - 5 - instrPos2); TexturePages.Add(newPage); } else { result.WarningAdd("Texture page missing (" + text + ")."); } returnResult.Add(result); } } //load PIEs string[] pieFiles = null; var pieList = new SimpleList <clsPIE>(); try { pieFiles = Directory.GetFiles(path + subDirPiEs); } catch (Exception) { returnResult.WarningAdd("Unable to access PIE files."); pieFiles = new string[0]; } foreach (var tempLoopVar_Text in pieFiles) { text = tempLoopVar_Text; var splitPath = new sSplitPath(text); if (splitPath.FileExtension.ToLower() == "pie") { var newPie = new clsPIE { Path = text, LCaseFileTitle = splitPath.FileTitle.ToLower() }; pieList.Add(newPie); } } //interpret stats clsAttachment attachment; clsAttachment baseAttachment; Body body; Propulsion propulsion; Weapon weapon; Sensor sensor; Ecm ecm; string[] fields = null; //interpret body foreach (var tempLoopVar_Fields in dataBody.ResultData) { fields = tempLoopVar_Fields; body = new Body(); body.ObjectDataLink.Connect(Bodies); body.Code = fields[0]; SetComponentName(dataNames.ResultData, body, returnResult); IOUtil.InvariantParse(fields[6], ref body.Hitpoints); body.Designable = fields[24] != "0"; body.Attachment.Models.Add(GetModelForPIE(pieList, fields[7].ToLower(), returnResult)); } //interpret propulsion foreach (var tempLoopVar_Fields in dataPropulsion.ResultData) { fields = tempLoopVar_Fields; propulsion = new Propulsion(Bodies.Count); propulsion.ObjectDataLink.Connect(Propulsions); propulsion.Code = fields[0]; SetComponentName(dataNames.ResultData, propulsion, returnResult); IOUtil.InvariantParse(fields[7], ref propulsion.HitPoints); //.Propulsions(Propulsion_Num).PIE = LCase(DataPropulsion.Entries(Propulsion_Num).FieldValues(8)) propulsion.Designable = fields[11] != "0"; } //interpret body-propulsions var bodyPropulsionPIEs = new BodyProp[Bodies.Count, Propulsions.Count]; for (var A = 0; A <= Bodies.Count - 1; A++) { for (var B = 0; B <= Propulsions.Count - 1; B++) { bodyPropulsionPIEs[A, B] = new BodyProp(); bodyPropulsionPIEs[A, B].LeftPIE = "0"; bodyPropulsionPIEs[A, B].RightPIE = "0"; } } foreach (var tempLoopVar_Fields in dataBodyPropulsion.ResultData) { fields = tempLoopVar_Fields; body = FindBodyCode(fields[0]); propulsion = FindPropulsionCode(fields[1]); if (body != null && propulsion != null) { if (fields[2] != "0") { bodyPropulsionPIEs[body.ObjectDataLink.ArrayPosition, propulsion.ObjectDataLink.ArrayPosition].LeftPIE = fields[2].ToLower(); } if (fields[3] != "0") { bodyPropulsionPIEs[body.ObjectDataLink.ArrayPosition, propulsion.ObjectDataLink.ArrayPosition].RightPIE = fields[3].ToLower(); } } } //set propulsion-body PIEs for (var a = 0; a <= Propulsions.Count - 1; a++) { propulsion = Propulsions[a]; for (var B = 0; B <= Bodies.Count - 1; B++) { body = Bodies[B]; propulsion.Bodies[B].LeftAttachment = new clsAttachment(); propulsion.Bodies[B].LeftAttachment.Models.Add(GetModelForPIE(pieList, bodyPropulsionPIEs[B, a].LeftPIE, returnResult)); propulsion.Bodies[B].RightAttachment = new clsAttachment(); propulsion.Bodies[B].RightAttachment.Models.Add(GetModelForPIE(pieList, bodyPropulsionPIEs[B, a].RightPIE, returnResult)); } } //interpret construction foreach (var tempLoopVar_Fields in dataConstruction.ResultData) { fields = tempLoopVar_Fields; Construct Construct = new Construct(); Construct.ObjectDataLink.Connect(Constructors); Construct.TurretObjectDataLink.Connect(Turrets); Construct.Code = fields[0]; SetComponentName(dataNames.ResultData, Construct, returnResult); Construct.Designable = fields[11] != "0"; Construct.Attachment.Models.Add(GetModelForPIE(pieList, fields[8].ToLower(), returnResult)); } //interpret weapons foreach (var tempLoopVar_Fields in dataWeapons.ResultData) { fields = tempLoopVar_Fields; weapon = new Weapon(); weapon.ObjectDataLink.Connect(Weapons); weapon.TurretObjectDataLink.Connect(Turrets); weapon.Code = fields[0]; SetComponentName(dataNames.ResultData, weapon, returnResult); IOUtil.InvariantParse(fields[7], ref weapon.HitPoints); weapon.Designable = fields[51] != "0"; weapon.Attachment.Models.Add(GetModelForPIE(pieList, Convert.ToString(fields[8].ToLower()), returnResult)); weapon.Attachment.Models.Add(GetModelForPIE(pieList, fields[9].ToLower(), returnResult)); } //interpret sensor foreach (var tempLoopVar_Fields in dataSensor.ResultData) { fields = tempLoopVar_Fields; sensor = new Sensor(); sensor.ObjectDataLink.Connect(Sensors); sensor.TurretObjectDataLink.Connect(Turrets); sensor.Code = fields[0]; SetComponentName(dataNames.ResultData, sensor, returnResult); IOUtil.InvariantParse(fields[7], ref sensor.HitPoints); sensor.Designable = fields[15] != "0"; switch (fields[11].ToLower()) { case "turret": sensor.Location = SensorLocationType.Turret; break; case "default": sensor.Location = SensorLocationType.Invisible; break; default: sensor.Location = SensorLocationType.Invisible; break; } sensor.Attachment.Models.Add(GetModelForPIE(pieList, fields[8].ToLower(), returnResult)); sensor.Attachment.Models.Add(GetModelForPIE(pieList, fields[9].ToLower(), returnResult)); } //interpret repair foreach (var tempLoopVar_Fields in dataRepair.ResultData) { fields = tempLoopVar_Fields; Repair Repair = new Repair(); Repair.ObjectDataLink.Connect(Repairs); Repair.TurretObjectDataLink.Connect(Turrets); Repair.Code = fields[0]; SetComponentName(dataNames.ResultData, Repair, returnResult); Repair.Designable = fields[13] != "0"; Repair.Attachment.Models.Add(GetModelForPIE(pieList, fields[9].ToLower(), returnResult)); Repair.Attachment.Models.Add(GetModelForPIE(pieList, fields[10].ToLower(), returnResult)); } //interpret brain foreach (var tempLoopVar_Fields in dataBrain.ResultData) { fields = tempLoopVar_Fields; Brain Brain = new Brain(); Brain.ObjectDataLink.Connect(Brains); Brain.TurretObjectDataLink.Connect(Turrets); Brain.Code = fields[0]; SetComponentName(dataNames.ResultData, Brain, returnResult); Brain.Designable = true; weapon = FindWeaponCode(fields[7]); if (weapon != null) { Brain.Weapon = weapon; Brain.Attachment = weapon.Attachment; } } //interpret ecm foreach (var tempLoopVar_Fields in dataEcm.ResultData) { fields = tempLoopVar_Fields; ecm = new Ecm(); ecm.ObjectDataLink.Connect(ECMs); ecm.TurretObjectDataLink.Connect(Turrets); ecm.Code = fields[0]; SetComponentName(dataNames.ResultData, ecm, returnResult); IOUtil.InvariantParse(fields[7], ref ecm.HitPoints); ecm.Designable = false; ecm.Attachment.Models.Add(GetModelForPIE(pieList, fields[8].ToLower(), returnResult)); } //interpret feature foreach (var tempLoopVar_Fields in dataFeatures.ResultData) { fields = tempLoopVar_Fields; FeatureTypeBase featureTypeBase = new FeatureTypeBase(); featureTypeBase.UnitType_ObjectDataLink.Connect(UnitTypes); featureTypeBase.FeatureType_ObjectDataLink.Connect(FeatureTypes); featureTypeBase.Code = fields[0]; if (fields[7] == "OIL RESOURCE") //type { featureTypeBase.FeatureType = FeatureType.OilResource; } SetFeatureName(dataNames.ResultData, featureTypeBase, returnResult); if (!IOUtil.InvariantParse(fields[1], ref featureTypeBase.Footprint.X)) { returnResult.WarningAdd("Feature footprint-x was not an integer for " + featureTypeBase.Code + "."); } if (!IOUtil.InvariantParse(fields[2], ref featureTypeBase.Footprint.Y)) { returnResult.WarningAdd("Feature footprint-y was not an integer for " + featureTypeBase.Code + "."); } featureTypeBase.BaseAttachment = new clsAttachment(); baseAttachment = featureTypeBase.BaseAttachment; text = fields[6].ToLower(); attachment = baseAttachment.CreateAttachment(); attachment.Models.Add(GetModelForPIE(pieList, text, returnResult)); } //interpret structure foreach (var tempLoopVar_Fields in dataStructures.ResultData) { fields = tempLoopVar_Fields; var structureCode = fields[0]; var structureTypeText = fields[1]; var structurePiEs = fields[21].ToLower().Split('@'); var structureFootprint = new XYInt(); var structureBasePie = fields[22].ToLower(); if (!IOUtil.InvariantParse(fields[5], ref structureFootprint.X)) { returnResult.WarningAdd("Structure footprint-x was not an integer for " + structureCode + "."); } if (!IOUtil.InvariantParse(fields[6], ref structureFootprint.Y)) { returnResult.WarningAdd("Structure footprint-y was not an integer for " + structureCode + "."); } if (structureTypeText != "WALL" || structurePiEs.GetLength(0) != 4) { //this is NOT a generic wall StructureTypeBase structureTypeBase = new StructureTypeBase(); structureTypeBase.UnitType_ObjectDataLink.Connect(UnitTypes); structureTypeBase.StructureType_ObjectDataLink.Connect(StructureTypes); structureTypeBase.Code = structureCode; SetStructureName(dataNames.ResultData, structureTypeBase, returnResult); structureTypeBase.Footprint = structureFootprint; switch (structureTypeText) { case "DEMOLISH": structureTypeBase.StructureType = StructureType.Demolish; break; case "WALL": structureTypeBase.StructureType = StructureType.Wall; break; case "CORNER WALL": structureTypeBase.StructureType = StructureType.CornerWall; break; case "FACTORY": structureTypeBase.StructureType = StructureType.Factory; break; case "CYBORG FACTORY": structureTypeBase.StructureType = StructureType.CyborgFactory; break; case "VTOL FACTORY": structureTypeBase.StructureType = StructureType.VTOLFactory; break; case "COMMAND": structureTypeBase.StructureType = StructureType.Command; break; case "HQ": structureTypeBase.StructureType = StructureType.HQ; break; case "DEFENSE": structureTypeBase.StructureType = StructureType.Defense; break; case "POWER GENERATOR": structureTypeBase.StructureType = StructureType.PowerGenerator; break; case "POWER MODULE": structureTypeBase.StructureType = StructureType.PowerModule; break; case "RESEARCH": structureTypeBase.StructureType = StructureType.Research; break; case "RESEARCH MODULE": structureTypeBase.StructureType = StructureType.ResearchModule; break; case "FACTORY MODULE": structureTypeBase.StructureType = StructureType.FactoryModule; break; case "DOOR": structureTypeBase.StructureType = StructureType.DOOR; break; case "REPAIR FACILITY": structureTypeBase.StructureType = StructureType.RepairFacility; break; case "SAT UPLINK": structureTypeBase.StructureType = StructureType.DOOR; break; case "REARM PAD": structureTypeBase.StructureType = StructureType.RearmPad; break; case "MISSILE SILO": structureTypeBase.StructureType = StructureType.MissileSilo; break; case "RESOURCE EXTRACTOR": structureTypeBase.StructureType = StructureType.ResourceExtractor; break; default: structureTypeBase.StructureType = StructureType.Unknown; break; } baseAttachment = structureTypeBase.BaseAttachment; if (structurePiEs.GetLength(0) > 0) { baseAttachment.Models.Add(GetModelForPIE(pieList, structurePiEs[0], returnResult)); } structureTypeBase.StructureBasePlate = GetModelForPIE(pieList, structureBasePie, returnResult); if (baseAttachment.Models.Count == 1) { if (baseAttachment.Models[0].ConnectorCount >= 1) { XYZDouble connector = baseAttachment.Models[0].Connectors[0]; var StructureWeapons = default(SimpleList <string[]>); StructureWeapons = GetRowsWithValue(dataStructureWeapons.ResultData, structureTypeBase.Code); if (StructureWeapons.Count > 0) { weapon = FindWeaponCode(Convert.ToString(StructureWeapons[0][1])); } else { weapon = null; } ecm = FindECMCode(fields[18]); sensor = FindSensorCode(fields[19]); if (weapon != null) { if (weapon.Code != "ZNULLWEAPON") { attachment = baseAttachment.CopyAttachment(weapon.Attachment); attachment.PosOffset = connector; } } if (ecm != null) { if (ecm.Code != "ZNULLECM") { attachment = baseAttachment.CopyAttachment(ecm.Attachment); attachment.PosOffset = connector; } } if (sensor != null) { if (sensor.Code != "ZNULLSENSOR") { attachment = baseAttachment.CopyAttachment(sensor.Attachment); attachment.PosOffset = connector; } } } } } else { //this is a generic wall var newWall = new clsWallType(); newWall.WallType_ObjectDataLink.Connect(WallTypes); newWall.Code = structureCode; SetWallName(dataNames.ResultData, newWall, returnResult); var wallBasePlate = GetModelForPIE(pieList, structureBasePie, returnResult); var wallNum = 0; for (wallNum = 0; wallNum <= 3; wallNum++) { var wallStructureTypeBase = new StructureTypeBase(); wallStructureTypeBase.UnitType_ObjectDataLink.Connect(UnitTypes); wallStructureTypeBase.StructureType_ObjectDataLink.Connect(StructureTypes); wallStructureTypeBase.WallLink.Connect(newWall.Segments); wallStructureTypeBase.Code = structureCode; text = newWall.Name; switch (wallNum) { case 0: text += " - "; break; case 1: text += " + "; break; case 2: text += " T "; break; case 3: text += " L "; break; } wallStructureTypeBase.Name = text; wallStructureTypeBase.Footprint = structureFootprint; wallStructureTypeBase.StructureType = StructureType.Wall; baseAttachment = wallStructureTypeBase.BaseAttachment; text = structurePiEs[wallNum]; baseAttachment.Models.Add(GetModelForPIE(pieList, text, returnResult)); wallStructureTypeBase.StructureBasePlate = wallBasePlate; } } } //interpret templates var turretConflictCount = 0; foreach (var tempLoopVar_Fields in dataTemplates.ResultData) { fields = tempLoopVar_Fields; var template = new DroidTemplate(); template.UnitType_ObjectDataLink.Connect(UnitTypes); template.DroidTemplate_ObjectDataLink.Connect(DroidTemplates); template.Code = fields[0]; SetTemplateName(dataNames.ResultData, template, returnResult); switch (fields[9]) //type { case "ZNULLDROID": template.TemplateDroidType = App.TemplateDroidType_Null; break; case "DROID": template.TemplateDroidType = App.TemplateDroidType_Droid; break; case "CYBORG": template.TemplateDroidType = App.TemplateDroidType_Cyborg; break; case "CYBORG_CONSTRUCT": template.TemplateDroidType = App.TemplateDroidType_CyborgConstruct; break; case "CYBORG_REPAIR": template.TemplateDroidType = App.TemplateDroidType_CyborgRepair; break; case "CYBORG_SUPER": template.TemplateDroidType = App.TemplateDroidType_CyborgSuper; break; case "TRANSPORTER": template.TemplateDroidType = App.TemplateDroidType_Transporter; break; case "PERSON": template.TemplateDroidType = App.TemplateDroidType_Person; break; default: template.TemplateDroidType = null; returnResult.WarningAdd("Template " + template.GetDisplayTextCode() + " had an unrecognised type."); break; } var loadPartsArgs = new DroidDesign.sLoadPartsArgs(); loadPartsArgs.Body = FindBodyCode(fields[2]); loadPartsArgs.Brain = FindBrainCode(fields[3]); loadPartsArgs.Construct = FindConstructorCode(fields[4]); loadPartsArgs.ECM = FindECMCode(fields[5]); loadPartsArgs.Propulsion = FindPropulsionCode(fields[7]); loadPartsArgs.Repair = FindRepairCode(fields[8]); loadPartsArgs.Sensor = FindSensorCode(fields[10]); var templateWeapons = GetRowsWithValue(dataAssignWeapons.ResultData, template.Code); if (templateWeapons.Count > 0) { text = Convert.ToString(templateWeapons[0][1]); if (text != "NULL") { loadPartsArgs.Weapon1 = FindWeaponCode(text); } text = Convert.ToString(templateWeapons[0][2]); if (text != "NULL") { loadPartsArgs.Weapon2 = FindWeaponCode(text); } text = Convert.ToString(templateWeapons[0][3]); if (text != "NULL") { loadPartsArgs.Weapon3 = FindWeaponCode(text); } } if (!template.LoadParts(loadPartsArgs)) { if (turretConflictCount < 16) { returnResult.WarningAdd("Template " + template.GetDisplayTextCode() + " had multiple conflicting turrets."); } turretConflictCount++; } } if (turretConflictCount > 0) { returnResult.WarningAdd(turretConflictCount + " templates had multiple conflicting turrets."); } return(returnResult); }
public void RemovePropulsion(Propulsion propulsion) { //Debug.Log("Remove"); propulsions.Remove(propulsion); }
// Make all of the parts, FFS put this in a ScriptableObject dude!! void GenerateObjects() { // -------------------------------------------------------- // Initial parts structure totaly 100% riped and taken from // http://gridsagegames.com/wiki/Item // -------------------------------------------------------- // Starter Deffinitions Power newPower; Propulsion newPropulsion; Utility newUtility; Weapon newWeapon; Manipulation newManipulation; #region Power_Systems // ------------ Power System // --- Engines #region New_Item newPower = new Power(); newPower.partName = "Standard Engine"; newPower.powerStorage = 10; newPower.powerSupply = 2; newPower.genHeat = 1; parts.Add(newPower); #endregion // --- Power_cores #region New_Item newPower = new Power(); newPower.partName = "Standard Power Core"; newPower.powerStorage = 50; newPower.powerSupply = 1; newPower.genHeat = 3; parts.Add(newPower); #endregion // --- Reactors #region New_Item newPower = new Power(); newPower.partName = "Standard Reactor"; newPower.powerStorage = 25; newPower.powerSupply = 5; newPower.genHeat = 10; parts.Add(newPower); #endregion #endregion #region Propulsion_Parts // ------------ Propulsion Parts // --- Legs #region New_Item newPropulsion = new Propulsion(); newPropulsion.propulsionType = Propulsion.partType.Legs; newPropulsion.partName = "Standard Legs"; parts.Add(newPropulsion); #endregion // --- Treads #region New_Item newPropulsion = new Propulsion(); newPropulsion.propulsionType = Propulsion.partType.Treads; newPropulsion.partName = "Standard Tread"; parts.Add(newPropulsion); #endregion // --- Wheels #region New_Item newPropulsion = new Propulsion(); newPropulsion.propulsionType = Propulsion.partType.Wheels; newPropulsion.partName = "Standard Wheel"; parts.Add(newPropulsion); #endregion // --- Fighter Unit (Thrusters) #region New_Item newPropulsion = new Propulsion(); newPropulsion.propulsionType = Propulsion.partType.Fighter_Unit; newPropulsion.partName = "Standard Fighter Unit"; parts.Add(newPropulsion); #endregion // --- Hover Unit (Slower, Kinda Ion Engine types... ) #region New_Item newPropulsion = new Propulsion(); newPropulsion.propulsionType = Propulsion.partType.Hover_Unit; newPropulsion.partName = "Standard Hover Unit"; parts.Add(newPropulsion); #endregion #endregion // ------------ Utility Parts newUtility = new Utility(); parts.Add(newUtility); #region Weapon_Parts // ------------ Weapon Parts // --- Legs #region New_Item newWeapon = new Weapon(); newWeapon.weaponType = Weapon.partType.Ballistic_Cannon; parts.Add(newWeapon); #endregion #endregion // ------------ Manipulation Parts newManipulation = new Manipulation(); parts.Add(newManipulation); }
public void AddNavigation(Propulsion prop) { navigator = new Navigator(prop); navigationTree = new NavigationTree(this, navigator, prop); navigationTree = new Regulator(navigationTree, tickInterval); }