Esempio n. 1
0
 void Awake()
 {
     itemComponent = GetComponent<AllItems>();
     animator = GetComponent<Animator>();
     radius = transform.localScale.x;
     Item1 = lootDictionary[0].icon;
     Item2 = lootDictionary[1].icon;
     Item3 = lootDictionary[2].icon;
     /*lootDictionary[0] = AllItems.swordIcon1;
     lootDictionary[1] = AllItems.wandIcon;*/
 }
Esempio n. 2
0
        /// <summary>
        /// Adds (inserts before) a child KmlItem to this nodes lists of children.
        /// If item to insert before is null or not contained, it will be added at the end.
        /// This is the basic add method, derived classes can override but should
        /// always call base.Add(beforeItem, newItem) within.
        /// Public Add, AddRange, InsertBefore and InsertAfter all use this protected
        /// method to access the lists.
        /// <see cref="KML.KmlNode.Add(KML.KmlItem)"/>
        /// </summary>
        /// <param name="beforeItem">The KmlItem where the new item should be inserted before</param>
        /// <param name="newItem">The KmlItem to add</param>
        protected virtual void Add(KmlItem beforeItem, KmlItem newItem)
        {
            // ensure that item.Parent is this node
            if (newItem.Parent != this)
            {
                RemapParent(newItem, this);
            }

            // Not add always to end of AllItems, add well ordered: attribs first, then nodes.
            // Like Add(attrib), Add(Node), Add(attrib) should result in attrib, attrib, node
            if (newItem is KmlAttrib && !(beforeItem is KmlAttrib) && Children.Count > 0)
            {
                Syntax.Warning(newItem, "KML attribute should not come after nodes, will be fixed when saved");
                beforeItem = Children[0];
            }

            if (beforeItem != null && AllItems.Contains(beforeItem))
            {
                AllItems.Insert(AllItems.IndexOf(beforeItem), newItem);
            }
            else
            {
                AllItems.Add(newItem);
            }

            if (newItem is KmlNode)
            {
                if (beforeItem is KmlNode && Children.Contains((KmlNode)beforeItem))
                {
                    Children.Insert(Children.IndexOf((KmlNode)beforeItem), (KmlNode)newItem);
                }
                else
                {
                    Children.Add((KmlNode)newItem);
                }
                InvokeChildrenChanged();
            }
            else if (newItem is KmlAttrib)
            {
                KmlAttrib attrib = (KmlAttrib)newItem;
                if (attrib.Name.ToLower() == "name")
                {
                    if (Name.Length == 0)
                    {
                        Name = attrib.Value;

                        // Get notified when Name changes
                        attrib.AttribValueChanged += Name_Changed;
                        attrib.CanBeDeleted        = false;

                        // And notify that the name changed
                        InvokeToStringChanged();
                    }
                }

                if (beforeItem is KmlAttrib && Attribs.Contains((KmlAttrib)beforeItem))
                {
                    Attribs.Insert(Attribs.IndexOf((KmlAttrib)beforeItem), attrib);
                }
                else
                {
                    Attribs.Add(attrib);
                }
                InvokeAttribChanged();
            }
            else
            {
                if (beforeItem != null && Unknown.Contains(newItem))
                {
                    Unknown.Insert(Unknown.IndexOf(beforeItem), newItem);
                }
                else
                {
                    Unknown.Add(newItem);
                }
                Syntax.Warning(this, "Unknown line in persistence file: " + newItem.ToString());
            }
        }
 public OapChecklistSubGroup GetBySubGroupName(int groupId, string name)
 {
     return(AllItems.FirstOrDefault(sg => sg.OapChecklistGroupId == groupId && sg.Name.Equals(name)));
 }
Esempio n. 4
0
 private void AddToAllItemsDic(Item newItem)
 {
     AllItems.Add(newItem, eItemLocation.shelf);
 }
Esempio n. 5
0
 public override void RemoveMatchingBookmarks() => bookmarksService.Value.Remove(AllItems.Select(a => a.Bookmark).ToArray());
