private static BaseRegion GetCommandData(CommandEventArgs args)
        {
            Mobile from = args.Mobile;

            Region reg;

            if (args.Length == 0)
            {
                reg = from.Region;
            }
            else
            {
                string name = args.GetString(0);
                //reg = (Region) from.Map.Regions[name];

                if (!from.Map.Regions.TryGetValue(name, out reg))
                {
                    from.SendMessage("Could not find region '{0}'.", name);
                    return(null);
                }
            }

            BaseRegion br = reg as BaseRegion;

            if (br == null || br.Spawns == null)
            {
                from.SendMessage("There are no spawners in region '{0}'.", reg);
                return(null);
            }

            return(br);
        }
Beispiel #2
0
        public override ISpawnable Spawn(SpawnEntry entry)
        {
            BaseRegion region = entry.Region;
            Map        map    = region.Map;

            Point3D loc = entry.RandomSpawnLocation(this.Height, this.Land, this.Water);

            if (loc == Point3D.Zero)
            {
                return(null);
            }

            return(Construct(entry, loc, map));
        }
        private static void StopRegionSpawns_OnCommand(CommandEventArgs args)
        {
            BaseRegion region = GetCommandData(args);

            if (region == null)
            {
                return;
            }

            for (int i = 0; i < region.Spawns.Length; i++)
            {
                region.Spawns[i].Stop();
            }

            args.Mobile.SendMessage("Spawners of region '{0}' have stopped.", region);
        }
        private static void DelRegionSpawns_OnCommand(CommandEventArgs args)
        {
            BaseRegion region = GetCommandData(args);

            if (region == null)
            {
                return;
            }

            for (int i = 0; i < region.Spawns.Length; i++)
            {
                region.Spawns[i].DeleteSpawnedObjects();
            }

            args.Mobile.SendMessage("Spawned objects of region '{0}' have been deleted.", region);
        }
        private static void RespawnRegion_OnCommand(CommandEventArgs args)
        {
            BaseRegion region = GetCommandData(args);

            if (region == null)
            {
                return;
            }

            for (int i = 0; i < region.Spawns.Length; i++)
            {
                region.Spawns[i].Respawn();
            }

            args.Mobile.SendMessage("Region '{0}' has respawned.", region);
        }
        public static string GetRuneNameFor(Region region)
        {
            while (region != null)
            {
                BaseRegion br = region as BaseRegion;

                if (br != null && br.m_RuneName != null)
                {
                    return(br.m_RuneName);
                }

                region = region.Parent;
            }

            return(null);
        }
        public SpawnEntry(int id, BaseRegion region, Point3D home, int range, Direction direction, SpawnDefinition definition, int max, TimeSpan minSpawnTime, TimeSpan maxSpawnTime)
        {
            m_ID             = id;
            m_Region         = region;
            m_Home           = home;
            m_Range          = range;
            m_Direction      = direction;
            m_Definition     = definition;
            m_SpawnedObjects = new List <ISpawnable>();
            m_Max            = max;
            m_MinSpawnTime   = minSpawnTime;
            m_MaxSpawnTime   = maxSpawnTime;
            m_Running        = false;

            if (m_Table.Contains(id))
            {
                Console.WriteLine("Warning: double SpawnEntry ID '{0}'", id);
            }
            else
            {
                m_Table[id] = this;
            }
        }
        public static bool CanSpawn(Region region, params Type[] types)
        {
            while (region != null)
            {
                if (!region.AllowSpawn())
                {
                    return(false);
                }

                BaseRegion br = region as BaseRegion;

                if (br != null)
                {
                    if (br.Spawns != null)
                    {
                        for (int i = 0; i < br.Spawns.Length; i++)
                        {
                            SpawnEntry entry = br.Spawns[i];

                            if (entry.Definition.CanSpawn(types))
                            {
                                return(true);
                            }
                        }
                    }

                    if (br.ExcludeFromParentSpawns)
                    {
                        return(false);
                    }
                }

                region = region.Parent;
            }

            return(false);
        }