IMyGps IMyGpsCollection.Create(string name, string description, Vector3D coords, bool showOnHud, bool temporary)
 {
     var gps = new MyGps();
     gps.Name = name;
     gps.Description = description;
     gps.Coords = coords;
     gps.ShowOnHud = showOnHud;
     if (temporary)
         gps.SetDiscardAt();
     else
         gps.DiscardAt = null;
     gps.UpdateHash();
     return gps;
 }
        public int ScanText(string input, string desc = null)
        {//scans given text and adds all as uncorfirmed
            int count = 0;
            // GPS:name without doublecolons:123.4:234.5:3421.6:
            foreach (Match match in Regex.Matches(input, m_ScanPattern))
            {
                String name = match.Groups[1].Value;
                double x, y, z;
                try
                {
                    x = double.Parse(match.Groups[2].Value, System.Globalization.CultureInfo.InvariantCulture);
                    x = Math.Round(x, 2);
                    y = double.Parse(match.Groups[3].Value, System.Globalization.CultureInfo.InvariantCulture);
                    y = Math.Round(y, 2);
                    z = double.Parse(match.Groups[4].Value, System.Globalization.CultureInfo.InvariantCulture);
                    z = Math.Round(z, 2);
                }
                catch (SystemException)
                {
                    continue;//search for next GPS in the input
                }

                MyGps newGps = new MyGps()
                {
                    Name = name,
                    Description = desc,
                    Coords = new Vector3D(x, y, z),
                    ShowOnHud = false
                };
                newGps.UpdateHash();
                MySession.Static.Gpss.SendAddGps(MySession.LocalPlayerId, ref newGps);
                ++count;
                if (count == PARSE_MAX_COUNT)
                    break;
            }

            return count;
        }
        static void OnAddGps(AddMsg msg)
        {
            MyGps gps = new MyGps();
            gps.Name = msg.Name;
            gps.Description = msg.Description;
            gps.Coords = msg.Coords;
            gps.ShowOnHud = msg.ShowOnHud;
            gps.AlwaysVisible = msg.AlwaysVisible;
            gps.DiscardAt = null;
            if (!msg.IsFinal)
                gps.SetDiscardAt();
            gps.UpdateHash();
            if(msg.EntityId > 0)
                gps.SetEntity(MyEntities.GetEntityById(msg.EntityId));
            if (MySession.Static.Gpss.AddPlayerGps(msg.IdentityId, ref gps))
            {//new entry succesfully added
                if (gps.ShowOnHud && msg.IdentityId == MySession.Static.LocalPlayerId)
                    MyHud.GpsMarkers.RegisterMarker(gps);
            }

            var handler = MySession.Static.Gpss.ListChanged;
            if (handler != null)
            {
                handler(msg.IdentityId);
            }
        }
        static void AddSuccess(ref AddMsg msg, MyNetworkClient sender)
        {
            MyGps gps=new MyGps();
            gps.Name=msg.Name;
            gps.Description=msg.Description;
            gps.Coords=msg.Coords;
            gps.ShowOnHud=msg.ShowOnHud;
            gps.DiscardAt=null;
            if (!msg.IsFinal)
               gps.SetDiscardAt();
            gps.UpdateHash();
            if (MySession.Static.Gpss.AddPlayerGps(msg.IdentityId, ref gps))
            {//new entry succesfully added
                if (gps.ShowOnHud && msg.IdentityId == MySession.LocalPlayerId)
                    MyHud.GpsMarkers.RegisterMarker(gps);
            }

            var handler = MySession.Static.Gpss.ListChanged;
            if (handler != null)
            {
                handler(msg.IdentityId);
            }
        }
Beispiel #5
0
        public override void UpdateOnceBeforeFrame()
        {
            base.UpdateOnceBeforeFrame();

            UpdateFloraAndPhysics(true);

            if (m_planetInitValues.AddGps)
            {
                MyGps newGps = new MyGps()
                {
                    Name = StorageName,
                    Coords = PositionComp.GetPosition(),
                    ShowOnHud = true
                };
                newGps.UpdateHash();
                MySession.Static.Gpss.SendAddGps(MySession.Static.LocalPlayerId, ref newGps);
            }
        }