Esempio n. 6
0
 IEnumerator IEnumerable.GetEnumerator() => AllItems.GetEnumerator();
        public void ServerRead(ClientNetObject type, IReadMessage msg, Client c)
        {
            List <Item> prevItems = new List <Item>(AllItems.Distinct());

            byte slotCount = msg.ReadByte();

            List <ushort>[] newItemIDs = new List <ushort> [slotCount];
            for (int i = 0; i < slotCount; i++)
            {
                newItemIDs[i] = new List <ushort>();
                int itemCount = msg.ReadRangedInteger(0, MaxStackSize);
                for (int j = 0; j < itemCount; j++)
                {
                    newItemIDs[i].Add(msg.ReadUInt16());
                }
            }

            if (c == null || c.Character == null)
            {
                return;
            }

            bool accessible = c.Character.CanAccessInventory(this);

            if (this is CharacterInventory characterInventory && accessible)
            {
                if (Owner == null || !(Owner is Character ownerCharacter))
                {
                    accessible = false;
                }
                else if (!characterInventory.AccessibleWhenAlive && !ownerCharacter.IsDead)
                {
                    accessible = false;
                }
            }

            if (!accessible)
            {
                //create a network event to correct the client's inventory state
                //otherwise they may have an item in their inventory they shouldn't have been able to pick up,
                //and receiving an event for that inventory later will cause the item to be dropped
                CreateNetworkEvent();
                for (int i = 0; i < capacity; i++)
                {
                    foreach (ushort id in newItemIDs[i])
                    {
                        if (!(Entity.FindEntityByID(id) is Item item))
                        {
                            continue;
                        }
                        item.PositionUpdateInterval = 0.0f;
                        if (item.ParentInventory != null && item.ParentInventory != this)
                        {
                            item.ParentInventory.CreateNetworkEvent();
                        }
                    }
                }
                return;
            }

            List <Inventory> prevItemInventories = new List <Inventory>()
            {
                this
            };

            for (int i = 0; i < capacity; i++)
            {
                foreach (Item item in slots[i].Items.ToList())
                {
                    if (!newItemIDs[i].Contains(item.ID))
                    {
                        Item   droppedItem = item;
                        Entity prevOwner   = Owner;
                        droppedItem.Drop(null);

                        var previousInventory = prevOwner switch
                        {
                            Item itemInventory => (itemInventory.FindParentInventory(inventory => inventory is CharacterInventory) as CharacterInventory),
                            Character character => character.Inventory,
                            _ => null
                        };

                        if (previousInventory != null && previousInventory != c.Character?.Inventory)
                        {
                            GameMain.Server?.KarmaManager.OnItemTakenFromPlayer(previousInventory, c, droppedItem);
                        }

                        if (droppedItem.body != null && prevOwner != null)
                        {
                            droppedItem.body.SetTransform(prevOwner.SimPosition, 0.0f);
                        }
                    }
                }

                foreach (ushort id in newItemIDs[i])
                {
                    Item newItem = id == 0 ? null : Entity.FindEntityByID(id) as Item;
                    prevItemInventories.Add(newItem?.ParentInventory);
                }
            }

            for (int i = 0; i < capacity; i++)
            {
                foreach (ushort id in newItemIDs[i])
                {
                    if (!(Entity.FindEntityByID(id) is Item item) || slots[i].Contains(item))
                    {
                        continue;
                    }

                    if (GameMain.Server != null)
                    {
                        var holdable = item.GetComponent <Holdable>();
                        if (holdable != null && !holdable.CanBeDeattached())
                        {
                            continue;
                        }

                        if (!prevItems.Contains(item) && !item.CanClientAccess(c))
                        {
    #if DEBUG || UNSTABLE
                            DebugConsole.NewMessage($"Client {c.Name} failed to pick up item \"{item}\" (parent inventory: {(item.ParentInventory?.Owner.ToString() ?? "null")}). No access.", Color.Yellow);
    #endif
                            if (item.body != null && !c.PendingPositionUpdates.Contains(item))
                            {
                                c.PendingPositionUpdates.Enqueue(item);
                            }
                            item.PositionUpdateInterval = 0.0f;
                            continue;
                        }
                    }
                    TryPutItem(item, i, true, true, c.Character, false);
                    for (int j = 0; j < capacity; j++)
                    {
                        if (slots[j].Contains(item) && !newItemIDs[j].Contains(item.ID))
                        {
                            slots[j].RemoveItem(item);
                        }
                    }
                }
            }

            CreateNetworkEvent();
            foreach (Inventory prevInventory in prevItemInventories.Distinct())
            {
                if (prevInventory != this)
                {
                    prevInventory?.CreateNetworkEvent();
                }
            }

            foreach (Item item in AllItems.Distinct())
            {
                if (item == null)
                {
                    continue;
                }
                if (!prevItems.Contains(item))
                {
                    if (Owner == c.Character)
                    {
                        HumanAIController.ItemTaken(item, c.Character);
                        GameServer.Log(GameServer.CharacterLogName(c.Character) + " picked up " + item.Name, ServerLog.MessageType.Inventory);
                    }
                    else
                    {
                        GameServer.Log(GameServer.CharacterLogName(c.Character) + " placed " + item.Name + " in " + Owner, ServerLog.MessageType.Inventory);
                    }
                }
            }
            foreach (Item item in prevItems.Distinct())
            {
                if (item == null)
                {
                    continue;
                }
                if (!AllItems.Contains(item))
                {
                    if (Owner == c.Character)
                    {
                        GameServer.Log(GameServer.CharacterLogName(c.Character) + " dropped " + item.Name, ServerLog.MessageType.Inventory);
                    }
                    else
                    {
                        GameServer.Log(GameServer.CharacterLogName(c.Character) + " removed " + item.Name + " from " + Owner, ServerLog.MessageType.Inventory);
                    }
                }
            }
        }
