/// <summary> /// Creates from another item instance. /// </summary> void FromItem(DaggerfallUnityItem other) { shortName = other.shortName; itemGroup = other.itemGroup; groupIndex = other.groupIndex; playerTextureArchive = other.playerTextureArchive; playerTextureRecord = other.playerTextureRecord; worldTextureArchive = other.worldTextureArchive; worldTextureRecord = other.worldTextureRecord; nativeMaterialValue = other.nativeMaterialValue; dyeColor = other.dyeColor; weightInKg = other.weightInKg; drawOrder = other.drawOrder; currentVariant = other.currentVariant; value = other.value; unknown = other.unknown; flags = other.flags; currentCondition = other.currentCondition; maxCondition = other.maxCondition; unknown2 = other.unknown2; stackCount = other.stackCount; enchantmentPoints = other.enchantmentPoints; message = other.message; if (other.legacyMagic != null) { legacyMagic = (int[])other.legacyMagic.Clone(); } }
public async Task <IHttpActionResult> PutItemGroups(int id, ItemGroups itemGroups) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != itemGroups.Id) { return(BadRequest()); } db.Entry(itemGroups).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ItemGroupsExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
/// <summary> /// Creates from a serialized item. /// </summary> internal void FromItemData(ItemData_v1 data) { uid = data.uid; shortName = data.shortName; nativeMaterialValue = data.nativeMaterialValue; dyeColor = data.dyeColor; weightInKg = data.weightInKg; drawOrder = data.drawOrder; value = data.value1; // These are being saved in DF Unity saves as one int32 value but are two 16-bit values in classic unknown = (ushort)(data.value2 & 0xffff); flags = (ushort)(data.value2 >> 16); currentCondition = data.hits1; maxCondition = data.hits2; // These are being saved in DF Unity saves as one int32 value but are two 8-bit values in classic unknown2 = (byte)(data.hits3 & 0xff); typeDependentData = (byte)(data.hits3 >> 8); enchantmentPoints = data.enchantmentPoints; message = data.message; legacyMagic = data.legacyMagic; playerTextureArchive = data.playerTextureArchive; playerTextureRecord = data.playerTextureRecord; worldTextureArchive = data.worldTextureArchive; worldTextureRecord = data.worldTextureRecord; itemGroup = data.itemGroup; groupIndex = data.groupIndex; currentVariant = data.currentVariant; stackCount = data.stackCount; isQuestItem = data.isQuestItem; questUID = data.questUID; questItemSymbol = data.questItemSymbol; trappedSoulType = data.trappedSoulType; }
/// <summary> /// Linear search that returns all items of particular group, template, and materialvalue from this collection. /// Does not change items in this collection. /// For speed purposes returns actual item reference not a clone. /// </summary> /// <param name="itemGroup">Item group.</param> /// <param name="templateIndex">Item template index. Use -1 to match group only.</param> /// <returns>List of item references.</returns> public List <DaggerfallUnityItem> SearchItems(ItemGroups itemGroup, int templateIndex = -1, int requestedMat = -1) { List <DaggerfallUnityItem> results = new List <DaggerfallUnityItem>(); foreach (DaggerfallUnityItem item in items.Values) { int materialIndex = Formulas.FormulaHelper.CalculateItemIngotMaterial(item); if (templateIndex == -1) { if (requestedMat == materialIndex && item.ItemGroup == itemGroup) { results.Add(item); } } else { if (requestedMat == materialIndex && item.IsOfTemplate(itemGroup, templateIndex)) { results.Add(item); } } } return(results); }
/// <summary> /// Creates a random ingredient from any of the ingredient groups. /// Passing a non-ingredient group will return null. /// </summary> /// <param name="group">Ingedient group.</param> /// <returns>DaggerfallUnityItem</returns> public static DaggerfallUnityItem CreateRandomIngredient(ItemGroups ingredientGroup) { int groupIndex; Array enumArray; switch (ingredientGroup) { case ItemGroups.CreatureIngredients1: case ItemGroups.CreatureIngredients2: case ItemGroups.CreatureIngredients3: case ItemGroups.MetalIngredients: case ItemGroups.MiscellaneousIngredients1: case ItemGroups.MiscellaneousIngredients2: case ItemGroups.PlantIngredients1: case ItemGroups.PlantIngredients2: enumArray = DaggerfallUnity.Instance.ItemHelper.GetEnumArray(ingredientGroup); groupIndex = UnityEngine.Random.Range(0, enumArray.Length); break; default: return(null); } // Create item DaggerfallUnityItem newItem = new DaggerfallUnityItem(ingredientGroup, groupIndex); return(newItem); }
private Item CreateFullAncient(byte itemSlot, ItemGroups group, byte number, byte level, string ancientName) { var ancient = this.Context.CreateNew <Item>(); ancient.Definition = this.GameConfiguration.Items.First(def => def.Group == (int)group && def.Number == number); ancient.Durability = ancient.Definition.Durability; ancient.ItemSlot = itemSlot; ancient.Level = level; ancient.HasSkill = ancient.Definition.Skill is { }; var optionLink = this.Context.CreateNew <ItemOptionLink>(); optionLink.ItemOption = ancient.Definition.PossibleItemOptions.SelectMany(o => o.PossibleOptions) .First(o => o.OptionType == ItemOptionTypes.Option); optionLink.Level = optionLink.ItemOption.LevelDependentOptions.Max(o => o.Level); ancient.ItemOptions.Add(optionLink); if (ancient.Definition.PossibleItemOptions.SelectMany(o => o.PossibleOptions) .FirstOrDefault(o => o.OptionType == ItemOptionTypes.Luck) is { } luckOption) { var luck = this.Context.CreateNew <ItemOptionLink>(); luck.ItemOption = luckOption; ancient.ItemOptions.Add(luck); } var set = ancient.Definition.PossibleItemSetGroups.First(a => a.Name == ancientName); var itemOfSet = set.Items.First(i => i.ItemDefinition == ancient.Definition); if (itemOfSet.BonusOption is { })
/// <summary> /// Finds existing stack of item. /// </summary> /// <param name="item">Item to find existing stack for.</param> /// <returns>Existing item stack, or null if no stack or not stackable.</returns> DaggerfallUnityItem FindExistingStack(DaggerfallUnityItem item) { if (!item.IsStackable()) { return(null); } ItemGroups itemGroup = item.ItemGroup; int groupIndex = item.GroupIndex; foreach (DaggerfallUnityItem checkItem in items.Values) { if (checkItem != item && checkItem.ItemGroup == itemGroup && checkItem.GroupIndex == groupIndex && checkItem.message == item.message && checkItem.PotionRecipeKey == item.PotionRecipeKey && checkItem.TimeForItemToDisappear == item.TimeForItemToDisappear && checkItem.IsStackable()) { return(checkItem); } } return(null); }
/// <summary> /// Clears all the global /// </summary> public static void ClearValues() { AccountingGroups.Clear(); CostProfileGroups.Clear(); CountriesOfOrigin.Clear(); CustomerIdConversions.Clear(); ExternalIdTypes.Clear(); ItemCategories.Clear(); ItemGroups.Clear(); ItemIds.Clear(); ItemIdSuffixes.Clear(); ItemRecords.Clear(); Languages.Clear(); Licenses.Clear(); LocalItemIds.Clear(); MetaDescriptions.Clear(); PricingGroups.Clear(); ProductCategories.Clear(); ProductFormats.Clear(); ProductGoups.Clear(); ProductLines.Clear(); Properties.Clear(); PsStatuses.Clear(); RequestStatus.Clear(); SpecialCharacters.Clear(); TariffCodes.Clear(); Territories.Clear(); ToolTips.Clear(); UpcProductFormatExceptions.Clear(); Upcs.Clear(); UserNames.Clear(); UserRoles.Clear(); WebCategoryList.Clear(); }
/// <summary> /// Checks if item is of both group and template index. /// </summary> /// <param name="itemGroup">Item group to check.</param> /// <param name="templateIndex">Template index to check.</param> /// <returns>True if item matches both group and template index.</returns> public bool IsOfTemplate(ItemGroups itemGroup, int templateIndex) { if (ItemGroup == itemGroup && TemplateIndex == templateIndex) return true; else return false; }
/// <summary> /// Sets item from group and index. /// Resets item data from new template. /// Retains existing UID. /// </summary> /// <param name="itemGroup">Item group.</param> /// <param name="groupIndex">Item group index.</param> public void SetItem(ItemGroups itemGroup, int groupIndex) { // Get template data ItemTemplate itemTemplate = DaggerfallUnity.Instance.ItemHelper.GetItemTemplate(itemGroup, groupIndex); // Assign new data shortName = itemTemplate.name; this.itemGroup = itemGroup; this.groupIndex = groupIndex; playerTextureArchive = itemTemplate.playerTextureArchive; playerTextureRecord = itemTemplate.playerTextureRecord; worldTextureArchive = itemTemplate.worldTextureArchive; worldTextureRecord = itemTemplate.worldTextureRecord; nativeMaterialValue = 0; dyeColor = DyeColors.Unchanged; weightInKg = itemTemplate.baseWeight; drawOrder = itemTemplate.drawOrderOrEffect; currentVariant = 0; value1 = itemTemplate.basePrice; value2 = itemTemplate.basePrice; hits1 = itemTemplate.hitPoints; hits2 = itemTemplate.hitPoints; hits3 = itemTemplate.hitPoints; enchantmentPoints = itemTemplate.enchantmentPoints; message = 0; stackCount = 1; // Fix leather helms ItemBuilder.FixLeatherHelm(this); }
/// <summary> /// Creates the weapon. /// </summary> /// <param name="itemSlot">The item slot.</param> /// <param name="group">The group.</param> /// <param name="number">The number.</param> /// <param name="level">The level.</param> /// <param name="optionLevel">The option level.</param> /// <param name="luck">if set to <c>true</c>, the item has luck option.</param> /// <param name="skill">if set to <c>true</c>, the item has skill.</param> /// <param name="targetExcellentOption">The target excellent option.</param> /// <returns>The created weapon.</returns> public Item CreateWeapon(byte itemSlot, ItemGroups group, byte number, byte level, byte optionLevel, bool luck, bool skill, AttributeDefinition targetExcellentOption) { var weapon = this.CreateEquippableItem(itemSlot, group, number, level, optionLevel, luck, targetExcellentOption); weapon.HasSkill = skill; return(weapon); }
/// <summary> /// Creates from another item instance. /// </summary> void FromItem(DaggerfallUnityItem other) { shortName = other.shortName; itemGroup = other.itemGroup; groupIndex = other.groupIndex; playerTextureArchive = other.playerTextureArchive; playerTextureRecord = other.playerTextureRecord; worldTextureArchive = other.worldTextureArchive; worldTextureRecord = other.worldTextureRecord; nativeMaterialValue = other.nativeMaterialValue; dyeColor = other.dyeColor; weightInKg = other.weightInKg; drawOrder = other.drawOrder; currentVariant = other.currentVariant; value1 = other.value1; value2 = other.value2; hits1 = other.hits1; hits2 = other.hits2; hits3 = other.hits3; enchantmentPoints = other.enchantmentPoints; message = other.message; stackCount = other.stackCount; if (other.legacyMagic != null) { legacyMagic = (int[])other.legacyMagic.Clone(); } }
public void Save(string fileName) { // StringWriter.Encoding always returns UTF16. We need it to return UTF8, so the // XmlDocument will write the UTF8 header. if (!this.Settings.MaintainOriginalItemOrder) { ItemGroups.Each(group => { XmlElement[] elements = null; elements = @group.Items.Select(x => x.Element).OrderBy(x => x.GetAttribute("Include")).ToArray(); group.Element.RemoveAll(); elements.Each(x => group.Element.AppendChild(x)); }); } var sw = new ProjectWriter(bom); sw.NewLine = newLine; doc.Save(sw); string content = sw.ToString(); if (endsWithEmptyLine && !content.EndsWith(newLine)) content += newLine; var shouldSave = !this.Settings.OnlySaveIfChanged || (File.Exists(fileName) && !File.ReadAllText(fileName).Equals(content)); if (shouldSave) new FileSystem().WriteStringToFile(fileName, content); }
public List <GameObject> GetAvailableObjects(IEnumerable <GameObject> gameObjects) { if (gameObjects == null || !gameObjects.Any()) { return(null); } IEnumerable <GameObject> leftGameObjects = gameObjects; List <GameObject> availableObjects = new List <GameObject>(); foreach (var ig in ItemGroups.Where(ig => !ig.IsCompleted)) { var objectForAction = ig.GetAvailableObjects(leftGameObjects); if (objectForAction != null && objectForAction.Any()) { availableObjects.AddRange(objectForAction); leftGameObjects = leftGameObjects.Except(objectForAction).ToList(); } if (!leftGameObjects.Any()) { break; } } ; return(availableObjects); }
/// <summary> /// Creates a generic item from group and template index. /// </summary> /// <param name="itemGroup">Item group.</param> /// <param name="templateIndex">Template index.</param> /// <returns>DaggerfallUnityItem.</returns> public static DaggerfallUnityItem CreateItem(ItemGroups itemGroup, int templateIndex) { // Handle custom items if (templateIndex > ItemHelper.LastDFTemplate) { // Allow custom item classes to be instantiated when registered Type itemClassType; if (DaggerfallUnity.Instance.ItemHelper.GetCustomItemClass(templateIndex, out itemClassType)) { return((DaggerfallUnityItem)Activator.CreateInstance(itemClassType)); } else { return(new DaggerfallUnityItem(itemGroup, templateIndex)); } } // Create classic item int groupIndex = DaggerfallUnity.Instance.ItemHelper.GetGroupIndex(itemGroup, templateIndex); if (groupIndex == -1) { Debug.LogErrorFormat("ItemBuilder.CreateItem() encountered an item with an invalid GroupIndex. Check you're passing 'template index' matching a value in ItemEnums - e.g. (int)Weapons.Dagger NOT a 'group index' (e.g. 0)."); return(null); } DaggerfallUnityItem newItem = new DaggerfallUnityItem(itemGroup, groupIndex); return(newItem); }
public void deleteItemGroup(int ItemGroupId) { ItemGroups itemGroupForDelete = dbContext.ItemGroups.Where(itemGroup => itemGroup.ItemGroupId.Equals(ItemGroupId)).SingleOrDefault(); dbContext.ItemGroups.Remove(itemGroupForDelete); dbContext.SaveChanges(); }
/// <summary> /// Sets item by merging item template and artifact template data. /// Result is a normal DaggerfallUnityItem with properties of both base template and magic item template. /// </summary> /// <param name="groupIndex">Artifact group index.</param> public void SetArtifact(ItemGroups itemGroup, int groupIndex) { // Must be an artifact type if (itemGroup != ItemGroups.Artifacts) { throw new Exception("An attempt was made to SetArtifact() with non-artifact ItemGroups value."); } // Get artifact template MagicItemTemplate magicItemTemplate = DaggerfallUnity.Instance.ItemHelper.GetArtifactTemplate(groupIndex); // Get base item template data, this is the fundamental item type being expanded ItemTemplate itemTemplate = DaggerfallUnity.Instance.ItemHelper.GetItemTemplate((ItemGroups)magicItemTemplate.group, magicItemTemplate.groupIndex); // Get artifact texture indices int archive, record; DaggerfallUnity.Instance.ItemHelper.GetArtifactTextureIndices((ArtifactsSubTypes)groupIndex, out archive, out record); // Assign new data shortName = magicItemTemplate.name; this.itemGroup = (ItemGroups)magicItemTemplate.group; this.groupIndex = magicItemTemplate.groupIndex; playerTextureArchive = archive; playerTextureRecord = record; worldTextureArchive = archive; // Not sure about artifact world textures, just using player texture for now worldTextureRecord = record; nativeMaterialValue = 0; dyeColor = DyeColors.Unchanged; weightInKg = itemTemplate.baseWeight; drawOrder = itemTemplate.drawOrderOrEffect; currentVariant = 0; value1 = itemTemplate.basePrice; value2 = itemTemplate.basePrice; hits1 = itemTemplate.hitPoints; hits2 = itemTemplate.hitPoints; hits3 = itemTemplate.hitPoints; enchantmentPoints = 0; message = 0; stackCount = 1; // All artifacts have magical effects bool foundEnchantment = false; legacyMagic = new int[magicItemTemplate.enchantments.Length]; for (int i = 0; i < magicItemTemplate.enchantments.Length; i++) { legacyMagic[i] = (ushort)magicItemTemplate.enchantments[i]; if (legacyMagic[i] != 0xffff) { foundEnchantment = true; } } // Discard list if no enchantment found if (!foundEnchantment) { legacyMagic = null; } }
/// <summary> /// Creates a new item of random clothing. /// </summary> /// <param name="gender">Gender of player</param> /// <returns>DaggerfallUnityItem.</returns> public static DaggerfallUnityItem CreateRandomClothing(Genders gender, Races race) { // Create random clothing by gender, including any custom items registered as clothes ItemGroups genderClothingGroup = (gender == Genders.Male) ? ItemGroups.MensClothing : ItemGroups.WomensClothing; ItemHelper itemHelper = DaggerfallUnity.Instance.ItemHelper; Array enumArray = itemHelper.GetEnumArray(genderClothingGroup); int[] customItemTemplates = itemHelper.GetCustomItemsForGroup(genderClothingGroup); int groupIndex = UnityEngine.Random.Range(0, enumArray.Length + customItemTemplates.Length); DaggerfallUnityItem newItem; if (groupIndex < enumArray.Length) { newItem = new DaggerfallUnityItem(genderClothingGroup, groupIndex); } else { newItem = CreateItem(genderClothingGroup, customItemTemplates[groupIndex - enumArray.Length]); } SetRace(newItem, race); // Random dye colour newItem.dyeColor = RandomClothingDye(); // Random variant SetVariant(newItem, UnityEngine.Random.Range(0, newItem.TotalVariants)); return(newItem); }
public MSBuildItemGroup AddNewItemGroup() { AssertCanModify(); var group = new MSBuildItemGroup(); MSBuildObject refNode = null; var lastGroup = ItemGroups.LastOrDefault(); if (lastGroup != null) { refNode = lastGroup; } else { var g = PropertyGroups.LastOrDefault(); if (g != null) { refNode = g; } } group.ParentNode = this; if (refNode != null) { ChildNodes = ChildNodes.Insert(ChildNodes.IndexOf(refNode) + 1, group); } else { ChildNodes = ChildNodes.Add(group); } group.ResetIndent(true); NotifyChanged(); return(group); }
/// <summary> /// Finds existing stack of item. /// </summary> /// <param name="item">Item to find existing stack for.</param> /// <returns>Existing item stack, or null if no stack or not stackable.</returns> DaggerfallUnityItem FindExistingStack(DaggerfallUnityItem item) { if (!item.IsStackable()) { return(null); } ItemGroups itemGroup = item.ItemGroup; int groupIndex = item.GroupIndex; foreach (DaggerfallUnityItem checkItem in items.Values) { if (checkItem != item && checkItem.ItemGroup == itemGroup && checkItem.GroupIndex == groupIndex && checkItem.PotionRecipeKey == item.PotionRecipeKey && checkItem.IsSummoned == item.IsSummoned && checkItem.message == item.message && checkItem.currentCondition == item.currentCondition && // So differently damaged condition books don't stack, when I apply condition variance to them at least. checkItem.nativeMaterialValue == item.nativeMaterialValue && checkItem.IsStackable()) { return(checkItem); } } return(null); }
/// <summary> /// Creates from a serialized item. /// </summary> void FromItemData(ItemData_v1 data) { uid = data.uid; shortName = data.shortName; nativeMaterialValue = data.nativeMaterialValue; dyeColor = data.dyeColor; weightInKg = data.weightInKg; drawOrder = data.drawOrder; value1 = data.value1; value2 = data.value2; hits1 = data.hits1; hits2 = data.hits2; hits3 = data.hits3; stackCount = data.stackCount; enchantmentPoints = data.enchantmentPoints; message = data.message; legacyMagic = data.legacyMagic; playerTextureArchive = data.playerTextureArchive; playerTextureRecord = data.playerTextureRecord; worldTextureArchive = data.worldTextureArchive; worldTextureRecord = data.worldTextureRecord; itemGroup = data.itemGroup; groupIndex = data.groupIndex; currentVariant = data.currentVariant; }
public void FinalizeObject() { Marshal.ReleaseComObject(_businessObject); _businessObject = null; GC.Collect(); }
public ProjectDataset( ) { Imports = new ProjectImports(); PropertyGroups = new PropertyGroups(); ProjectFile = FilePath.Empty; ItemGroups = new ItemGroups(); ToolsVersion = string.Empty; }
public static ItemGroups GetAllAsFlags() { List <ItemGroups> groups = GetAllAsList(); ItemGroups result = ItemGroups.All; groups.ForEach(g => result |= g); return(result); }
/// <summary> /// Creates a generic item from group and template index. /// </summary> /// <param name="itemGroup">Item group.</param> /// <param name="itemIndex">Template index.</param> /// <returns>DaggerfallUnityItem.</returns> public static DaggerfallUnityItem CreateItem(ItemGroups itemGroup, int templateIndex) { // Create item int groupIndex = DaggerfallUnity.Instance.ItemHelper.GetGroupIndex(itemGroup, templateIndex); DaggerfallUnityItem newItem = new DaggerfallUnityItem(itemGroup, groupIndex); return(newItem); }
static void RandomIngredient(float chance, ItemGroups ingredientGroup, List <DaggerfallUnityItem> targetItems) { while (Dice100.SuccessRoll((int)chance)) { targetItems.Add(ItemBuilder.CreateRandomIngredient(ingredientGroup)); chance *= 0.5f; } }
static void RandomIngredient(float chance, ItemGroups ingredientGroup, List <DaggerfallUnityItem> targetItems) { while (Random.Range(0, 100) < chance) { targetItems.Add(ItemBuilder.CreateRandomIngredient(ingredientGroup)); chance *= 0.5f; } }
/// <summary> /// Creates the learnable. /// </summary> /// <param name="itemSlot">The item slot.</param> /// <param name="learnableId">The learnable identifier.</param> /// <param name="group">The group.</param> /// <returns>The learnable.</returns> public Item CreateLearnable(byte itemSlot, byte learnableId, ItemGroups group) { var item = this.context.CreateNew <Item>(); item.Definition = this.gameConfiguration.Items.First(def => def.Group == (byte)group && def.Number == learnableId); item.ItemSlot = itemSlot; return(item); }
public void InitializeObject(int groupCode) { _businessObject = (ItemGroups)Controller.ConnectionController.Instance.Company.GetBusinessObject(BoObjectTypes.oItemGroups); if (!_businessObject.GetByKey(groupCode)) { _newObject = true; } }
public static MsBuildItemGroup Create(params ProjectReference[] projects) { var items = new List <MsBuildItem>(); foreach (var project in projects) { items.Add(SdkItems.ProjectReference(in project)); } return(ItemGroups.Create(items.ToArray())); }
static void RandomIngredient(float chance, ItemGroups ingredientGroup, List<DaggerfallUnityItem> targetItems) { while (Random.Range(1, 100) < chance) { targetItems.Add(ItemBuilder.CreateRandomIngredient(ingredientGroup)); chance *= 0.5f; } }
///// <summary> ///// Checks legacy item ID against legacy equip index to determine if item is equipped to a slot. ///// Must have previously used SetLegacyEquipTable to EntityItems provided. ///// </summary> ///// <param name="item">Item to test.</param> ///// <param name="entityItems">EntityItems with legacy equip table set.</param> ///// <returns>Index of item in equip table or -1 if not equipped.</returns> //public int GetLegacyEquipIndex(DaggerfallUnityItem item, EntityItems entityItems) //{ // // Interim use of classic data // //ItemRecord.ItemRecordData itemRecord = item.ItemRecord.ParsedData; // uint[] legacyEquipTable = (GameManager.Instance.PlayerEntity as DaggerfallEntity).Items.LegacyEquipTable; // if (legacyEquipTable == null || legacyEquipTable.Length == 0) // return -1; // // Try to match item RecordID with equipped item IDs // // Item RecordID must be shifted right 8 bits // for (int i = 0; i < legacyEquipTable.Length; i++) // { // if (legacyEquipTable[i] == (item.ItemRecord.RecordRoot.RecordID >> 8)) // return i; // } // return -1; //} /// <summary> /// Helps bridge classic item index pair back to item template index. /// </summary> /// <param name="group">Group enum to retrieve.</param> /// <return>Array of group enum values.</return> public Array GetEnumArray(ItemGroups group) { switch (group) { case ItemGroups.Drugs: return Enum.GetValues(typeof(Drugs)); case ItemGroups.UselessItems1: return Enum.GetValues(typeof(UselessItems1)); case ItemGroups.Armor: return Enum.GetValues(typeof(Armor)); case ItemGroups.Weapons: return Enum.GetValues(typeof(Weapons)); case ItemGroups.MagicItems: return Enum.GetValues(typeof(MagicItemSubTypes)); case ItemGroups.Artifacts: return Enum.GetValues(typeof(ArtifactsSubTypes)); case ItemGroups.MensClothing: return Enum.GetValues(typeof(MensClothing)); case ItemGroups.Books: return Enum.GetValues(typeof(Books)); case ItemGroups.Error: return Enum.GetValues(typeof(ERROR)); case ItemGroups.UselessItems2: return Enum.GetValues(typeof(UselessItems2)); case ItemGroups.ReligiousItems: return Enum.GetValues(typeof(ReligiousItems)); case ItemGroups.Maps: return Enum.GetValues(typeof(Maps)); case ItemGroups.WomensClothing: return Enum.GetValues(typeof(WomensClothing)); case ItemGroups.Paintings: return Enum.GetValues(typeof(Paintings)); case ItemGroups.Gems: return Enum.GetValues(typeof(Gems)); case ItemGroups.PlantIngredients1: return Enum.GetValues(typeof(PlantIngredients1)); case ItemGroups.PlantIngredients2: return Enum.GetValues(typeof(PlantIngredients2)); case ItemGroups.CreatureIngredients1: return Enum.GetValues(typeof(CreatureIngredients1)); case ItemGroups.CreatureIngredients2: return Enum.GetValues(typeof(CreatureIngredients2)); case ItemGroups.CreatureIngredients3: return Enum.GetValues(typeof(CreatureIngredients3)); case ItemGroups.MiscellaneousIngredients1: return Enum.GetValues(typeof(MiscellaneousIngredients1)); case ItemGroups.MetalIngredients: return Enum.GetValues(typeof(MetalIngredients)); case ItemGroups.MiscellaneousIngredients2: return Enum.GetValues(typeof(MiscellaneousIngredients2)); case ItemGroups.Transportation: return Enum.GetValues(typeof(Transportation)); case ItemGroups.Deeds: return Enum.GetValues(typeof(Deeds)); case ItemGroups.Jewellery: return Enum.GetValues(typeof(Jewellery)); case ItemGroups.QuestItems: return Enum.GetValues(typeof(QuestItems)); case ItemGroups.MiscItems: return Enum.GetValues(typeof(MiscItems)); case ItemGroups.Currency: return Enum.GetValues(typeof(Currency)); default: throw new Exception("Error: Item group not found."); } }
// Basics: ID, Name, Icon, ItemType private void UpdatePreviewBox0() { int _i; try { iconPreview.Image = itemIcons.Images[TextField("icon")]; } catch { iconPreview.Image = null; } textPreviewBox0.Text = TextField("name") + " (" + TextField("id") + ")"; switch (_i = IntField("itemtype")) { case 1: case 2: case 3: case 4: case 5: case 7: case 19: case 27: case 35: case 45: ItemGroup = ItemGroups.Weapon; break; case 10: case 29: case 52: ItemGroup = ItemGroups.Armor; break; case 21: ItemGroup = ItemGroups.Potion; break; case 23: case 24: case 25: case 26: case 50: case 51: ItemGroup = ItemGroups.Instrument; break; case 14: case 15: ItemGroup = ItemGroups.FoodDrink; break; case 54: ItemGroup = ItemGroups.Augmentation; break; default: if (IntField("bagslots") > 0) { ItemGroup = ItemGroups.Container; } else if (IntField("benefitflag") > 0) { ItemGroup = ItemGroups.Benefit; } else if ((_i == 0) && (IntField("delay") > 0)) { ItemGroup = ItemGroups.Weapon; } else { ItemGroup = ItemGroups.Unknown; } break; } }
/// <summary> /// Creates from another item instance. /// </summary> void FromItem(DaggerfallUnityItem other) { shortName = other.shortName; itemGroup = other.itemGroup; groupIndex = other.groupIndex; playerTextureArchive = other.playerTextureArchive; playerTextureRecord = other.playerTextureRecord; worldTextureArchive = other.worldTextureArchive; worldTextureRecord = other.worldTextureRecord; nativeMaterialValue = other.nativeMaterialValue; dyeColor = other.dyeColor; weightInKg = other.weightInKg; drawOrder = other.drawOrder; currentVariant = other.currentVariant; value1 = other.value1; value2 = other.value2; hits1 = other.hits1; hits2 = other.hits2; hits3 = other.hits3; enchantmentPoints = other.enchantmentPoints; message = other.message; stackCount = other.stackCount; if (other.legacyMagic != null) legacyMagic = (int[])other.legacyMagic.Clone(); }
/// <summary> /// Create from native save ItemRecord data. /// </summary> void FromItemRecord(ItemRecord itemRecord) { // Get template data ItemGroups group = (ItemGroups)itemRecord.ParsedData.category1; int index = itemRecord.ParsedData.category2; ItemTemplate itemTemplate = DaggerfallUnity.Instance.ItemHelper.GetItemTemplate(group, index); // Get player image int playerBitfield = (int)itemRecord.ParsedData.image1; int playerArchive = playerBitfield >> 7; int playerRecord = (playerBitfield & 0x7f); // Get world image int worldBitfield = (int)itemRecord.ParsedData.image2; int worldArchive = worldBitfield >> 7; int worldRecord = (worldBitfield & 0x7f); // Assign new data shortName = itemRecord.ParsedData.name; itemGroup = group; groupIndex = index; playerTextureArchive = playerArchive; playerTextureRecord = playerRecord; worldTextureArchive = worldArchive; worldTextureRecord = worldRecord; nativeMaterialValue = itemRecord.ParsedData.material; dyeColor = (DyeColors)itemRecord.ParsedData.color; weightInKg = (float)itemRecord.ParsedData.weight * 0.25f; drawOrder = itemTemplate.drawOrderOrEffect; value1 = (int)itemRecord.ParsedData.value1; value2 = (int)itemRecord.ParsedData.value2; hits1 = itemRecord.ParsedData.hits1; hits2 = itemRecord.ParsedData.hits2; hits3 = itemRecord.ParsedData.hits3; currentVariant = 0; enchantmentPoints = itemRecord.ParsedData.enchantmentPoints; message = (int)itemRecord.ParsedData.message; stackCount = 1; // Assign current variant if (itemTemplate.variants > 0) { if (IsCloak()) currentVariant = playerRecord - (itemTemplate.playerTextureRecord + 1); else currentVariant = playerRecord - itemTemplate.playerTextureRecord; } // Assign legacy magic effects array bool foundEnchantment = false; if (itemRecord.ParsedData.magic != null) { legacyMagic = new int[itemRecord.ParsedData.magic.Length]; for (int i = 0; i < itemRecord.ParsedData.magic.Length; i++) { legacyMagic[i] = itemRecord.ParsedData.magic[i]; if (legacyMagic[i] != 0xffff) foundEnchantment = true; } } // Discard list if no enchantment found if (!foundEnchantment) legacyMagic = null; // Fix leather helms ItemBuilder.FixLeatherHelm(this); // TEST: Force dye color to match material of imported weapons & armor // This is to fix cases where dye colour may be set incorrectly on imported item dyeColor = DaggerfallUnity.Instance.ItemHelper.GetDyeColor(this); }
/// <summary> /// Creates a random ingredient from any of the ingredient groups. /// Passing a non-ingredient group will return null. /// </summary> /// <param name="group">Ingedient group.</param> /// <returns>DaggerfallUnityItem</returns> public static DaggerfallUnityItem CreateRandomIngredient(ItemGroups ingredientGroup) { int groupIndex; Array enumArray; switch (ingredientGroup) { case ItemGroups.CreatureIngredients1: case ItemGroups.CreatureIngredients2: case ItemGroups.CreatureIngredients3: case ItemGroups.MetalIngredients: case ItemGroups.MiscellaneousIngredients1: case ItemGroups.MiscellaneousIngredients2: case ItemGroups.PlantIngredients1: case ItemGroups.PlantIngredients2: enumArray = DaggerfallUnity.Instance.ItemHelper.GetEnumArray(ingredientGroup); groupIndex = UnityEngine.Random.Range(0, enumArray.Length); break; default: return null; } // Create item DaggerfallUnityItem newItem = new DaggerfallUnityItem(ingredientGroup, groupIndex); return newItem; }
/// <summary> /// Gets item template data using group and index. /// </summary> public ItemTemplate GetItemTemplate(ItemGroups itemGroup, int groupIndex) { Array values = GetEnumArray(itemGroup); if (groupIndex < 0 || groupIndex >= values.Length) { string message = string.Format("Item index out of range: Group={0} Index={1}", itemGroup.ToString(), groupIndex); Debug.Log(message); return new ItemTemplate(); } int templateIndex = Convert.ToInt32(values.GetValue(groupIndex)); return itemTemplates[templateIndex]; }
/// <summary> /// Creates a generic item from group and template index. /// </summary> /// <param name="itemGroup">Item group.</param> /// <param name="itemIndex">Template index.</param> /// <returns>DaggerfallUnityItem.</returns> public static DaggerfallUnityItem CreateItem(ItemGroups itemGroup, int templateIndex) { // Create item int groupIndex = DaggerfallUnity.Instance.ItemHelper.GetGroupIndex(itemGroup, templateIndex); DaggerfallUnityItem newItem = new DaggerfallUnityItem(itemGroup, groupIndex); return newItem; }
/// <summary> /// Gets item group index from group and template index. /// </summary> /// <returns>Item group index, or -1 if not found.</returns> public int GetGroupIndex(ItemGroups itemGroup, int templateIndex) { Array values = GetEnumArray(itemGroup); for (int i = 0; i < values.Length; i++) { int checkTemplateIndex = Convert.ToInt32(values.GetValue(i)); if (checkTemplateIndex == templateIndex) return i; } return -1; }
/// <summary> /// Caches item template. /// </summary> ItemTemplate GetCachedItemTemplate() { if (itemGroup != cachedItemGroup || groupIndex != cachedGroupIndex) { cachedItemTemplate = DaggerfallUnity.Instance.ItemHelper.GetItemTemplate(itemGroup, groupIndex); cachedItemGroup = itemGroup; cachedGroupIndex = groupIndex; } return cachedItemTemplate; }
/// <summary> /// Construct from item group and index. /// Generates new UID. /// </summary> public DaggerfallUnityItem(ItemGroups itemGroup, int groupIndex) { uid = DaggerfallUnity.NextUID; SetItem(itemGroup, groupIndex); }