Example #1
0
        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);
        }
Example #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));
        }
Example #3
0
        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);
        }
Example #4
0
        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);
        }
Example #5
0
        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);
        }
Example #6
0
        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);
        }
Example #7
0
        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;
            }
        }
Example #8
0
        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);
        }