Ejemplo n.º 1
0
        public int ScanText(string input, string desc = null)
        {//scans given text and adds all as uncorfirmed
            int count = 0;

#if XB1
            System.Diagnostics.Debug.Assert(false, "TODO for XB1.");
#else // !XB1
            // 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.Static.LocalPlayerId, ref newGps);
                ++count;
                if (count == PARSE_MAX_COUNT)
                {
                    break;
                }
            }
#endif // !XB1

            return(count);
        }
Ejemplo n.º 2
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);
            }
        }
Ejemplo n.º 3
0
        private MyGps CreateGps(int index, MyCubeGrid grid, Color gpsColor, long seconds)
        {
            MyGps gps = new MyGps {
                Coords         = grid.PositionComp.GetPosition(),
                Name           = "Top Grid - " + grid.DisplayName + " " + seconds,
                DisplayName    = "Top Grid: " + grid.DisplayName,
                Description    = ($"Top Grid: Grid currently in Top {index} by {Plugin.GpsIdentifierName}"),
                GPSColor       = gpsColor,
                IsContainerGPS = true,
                ShowOnHud      = true,
                DiscardAt      = new TimeSpan?()
            };

            gps.UpdateHash();
            gps.SetEntityId(grid.EntityId);

            return(gps);
        }
        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);
        }
Ejemplo n.º 5
0
        private MyGps CreateGps(Vector3D Position, Color gpsColor, int seconds, String Nation, String Reason)
        {
            MyGps gps = new MyGps
            {
                Coords         = Position,
                Name           = Nation + " - Distress Signal ",
                DisplayName    = Nation + " - Distress Signal ",
                GPSColor       = gpsColor,
                IsContainerGPS = true,
                ShowOnHud      = true,
                DiscardAt      = new TimeSpan(0, 0, seconds, 0),
                Description    = "Nation Distress Signal \n" + Reason,
            };

            gps.UpdateHash();


            return(gps);
        }
Ejemplo n.º 6
0
        private MyGps CreateGps(MyCubeGrid grid, Color gpsColor, long seconds, float distance)
        {
            MyGps gps = new MyGps
            {
                Coords         = grid.PositionComp.GetPosition(),
                Name           = "Radar Signature - " + distance + "m - " + grid.DisplayName,
                DisplayName    = "Radar Signature - " + distance + "m - " + grid.DisplayName,
                GPSColor       = gpsColor,
                IsContainerGPS = true,
                ShowOnHud      = true,
                DiscardAt      = new TimeSpan?(),
                Description    = "Cronch"
            };

            gps.UpdateHash();
            gps.SetEntityId(grid.EntityId);

            return(gps);
        }
Ejemplo n.º 7
0
        private static MyGps CreateGps(Vector3D Position, Color gpsColor, int seconds, string Name)
        {
            MyGps gps = new MyGps
            {
                Coords         = Position,
                Name           = Name.Split('_')[0],
                DisplayName    = Name.Split('_')[0] + " Paste Position",
                GPSColor       = gpsColor,
                IsContainerGPS = true,
                ShowOnHud      = true,
                DiscardAt      = new TimeSpan(0, 0, seconds, 0),
                Description    = "Paste Position",
            };

            gps.UpdateHash();


            return(gps);
        }
Ejemplo n.º 8
0
        public MyGps GetGps()
        {
            MyGps gps = new MyGps
            {
                Coords         = new VRageMath.Vector3D(x, y, z),
                Name           = "Shipyard Position",
                DisplayName    = "Shipyard Position",
                GPSColor       = Color.OrangeRed,
                IsContainerGPS = true,
                ShowOnHud      = true,
                DiscardAt      = new TimeSpan(0, 0, 180, 0),
                Description    = "Shipyard Position",
            };

            gps.UpdateHash();


            return(gps);
        }
