예제 #1
0
        // ReSharper disable once InconsistentNaming
        private static void InitInternalPatch(ref MyObjectBuilder_SafeZone ob)
        {
            var size = ob.Size;

            if (!size.IsInsideInclusive(ref _minSize, ref _maxSize))
            {
                ob.Size = size.Clamp(ref _minSize, ref _maxSize);
            }
        }
예제 #2
0
        public void reload() {
            //Delete all registered gates
            int i = 0;
            foreach (var zone in Plugin.zones) {
                foreach (var entity in MyEntities.GetEntities()) {
                    if (entity?.DisplayName?.Contains(zone, StringComparison.CurrentCultureIgnoreCase) ?? false) {
                        i++;
                        entity.Close();
                    }
                }
            }
            IMyPlayer player = Context.Player;
            if (player == null) {
                Context.Respond($"{i} Jumpgates closed!");
            }
            else {
                utils.NotifyMessage($"{i} Jumpgates closed!", Context.Player.SteamUserId);
            }

            //Rebuild all gates
            int gates = 0;
            IEnumerable<string> channelIds = Plugin.Config.Gates;
            string name = "";
            string location = "";
            foreach (string chId in channelIds) {
                name = chId.Split('/')[0];
                location = chId.Split('/')[1];
                location = location.TrimStart('{').TrimEnd('}');
                Vector3D.TryParse(location, out Vector3D gps);
                var ob = new MyObjectBuilder_SafeZone();
                ob.PositionAndOrientation = new MyPositionAndOrientation(gps, Vector3.Forward, Vector3.Up);
                ob.PersistentFlags = MyPersistentEntityFlags2.InScene;
                ob.Shape = MySafeZoneShape.Sphere;
                ob.Radius = Plugin.Config.GateSize;
                ob.Enabled = true;
                ob.DisplayName = $"SM-{gps}";
                ob.AccessTypeGrids = MySafeZoneAccess.Blacklist;
                ob.AccessTypeFloatingObjects = MySafeZoneAccess.Blacklist;
                ob.AccessTypeFactions = MySafeZoneAccess.Blacklist;
                ob.AccessTypePlayers = MySafeZoneAccess.Blacklist;
                var zone = MyEntities.CreateFromObjectBuilderAndAdd(ob, true);
                gates++;
                if (!Plugin.zones.Contains(ob.DisplayName)) {
                    Plugin.zones.Add(ob.DisplayName);
                }
            }
            if (player == null) {
                Context.Respond($"{gates} Jumpgates created!");
            }
            else {
                utils.NotifyMessage($"{gates} Jumpgates created!", Context.Player.SteamUserId);
            }
        }
예제 #3
0
        public void Safezone(float radius = -1)
        {
            if (radius == -1)
            {
                radius = (float)Plugin.Config.RadiusGate;
            }
            var entities = MyEntities.GetEntities();

            if (entities != null)
            {
                foreach (MyEntity entity in entities)
                {
                    if (entity != null)
                    {
                        if (entity is MySafeZone)
                        {
                            if (entity.DisplayName.Contains("[NPC-IGNORE]_[Wormhole-SafeZone]"))
                            {
                                entity.Close();
                            }
                        }
                    }
                }
            }
            foreach (var server in Plugin.Config.WormholeGates)
            {
                var ob = new MyObjectBuilder_SafeZone
                {
                    PositionAndOrientation = new MyPositionAndOrientation(new Vector3D(server.X, server.Y, server.Z), Vector3.Forward, Vector3.Up),
                    PersistentFlags        = MyPersistentEntityFlags2.InScene,
                    Shape                     = MySafeZoneShape.Sphere,
                    Radius                    = radius,
                    Enabled                   = true,
                    DisplayName               = "[NPC-IGNORE]_[Wormhole-SafeZone]_" + server.Name,
                    AccessTypeGrids           = MySafeZoneAccess.Blacklist,
                    AccessTypeFloatingObjects = MySafeZoneAccess.Blacklist,
                    AccessTypeFactions        = MySafeZoneAccess.Blacklist,
                    AccessTypePlayers         = MySafeZoneAccess.Blacklist
                };
                MyEntities.CreateFromObjectBuilderAndAdd(ob, true);
            }
            Context.Respond("Deleted all entities with '[NPC-IGNORE]_[Wormhole-SafeZone]' in them and readded Safezones to each Wormhole");
        }