Esempio n. 8
0
 public Item GetItemById(int itemId)
 {
     return(AllItems.FirstOrDefault(i => i.ItemId == itemId));
 }
Esempio n. 9
0
 public void SortItems()
 {
     AllItems.Sort();
 }
Esempio n. 10
0
 public void RemoveSelected()
 {
     AllItems.RemoveAll(item => SelectedItems.Contains(item));
     SelectedItems.Clear();
 }
Esempio n. 11
0
 private Task <bool> OnDeleteAsync(IEnumerable <EditFooTree> items)
 {
     items.ToList().ForEach(i => AllItems.Remove(i));
     return(Task.FromResult(true));
 }
Esempio n. 12
0
    private async Task <IEnumerable <EditFooTree> > OnTreeExpandQuery(EditFooTree foo)
    {
        await Task.Delay(50);

        return(AllItems.Where(f => f.ParentId == foo.Id));
    }
Esempio n. 13
0
        public static void RepointInflictStatus(AllItems items, AllAbilities abilities, AllInflictStatuses allInflictStatuses)
        {
            Dictionary <int, int> repointMap = GetRepointMap <InflictStatus>(allInflictStatuses.InflictStatuses);

            for (int itemIndex = 0; itemIndex < items.Items.Count; itemIndex++)
            {
                Item item = items.Items[itemIndex];
                if (item is Weapon)
                {
                    Weapon weapon = (Weapon)item;
                    if (weapon.Formula.Value != 2)
                    {
                        int newID = 0;
                        if (repointMap.TryGetValue(weapon.InflictStatus, out newID))
                        {
                            weapon.InflictStatus    = (byte)newID;
                            weapon.OldInflictStatus = (byte)newID;
                            allInflictStatuses.InflictStatuses[newID].ReferencingItemIndexes.Add(itemIndex);
                        }
                    }
                }
                else if (item is ChemistItem)
                {
                    ChemistItem chemistItem = (ChemistItem)item;
                    if (chemistItem.Formula != 2)
                    {
                        int newID = 0;
                        if (repointMap.TryGetValue(chemistItem.InflictStatus, out newID))
                        {
                            chemistItem.InflictStatus    = (byte)newID;
                            chemistItem.OldInflictStatus = (byte)newID;
                            allInflictStatuses.InflictStatuses[newID].ReferencingItemIndexes.Add(itemIndex);
                        }
                    }
                }
            }

            for (int abilityIndex = 0; abilityIndex < abilities.Abilities.Length; abilityIndex++)
            {
                Ability ability = abilities.Abilities[abilityIndex];
                if (!ability.IsNormal)
                {
                    continue;
                }

                AbilityAttributes abilityAttrs = ability.Attributes;
                if (abilityAttrs.Formula.Value != 2)
                {
                    int newID = 0;
                    if (repointMap.TryGetValue(abilityAttrs.InflictStatus, out newID))
                    {
                        abilityAttrs.InflictStatus    = (byte)newID;
                        abilityAttrs.OldInflictStatus = (byte)newID;
                        allInflictStatuses.InflictStatuses[newID].ReferencingAbilityIDs.Add(abilityIndex);
                    }
                }
            }

            foreach (int index in repointMap.Keys)
            {
                InflictStatus inflictStatus = allInflictStatuses.InflictStatuses[index];
                inflictStatus.ReferencingItemIndexes.Clear();
                inflictStatus.ReferencingAbilityIDs.Clear();
            }
        }
