コード例 #1
0
        /// <summary>
        /// Removes a dynamic gps from a player, if it exists
        /// </summary>
        /// <param name="gpsName">Name of the gps</param>
        /// <param name="playerId">Player id of the player</param>
        public void RemoveDynamicGps(string gpsName, long playerId)
        {
            DynamicGpsId id = new DynamicGpsId(playerId, gpsName);

            if (DynamicGpss.ContainsKey(id))
            {
                MySession.Static.Gpss.SendDelete(playerId, DynamicGpss[id]);
                DynamicGpss.Remove(id);
            }
        }
コード例 #2
0
        /// <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;
            }
        }