public static Item Deserialize(dynamic data) { var item = new Item { WearLoc = ( WearLocation )Enum.Parse(typeof(WearLocation), ( string )data.WearLoc), Cost = data.Cost ?? 0, }; if (data.Flags != null) { item.Flags = ( ItemFlags )Enum.Parse(typeof(ItemFlags), ( string )data.Flags); } if (data.Stack != null) { item.Stack = Stack.Deserialize(data.Stack); } if (data.Stats != null) { item.Stats = AspectFactory.Stats().Deserialize(data.Stats); } if (data.Weapon != null) { item.Weapon = AspectFactory.Weapon().Deserialize(data.Weapon); } EntitySerializer.Deserialize(data, item); return(item); }
public static Area Deserialize(dynamic data) { var area = new Area(); EntitySerializer.Deserialize(data, area); Func <dynamic, Room> deserializeRoom = roomData => RoomManager.Deserialize(roomData); area.Rooms = new List <Room>(Enumerable.Select <dynamic, Room>(data.Rooms, deserializeRoom)); return(area); }
public static Room Deserialize(dynamic data) { var room = new Room { Description = data.Description }; if (data.Exits != null) { room._exits = ExitSet.Deserialize(data.Exits); } if (data.Resets != null) { room.Resets = RoomReset.Deserialize(data.Resets); } EntitySerializer.Deserialize(data, room); return(room); }
public static Character Deserialize(dynamic data) { var character = new Character(); EntitySerializer.Deserialize(data, character); if (data.Stats != null) { character.Stats.Deserialize(data.Stats); } Func <dynamic, Item> deserializeItem = itemData => ItemManager.Deserialize(itemData); if (data.Inventory != null) { character.Inventory = new ItemSet(Enumerable.Select(data.Inventory, deserializeItem)); } if (data.Equipment != null) { character.Eq = ItemManager.DeserializeEquipment(data.Equipment); } if (data.RespawnAt != null) { character.RespawnAtId = data.RespawnAt; } if (data.LoginAt != null) { character.RoomId = data.LoginAt; } if (data.Data != null) { Func <dynamic, string> keySelector = item => item.Name; Func <dynamic, string> valueSelector = item => item.First; character.Data = Enumerable.ToDictionary(data.Data, keySelector, valueSelector); } return(character); }