Exemple #1
0
        public static AntennaTarget LoadFromConfig(ConfigNode node, RealAntenna ra)
        {
            var go = AntennaTargetManager.AcquireTarget(ra);

            foreach (var del in go.GetComponents <AntennaTarget>())
            {
                Destroy(del);
            }
            AntennaTarget t = null;
            string        n = string.Empty;

            if (node.TryGetValue("name", ref n))
            {
                if (n.Equals(TargetMode.BodyLatLonAlt.ToString()))
                {
                    t = go.AddComponent <AntennaTargetLatLonAlt>();
                }
                else if (n.Equals(TargetMode.Vessel.ToString()))
                {
                    t = go.AddComponent <AntennaTargetVessel>();
                }
                else if (n.Equals(TargetMode.AzEl.ToString()))
                {
                    t = go.AddComponent <AntennaTargetAzEl>();
                }
                else if (n.Equals(TargetMode.OrbitRelative.ToString()))
                {
                    t = go.AddComponent <AntennaTargetOrbitRelative>();
                }
                t?.Load(node);
            }
            return(t);
        }
 public void OnDestroy()
 {
     AntennaTargetManager.Release(antenna, this);
 }