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

            if (m_Table.Contains(id))
                Console.WriteLine("Warning: double SpawnEntry ID '{0}'", id);
            else
                m_Table[id] = this;
        }
Exemplo n.º 2
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;
            }
        }
Exemplo n.º 3
0
        public SpawnEntry(int id, BaseRegion region, Point3D home, int range, Direction direction,
                          SpawnDefinition definition, int max, TimeSpan minSpawnTime, TimeSpan maxSpawnTime)
        {
            ID             = id;
            Region         = region;
            HomeLocation   = home;
            HomeRange      = range;
            Direction      = direction;
            Definition     = definition;
            SpawnedObjects = new List <ISpawnable>();
            Max            = max;
            MinSpawnTime   = minSpawnTime;
            MaxSpawnTime   = maxSpawnTime;
            Running        = false;

            if (Table.ContainsKey(id))
            {
                Console.WriteLine("Warning: double SpawnEntry ID '{0}'", id);
            }
            else
            {
                Table[id] = this;
            }
        }
Exemplo n.º 4
0
        public BaseRegion(XmlElement xml, Map map, Region parent) : base(xml, map, parent)
        {
            ReadString(xml["rune"], "name", ref m_RuneName, false);

            bool logoutDelayActive = true;

            ReadBoolean(xml["logoutDelay"], "active", ref logoutDelayActive, false);
            m_NoLogoutDelay = !logoutDelayActive;


            XmlElement spawning = xml["spawning"];

            if (spawning != null)
            {
                ReadBoolean(spawning, "excludeFromParent", ref m_ExcludeFromParentSpawns, false);

                SpawnZLevel zLevel = SpawnZLevel.Lowest;
                ReadEnum(spawning, "zLevel", ref zLevel, false);
                m_SpawnZLevel = zLevel;


                List <SpawnEntry> list = new List <SpawnEntry>();

                foreach (XmlNode node in spawning.ChildNodes)
                {
                    XmlElement el = node as XmlElement;

                    if (el != null)
                    {
                        SpawnDefinition def = SpawnDefinition.GetSpawnDefinition(el);
                        if (def == null)
                        {
                            continue;
                        }

                        int id = 0;
                        if (!ReadInt32(el, "id", ref id, true))
                        {
                            continue;
                        }

                        int amount = 0;
                        if (!ReadInt32(el, "amount", ref amount, true))
                        {
                            continue;
                        }

                        TimeSpan minSpawnTime = SpawnEntry.DefaultMinSpawnTime;
                        ReadTimeSpan(el, "minSpawnTime", ref minSpawnTime, false);

                        TimeSpan maxSpawnTime = SpawnEntry.DefaultMaxSpawnTime;
                        ReadTimeSpan(el, "maxSpawnTime", ref maxSpawnTime, false);

                        Point3D home  = Point3D.Zero;
                        int     range = 0;

                        XmlElement homeEl = el["home"];
                        if (ReadPoint3D(homeEl, map, ref home, false))
                        {
                            ReadInt32(homeEl, "range", ref range, false);
                        }

                        Direction dir = SpawnEntry.InvalidDirection;
                        ReadEnum(el["direction"], "value", ref dir, false);

                        SpawnEntry entry = new SpawnEntry(id, this, home, range, dir, def, amount, minSpawnTime, maxSpawnTime);
                        list.Add(entry);
                    }
                }

                if (list.Count > 0)
                {
                    m_Spawns = list.ToArray();
                }
            }
        }
Exemplo n.º 5
0
		public SpawnGroupElement( SpawnDefinition spawnDefinition, int weight )
		{
			m_SpawnDefinition = spawnDefinition;
			m_Weight = weight;
		}
Exemplo n.º 6
0
 public SpawnGroupElement(SpawnDefinition spawnDefinition, int weight)
 {
     m_SpawnDefinition = spawnDefinition;
     m_Weight          = weight;
 }
Exemplo n.º 7
0
        public static SpawnDefinition GetSpawnDefinition(XmlElement xml)
        {
            switch (xml.Name)
            {
            case "object":
            {
                Type type = null;
                if (!Region.ReadType(xml, "type", ref type))
                {
                    return(null);
                }

                if (typeof(Mobile).IsAssignableFrom(type))
                {
                    return(SpawnMobile.Get(type));
                }
                else if (typeof(Item).IsAssignableFrom(type))
                {
                    return(SpawnItem.Get(type));
                }
                else
                {
                    Console.WriteLine("Invalid type '{0}' in a SpawnDefinition", type.FullName);
                    return(null);
                }
            }

            case "group":
            {
                string group = null;
                if (!Region.ReadString(xml, "name", ref group))
                {
                    return(null);
                }

                SpawnDefinition def = (SpawnDefinition)SpawnGroup.Table[group];

                if (def == null)
                {
                    Console.WriteLine("Could not find group '{0}' in a SpawnDefinition", group);
                    return(null);
                }
                else
                {
                    return(def);
                }
            }

            case "treasureChest":
            {
                int itemID = 0xE43;
                Region.ReadInt32(xml, "itemID", ref itemID, false);

                BaseTreasureChest.TreasureLevel level = BaseTreasureChest.TreasureLevel.Level2;

                Region.ReadEnum(xml, "level", ref level, false);

                return(new SpawnTreasureChest(itemID, level));
            }

            default:
            {
                return(null);
            }
            }
        }
Exemplo n.º 8
0
        static SpawnGroup()
        {
            string path = Path.Combine(Core.BaseDirectory, "Data/SpawnDefinitions.xml");

            if (!File.Exists(path))
            {
                return;
            }

            try
            {
                XmlDocument doc = new XmlDocument();
                doc.Load(path);

                XmlElement root = doc["spawnDefinitions"];

                if (root == null)
                {
                    return;
                }

                var defs = root.SelectNodes("spawnGroup");

                if (defs != null)
                {
                    for (var i = 0; i < defs.Count; i++)
                    {
                        var xmlDef = (XmlElement)defs[i];

                        string name = null;

                        if (!Region.ReadString(xmlDef, "name", ref name))
                        {
                            continue;
                        }

                        List <SpawnGroupElement> list = new List <SpawnGroupElement>();

                        for (var index = 0; index < xmlDef.ChildNodes.Count; index++)
                        {
                            XmlNode node = xmlDef.ChildNodes[index];

                            if (node is XmlElement el)
                            {
                                SpawnDefinition def = GetSpawnDefinition(el);

                                if (def == null)
                                {
                                    continue;
                                }

                                int weight = 1;

                                Region.ReadInt32(el, "weight", ref weight, false);

                                SpawnGroupElement groupElement = new SpawnGroupElement(def, weight);
                                list.Add(groupElement);
                            }
                        }

                        SpawnGroupElement[] elements = list.ToArray();
                        SpawnGroup          group    = new SpawnGroup(name, elements);
                        Register(group);
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Could not load SpawnDefinitions.xml: ");
                Diagnostics.ExceptionLogging.LogException(ex);
            }
        }