using UnityEngine; // Sci-Fi Ship Controller. Copyright (c) 2018-2023 SCSM Pty Ltd. All rights reserved. namespace SciFiShipController { /// /// This should always be a DATA-ONLY class. /// Used with the radar system to send RadarItem data to the centralised system. /// Although a subset of the SSCRadarItem, it was decided not to make this a base /// class for SSCRadarItem. /// public class SSCRadarPacket { #region Public variables // IMPORTANT - when changing this section also update SetClassDefault() // Also update ClassName(ClassName className) Clone Constructor (if there is one) /// /// World space position in the scene of this item /// /// [Unity.VisualScripting.Inspectable] public Vector3 position; /// /// The current velocity of the item being tracked /// /// [Unity.VisualScripting.Inspectable] public Vector3 velocity; /// /// Is this item currently visible to radar queries? /// For example, when a ship has been destroyed or is respawning, this should /// be set to false. /// /// [Unity.VisualScripting.Inspectable] public bool isVisibleToRadar; /// /// The faction or alliance the item belongs to. This can be used to identify if an item is friend or foe. /// 0 = Neutral /// /// [Unity.VisualScripting.Inspectable] public int factionId; /// /// The squadron this item is a member of. Typically only applies to Ships /// /// [Unity.VisualScripting.Inspectable] public int squadronId; #endregion #region Class Constructors /// /// Default constructor /// public SSCRadarPacket() { SetClassDefaults(); } /// /// Create a packet to transmit based on the current data in a SSCRadarItem /// e.g. from a ship's data. /// /// public SSCRadarPacket(SSCRadarItem sscRadarItem) { if (sscRadarItem == null) { SetClassDefaults(); } else { position = sscRadarItem.position; velocity = sscRadarItem.velocity; isVisibleToRadar = sscRadarItem.isVisibleToRadar; factionId = sscRadarItem.factionId; squadronId = sscRadarItem.squadronId; } } #endregion #region Private Methods private void SetClassDefaults() { position = Vector3.zero; velocity = Vector3.zero; isVisibleToRadar = true; factionId = 0; // Neutral squadronId = -1; // NOT SET } #endregion } }