Esempio n. 14
0
        public static void BuildReferenceList(AllItemAttributes itemAttributes, AllInflictStatuses inflictStatuses, AllAbilities abilities, AllItems items)
        {
            foreach (ItemAttributes itemAttr in itemAttributes.ItemAttributes)
            {
                itemAttr.ReferencingItemIndexes.Clear();
            }

            foreach (InflictStatus inflictStatus in inflictStatuses.InflictStatuses)
            {
                inflictStatus.ReferencingAbilityIDs.Clear();
                inflictStatus.ReferencingItemIndexes.Clear();
            }

            for (int index = 0; index < items.Items.Count; index++)
            {
                Item item = items.Items[index];

                if (item.SIA < itemAttributes.ItemAttributes.Length)
                {
                    itemAttributes.ItemAttributes[item.SIA].ReferencingItemIndexes.Add(index);
                }

                if (item is Weapon)
                {
                    Weapon weapon = (Weapon)item;
                    if (weapon.Formula.Value != 2)
                    {
                        if (weapon.InflictStatus < inflictStatuses.InflictStatuses.Length)
                        {
                            inflictStatuses.InflictStatuses[weapon.InflictStatus].ReferencingItemIndexes.Add(index);
                        }
                    }
                }
                else if (item is ChemistItem)
                {
                    ChemistItem chemistItem = (ChemistItem)item;
                    if (chemistItem.Formula != 2)
                    {
                        if (chemistItem.InflictStatus < inflictStatuses.InflictStatuses.Length)
                        {
                            inflictStatuses.InflictStatuses[chemistItem.InflictStatus].ReferencingItemIndexes.Add(index);
                        }
                    }
                }
            }

            for (int index = 0; index < abilities.Abilities.Length; index++)
            {
                Ability ability = abilities.Abilities[index];
                if (ability.IsNormal)
                {
                    if ((ability.Attributes.Formula.Value != 2) && (ability.Attributes.InflictStatus < inflictStatuses.InflictStatuses.Length))
                    {
                        inflictStatuses.InflictStatuses[ability.Attributes.InflictStatus].ReferencingAbilityIDs.Add(index);
                    }
                }
            }
        }
Esempio n. 15
0
 private void Add()
 {
     AllItems.Add(new NamespaceItem());
 }
Esempio n. 16
0
 public async Task <List <Teacher> > GetTeacher()
 {
     return(await AllItems.Include(d => d.Departament).Include(t => t.TeacherSubjects).ThenInclude(s => s.Subject).ToListAsync());
 }
Esempio n. 17
0
 public static Item GetItemByLabel(string label)
 {
     return(AllItems.Where(t => t.Label == label).FirstOrDefault() ?? new Item());
 }
