public static Message <Accept> ReadAssociationAccept(NetworkBinaryReader dr) { var acc = new Accept(); acc.PresentationContexts = new List <PresentationContext>(); dr.Skip(1); //PDU ID and Reserved Null Byte int length = LengthReader.ReadBigEndian(dr.Take(4)); using (DICOMBinaryReader sub = dr.GetSubStream(length)) { acc.ProtocolVersion = LengthReader.ReadBigEndian(sub, 2); sub.Skip(2); //Reserved Null Bytes acc.CalledEntityTitle = sub.ReadString(16).Trim(); acc.CallingEntityTitle = sub.ReadString(16).Trim(); sub.Skip(32); //Reserved Null Bytes acc.ApplicationContext = ItemReader.ReadApplicationContext(sub); while (sub.Peek(1).First() == (byte)ItemType.PRESENTATION_CONTEXT_ACCEPT) { PresentationContext context = ItemReader.ReadPresentationCtxAccept(sub); if (context != null) { acc.PresentationContexts.Add(context); } } acc.UserInfo = ItemReader.ReadUserInfo(sub); } return(new Message <Accept> { Payload = acc, Type = MessageType.PDU }); }
public static Message <Request> ReadAssociationRequest(NetworkBinaryReader dr) { var rq = new Request(); rq.PresentationContexts = new List <PresentationContext>(); dr.Skip(1); //PDU ID and Reserved Null Byte int length = LengthReader.ReadBigEndian(dr.Take(4)); using (DICOMBinaryReader sub = dr.GetSubStream(length)) { rq.ProtocolVersion = LengthReader.ReadBigEndian(sub, 2); sub.Skip(2); //Reserved Null Bytes rq.CalledEntityTitle = sub.ReadString(16).Trim(); rq.CallingEntityTitle = sub.ReadString(16).Trim(); sub.Skip(32); //Reserved Null Bytes rq.ApplicationContext = ItemReader.ReadApplicationContext(sub); while (sub.Peek(1)[0] == (byte)ItemType.PRESENTATION_CONTEXT_REQUEST) { PresentationContext context = ItemReader.ReadPresentationCtxRequest(sub); rq.PresentationContexts.Add(context); } rq.UserInfo = ItemReader.ReadUserInfo(sub); } return(new Message <Request> { Payload = rq, Type = MessageType.PDU }); }
/* * Fills the given list from the given reader with data created by the given item reader. */ public static void FillList <T>(List <T> toFill, ItemReader <T> readItem, BinaryReader reader, bool skipIndex = true, int itemCount = -1) { try { #if DEBUG long listStartPosition = reader.BaseStream.Position; #endif if (itemCount == -1) { itemCount = reader.ReadInt32(); } #if DEBUG Console.WriteLine("Reading list at {0:x}, {1} entries", listStartPosition, itemCount); #endif for (int i = 0; i < itemCount; i++) { try { if (skipIndex) { reader.ReadInt32(); } toFill.Add(readItem(reader)); } catch (Exception ex) { throw new ParseException(string.Format("Failed to read item {0}", i), reader.BaseStream.Position, ex); } } } catch (Exception ex) { throw new ParseException(string.Format("Failed to entries for list {0}"), reader.BaseStream.Position, ex); } }
private void ReadJson() { Stream stream = Resources.OpenRawResource(Resource.Raw.radar_search); var items = ItemReader.StreamToClusterMarker(stream); clusterManager.AddItems(items); }
private static T[] ReadArray <T>(BinaryReader reader, ItemReader <T> itemReader) { int size = reader.ReadInt32(); return(Enumerable.Range(0, size) .Select(i => itemReader(reader)).ToArray()); }
public static Message <PDataTF> ReadPDFData(NetworkBinaryReader dr, bool firstByteRead = false, int i = 0) { PDataTF pdata = null; pdata = new PDataTF(); if (!firstByteRead) { dr.Skip(1); } dr.Skip(1); // PDU ID and Reserved Null Byte var lengthBytes = dr.Take(4); int length = LengthReader.ReadBigEndian(lengthBytes); using (DICOMBinaryReader dbr = dr.GetSubStream(length)) { while (dbr.StreamPosition < dbr.StreamLength) { PDVItem item = ItemReader.ReadPDVItem(dbr); pdata.Items.Add(item); } } return(new Message <PDataTF> { Payload = pdata, Type = MessageType.PDATA_TF }); }
public void OnEnable() { if (gameManager == null) { gameManager = GameObject.FindObjectOfType <GameManager>(); } itemReader = new ItemReader(); itemReader.ReadFile(); }
public XLMFileImporter(String filePath, ItemReader reader) : base(reader) { this.reader = reader; this.filePath = filePath; head = new TreeNode(null) { children = new List <TreeNode>() }; }
public ItemInfo(ItemReader itemReader, D2Unit item) { ItemName = itemReader.GetFullItemName(item); Properties = itemReader.GetMagicalStrings(item); Location = itemReader.GetItemData(item)?.BodyLoc ?? BodyLocation.None; // backwards compatibility with D2ID BaseItem = itemReader.GetGrammaticalName(itemReader.GetItemName(item), out string grammerCase); Quality = QualityColor(itemReader.GetItemQuality(item)); }
List <T> ReadList <T>(BinaryReader reader, ItemReader <T> readItem) { List <T> list = new List <T>(); int itemCount = reader.ReadInt32(); for (int i = 0; i < itemCount; i++) { list.Add(readItem(reader)); } return(list); }
public void UpdateItem() { name.text = itemType.ToString(); reader = new ItemReader(); reader.ReadFile(); item = reader.GetItemData(itemType); image.sprite = item.sprite; type.text = item.itemPrimaryType.ToString(); intro.text = item.Intro.Trim() + "\n"; use.text = item.Use.Trim() + "\n" + item.Access.Trim() + "\n"; }
private static int Main(string[] args) { var itemReader = new ItemReader(); var clothing = new List <Clothing>(); var recipes = new List <Recipe>(); var weapons = new List <Weapon>(); Add(clothing, new ClothingMapper("body").MapMany(itemReader.Read("clothing/body.html"))); Add(clothing, new ClothingMapper("head").MapMany(itemReader.Read("clothing/head.html"))); Add(clothing, new ClothingMapper("leg").MapMany(itemReader.Read("clothing/leg.html"))); Add(recipes, new RecipeMapper("chill").MapMany(itemReader.Read("recipes/chill.html"))); Add(recipes, new RecipeMapper("shock").MapMany(itemReader.Read("recipes/electro.html"))); Add(recipes, new RecipeMapper("elixir").MapMany(itemReader.Read("recipes/elixirs.html"))); Add(recipes, new RecipeMapper("energy").MapMany(itemReader.Read("recipes/energizing.html"))); Add(recipes, new RecipeMapper("generic").MapMany(itemReader.Read("recipes/general.html"))); Add(recipes, new RecipeMapper("hearty").MapMany(itemReader.Read("recipes/hearty.html"))); Add(recipes, new RecipeMapper("mighty").MapMany(itemReader.Read("recipes/mighty.html"))); Add(recipes, new RecipeMapper("sneak").MapMany(itemReader.Read("recipes/sneaky.html"))); Add(recipes, new RecipeMapper("warmth").MapMany(itemReader.Read("recipes/spicy.html"))); Add(recipes, new RecipeMapper("defense").MapMany(itemReader.Read("recipes/tough.html"))); Add(weapons, new WeaponMapper("bow").MapMany(itemReader.Read("weapons/bows-arrows-boomerangs-and-rods.html"))); Add(weapons, new WeaponMapper("club").MapMany(itemReader.Read("weapons/clubs-hammers-and-axes.html"))); Add(weapons, new WeaponMapper("shield").MapMany(itemReader.Read("weapons/shields.html"))); Add(weapons, new WeaponMapper("spear").MapMany(itemReader.Read("weapons/spears.html"))); Add(weapons, new WeaponMapper("sword").MapMany(itemReader.Read("weapons/swords.html"))); var items = new ItemMapper().MapMany(itemReader.Read("items.html"), new List <Model>(recipes)); Output(clothing); Output(recipes); Output(weapons); Output(items); var client = new Connection().Client; Console.WriteLine("STARTING IMPORT"); var tasks = new Task[] { Import(clothing, client), Import(recipes, client), Import(weapons, client), Import(items, client) }; Task.WaitAll(tasks); Console.WriteLine("FINISHED IMPORT"); return(0); }
public void Test() { using var stream = new MemoryStream(); var serializer = new UserSerializer(); int total = 0, idx; Span <byte> span = stackalloc byte[32]; for (idx = 0; idx < 10000; idx++) { var length = serializer.Serialize(new User { Login = idx.ToString(), Pass = idx.ToString(), Bio = idx.ToString(), Created = DateTime.MaxValue }, span); stream.Write(span.Slice(0, length)); total += length; } var lastLength = serializer.Serialize(new User { Login = "******", Pass = "******", Bio = "bad", Created = DateTime.MaxValue }, span); stream.Write(span.Slice(lastLength - 1)); stream.Flush(); stream.Seek(0, SeekOrigin.Begin); Span <byte> buffer = stackalloc byte[32]; var reader = new ItemReader <User>(stream, buffer, serializer); for (idx = 0; idx < 10000; idx++) { Assert.IsTrue(reader.TryReadItem(out var user)); Assert.IsTrue(user != null); var val = idx.ToString(); Assert.AreEqual(val, user.Login); Assert.AreEqual(val, user.Pass); Assert.AreEqual(val, user.Bio); Assert.AreEqual(DateTime.MaxValue, user.Created); } Assert.IsFalse(reader.TryReadItem(out _)); Assert.AreEqual(total, reader.TotalBytesRead); }
private void ReadJson() { Stream stream = Resources.OpenRawResource(Resource.Raw.radar_search); var items = ItemReader.StreamToClusterMarker(stream); for (int i = 0; i < 10; i++) { double offset = i / 60d; foreach (var item in items) { var position = item.Position; double lat = position.Latitude + offset; double lng = position.Longitude + offset; var offsetItem = new ClusterMarker(lat, lng); clusterManager.AddItem(offsetItem); } } }
public UserWindow(string username) { InitializeComponent(); IEnumerable <User> users = _readUser.ReadAll(); foreach (User user in users) { if (user.Username == username) { username = user.Username + ".txt"; _userId = user.Id; name.Text = user.Username; id.Text = Convert.ToString(user.Id); } } _dirToUser = Directory.GetCurrentDirectory() + @"\Users\" + username; _writeItem = new ItemWriter(_dirToUser); _itemReader = new ItemReader(_dirToUser); }
public void UpdateItemDisplay() { if (itemReader == null) { itemReader = FindObjectOfType <GameManager>().itemReader; } item = itemReader.GetItemData(type); if (item.sprite != null) { image.sprite = item.sprite; } if (num < numneed) { text.text = "<color=red>" + num + "</color>/" + numneed; } else { text.text = num + "/" + numneed; } switch (item.itemPrimaryType) { case ItemPrimaryType.SoulType: bg.color = Item.SoulColor; break; case ItemPrimaryType.Farm: bg.color = Item.FarmColor; break; case ItemPrimaryType.Mine: bg.color = Item.MineColor; break; case ItemPrimaryType.Buff: bg.color = Item.BuffColor; break; default: return; } }
public void InitReaders() { itemReader = new ItemReader(); itemReader.ReadFile(); }
static void Main(string[] args) { Console.WriteLine("Welcome to Assignment 5 - Pokemon Edition"); PokemonReader reader = new PokemonReader(); Pokedex pokedex = reader.Load("pokemon151.xml"); // List out all the pokemons loaded foreach (Pokemon pokemon in pokedex.Pokemons) { Console.WriteLine(pokemon.Name); } // TODO: Add a pokemon bag with 2 bulbsaur, 1 charlizard, 1 mew and 1 dragonite // and save it out and load it back and list it out. // TODO: Add item reader and print out all the items ItemReader itemReader = new ItemReader(); ItemsData itemsData = itemReader.Load("itemData.xml"); foreach (var item in itemsData.Items) { Console.WriteLine(item.Name); } // TODO: hook up item data to display with the inventory var source = new Inventory() { ItemToQuantity = new Dictionary <object, object> { { "Poke ball", 10 }, { "Potion", 10 } } }; // TODO: move this into a inventory with a serialize and deserialize function. string inventoryFile = "inventory.xml"; source.Load(inventoryFile, itemsData); source.Save("invent.xml"); Console.WriteLine("=========Bag========="); PokemonBag pokebag = new PokemonBag(); pokebag.Pokemons.Add(pokedex.GetPokemonByName("Bulbasaur")); pokebag.Pokemons.Add(pokedex.GetPokemonByName("Bulbasaur")); pokebag.Pokemons.Add(pokedex.GetPokemonByName("Charizard")); pokebag.Pokemons.Add(pokedex.GetPokemonByName("Mew")); pokebag.Pokemons.Add(pokedex.GetPokemonByName("Dragonite")); Pokedex bagdex = new Pokedex(); bagdex.Pokemons = pokebag.Pokemons; reader.Save("bagdex", bagdex); Pokedex loadDex = reader.Load("bagdex.xml"); foreach (Pokemon pokemon in loadDex.Pokemons) { Console.WriteLine(pokemon.Name); } Console.ReadKey(); }
/// <summary> /// Starts this instance. /// </summary> /// <returns>The task.</returns> public virtual async Task Start() { Logger.LogStart(">> Loading vocations"); VocationXmlReader vocationXmlReader = new VocationXmlReader(); IEnumerable <IVocation> vocations = await vocationXmlReader.LoadAsync(Settings.Default.Vocations_Xml); _vocationService = new VocationService(vocations); Logger.LogDone(); Logger.LogStart(">> Loading items"); ItemReader itemReader = new ItemReader(); IEnumerable <IItem> items = await itemReader.LoadAsync(Settings.Default.Items_Otb); _itemService = new ItemService(items); ItemXmlReader itemXmlReader = new ItemXmlReader(_itemService); await itemXmlReader.LoadAsync(Settings.Default.Items_Xml); Logger.LogDone(); Logger.LogStart(">> Loading spells"); SpellXmlReader spellXmlReader = new SpellXmlReader(); IEnumerable <ISpell> spells = await spellXmlReader.LoadAsync(Settings.Default.Spells_Xml); _spellService = new SpellService(spells); Logger.LogDone(); Logger.LogStart(">> Loading monsters"); MonsterXmlReader monsterXmlReader = new MonsterXmlReader(_spellService); IEnumerable <IMonster> monsters = await monsterXmlReader.LoadAsync(Settings.Default.Monsters_Xml); _monsterService = new MonsterService(monsters); Logger.LogDone(); Logger.LogStart(">> Loading npcs"); NpcXmlReader npcXmlReader = new NpcXmlReader(); IEnumerable <INpc> npcs = await npcXmlReader.LoadAsync(Settings.Default.Npcs_Xml); _npcService = new NpcService(npcs); Logger.LogDone(); Logger.LogStart(">> Loading map"); MapReader mapReader = new MapReader(_itemService); WorldMap map = await mapReader.LoadAsync(Settings.Default.Map_Otb); Logger.LogDone(); Logger.LogStart(">> Loading outfits"); DrkOutfitReader outfitReader = new DrkOutfitReader(); IEnumerable <IOutfit> outfits = await outfitReader.LoadAsync(Settings.Default.Outfits_Xml); _outfitService = new OutfitService(outfits); Logger.LogDone(); Logger.LogStart(">> Loading mounts"); DrkMountReader mountReader = new DrkMountReader(); IEnumerable <IMount> mounts = await mountReader.LoadAsync(Settings.Default.Mounts_Xml); _mountService = new MountService(mounts); Logger.LogDone(); Logger.LogStart(">> Loading channels"); // TODO: Channels are broken. They should be handled by a category like ChannelType (e.g.: Public, Private, Guild, Party, etc.), then each category has an ID // TODO: Eventually loading channels this away should be replaced. // TODO Alternatively, we could move the specific implementation of LocalChannel to a scripting language (like Lua) // TODO: This could be also converted into a more modular approach (like a CS-Script) IDictionary <ChannelType, IChannel> channels = new Dictionary <ChannelType, IChannel>(); channels.Add(ChannelType.Local, new LocalChannel()); channels.Add(ChannelType.Loot, new LootChannel()); channels.Add(ChannelType.Advertising, new AdvertisingChannel()); channels.Add(ChannelType.AdvertisingRookgaard, new AdvertisingRookgaardChannel()); channels.Add(ChannelType.English, new EnglishChannel()); channels.Add(ChannelType.Help, new HelpChannel()); channels.Add(ChannelType.World, new WorldChannel()); Logger.LogDone(); Logger.LogStart(">> Initializing town services"); _townService = new TownService(map.Towns.Values); Logger.LogDone(); Logger.LogStart(">> Initializing tile services"); _tileService = new TileService(map.Tiles.Values); Logger.LogDone(); // TODO: Remove this after project is complete InitializeTest(); Logger.LogStart(">> Initializing repositories"); _accountsRepository = new Repository <IAccount, uint>(); // TODO: Remove this when repositories are implemented _accountsRepository.Create(_characterSpawn.Account); Logger.LogDone(); Logger.LogStart(">> Initializing spawn services"); SpawnXmlReader spawnXmlReader = new SpawnXmlReader(_monsterService, _npcService); ICollection <SpawnSource> spawnSources = (await spawnXmlReader.LoadAsync(Settings.Default.Spawns_Xml)).ToList(); _creatureSpawnService = new CreatureSpawnService(spawnSources); RegisterSpawns(spawnSources); // TODO: Remove this when player repositories are implemented; _creatureSpawnService.RegisterCreature(_characterSpawn); Logger.LogDone(); Logger.LogStart(">> Initializing communication services"); _chatService = new ChatService(_accountsRepository.GetAll(), channels); _commandService = new CommandService(); _commandService.Register(new TeleportCommand(_townService, _creatureSpawnService)); _commandService.Register(new TownListCommand(_townService)); _commandService.Register(new PositionInfoCommand()); _commandService.Register(new ChangeSexCommand()); _commandService.Register(new BroadcastCommand(_creatureSpawnService)); Logger.LogDone(); Logger.LogStart(">> Initializing game server"); _gameConnections = new List <GameConnection>(); _gameListener = new TcpListener(IPAddress.Any, Settings.Default.Network_Port_GameServer); _gameListener.Start(); _gameListener.BeginAcceptSocket(OnGameMessageReceived, _gameListener); Logger.LogDone(); Logger.LogStart(">> Initializing login server"); _loginConnections = new List <LoginConnection>(); _loginListener = new TcpListener(IPAddress.Any, Settings.Default.Network_Port_LoginServer); _loginListener.Start(); _loginListener.BeginAcceptSocket(OnLoginMessageReceived, _loginListener); Logger.LogDone(); _onlineTimer = new Stopwatch(); }
/* Some interesting offsets: * * 2nd data hunk * ============= * * Offsets are for German 1.05. * * 0x7AA0: Palette indices for event pix (only 8 of 9) * 0x8085: Name of the dictionary file. From here on the relative * text offsets will differ between german and english version! */ public ExecutableData(List <AmigaExecutable.IHunk> hunks) { var firstCodeHunk = hunks.FirstOrDefault(h => h.Type == AmigaExecutable.HunkType.Code); if (firstCodeHunk == null) { DataInfoString = "Unknown data version"; } else { var infoReader = new DataReader((firstCodeHunk as AmigaExecutable.Hunk?)?.Data); infoReader.Position = 6; DataVersionString = infoReader.ReadNullTerminatedString(AmigaExecutable.Encoding); DataInfoString = infoReader.ReadNullTerminatedString(AmigaExecutable.Encoding); } var reloc32Hunk = (AmigaExecutable.Reloc32Hunk?)hunks.LastOrDefault(h => h.Type == AmigaExecutable.HunkType.RELOC32); var dataHunkReaders = hunks.Where(h => h.Type == AmigaExecutable.HunkType.Data) .Select(h => new DataReader(((AmigaExecutable.Hunk)h).Data)).ToArray(); int dataHunkIndex = 0; if (reloc32Hunk == null || !reloc32Hunk.Value.Entries.ContainsKey(5) || reloc32Hunk.Value.Entries[5].Count != 15) { throw new AmbermoonException(ExceptionScope.Data, "Unexpected executable format."); } var relocOffsets = reloc32Hunk.Value.Entries[5]; uint digitOffset = relocOffsets.Take(9).Aggregate((a, b) => a + b) + 0x76D; // TODO: does this work for all versions? uint codepageOffset = relocOffsets.Take(12).Aggregate((a, b) => a + b); uint textOffset = codepageOffset + relocOffsets.Skip(12).Take(2).Aggregate((a, b) => a + b) + 4; uint glyphOffset = codepageOffset + relocOffsets.Skip(12).Aggregate((a, b) => a + b) + 262; if (glyphOffset % 4 != 0) { glyphOffset += 4 - glyphOffset % 4; } dataHunkIndex = 0; UIGraphics = Read <UIGraphics>(dataHunkReaders, ref dataHunkIndex); dataHunkIndex = 1; dataHunkReaders[1].Position = (int)digitOffset; DigitGlyphs = Read <DigitGlyphs>(dataHunkReaders, ref dataHunkIndex); // TODO ... dataHunkReaders[1].Position = (int)glyphOffset; Glyphs = Read <Glyphs>(dataHunkReaders, ref dataHunkIndex); Cursors = Read <Cursors>(dataHunkReaders, ref dataHunkIndex); // Here are the 3 builtin palettes for primary UI, automap and secondary UI. for (int i = 0; i < 3; ++i) { BuiltinPalettes[i] = GraphicProvider.ReadPalette(dataHunkReaders[dataHunkIndex]); } // Then 9 vertical color gradients used for skies are stored. They are stored // as 16 bit XRGB colors and not color indices! // The first 3 skies are for Lyramion, the next 3 for the forest moon and the last // 3 for Morag. The first sky is night, the second twilight and the third day. // Transitions blend night with twilight or day with twilight. var skyGraphicInfo = new GraphicInfo { Alpha = false, GraphicFormat = GraphicFormat.XRGB16, Width = 1, Height = 72 }; var graphicReader = new GraphicReader(); List <uint> colors = new List <uint>(); for (int i = 0; i < 9; ++i) { var sky = SkyGradients[i] = new Graphic(); graphicReader.ReadGraphic(sky, dataHunkReaders[dataHunkIndex], skyGraphicInfo); } // After the 9 sky gradients there are 6 partial palettes (16 colors). // Two of them per world (first for night, second for twilight). // They are also blended together (the first 16 colors of the map's palette is // used for day) and then replaces the first 16 colors of the map's palette. var daytimePaletteReplacementInfo = new GraphicInfo { Alpha = false, GraphicFormat = GraphicFormat.XRGB16, Width = 1, Height = 16 }; for (int i = 0; i < 6; ++i) { var replacement = DaytimePaletteReplacements[i] = new Graphic(); graphicReader.ReadGraphic(replacement, dataHunkReaders[dataHunkIndex], daytimePaletteReplacementInfo); } // TODO ... const string search = "Amberfiles/"; dataHunkReaders[1].Position = (int)dataHunkReaders[1].FindString(search, dataHunkReaders[1].Position) + search.Length + 50; FileList = Read <FileList>(dataHunkReaders, ref dataHunkIndex); WorldNames = Read <WorldNames>(dataHunkReaders, ref dataHunkIndex); Messages = Read <Messages>(dataHunkReaders, ref dataHunkIndex); AutomapNames = Read <AutomapNames>(dataHunkReaders, ref dataHunkIndex); OptionNames = Read <OptionNames>(dataHunkReaders, ref dataHunkIndex); SongNames = Read <SongNames>(dataHunkReaders, ref dataHunkIndex); SpellTypeNames = Read <SpellTypeNames>(dataHunkReaders, ref dataHunkIndex); SpellNames = Read <SpellNames>(dataHunkReaders, ref dataHunkIndex); LanguageNames = Read <LanguageNames>(dataHunkReaders, ref dataHunkIndex); ClassNames = Read <ClassNames>(dataHunkReaders, ref dataHunkIndex); RaceNames = Read <RaceNames>(dataHunkReaders, ref dataHunkIndex); AbilityNames = Read <AbilityNames>(dataHunkReaders, ref dataHunkIndex); AttributeNames = Read <AttributeNames>(dataHunkReaders, ref dataHunkIndex); AbilityNames.AddShortNames(dataHunkReaders[dataHunkIndex]); AttributeNames.AddShortNames(dataHunkReaders[dataHunkIndex]); ItemTypeNames = Read <ItemTypeNames>(dataHunkReaders, ref dataHunkIndex); AilmentNames = Read <AilmentNames>(dataHunkReaders, ref dataHunkIndex); UITexts = Read <UITexts>(dataHunkReaders, ref dataHunkIndex); Buttons = Read <Buttons>(dataHunkReaders, ref dataHunkIndex); int itemCount = dataHunkReaders[dataHunkIndex].ReadWord(); if (dataHunkReaders[dataHunkIndex].ReadWord() != itemCount || itemCount != 402) { throw new AmbermoonException(ExceptionScope.Data, "Invalid item data."); } var itemReader = new ItemReader(); var items = new Dictionary <uint, Item>(); for (uint i = 1; i <= 402; ++i) // there are 402 items { items.Add(i, Item.Load(i, itemReader, dataHunkReaders[dataHunkIndex])); } ItemManager = new ItemManager(items); }
public void OnEnable() { button.onClick.AddListener(OnItemBtn); itemReader = FindObjectOfType <GameManager>().itemReader; }
public FileImporter(ItemReader reader) { this.reader = reader; }
public void OnEnable() { reader = new ItemReader(); reader.ReadFile(); }
public void OnEnable() { itemReader = FindObjectOfType <GameManager>().itemReader; }
public ItemReaderTest() { _subject = new ItemReader(); }
public ItemInfo(ItemReader itemReader, D2Unit item) { ItemName = itemReader.GetFullItemName(item); Properties = itemReader.GetMagicalStrings(item); Location = itemReader.GetItemData(item)?.BodyLoc ?? BodyLocation.None; }
public TXTFileImporter(String filePath, ItemReader reader) : base(reader) { lines = File.ReadAllLines(filePath); head = new TreeNode(); }
private List<LatLng> ReadItems(int resource) { Stream inputStream = Resources.OpenRawResource(resource); return ItemReader.StreamToLatLng(inputStream); }
public static List <T> ReadFrom <T>(BinaryReader reader, int itemSize, ItemReader <T> itemReader, bool keepGaps) { var elementSize = reader.ReadInt32(); var count = reader.ReadInt32(); reader.ReadInt32(); // Unused transient data if (elementSize != itemSize) { throw new Exception($"Read element size {elementSize} from stream, but " + $"expected {itemSize}"); } var result = new List <T>(count); for (var i = 0; i < count; i++) { var startPos = reader.BaseStream.Position; result.Add(itemReader(reader)); var bytesRead = reader.BaseStream.Position - startPos; if (bytesRead != itemSize) { throw new IOException($"Item writer read {bytesRead} bytes. Expected {itemSize}."); } } var blockCount = reader.ReadInt32(); if (!keepGaps) { for (var i = 0; i < blockCount; i++) { reader.ReadInt32(); } } else { var currentIdx = 0; for (var i = 0; i < blockCount; i++) { var indexBlock = reader.ReadUInt32(); if (indexBlock == uint.MaxValue) { // Easy case, fully populated currentIdx += 32; continue; } for (var j = 0; j < 32; j++) { var mask = (1u << j); if ((indexBlock & mask) == 0) { // Insert a default value if (currentIdx < result.Count) { result.Insert(currentIdx, default); } else { result.Add(default);
private static T[] ReadArray <T>(BinaryReader reader, ItemReader <T> itemReader) => Enumerable.Range(0, reader.ReadInt32()) .Select(i => itemReader(reader)).ToArray();