Ejemplo n.º 9
0
        public static MyGps ScanChat(string input, string desc = null)
        {
            int             num             = 0;
            bool            flag            = true;
            MatchCollection matchCollection = Regex.Matches(input, "GPS:([^:]{0,32}):([\\d\\.-]*):([\\d\\.-]*):([\\d\\.-]*):");

            Color color = new Color(117, 201, 241);

            foreach (Match match in matchCollection)
            {
                string str = match.Groups[1].Value;
                double x;
                double y;
                double z;
                try
                {
                    x = Math.Round(double.Parse(match.Groups[2].Value, (IFormatProvider)CultureInfo.InvariantCulture), 2);
                    y = Math.Round(double.Parse(match.Groups[3].Value, (IFormatProvider)CultureInfo.InvariantCulture), 2);
                    z = Math.Round(double.Parse(match.Groups[4].Value, (IFormatProvider)CultureInfo.InvariantCulture), 2);
                    if (flag)
                    {
                        color = (Color) new ColorDefinitionRGBA(match.Groups[5].Value);
                    }
                }
                catch (SystemException ex)
                {
                    continue;
                }
                MyGps gps = new MyGps()
                {
                    Name        = str,
                    Description = desc,
                    Coords      = new Vector3D(x, y, z),
                    GPSColor    = color,
                    ShowOnHud   = false
                };
                gps.UpdateHash();

                return(gps);
            }
            return(null);
        }
        /// <summary>
        /// Adds or updates a dynamic gps. If the dynamic gps with the given name currently is not
        /// added to the player with playerId, it will be added as a new one. If it already exists, it will
        /// be updated.
        /// </summary>
        /// <param name="gpsName">Name of the gps</param>
        /// <param name="playerId">Id of the player</param>
        /// <param name="position">Position of the gps</param>
        /// <param name="color">Color of the gps</param>
        public void AddOrUpdateDynamicGps(string gpsName, long playerId, Vector3D position, Color color)
        {
            DynamicGpsId id = new DynamicGpsId(playerId, gpsName);

            MyGps gps;

            if (!DynamicGpss.ContainsKey(id))
            {
                gps = new MyGps()
                {
                    Name          = gpsName,
                    Coords        = position,
                    ShowOnHud     = true,
                    GPSColor      = color,
                    AlwaysVisible = false,
                    DiscardAt     = null
                };
                gps.CalculateHash();
                gps.UpdateHash();
                MySession.Static.Gpss.SendAddGps(playerId, ref gps, playSoundOnCreation: false);
                DynamicGpss.Add(id, gps.Hash);
            }
            else
            {
                MySession.Static.Gpss[playerId].TryGetValue(DynamicGpss[id], out gps);
                if (gps == null)
                {
                    DynamicGpss.Remove(id);
                    AddOrUpdateDynamicGps(gpsName, playerId, position, color);
                    return;
                }

                gps.Coords = position;
                MySession.Static.Gpss.SendModifyGps(playerId, gps);
                gps.UpdateHash();
                DynamicGpss[id] = gps.Hash;
            }
        }
Ejemplo n.º 11
0
        public void LoadFromHangar(string slotNumber)
        {
            if (!AlliancePlugin.config.HangarEnabled)
            {
                Context.Respond("Alliance hangar is not enabled.");
                return;
            }
            if (cooldowns.TryGetValue(Context.Player.IdentityId, out DateTime value))
            {
                if (DateTime.Now <= value)
                {
                    Context.Respond(GetCooldownMessage(value));
                    return;
                }
                else
                {
                    cooldowns[Context.Player.IdentityId] = DateTime.Now.AddSeconds(60);
                }
            }
            else
            {
                cooldowns.Add(Context.Player.IdentityId, DateTime.Now.AddSeconds(60));
            }
            MyFaction fac = MySession.Static.Factions.GetPlayerFaction(Context.Player.IdentityId);

            if (fac == null)
            {
                Context.Respond("You must be in a faction to use alliance features.");
                return;
            }
            Alliance alliance = AlliancePlugin.GetAlliance(fac);

            if (alliance == null)
            {
                Context.Respond("You are not a member of an alliance.");
                return;
            }
            if (AlliancePlugin.HasFailedUpkeep(alliance))
            {
                Context.Respond("Alliance failed to pay upkeep. Upgrades disabled.");
                return;
            }
            if (!alliance.HasAccess(Context.Player.SteamUserId, AccessLevel.HangarLoad) && !alliance.HasAccess(Context.Player.SteamUserId, AccessLevel.HangarLoadOther))
            {
                Context.Respond("Current rank does not have access to hangar load.");
                return;
            }
            if (alliance.hasUnlockedHangar)
            {
                HangarData hangar = alliance.LoadHangar();
                if (hangar == null)
                {
                    Context.Respond("Error loading the hangar.");
                    return;
                }
                int slot;
                try
                {
                    slot = int.Parse(slotNumber);
                }
                catch (Exception)
                {
                    Context.Respond("Cannot parse that number.");
                    return;
                }
                if (!hangar.ItemsInHangar.ContainsKey(slot))
                {
                    Context.Respond("No grid available to load for that number!");
                    return;
                }
                HangarItem item = hangar.ItemsInHangar[slot];

                //this took up way too much of one line

                if (hangar.LoadGridFromHangar(slot, Context.Player.SteamUserId, alliance, Context.Player.Identity as MyIdentity, fac))
                {
                    Context.Respond("Grid should be loaded!");
                }
                else
                {
                    Context.Respond("Could not load, are there enemies within 15km?");
                    MyGps gps = new MyGps
                    {
                        Coords         = item.position,
                        Name           = item.name + " Failed load location",
                        DisplayName    = item.name + " Failed load location",
                        Description    = "Failed load location",
                        GPSColor       = Color.LightBlue,
                        IsContainerGPS = true,
                        ShowOnHud      = true,
                        DiscardAt      = new TimeSpan(50000)
                    };
                    gps.UpdateHash();
                    MyGpsCollection gpscol = (MyGpsCollection)MyAPIGateway.Session?.GPS;


                    gpscol.SendAddGps(Context.Player.IdentityId, ref gps);
                }
            }
            else
            {
                Context.Respond("Alliance has not unlocked the hangar to unlock use !ah unlock.");
            }
        }