Esempio n. 18
0
        /// <summary>
        /// Adds a child KmlItem to this nodes lists of children, depending of its
        /// derived class KmlNode, KmlPart, KmlAttrib or further derived from these.
        /// When an KmlAttrib "Name", "Type" or "Root" are found, their value
        /// will be used for the corresponding property of this node.
        /// </summary>
        /// <param name="beforeItem">The KmlItem where the new item should be inserted before</param>
        /// <param name="newItem">The KmlItem to add</param>
        protected override void Add(KmlItem beforeItem, KmlItem newItem)
        {
            if (newItem is KmlAttrib)
            {
                KmlAttrib attrib = (KmlAttrib)newItem;
                if (attrib.Name.ToLower() == "type" && Type.Length == 0)
                {
                    Type = attrib.Value;

                    // Get notified when Type changes
                    attrib.AttribValueChanged += Type_Changed;
                    attrib.CanBeDeleted        = false;
                }
                else if (attrib.Name.ToLower() == "sit" && Situation.Length == 0)
                {
                    Situation = attrib.Value;

                    // Get notified when Type changes
                    attrib.AttribValueChanged += Situation_Changed;
                    attrib.CanBeDeleted        = false;
                }
                else if (attrib.Name.ToLower() == "root" && RootPart == null)
                {
                    SetRootPart(attrib.Value);

                    // Get notified when Type changes
                    attrib.AttribValueChanged += Root_Changed;
                    attrib.CanBeDeleted        = false;
                }
            }
            else if (newItem is KmlPart)
            {
                KmlPart part = (KmlPart)newItem;
                if (beforeItem != null)
                {
                    KmlPart beforePart = null;
                    int     allIndex   = AllItems.IndexOf(beforeItem);
                    for (int i = allIndex; i < AllItems.Count; i++)
                    {
                        if (AllItems[i] is KmlPart && Parts.Contains((KmlPart)AllItems[i]))
                        {
                            beforePart = (KmlPart)AllItems[i];
                            break;
                        }
                    }
                    if (beforePart != null)
                    {
                        beforePart.InsertionPreparation();
                        Parts.Insert(Parts.IndexOf(beforePart), part);
                        beforePart.InsertionFinalization();
                    }
                    else
                    {
                        Parts.Add(part);
                    }
                }
                else
                {
                    Parts.Add(part);
                }
                if (Parts.Count == rootPartIndex + 1)
                {
                    RootPart = Parts[rootPartIndex];
                }
                if (part.Flag != "" && !Flags.Any(x => x.ToLower() == part.Flag.ToLower()))
                {
                    Flags.Add(part.Flag);
                }
                if (part.HasResources)
                {
                    foreach (string resType in part.ResourceTypes)
                    {
                        ResourceTypes.Add(resType);
                    }
                }
                KmlAttrib flag = part.GetAttrib("flag");
                if (flag != null)
                {
                    flag.AttribValueChanged += Flag_Changed;
                }
            }
            base.Add(beforeItem, newItem);
        }
Esempio n. 19
0
 public static Item GetItemById(string id)
 {
     return(AllItems.Where(t => t.ID == id).FirstOrDefault() ?? new Item());
 }
Esempio n. 20
0
 private void RestoreData()
 {
     this.AllItems = new List <Item>();
     this.RawData.ForEach(i => AllItems.Add(i.GetCopy(true)));
 }
Esempio n. 21
0
 private void Button_Click(object sender, RoutedEventArgs e)
 {
     AllItems.Add("Testing");
 }
Esempio n. 22
0
 public IEnumerator <TrinityItem> GetEnumerator() => AllItems.GetEnumerator();
 public Ingredient GetById(int ingredientId)
 {
     return(AllItems.FirstOrDefault(i => i.Id == ingredientId));
 }
        public override AdminCustom GetByName(string name)
        {
            var r = AllItems.FirstOrDefault(i => i.Name.Equals(name));

            return(r);
        }
Esempio n. 25
0
 public Formulation GetById(int formulationId)
 {
     return(AllItems.FirstOrDefault(f => f.Id == formulationId));
 }
Esempio n. 26
0
 public eItemLocation curLocation(Item item)
 {
     return(AllItems.ContainsKey(item) ? AllItems[item] : eItemLocation.shelf);
 }
Esempio n. 27
0
 public override void RemoveMatchingCodeBreakpoints() => dbgCodeBreakpointsService.Value.Remove(AllItems.Select(a => a.CodeBreakpoint).ToArray());
 public void ClearItems()
 {
     AllItems.Clear();
     Items.Clear();
 }
