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)); } if (typeof(Item).IsAssignableFrom(type)) { return(SpawnItem.Get(type)); } 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); } if (!SpawnGroup.Table.TryGetValue(group, out SpawnGroup def)) { Console.WriteLine("Could not find group '{0}' in a SpawnDefinition", group); return(null); } 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); } } }
public static SpawnItem Get(Type type) { if (!m_Table.TryGetValue(type, out SpawnItem si)) { m_Table[type] = si = new SpawnItem(type); } return(si); }
public static SpawnItem Get(Type type) { SpawnItem si = (SpawnItem)m_Table[type]; if (si == null) { si = new SpawnItem(type); m_Table[type] = si; } return(si); }
public static SpawnItem Get( Type type ) { SpawnItem si = (SpawnItem) m_Table[type]; if ( si == null ) { si = new SpawnItem( type ); m_Table[type] = si; } return si; }