public override void Render() { switch (m_oSystemContect.SSEntity) { case StarSystemEntityType.TaskGroup: TaskGroupTN TaskGroup = m_oSystemContect.Entity as TaskGroupTN; /// <summary> /// Update this contact's sensor elements. /// </summary> if (TaskGroup.SensorUpdateAck != _LastSensorUpdateAck) { /// <summary> /// Remove those sensors that are no longer active. /// </summary> BindingList <Guid> SensorRemoveList = new BindingList <Guid>(); foreach (KeyValuePair <Guid, SensorElement> SCE in _SensorContactElements) { switch (SCE.Value._sensorType) { case ComponentTypeTN.ActiveSensor: ActiveSensorTN aSensor = (SCE.Value.SceenEntity as ActiveSensorTN); if (aSensor.isActive == false || aSensor.isDestroyed == true || ParentSceen.ShowActives == false) { SensorRemoveList.Add(SCE.Key); } break; case ComponentTypeTN.PassiveSensor: PassiveSensorTN pSensor = (SCE.Value.SceenEntity as PassiveSensorTN); /// <summary> /// Remove this sensor if it is destroyed, or if it isn't the current best thermal/em sensor. if a sensor is destroyed it should be replaced as the best em/thermal. /// </summary> if (pSensor.isDestroyed == true || ParentSceen.ShowPassives == false) { SensorRemoveList.Add(SCE.Key); } else { if (pSensor.pSensorDef.thermalOrEM == PassiveSensorType.Thermal) { if (pSensor != TaskGroup.BestThermal) { SensorRemoveList.Add(SCE.Key); } } else { if (pSensor != TaskGroup.BestEM) { SensorRemoveList.Add(SCE.Key); } } } break; } } if (SensorRemoveList.Count != 0) { foreach (Guid SCE in SensorRemoveList) { _SensorContactElements.Remove(SCE); } } if (_SensorContactElements.ContainsKey(TaskGroup.BestEM.pSensorDef.Id) == false && ParentSceen.ShowPassives == true) { PassiveSensorDefTN pSensorDef = TaskGroup.BestEM.pSensorDef; #warning all of these 10000.0's are related to the fact that distance is done by 10k km in Aurora. double factor = Constants.Units.KmPerAu / 10000.0; double AURadius = (double)pSensorDef.range * ((float)Constants.SensorTN.DefaultPassiveSignature / (float)ParentSceen.ShowPassiveSignatureRange) / factor; Vector3 TGPos = new Vector3((float)TaskGroup.Contact.Position.X, (float)TaskGroup.Contact.Position.Y, 0.0f); SensorElement NSE = new SensorElement(_DefaultEffect, TGPos, (float)AURadius, System.Drawing.Color.Blue, TaskGroup.BestEM.Name, TaskGroup.BestEM, TaskGroup.BestEM.pSensorDef.componentType, ParentSceen); _SensorContactElements.Add(TaskGroup.BestEM.pSensorDef.Id, NSE); } if (_SensorContactElements.ContainsKey(TaskGroup.BestThermal.pSensorDef.Id) == false && ParentSceen.ShowPassives == true) { PassiveSensorDefTN pSensorDef = TaskGroup.BestThermal.pSensorDef; double factor = Constants.Units.KmPerAu / 10000.0; double AURadius = (double)pSensorDef.range * ((float)Constants.SensorTN.DefaultPassiveSignature / (float)ParentSceen.ShowPassiveSignatureRange) / factor; Vector3 TGPos = new Vector3((float)TaskGroup.Contact.Position.X, (float)TaskGroup.Contact.Position.Y, 0.0f); SensorElement NSE = new SensorElement(_DefaultEffect, TGPos, (float)AURadius, System.Drawing.Color.Red, TaskGroup.BestThermal.Name, TaskGroup.BestThermal, TaskGroup.BestThermal.pSensorDef.componentType, ParentSceen); _SensorContactElements.Add(TaskGroup.BestThermal.pSensorDef.Id, NSE); } /// <summary> /// Check for newly activated sensors. /// </summary> if (ParentSceen.ShowActives == true) { foreach (ActiveSensorTN Sensor in TaskGroup.ActiveSensorQue) { /// <summary> /// This sensor survived the above cleanup, and is in the sensor contact element list, so don't re check whether it should be here. /// </summary> if (_SensorContactElements.ContainsKey(Sensor.aSensorDef.Id) == true) { continue; } ActiveSensorDefTN SensorDef = Sensor.aSensorDef; double factor = Constants.Units.KmPerAu / 10000.0; double AURadius = (double)SensorDef.maxRange / factor; Vector3 TGPos = new Vector3((float)TaskGroup.Contact.Position.X, (float)TaskGroup.Contact.Position.Y, 0.0f); SensorElement NSE = new SensorElement(_DefaultEffect, TGPos, (float)AURadius, System.Drawing.Color.Turquoise, Sensor.Name, Sensor, Sensor.aSensorDef.componentType, ParentSceen); _SensorContactElements.Add(SensorDef.Id, NSE); } } _LastSensorUpdateAck = TaskGroup.SensorUpdateAck; } break; case StarSystemEntityType.Population: Population CurrentPop = (m_oSystemContect.Entity as Population); /// <summary> /// Populations only have one sensor element. /// </summary> _SensorContactElements.Clear(); if (CurrentPop._sensorUpdateAck != _LastSensorUpdateAck && ParentSceen.ShowPassives == true) { /// <summary> /// This calculates the default detection distance for strength 1000 signatures. /// </summary> int DSTS = (int)Math.Floor(CurrentPop.Installations[(int)Installation.InstallationType.DeepSpaceTrackingStation].Number); int SensorTech = CurrentPop.Faction.FactionTechLevel[(int)Faction.FactionTechnology.DSTSSensorStrength]; if (SensorTech > Constants.Colony.DeepSpaceMax) { SensorTech = Constants.Colony.DeepSpaceMax; } #warning if EM strength differs from Thermal handle that here. int ScanStrength = DSTS * Constants.Colony.ThermalDeepSpaceStrength[SensorTech] * 100; double factor = Constants.Units.KmPerAu / 10000.0; double AURadius = (double)ScanStrength * ((float)Constants.SensorTN.DefaultPassiveSignature / (float)ParentSceen.ShowPassiveSignatureRange) / factor; Vector3 PopPosition = new Vector3((float)CurrentPop.Contact.Position.X, (float)CurrentPop.Contact.Position.Y, 0.0f); /// <summary> /// Type is set to TypeCount because only the taskgroup section requires it. Likewise for CurrentPop, and CurrentPop.Id, these aren't strictly necessary, but the /// taskgroup section requires more information as more sensor contact elements can be associated with a taskgroup. /// </summary> SensorElement NSE = new SensorElement(_DefaultEffect, PopPosition, (float)AURadius, System.Drawing.Color.Purple, CurrentPop.Name + " DSTS Coverage", CurrentPop, ComponentTypeTN.TypeCount, ParentSceen); _SensorContactElements.Add(CurrentPop.Id, NSE); } break; case StarSystemEntityType.Missile: OrdnanceGroupTN MissileGroup = (m_oSystemContect.Entity as OrdnanceGroupTN); /// <summary> /// This ordnance group was just created, so check whether or not any sensors need to be displayed. Or the display could request that passives or actives not be displayed. /// </summary> if (_LastSensorUpdateAck != MissileGroup._sensorUpdateAck) { _SensorContactElements.Clear(); OrdnanceDefTN OrdDef = MissileGroup.missiles[0].missileDef; if (OrdDef.aSD != null && ParentSceen.ShowActives == true) { double factor = Constants.Units.KmPerAu / 10000.0; double AURadius = (double)OrdDef.aSD.maxRange / factor; Vector3 MGPos = new Vector3((float)MissileGroup.contact.Position.X, (float)MissileGroup.contact.Position.Y, 0.0f); SensorElement NSE = new SensorElement(_DefaultEffect, MGPos, (float)AURadius, System.Drawing.Color.Turquoise, MissileGroup.missiles[0].missileDef.Name + " Active Sensor", MissileGroup, ComponentTypeTN.TypeCount, ParentSceen); _SensorContactElements.Add(OrdDef.aSD.Id, NSE); } if (OrdDef.tHD != null && ParentSceen.ShowPassives == true) { double factor = Constants.Units.KmPerAu / 10000.0; double AURadius = (double)OrdDef.tHD.range * ((float)Constants.SensorTN.DefaultPassiveSignature / (float)ParentSceen.ShowPassiveSignatureRange) / factor; Vector3 MGPos = new Vector3((float)MissileGroup.contact.Position.X, (float)MissileGroup.contact.Position.Y, 0.0f); SensorElement NSE = new SensorElement(_DefaultEffect, MGPos, (float)AURadius, System.Drawing.Color.Red, MissileGroup.missiles[0].missileDef.Name + " Thermal Sensor", MissileGroup, ComponentTypeTN.TypeCount, ParentSceen); _SensorContactElements.Add(OrdDef.tHD.Id, NSE); } if (OrdDef.eMD != null && ParentSceen.ShowPassives == true) { double factor = Constants.Units.KmPerAu / 10000.0; double AURadius = (double)OrdDef.eMD.range * ((float)Constants.SensorTN.DefaultPassiveSignature / (float)ParentSceen.ShowPassiveSignatureRange) / factor; Vector3 MGPos = new Vector3((float)MissileGroup.contact.Position.X, (float)MissileGroup.contact.Position.Y, 0.0f); SensorElement NSE = new SensorElement(_DefaultEffect, MGPos, (float)AURadius, System.Drawing.Color.Blue, MissileGroup.missiles[0].missileDef.Name + " EM Sensor", MissileGroup, ComponentTypeTN.TypeCount, ParentSceen); _SensorContactElements.Add(OrdDef.eMD.Id, NSE); } _LastSensorUpdateAck = MissileGroup._sensorUpdateAck; } break; } foreach (GLPrimitive oPrimitive in m_lPrimitives) { oPrimitive.Render(); } /// <summary> /// Adding sensor elements to children causes wierd behavior that I'd rather not deal with. /// </summary> foreach (KeyValuePair <Guid, SensorElement> sElement in _SensorContactElements) { sElement.Value.Render(); } if (RenderChildren == true) { foreach (SceenElement oElement in m_lChildren) { oElement.Render(); } } // render lable: if (m_oLable != null) { m_oLable.Render(); } }
public override void Refresh(float a_fZoomScaler) { // Adjust the size of the Primary Sprite (the TG icon) if necessary. if (MinimumSize.X > 0 && MinimumSize.Y > 0) { // calc size in pixels given current zoom factor: Vector2 v2CurrSize = RealSize * a_fZoomScaler; if (MinimumSize.X > v2CurrSize.X && MinimumSize.Y > v2CurrSize.Y) { // then it is too small, make it display at a proper size: PrimaryPrimitive.SetSize(MinimumSize / a_fZoomScaler); } else { // we want to draw to scale: PrimaryPrimitive.SetSize(RealSize); } } /// <summary> /// update position of the selected contact and its travelline: /// </summary> Vector3 pos = Vector3.Zero, lastPos = Vector3.Zero; switch (m_oSystemContect.SSEntity) { case StarSystemEntityType.TaskGroup: pos = new Vector3((float)m_oSystemContect.Position.X, (float)m_oSystemContect.Position.Y, 0.0f); lastPos = new Vector3((float)m_oSystemContect.LastPosition.X, (float)m_oSystemContect.LastPosition.Y, 0.0f); TaskGroupTN TaskGroup = m_oSystemContect.Entity as TaskGroupTN; if (TaskGroup.DrawTravelLine != 3) { m_oTravelLine.StartPos = lastPos; m_oTravelLine.EndPos = pos; } else if (TaskGroup.DrawTravelLine == 3) { m_oTravelLine.StartPos = pos; m_oTravelLine.EndPos = pos; } if (TaskGroup.DrawTravelLine == 2) { TaskGroup.DrawTravelLine = 3; } break; case StarSystemEntityType.Population: break; case StarSystemEntityType.Missile: pos = new Vector3((float)m_oSystemContect.Position.X, (float)m_oSystemContect.Position.Y, 0.0f); lastPos = new Vector3((float)m_oSystemContect.LastPosition.X, (float)m_oSystemContect.LastPosition.Y, 0.0f); OrdnanceGroupTN MissileGroup = m_oSystemContect.Entity as OrdnanceGroupTN; if (MissileGroup.DrawTravelLine != 3) { m_oTravelLine.StartPos = lastPos; m_oTravelLine.EndPos = pos; } else if (MissileGroup.DrawTravelLine == 3) { m_oTravelLine.StartPos = pos; m_oTravelLine.EndPos = pos; } if (MissileGroup.DrawTravelLine == 2) { MissileGroup.DrawTravelLine = 3; } break; } PrimaryPrimitive.Position = pos; Lable.Position = pos; // Adjust the size of the text so it is always 10 point: Lable.Size = UIConstants.DEFAULT_TEXT_SIZE / a_fZoomScaler; switch (m_oSystemContect.SSEntity) { case StarSystemEntityType.TaskGroup: Lable.Text = m_oSystemContect.Entity.Name; break; } // loop through any children: foreach (SceenElement oElement in m_lChildren) { oElement.Refresh(a_fZoomScaler); } }
/// <summary> /// creates a new post sceen creation contact element. /// </summary> /// <param name="a_oDefaultEffect">default effect, I don't know what these are really.</param> /// <param name="oContact">The system contact to be created.</param> public void AddContactElement(GLEffect a_oDefaultEffect, SystemContact oContact) { SceenElement oContactElement; Vector3 v3ContactPos; GLUtilities.GLFont oNameLable; GLUtilities.GLQuad oContactQuad; switch (oContact.SSEntity) { case StarSystemEntityType.TaskGroup: TaskGroupTN TaskGroup = oContact.Entity as TaskGroupTN; oContactElement = new ContactElement(a_oDefaultEffect, oContact); oContactElement.EntityID = oContact.Id; v3ContactPos = new Vector3((float)TaskGroup.Contact.Position.X, (float)TaskGroup.Contact.Position.Y, 0.0f); oContactQuad = new GLUtilities.GLQuad(a_oDefaultEffect, v3ContactPos, new Vector2(0.0001f, 0.0001f), // what size is a task groug anyway??? oContact.faction.FactionColor, UIConstants.Textures.DEFAULT_TASKGROUP_ICON); oNameLable = new GLUtilities.GLFont(a_oDefaultEffect, v3ContactPos, UIConstants.DEFAULT_TEXT_SIZE, oContact.faction.FactionColor, UIConstants.Textures.DEFAULT_GLFONT2, TaskGroup.Name); oContactElement.Lable = oNameLable; oContactElement.Lable.Size = UIConstants.DEFAULT_TEXT_SIZE / m_fZoomScaler; //Initial taskgroup names weren't being scaled properly for whatever reason. oContactElement.PrimaryPrimitive = oContactQuad; oContactElement.AddPrimitive(oContactQuad); oContactElement.RealSize = new Vector2(0.0001f, 0.0001f); this.AddElement(oContactElement); (oContactElement as ContactElement).ParentSceen = this; break; case StarSystemEntityType.Missile: OrdnanceGroupTN MissileGroup = oContact.Entity as OrdnanceGroupTN; oContactElement = new ContactElement(a_oDefaultEffect, oContact); oContactElement.EntityID = oContact.Id; v3ContactPos = new Vector3((float)MissileGroup.contact.Position.X, (float)MissileGroup.contact.Position.Y, 0.0f); oContactQuad = new GLUtilities.GLQuad(a_oDefaultEffect, v3ContactPos, new Vector2(0.0001f, 0.0001f), // what size is a missile? oContact.faction.FactionColor, UIConstants.Textures.DEFAULT_TASKGROUP_ICON); oNameLable = new GLUtilities.GLFont(a_oDefaultEffect, v3ContactPos, UIConstants.DEFAULT_TEXT_SIZE, oContact.faction.FactionColor, UIConstants.Textures.DEFAULT_GLFONT2, MissileGroup.Name); oContactElement.Lable = oNameLable; oContactElement.Lable.Size = UIConstants.DEFAULT_TEXT_SIZE / m_fZoomScaler; //Same problem may exist with missile labels. oContactElement.PrimaryPrimitive = oContactQuad; oContactElement.AddPrimitive(oContactQuad); oContactElement.RealSize = new Vector2(0.0001f, 0.0001f); this.AddElement(oContactElement); (oContactElement as ContactElement).ParentSceen = this; break; case StarSystemEntityType.Population: Population CurrentPopulation = oContact.Entity as Population; oContactElement = new ContactElement(a_oDefaultEffect, oContact); oContactElement.EntityID = oContact.Id; v3ContactPos = new Vector3((float)CurrentPopulation.Contact.Position.X, (float)CurrentPopulation.Contact.Position.Y, 0.0f); oContactQuad = new GLUtilities.GLQuad(a_oDefaultEffect, v3ContactPos, new Vector2(0.0001f, 0.0001f), // what size is a population? oContact.faction.FactionColor, UIConstants.Textures.DEFAULT_TASKGROUP_ICON); oNameLable = new GLUtilities.GLFont(a_oDefaultEffect, v3ContactPos, UIConstants.DEFAULT_TEXT_SIZE, oContact.faction.FactionColor, UIConstants.Textures.DEFAULT_GLFONT2, CurrentPopulation.Name); oContactElement.Lable = oNameLable; oContactElement.Lable.Size = UIConstants.DEFAULT_TEXT_SIZE / m_fZoomScaler; //Same problem may exist with population labels. oContactElement.PrimaryPrimitive = oContactQuad; oContactElement.AddPrimitive(oContactQuad); oContactElement.RealSize = new Vector2(0.0001f, 0.0001f); this.AddElement(oContactElement); (oContactElement as ContactElement).ParentSceen = this; break; } }
/// <summary> /// Fire this MFC in point defense mode. /// </summary> /// <param name="TG">Taskgroup the MFC is in</param> /// <param name="FiredFrom">Ship the MFC is on</param> /// <param name="Target">Target of point defense fire.</param> /// <param name="MissilesToFire">Number of missiles to fire at it</param> /// <returns></returns> public int FireWeaponsPD(TaskGroupTN TG, ShipTN FiredFrom, OrdnanceGroupTN Target, int MissilesToFire) { /// <summary> /// simple stupid sanity check. /// </summary> if (MissilesToFire == 0) { return(0); } int LaunchCount = 0; /// <summary> /// Just a temporary variable for this function. /// </summary> BindingList <OrdnanceGroupTN> LocalMissileGroups = new BindingList <OrdnanceGroupTN>(); foreach (MissileLauncherTN LaunchTube in m_lLinkedWeapons) //int loop = 0; loop < LinkedWeapons.Count; loop++) { if (LaunchTube.isDestroyed == false && LaunchTube.loadTime == 0 && LaunchTube.loadedOrdnance != null) { if (FiredFrom.ShipOrdnance.ContainsKey(LaunchTube.loadedOrdnance) == true) { OrdnanceTN newMissile = new OrdnanceTN(this, LaunchTube.loadedOrdnance, FiredFrom); /// <summary> /// Point defense does not go by MFC targetting. have to add target here. /// </summary> newMissile.target = new TargetTN(Target); LaunchCount++; /// <summary> /// Create a new missile group /// </summary> if (LocalMissileGroups.Count == 0) { OrdnanceGroupTN newMissileGroup = new OrdnanceGroupTN(TG, newMissile); LocalMissileGroups.Add(newMissileGroup); TG.TaskGroupFaction.MissileGroups.Add(newMissileGroup); /// <summary> /// Add this ordnance group to the ord groups targetting list for the intended target missile group. /// This is only necessary here as Manually fired MFC missiles are connected to their MFC. /// </summary> Target.ordGroupsTargetting.Add(newMissileGroup); } /// <summary> /// An existing missile group may be useable. /// </summary> else { bool foundGroup = false; foreach (OrdnanceGroupTN OrdGroup in LocalMissileGroups) { /// <summary> /// All Missile groups should be composed of just 1 type of missile for convienence. if (OrdGroup.missiles[0].missileDef.Id == LaunchTube.loadedOrdnance.Id) { OrdGroup.AddMissile(newMissile); foundGroup = true; break; } } /// <summary> /// Have to create a new missile group after all. /// </summary> if (foundGroup == false) { OrdnanceGroupTN newMissileGroup = new OrdnanceGroupTN(TG, newMissile); LocalMissileGroups.Add(newMissileGroup); TG.TaskGroupFaction.MissileGroups.Add(newMissileGroup); /// <summary> /// Add this ordnance group to the ord groups targetting list for the intended target missile group. /// This is only necessary here as Manually fired MFC missiles are connected to their MFC. /// </summary> Target.ordGroupsTargetting.Add(newMissileGroup); } } /// <summary> /// Decrement the loaded ordnance count, and remove the type entirely if this was the last one. /// </summary> FiredFrom.ShipOrdnance[LaunchTube.loadedOrdnance] = FiredFrom.ShipOrdnance[LaunchTube.loadedOrdnance] - 1; if (FiredFrom.ShipOrdnance[LaunchTube.loadedOrdnance] == 0) { FiredFrom.ShipOrdnance.Remove(LaunchTube.loadedOrdnance); } /// <summary> /// Set the launch tube cooldown time as a missile was just fired from it. /// </summary> LaunchTube.loadTime = LaunchTube.missileLauncherDef.rateOfFire; if (LaunchCount == MissilesToFire) { break; } } else { String Msg = String.Format("No ordnance {0} on ship {1} is available for Launch Tube {2} in PD Mode", LaunchTube.Name, FiredFrom.Name, LaunchTube.Name); MessageEntry newMessage = new MessageEntry(MessageEntry.MessageType.FiringNoAvailableOrdnance, TG.Contact.Position.System, TG.Contact, GameState.Instance.GameDateTime, GameState.Instance.LastTimestep, Msg); TG.TaskGroupFaction.MessageLog.Add(newMessage); } } else if (LaunchTube.isDestroyed == true) { String Msg = String.Format("Destroyed launch tube {0} is still attached to {1}'s MFC in PD Mode", LaunchTube.Name, FiredFrom.Name); MessageEntry newMessage = new MessageEntry(MessageEntry.MessageType.Error, TG.Contact.Position.System, TG.Contact, GameState.Instance.GameDateTime, GameState.Instance.LastTimestep, Msg); TG.TaskGroupFaction.MessageLog.Add(newMessage); } else if (LaunchTube.loadedOrdnance == null) { String Msg = String.Format("No loaded ordnance for launch tube {0} on ship {1} in PD Mode", LaunchTube.Name, FiredFrom.Name); MessageEntry newMessage = new MessageEntry(MessageEntry.MessageType.FiringNoLoadedOrdnance, TG.Contact.Position.System, TG.Contact, GameState.Instance.GameDateTime, GameState.Instance.LastTimestep, Msg); TG.TaskGroupFaction.MessageLog.Add(newMessage); } } return(LaunchCount); }
/// <summary> /// Fire Weapons spawns new missiles groups or adds missiles to existing ones. /// </summary> /// <param name="TG">Taskgroup this MFC is in.</param> /// <param name="FiredFrom">Ship these missiles were fired from.</param> /// <returns>If missiles were fired at all from this MFC. true = atleast 1 missile(and therefore missile group, false = no missiles.</returns> public bool FireWeapons(TaskGroupTN TG, ShipTN FiredFrom) { bool retv = false; if (m_oTarget != null) { /// <summary> /// Just a temporary variable for this function. /// </summary> BindingList <OrdnanceGroupTN> LocalMissileGroups = new BindingList <OrdnanceGroupTN>(); foreach (MissileLauncherTN LaunchTube in m_lLinkedWeapons) { if (LaunchTube.isDestroyed == false && LaunchTube.loadTime == 0 && LaunchTube.loadedOrdnance != null) { if (FiredFrom.ShipOrdnance.ContainsKey(LaunchTube.loadedOrdnance) == true) { OrdnanceTN newMissile = new OrdnanceTN(this, LaunchTube.loadedOrdnance, FiredFrom); /// <summary> /// Create a new missile group /// </summary> if (LocalMissileGroups.Count == 0) { OrdnanceGroupTN newMissileGroup = new OrdnanceGroupTN(TG, newMissile); LocalMissileGroups.Add(newMissileGroup); TG.TaskGroupFaction.MissileGroups.Add(newMissileGroup); } /// <summary> /// An existing missile group may be useable. /// </summary> else { bool foundGroup = false; foreach (OrdnanceGroupTN OrdGroup in LocalMissileGroups) { /// <summary> /// All Missile groups should be composed of just 1 type of missile for convienence. if (OrdGroup.missiles[0].missileDef.Id == LaunchTube.loadedOrdnance.Id) { OrdGroup.AddMissile(newMissile); foundGroup = true; break; } } /// <summary> /// Have to create a new missile group after all. /// </summary> if (foundGroup == false) { OrdnanceGroupTN newMissileGroup = new OrdnanceGroupTN(TG, newMissile); LocalMissileGroups.Add(newMissileGroup); TG.TaskGroupFaction.MissileGroups.Add(newMissileGroup); } } /// <summary> /// Decrement the loaded ordnance count, and remove the type entirely if this was the last one. /// </summary> FiredFrom.ShipOrdnance[LaunchTube.loadedOrdnance] = FiredFrom.ShipOrdnance[LaunchTube.loadedOrdnance] - 1; if (FiredFrom.ShipOrdnance[LaunchTube.loadedOrdnance] == 0) { FiredFrom.ShipOrdnance.Remove(LaunchTube.loadedOrdnance); } /// <summary> /// Set the launch tube cooldown time as a missile was just fired from it. /// </summary> LaunchTube.loadTime = LaunchTube.missileLauncherDef.rateOfFire; /// <summary> /// return that a missile was launched. /// </summary> retv = true; } else { String Msg = String.Format("No ordnance {0} on ship {1} is available for Launch Tube {2}", LaunchTube.Name, FiredFrom.Name, LaunchTube.Name); MessageEntry newMessage = new MessageEntry(MessageEntry.MessageType.FiringNoAvailableOrdnance, TG.Contact.Position.System, TG.Contact, GameState.Instance.GameDateTime, GameState.Instance.LastTimestep, Msg); TG.TaskGroupFaction.MessageLog.Add(newMessage); } } else if (LaunchTube.isDestroyed == true) { String Msg = String.Format("Destroyed launch tube {0} is still attached to {1}'s MFC", LaunchTube.Name, FiredFrom.Name); MessageEntry newMessage = new MessageEntry(MessageEntry.MessageType.Error, TG.Contact.Position.System, TG.Contact, GameState.Instance.GameDateTime, GameState.Instance.LastTimestep, Msg); TG.TaskGroupFaction.MessageLog.Add(newMessage); } else if (LaunchTube.loadedOrdnance == null) { String Msg = String.Format("No loaded ordnance for launch tube {0} on ship {1}", LaunchTube.Name, FiredFrom.Name); MessageEntry newMessage = new MessageEntry(MessageEntry.MessageType.FiringNoLoadedOrdnance, TG.Contact.Position.System, TG.Contact, GameState.Instance.GameDateTime, GameState.Instance.LastTimestep, Msg); TG.TaskGroupFaction.MessageLog.Add(newMessage); } } return(retv); } else { return(false); } }
/// <summary> /// Simple assignment of a missile group as the target of this MFC /// </summary> /// <param name="OrdnanceTarget">missile group to be targetted.</param> public void assignTarget(OrdnanceGroupTN OrdnanceTarget) { m_oTarget = new TargetTN(OrdnanceTarget); }
/// <summary> /// Constructor for Missile group targets. /// </summary> /// <param name="OGTarget">missile targeted on.</param> public TargetTN(OrdnanceGroupTN OGTarget) : base() { TargetType = OGTarget.SSEntity; MissileGroup = OGTarget; }