Esempio n. 29
0
        private async Task FilterAndSort(string?text, CancellationTokenSource tokenSource, CancellationToken cancellationToken)
        {
            while (currentToken != null)
            {
                await Task.Run(() => Thread.Sleep(50)).ConfigureAwait(true);

                currentToken = tokenSource;
            }

            var lower = text?.ToLower();

            // filtering on a separate thread, so that UI doesn't lag
            await Task.Run(() =>
            {
                visibleCount = 0;
                foreach (var item in AllItems)
                {
                    if (string.IsNullOrEmpty(lower))
                    {
                        item.Score = 100;
                    }
                    else if (item.Name.ToLower() == lower)
                    {
                        item.Score = 101;
                    }
                    else
                    {
                        int indexOf      = item.SearchName.IndexOf(lower, StringComparison.Ordinal);
                        bool contains    = indexOf != -1;
                        bool isFullWorld = false;
                        if (contains)
                        {
                            isFullWorld = true;
                            if (indexOf > 0 && item.SearchName[indexOf - 1] != ' ')
                            {
                                isFullWorld = false;
                            }
                            indexOf += lower.Length;
                            if (indexOf < item.SearchName.Length && item.SearchName[indexOf] != ' ')
                            {
                                isFullWorld = false;
                            }
                        }
                        var score  = FuzzySharp.Fuzz.WeightedRatio(item.SearchName, lower);
                        item.Score = contains ? (Math.Max(score, isFullWorld ? 85 : 62)) : score;
                    }
                    if (item.ShowItem)
                    {
                        visibleCount++;
                    }
                    else if (item == SelectedItem)
                    {
                        SelectedItem = null;
                    }
                    if (cancellationToken.IsCancellationRequested)
                    {
                        currentToken = null;
                        return;
                    }
                }
            }, cancellationToken).ConfigureAwait(true);

            if (cancellationToken.IsCancellationRequested)
            {
                currentToken = null;
                return;
            }

            var filtered = AllItems.OrderByDescending(f => string.IsNullOrEmpty(lower) ? -f.Order : f.Score).ToList();

            Items.OverrideWith(filtered);

            SelectedItem ??= Items.FirstOrDefault();
            currentToken = null;
        }
Esempio n. 30
0
 public bool Contains(TEntity item) => AllItems.Contains(item);
Esempio n. 31
0
        public ActionResult Index(int?pageNo, string filter)
        {
            if (filter == null && TempData["filter"] != null)
            {
                filter = TempData["filter"].ToString();
            }
            TempData.Remove("pricefilter");
            TempData.Remove("search");
            TempData.Remove("category");
            int pageNumber;

            if (TempData["PageNumber"] == null)
            {
                pageNumber             = 1;
                TempData["PageNumber"] = 1;
            }
            else
            {
                if (pageNo == 1)
                {
                    pageNumber             = Convert.ToInt32(TempData["PageNumber"]) + 1;
                    TempData["PageNumber"] = pageNumber;
                }
                else if (pageNo == -1)
                {
                    pageNumber             = Convert.ToInt32(TempData["PageNumber"]) - 1;
                    TempData["PageNumber"] = pageNumber;
                }
                else
                {
                    pageNumber             = 1;
                    TempData["PageNumber"] = pageNumber;
                }
            }

            if (pageNumber < 1)
            {
                pageNumber             = 1;
                TempData["PageNumber"] = 1;
            }
            pageNumber = (pageNumber - 1) * pageSize;
            IEnumerable <Item> AllItems;

            if (filter != null)
            {
                if (filter == "1")
                {
                    TempData["filter"] = "1";
                    AllItems           = _context.Items.OrderByDescending(item => item.Price).Skip(pageNumber).Take(pageSize).ToList();
                }
                else
                {
                    TempData["filter"] = "2";
                    AllItems           = _context.Items.OrderBy(item => item.Price).Skip(pageNumber).Take(pageSize).ToList();
                }
            }
            else
            {
                AllItems = _context.Items.OrderBy(item => item.Id).Skip(pageNumber).Take(pageSize).ToList();
            }


            if (AllItems.Any() == false)
            {
                return(View("ProductSearchEnded"));
            }
            TempData.Keep();
            return(View(AllItems));
        }