public ItemDescriptor LoadItem(string filePath) { if (_items.ContainsKey(filePath)) { return(_items[filePath]); } var item = ItemDescriptor.Load(filePath); _items.Add(filePath, item); return(item); }
private void LoadItems() { Console.WriteLine("Loading Items..."); var directoryInfo = new DirectoryInfo(EngineConstants.FILEPATH_ITEMS); FileInfo[] files = directoryInfo.GetFiles("*.litm"); foreach (var file in files) { ItemDescriptor itemDescriptor = ItemDescriptor.Load(EngineConstants.FILEPATH_ITEMS + file.Name); _items.Add(itemDescriptor.Name, new ItemDefinition(itemDescriptor)); } Console.WriteLine($"Loaded {files.Length} items."); }
public DockSpriteSheetEditor(Project project, string text, Image icon, FileInfo file) : this() { _project = project; _regularDockText = text; _unsavedDockText = text + "*"; DockText = text; Icon = icon; _file = file; _item = ItemDescriptor.Load(file.FullName); this.txtName.Text = _item.Name; this.radioStackable.Checked = _item.Stackable; this.radioNotStackable.Checked = !_item.Stackable; this.cmbType.DataSource = Enum.GetValues(typeof(ItemTypes)); this.cmbType.SelectedItem = _item.ItemType; this.txtStr.Text = _item.Strength.ToString(); this.txtInt.Text = _item.Intelligence.ToString(); this.txtDef.Text = _item.Defence.ToString(); this.txtHealth.Text = _item.Health.ToString(); this.txtDex.Text = _item.Dexterity.ToString(); this.cmbEquipmentSlot.DataSource = Enum.GetValues(typeof(EquipmentSlots)); this.cmbEquipmentSlot.SelectedItem = _item.SlotType; this.picTexture.Load(_item.TexturePath); onUseToolStripMenuItem.Checked = true; if (_item.Scripts.ContainsKey("OnUse")) { this.txtEditor.Text = _item.Scripts["OnUse"]; } else { this.txtEditor.Text = "function OnUse(args) \n end"; } }