/// <summary> /// Creates a shallow copy of the tombstone item and adds it to the list of tombstones. Does not check if it already /// exists. Only safety is that multiple tombstones cannot be placed at the same mile marker. /// </summary> /// <param name="tombstoneItem">The tombstone Item.</param> public void Add(Tombstone tombstoneItem) { // Clone the tombstone. var tombstoneClone = tombstoneItem.Clone() as Tombstone; // Skip if the cloning fails. if (tombstoneClone == null) return; // Check if we already have a tombstone at this mile marker. if (Tombstones.ContainsKey(tombstoneClone.MileMarker)) return; // Actually adds the tombstone to the internal list of them using mile marker as a key. Tombstones.Add(tombstoneItem.MileMarker, tombstoneClone); }
/// <summary> /// Creates a shallow copy of the tombstone item and adds it to the list of tombstones. Does not check if it already /// exists. Only safety is that multiple tombstones cannot be placed at the same mile marker. /// </summary> /// <param name="tombstoneItem">The tombstone Item.</param> public void Add(Tombstone tombstoneItem) { // Clone the tombstone. var tombstoneClone = tombstoneItem.Clone() as Tombstone; // Skip if the cloning fails. if (tombstoneClone == null) { return; } // Check if we already have a tombstone at this mile marker. if (Tombstones.ContainsKey(tombstoneClone.MileMarker)) { return; } // Actually adds the tombstone to the internal list of them using mile marker as a key. Tombstones.Add(tombstoneItem.MileMarker, tombstoneClone); }
/// <summary> /// Destroys any currently existing temporary tombstone. /// </summary> public void ClearTombstone() { tempTombstone = null; }
/// <summary> /// Initializes a new instance of the <see cref="TombstoneInfo" /> class. /// </summary> public TombstoneInfo() { tempTombstone = null; }
/// <summary>Delegating method for the internal tombstones dictionary, used to make grabbing values less verbose.</summary> /// <param name="odometer">Number of miles the vehicle has traveled (to check for grave-site).</param> /// <param name="foundTombstone">Tombstone item returned from this mile marker if one exists, NULL if no tombstone found.</param> public void FindTombstone(int odometer, out Tombstone foundTombstone) { Tombstones.TryGetValue(odometer, out foundTombstone); }