Пример #1
0
        /// <summary>
        /// This function removes contacts from the system wide contact list when a contact deletion event occurs.
        /// This happens whenever a ship is scrapped or otherwise destroyed, ships/fighters land on a hangar, missiles hit their target or run out of endurance, and jump point exits.
        /// </summary>
        /// <param name="Contact">Contact to be removed.</param>
        public void RemoveContact(SystemContact Contact)
        {
            int index = SystemContactList.IndexOf(Contact);

            if (index != -1)
            {
                /// <summary>
                /// Remove the contact from each of the faction contact lists as well as the System contact list.
                /// </summary>
                for (int loop = 0; loop < FactionDetectionLists.Count; loop++)
                {
                    FactionDetectionLists[loop].RemoveContact(index);
                }

                SystemContactList.Remove(Contact);

                /// <summary>
                /// Distance Table is updated every tick, and doesn't care about last tick's info. so deleting simply the last entry
                /// causes no issues with distance calculations.
                /// </summary>
                for (int loop = 0; loop < SystemContactList.Count; loop++)
                {
                    SystemContactList[loop].DistanceTable.RemoveAt(SystemContactList.Count - 1);
                    SystemContactList[loop].DistanceUpdate.RemoveAt(SystemContactList.Count - 1);
                }

                /// <summary>
                /// inform the display that this contact needs to be deleted.
                /// </summary>
                ContactDeleteList.Add(Contact);

                /// <summary>
                /// also clean up the contact create list if this contact hasn't been created yet by the display.
                /// </summary>
                if (ContactCreateList.Contains(Contact) == true)
                {
                    ContactCreateList.Remove(Contact);
                }
            }
            else
            {
                String       Entry  = String.Format("Index for the system contact list is {0} for system {1}", index, Name);
                MessageEntry Entry2 = new MessageEntry(MessageEntry.MessageType.Error, Contact.CurrentSystem, Contact,
                                                       GameState.Instance.GameDateTime, (GameState.SE.CurrentTick - GameState.SE.lastTick), Entry);
                GameState.Instance.Factions[0].MessageLog.Add(Entry2);
            }
        }
Пример #2
0
        /// <summary>
        /// Systems have to store a global(or perhaps system wide) list of contacts. This function adds a contact in the event one is generated.
        /// Generation events include construction, hangar launches, missile launches, and Jump Point Entry into the System.
        /// </summary>
        /// <param name="Contact">Contact to be added.</param>
        public void AddContact(SystemContact Contact)
        {
            /// <summary>
            /// Add a new entry to every distance table for every contact.
            /// </summary>
            for (int loop = 0; loop < SystemContactList.Count; loop++)
            {
                SystemContactList[loop].DistanceTable.Add(0.0f);
                SystemContactList[loop].DistanceUpdate.Add(-1);
            }


            SystemContactList.Add(Contact);
            Contact.UpdateSystem(this);

            /// <summary>
            /// Update all the faction contact lists with the new contact.
            /// </summary>
            for (int loop = 0; loop < FactionDetectionLists.Count; loop++)
            {
                FactionDetectionLists[loop].AddContact();
            }

            /// <summary>
            /// Inform the systemmap/sceen that a new contact needs to be created.
            /// </summary>
            ContactCreateList.Add(Contact);

            /// <summary>
            /// In the event that this contact is in the delete list, it probably means that this contact travelled through this system, left, and is back in the system, without being drawn.
            /// If so put it in the contactCreateList and take it out of the contactDeleteList.
            /// </summary>
            if (ContactDeleteList.Contains(Contact) == true)
            {
                ContactDeleteList.Remove(Contact);
            }
        }