public void Add(Item item, int count) { bool newItem = true; ItemWrapper wrapper = new ItemWrapper(item, count); /*if(item.type == "cons") { return; } if(item.type == "ammo") { } * */ //if item exists within inventory, count up for (int i = 0; i < content.Count; i++) { if (content[i].item.name == wrapper.item.name) { content[i].count += 1; newItem = false; } } //if item not found, add it as new item with count 1 if (newItem) { content.Add(wrapper); } }
public FieldWrapper(string key, ref ItemWrapper item, string value, ISpawnProvider spawnProvider) { Sitecore.Diagnostics.Assert.ArgumentNotNull(key, "key"); Sitecore.Diagnostics.Assert.ArgumentNotNull(item, "item"); _key = key; _item = item; _rawValue = value; SpawnProvider = spawnProvider; }
public ItemWrapperTest() { ID id = ID.NewID; ID templateId = ID.NewID; Database database = Database.GetDatabase("master"); Language language = Language.Parse("uk-UA"); var itemWrapper = new ItemWrapper(id, new ItemData(new ItemDefinition(id, "item", templateId, ID.Null), language, Version.First, new FieldList()), database); item = itemWrapper as Item; }
public void ShouldBeEqualItemWithSameID() { ID id = item.ID; ID templateId = ID.NewID; Database database = Database.GetDatabase("master"); Language language = Language.Parse("uk-UA"); var item2 = new ItemWrapper(id, new ItemData(new ItemDefinition(id, "item", templateId, ID.Null), language, Version.First, new FieldList()), database) as Item; item.Equals(item2).Should().BeTrue(); }
/// <summary> /// 기존의 Inventory 데이터를 수정하고자 할 생성자 /// </summary> /// <param name="viewModel"></param> /// <param name="inventoryWrapper">수정하고자할 inventory 래핑 클래스</param> public InventoryWrapperEditorViewModel(InventoryWrapperViewModel viewModel, InventoryWrapper inventoryWrapper) : base(inventoryWrapper) { if (inventoryWrapper == null) throw new ArgumentNullException(); _viewModel = viewModel; _target = inventoryWrapper; Specification = inventoryWrapper.Specification; Item = inventoryWrapper.Item; Warehouse = inventoryWrapper.Warehouse; ItemList = new ItemWrapper[] { Item }; SpecificationList = new SpecificationWrapper[] { Specification }; WarehouseList = FieldWrapperDirector.GetInstance().CreateCollection<Warehouse, Observable<Warehouse>>().Where(x => !x.IsDeleted); }
public async Task LoadAsync(int itemId) { var item = await _dataService.GetByIdAsync(itemId); Item = new ItemWrapper(item); Item.PropertyChanged += (s, e) => { if (e.PropertyName == nameof(Item.HasErrors)) { ((DelegateCommand)SaveCommand).RaiseCanExecuteChanged(); } }; ((DelegateCommand)SaveCommand).RaiseCanExecuteChanged(); }
/// <summary> /// Wehn first started will check to see if this has been instantiated /// from the owning player with item data. If not it will destroy this /// object because it was instantiated from Invector and not photon. /// This is to prevent duplicates appearing for the player that /// originally dropped this. /// </summary> protected virtual void Start() { if (skipStartCheck == false) { object[] data = GetComponent <PhotonView>().InstantiationData; if (PhotonNetwork.InRoom == true && data == null && syncCreateDestroy == true) { Destroy(gameObject); } else if (PhotonNetwork.InRoom == true && syncCreateDestroy == true) { ItemWrapper wrapper = JsonUtility.FromJson <ItemWrapper>(data[0] as string); GetComponent <vItemCollection>().items = wrapper.items; } } }
public static Item CreateInstance(Database database, string itemName, ID itemId, ID templateId, ID branchId, FieldList fields, Language language, Version version) { Assert.ArgumentNotNull(database, "database"); Assert.ArgumentNotNullOrEmpty(itemName, "itemName"); Assert.ArgumentNotNull(itemId, "itemId"); Assert.ArgumentNotNull(templateId, "templateId"); Assert.ArgumentNotNull(fields, "fields"); Assert.ArgumentNotNull(language, "language"); Assert.ArgumentNotNull(version, "version"); var item = new ItemWrapper(itemId, new ItemData(new ItemDefinition(itemId, itemName, templateId, branchId ?? ID.Null), language, version, fields), database); EnsureItemFields(item); return item; }
/// <summary> /// 기존의 InOutStock 데이터를 수정할 때 쓰이는 생성자입니다. /// </summary> /// <param name="viewModel"></param> /// <param name="ioStockWrapper"></param> public StockWrapperEditorViewModel(StockWrapperViewModel viewModel, StockWrapper ioStockWrapper) : base(ioStockWrapper) { if (ioStockWrapper == null) throw new ArgumentNullException(); _target = ioStockWrapper; Initialize(viewModel); //수정할 데이터를 변경할 수 없도록 고정 ItemList = new ItemWrapper[] { _target.Item }; SpecificationList = new SpecificationWrapper[] { _target.Specification }; WarehouseList = new Observable<Warehouse>[] { _target.Warehouse }; Item = ItemList.First(); Specification = SpecificationList.First(); Warehouse = WarehouseList.First(); }
void UpdateItem() { if (Item == null) { Item = new ItemWrapper() { Amount = 0, Item = null } } ; if (Item != null && (Item.Amount == 0 || Item.Item == null)) { Item.Item = null; Item.Amount = 0; } } }
internal static bool ShouldStashItem(CachedACDItem cItem) { if (cItem.AcdItem != null && cItem.AcdItem.IsValid) { bool result = false; var item = new Item(cItem.AcdItem); var wrappedItem = new ItemWrapper(cItem.AcdItem); result = ShouldStashItem(item, cItem); string action = result ? "KEEP" : "TRASH"; return result; } return false; }
public ItemWrapper UpdateQuality(ItemWrapper item) { if (item.Quality > 0) { item.Quality = item.Quality - 1; } item.SellIn = item.SellIn - 1; if (item.SellIn < 0) { if (item.Quality > 0) { item.Quality = item.Quality - 1; } } return item; }
public NameValueListFieldWrapper(string key, ref ItemWrapper item, ISpawnProvider spawnProvider, ArrayList value = null) : base(key, ref item, string.Empty, spawnProvider) { if (value == null) { return; } _value = new NameValueCollection(); foreach (object val in value) { if (val is ArrayList) { var tmp = val as ArrayList; _value.Add(tmp[0].ToString(), tmp[1].ToString()); } } this._rawValue = _value.ToString(); }
public bool MoveNext() { _currentItemWrapper?.PlaceInQuarantine(); while (true) { if (_testedItemWrappers.Count == _itemsWrappers.Length) { _currentItemWrapper = null; return(false); } _currentItemWrapper = _getNextItem(); _testedItemWrappers.Add(_currentItemWrapper); if (!_currentItemWrapper.QuarantinedUntil.HasValue || _currentItemWrapper.QuarantinedUntil.Value <= _dateTimeProvider.Time()) { return(true); } } }
public bool MoveNext() { _currentItemWrapper?.PlaceInQuarantine(); while (true) { _currentIndex++; if (_currentIndex >= _itemsWrappers.Length) { _currentItemWrapper = null; return(false); } _currentItemWrapper = _itemsWrappers[_currentIndex]; if (!_currentItemWrapper.QuarantinedUntil.HasValue || _currentItemWrapper.QuarantinedUntil.Value <= _dateTimeProvider.Time()) { return(true); } } }
public bool Put(ItemWrapper items) { if (Item == null) { Item = new ItemWrapper() { Amount = 0, Item = items.Item }; } else if (Item.Item == null) { Item.Item = items.Item; } else if (Item.Item != items.Item) { return(false); } var accept = Mathf.Min(Item.Amount + items.Amount, Volume) - Item.Amount; Item.Amount += accept; items.Amount -= accept; return(true); }
private static void MarkCellAsUsed(int currentRow, int currentCol, ItemWrapper i) { _usedGrid[currentCol, currentRow] = true; if (i.IsTwoSquareItem) { Logger.LogDebug("{0} is two squares, marking {1},{2} as used", i.Name, currentCol, currentRow + 1); _usedGrid[currentCol, currentRow + 1] = true; } }
/// <summary> /// Compares items for sorting. Returns -1 if item1 comes before item2. Returns 0 if items are of equal sort. Returns 1 if item1 should come after item2. /// </summary> /// <param name="thisItem">The item1.</param> /// <param name="thatItem">The item2.</param> /// <returns>System.Int32.</returns> public static int Compare(this ItemWrapper thisItem, ItemWrapper thatItem) { Logger.LogDebug("Comparing item {0} ({1}) to {2} ({3})", thisItem.Name, thisItem.InternalName, thatItem.Name, thatItem.InternalName); if (thisItem.DynamicId == thatItem.DynamicId) return 0; string thisInternalName = thisItem.InternalName.ToLower().Replace("x1_", "").Replace("p1_", ""); string thatInternalName = thatItem.InternalName.ToLower().Replace("x1_", "").Replace("p1_", ""); string thisSortName = thisItem.Name; string thatSortName = thatItem.Name; // Compare front to back, or back to front if (!thisItem.IsEquipment) { /* * Non-Equipent (Potions, Gems, Keys, Consumables, Follower Items) */ // Potions if (thisItem.ItemType == ItemType.Potion) { if (thatItem.ItemType == ItemType.Potion) { return String.Compare(thisSortName, thatSortName, StringComparison.InvariantCulture); } return 1; } if (thisItem.ItemType != ItemType.Potion && thatItem.ItemType == ItemType.Potion) return -1; // Gems if (thisItem.IsGem) { if (thatItem.IsGem) { // Amethyst // Diamond // Emerald // Ruby // Topaz var gemType = new[] { thisInternalName.Substring(0, 4), thatInternalName.Substring(0, 4) }; if (gemType[0] != gemType[1]) return String.Compare(gemType[0], gemType[1], StringComparison.InvariantCulture); if (thisItem.GemQuality == thatItem.GemQuality) return thisItem.ItemStackQuantity.CompareTo(thatItem.ItemStackQuantity) * -1; return thisItem.GemQuality.CompareTo(thatItem.GemQuality); } return 1; } if (thatItem.IsGem && !thisItem.IsGem) return -1; // Rift Keys if (thisItem.ItemType == ItemType.KeystoneFragment) { // Greater // Trial // Normal if (thatItem.ItemType == ItemType.KeystoneFragment) { return thisItem.TieredLootRunKeyLevel.CompareTo(thatItem.TieredLootRunKeyLevel); } return 1; } if (thatItem.ItemType == ItemType.KeystoneFragment && thisItem.ItemType != ItemType.KeystoneFragment) return -1; // Ramadalini's Gift const string ramadalinisGiftInternalname = "Consumable_Add_Sockets"; if (thisItem.Name.StartsWith(ramadalinisGiftInternalname)) { if (thatItem.Name.StartsWith(ramadalinisGiftInternalname)) return 0; return 1; } if (thatItem.Name.StartsWith(ramadalinisGiftInternalname) && !thatItem.Name.StartsWith(ramadalinisGiftInternalname)) return -1; // Item Quality if (thisItem.ItemQualityLevel != thatItem.ItemQualityLevel) { return thisItem.ItemQualityLevel.CompareTo(thatItem.ItemQualityLevel); } // Item Base Type if (thisItem.ItemBaseType != thatItem.ItemBaseType) { return thisItem.ItemBaseType.CompareTo(thatItem.ItemBaseType); } // Item Type if (thisItem.ItemType != thatItem.ItemType) { return thisItem.ItemType.CompareTo(thatItem.ItemType); } return String.Compare(thisSortName, thatSortName, StringComparison.InvariantCulture); } if (thisItem.IsEquipment) { /* * Equipment (Weapons, Armor, Jewlery) */ // Two slots before one slots if (!thisItem.IsTwoSquareItem && thatItem.IsTwoSquareItem) return -1; if (thisItem.IsTwoSquareItem && !thatItem.IsTwoSquareItem) return 1; // Sort Sets if (thisItem.IsSetItem && thatItem.IsSetItem && thisItem.IsTwoSquareItem) { bool isSameSet = thisItem.ItemSetName == thatItem.ItemSetName; if (isSameSet) { return String.Compare(thisSortName, thatSortName, StringComparison.InvariantCulture); } return String.Compare(thisItem.ItemSetName, thatItem.ItemSetName, StringComparison.InvariantCulture); } // Compare ItemQualityLevel - Legendaries come before other junk if (thisItem.ItemQualityLevel != thatItem.ItemQualityLevel) { return thisItem.ItemQualityLevel.CompareTo(thatItem.ItemQualityLevel); } // Compare ItemBaseType order if (thisItem.ItemBaseType == ItemBaseType.Weapon && thatItem.ItemBaseType != ItemBaseType.Weapon) return 1; if (thatItem.ItemBaseType == ItemBaseType.Weapon && thisItem.ItemBaseType != ItemBaseType.Weapon) return -1; // Compare Armor if (thisItem.ItemBaseType == ItemBaseType.Armor) { if (thatItem.ItemBaseType == ItemBaseType.Weapon) return -1; if (thatItem.ItemBaseType != ItemBaseType.Armor) return 1; if (thisItem.ItemType != thatItem.ItemType) { if (thisItem.IsTwoSquareItem && !thatItem.IsTwoSquareItem) return 1; if (!thisItem.IsTwoSquareItem && thatItem.IsTwoSquareItem) return -1; return thisItem.ItemType.CompareTo(thatItem.ItemType); } return String.Compare(thisSortName, thatSortName, StringComparison.InvariantCulture); } // Compare Jewlery if (thisItem.ItemBaseType == ItemBaseType.Jewelry) { if (thatItem.ItemBaseType == ItemBaseType.Weapon) return -1; if (thatItem.ItemBaseType == ItemBaseType.Armor) return -1; if (thisItem.ItemType != thatItem.ItemType) { return thisItem.ItemType.CompareTo(thatItem.ItemType); } return String.Compare(thisSortName, thatSortName, StringComparison.InvariantCulture); } // Weapons, sort by Has Sockets, Average Damage if (thisItem.ItemBaseType == ItemBaseType.Weapon) { if (thisItem.StatsData.Sockets > 0 && thatItem.StatsData.Sockets == 0) return 1; if (thatItem.StatsData.Sockets > 0 && thisItem.StatsData.Sockets == 0) return -1; if (((thisItem.StatsData.MinDamage + thisItem.Stats.MaxDamage) / 2) > ((thatItem.StatsData.MinDamage + thatItem.StatsData.MaxDamage) / 2)) return 1; if (((thisItem.StatsData.MinDamage + thisItem.Stats.MaxDamage) / 2) < ((thatItem.StatsData.MinDamage + thatItem.StatsData.MaxDamage) / 2)) return -1; if (thisItem.ItemType != thatItem.ItemType) return thisItem.ItemType.CompareTo(thatItem.ItemType); return thisItem.StatsData.WeaponDamagePerSecond.CompareTo(thatItem.StatsData.WeaponDamagePerSecond); } return 1; } return -1; }
public void AddOutgoingDependency(ItemWrapper item) { outgoingDependencies.Add(item); }
public NameValueListFieldWrapper(string key, ref ItemWrapper item, ISpawnProvider spawnProvider, NameValueCollection value = null) : base(key, ref item, (value ?? new NameValueCollection(0)).ToString(), spawnProvider) { _value = value; }
public GeneralLinkFieldWrapper(string key, ref ItemWrapper item, ISpawnProvider spawnProvider, string value = null) : base(key, ref item, value, spawnProvider) { }
public override void CopyTo(ItemWrapper itemWrapperToCopyTo) { base.CopyTo(itemWrapperToCopyTo); if (itemWrapperToCopyTo is MyDomainModel.FeedReader.FeedCollection) { ((MyDomainModel.FeedReader.FeedCollection)itemWrapperToCopyTo).RemoveOldItems = RemoveOldItems; } }
public void AddIncomingDependency(ItemWrapper item) { incomingDependencies.Push(item); }
public void RemoveOutgoingDependency(ItemWrapper item) { if (outgoingDependencies.Contains(item)) outgoingDependencies.Remove(item); }
public static Item CreateTypedItem(ItemWrapper itemWrapper) { return (itemWrapper != null && TypeMappings.ContainsKey(itemWrapper.GetType())) ? TypeMappings[itemWrapper.GetType()].InvokeMember("ctor", System.Reflection.BindingFlags.CreateInstance, null, null, new object[] { itemWrapper }) as Item : new Item(itemWrapper); }
public NameValueListFieldWrapper(string key, ref ItemWrapper item, ISpawnProvider spawnProvider, string value = null) : this(key, ref item, spawnProvider, HttpUtility.ParseQueryString(value ?? "")) { }
protected void on_search_results(List<File> search_results) { System.Console.WriteLine("got results {0}", search_results.Count); Singleton<OverlayTracker>.Instance.hide_all_and_die(); List<ItemWrapper> items = new List<ItemWrapper>(); List<string> files = new List<string>(); Dictionary<string, VoidFunction<string[]>> callbacks = new Dictionary<string, VoidFunction<string[]>>(); foreach (File file in search_results) { string path = "file://" + file.path; if (callbacks.ContainsKey(path)) { continue; } ItemWrapper wrapper = new ItemWrapper(new Nemo.Item(file)); files.Add(file.path); callbacks.Add(path, Helpers.RunInMainThread<string[]>(delegate(string[] result) { // System.Console.WriteLine("results: {0}", result.Length); System.Console.WriteLine("result: {0} for {1}", result[0], path); if (Nemo.DocumentItem.is_document(result[0])) { Nemo.VoidFunction data_callback = wrapper.item.on_data_callback; Nemo.VoidFunction label_callback = wrapper.item.on_labels_callback; Nemo.VoidFunction<bool> small_starred_update = wrapper.item.small_starred_update_function; // in case something was changed before we got data from tracker wrapper.item.file.labels.Clear(); foreach (Nemo.UserLabel l in wrapper.item.labels) wrapper.item.file.labels.Add(l.metalabel); wrapper.item = new Nemo.DocumentItem(wrapper.item.file, result, search_input.Text); if (data_callback != null) { wrapper.item.on_data_callback = data_callback; wrapper.item.on_data_callback(); } if (label_callback != null) wrapper.item.on_labels_callback = label_callback; if (small_starred_update != null) wrapper.item.small_starred_update_function = small_starred_update; } else if (Nemo.PictureItem.is_image(result[0])) { Nemo.VoidFunction data_callback = wrapper.item.on_data_callback; Nemo.VoidFunction label_callback = wrapper.item.on_labels_callback; Nemo.VoidFunction<bool> small_starred_update = wrapper.item.small_starred_update_function; // in case something was changed before we got data from tracker wrapper.item.file.labels.Clear(); foreach (Nemo.UserLabel l in wrapper.item.labels) wrapper.item.file.labels.Add(l.metalabel); wrapper.item = new Nemo.PictureItem(wrapper.item.file, result); if (data_callback != null) { wrapper.item.on_data_callback = data_callback; wrapper.item.on_data_callback(); } if (label_callback != null) wrapper.item.on_labels_callback = label_callback; if (small_starred_update != null) wrapper.item.small_starred_update_function = small_starred_update; } else wrapper.item.mime_type = result[0]; })); wrapper.item.search_func = do_search; items.Add(wrapper); } broker.get_metadata(files, callbacks); calendar_driver.new_elements_in_view(items); }
internal static R __convert <R>(object obj) where R : FizzleObject { ConstructorInfo constructor = typeof(R).GetConstructor(new[] { typeof(string) }); return(constructor == null ? null : constructor.Invoke(new object[] { ItemWrapper.GetWrapper(obj).name }) as R); }
public IntegerFieldWrapper(string key, ref ItemWrapper item, ISpawnProvider spawnProvider, long value) : base(key, ref item, value.ToString(), spawnProvider) { _value = value; }
// compare whether two ItemWrapper classes are same by comparing // their name and their array of unique dependencies public bool Equals(ItemWrapper item) { if (!item.GetName().Equals(this.name)) return false; string[] otherDependencies = item.GetDependencies(); if (otherDependencies == null && dependencies == null) return true; else if (dependencies == null || otherDependencies == null) return false; otherDependencies = otherDependencies.Distinct().ToArray(); dependencies = dependencies.Distinct().ToArray(); Array.Sort(otherDependencies); Array.Sort(dependencies); for (int i = 0; i < dependencies.Length; i++) { if (!dependencies[i].Equals(otherDependencies[i])) return false; } return true; }
public RulesFieldWrapper(string key, ref ItemWrapper item, ISpawnProvider spawnProvider, string value = null) : base(key, ref item, value, spawnProvider) { }
public NumberFieldWrapper(string key, ref ItemWrapper item, ISpawnProvider spawnProvider, float value) : base(key, ref item, value.ToString(), spawnProvider) { _value = value; }
public override void CopyTo(ItemWrapper itemWrapperToCopyTo) { base.CopyTo(itemWrapperToCopyTo); if (itemWrapperToCopyTo is MyDomainModel.FeedReader.Feed) { ((MyDomainModel.FeedReader.Feed)itemWrapperToCopyTo).Url = Url; ((MyDomainModel.FeedReader.Feed)itemWrapperToCopyTo).Name = Name; } }
public BooleanFieldWrapper(string key, ref ItemWrapper item, ISpawnProvider spawnProvider, bool value) : base(key, ref item, value ? "1" : "", spawnProvider) { _boolean = value; }
public override void CopyTo(ItemWrapper itemWrapperToCopyTo) { base.CopyTo(itemWrapperToCopyTo); if (itemWrapperToCopyTo is MyDomainModel.FeedReader.FeedItem) { ((MyDomainModel.FeedReader.FeedItem)itemWrapperToCopyTo).Title = Title; ((MyDomainModel.FeedReader.FeedItem)itemWrapperToCopyTo).Link = Link; ((MyDomainModel.FeedReader.FeedItem)itemWrapperToCopyTo).Description = Description; } }
public DateTimeFieldWrapper(string key, ref ItemWrapper item, ISpawnProvider spawnProvider, DateTime value) : base(key, ref item, value.ToString(), spawnProvider) { _dateTime = value; }
public override void CopyTo(ItemWrapper itemWrapperToCopyTo) { base.CopyTo(itemWrapperToCopyTo); if (itemWrapperToCopyTo is MyDomainModel.FeedReader.Comment) { ((MyDomainModel.FeedReader.Comment)itemWrapperToCopyTo).Text = Text; ((MyDomainModel.FeedReader.Comment)itemWrapperToCopyTo).FeedItem = ItemWrapper.CreateTypedWrapper(itemWrapperToCopyTo.Item.Database.GetItem(new ID(FeedItem.ReferenceId))); } }
public RichTextFieldWrapper(string key, ref ItemWrapper item, ISpawnProvider spawnProvider, string value = null) : base(key, ref item, spawnProvider, value) { }