public static Item Load(Map map, System.IO.BinaryReader reader) { Item item = null; String typeName = reader.ReadString(); bool equipped = reader.ReadBoolean(); UInt32 equipper = equipped ? reader.ReadUInt32() : 0; Exception innerException = new Exception(); try { Type t = Assembly.GetAssembly(typeof(Entity)).GetType(typeName) ?? Scripts.GetType(typeName); if (t.BaseType == typeof(SpellItem)) { item = SpellItem.Load(reader); } else { UInt16 infoID = reader.ReadUInt16(); double quality = reader.ReadDouble(); String infoTypeName = (t.GetCustomAttributes(typeof(ItemInfoNameAttribute), true)[0] as ItemInfoNameAttribute).Value; ConstructorInfo c = t.GetConstructor(new Type[] { typeof(ItemInfo), typeof(Double) }); item = c.Invoke(new object[] { ItemInfo.Get(infoTypeName, infoID), quality }) as Item; } if (equipped) { item.Equip(map.GetEntity(equipper) as Character); } } catch (Exception e) { innerException = e; } if (item == null) { throw new Exception("Item of type '" + typeName + "' could not be created!", innerException); } item.OnLoad(reader); return(item); }
public SpellItem(SpellItem copy) : this(copy.Spell.Info, copy.Strength) { }