Пример #1
0
        public Item Construct(IEntity from, int luckChance, LootStage stage, bool hasBeenStolenFrom)
        {
            int totalChance = 0;

            for (int i = 0; i < Items.Length; ++i)
            {
                totalChance += Items[i].Chance;
            }

            int rnd = Utility.Random(totalChance);

            for (int i = 0; i < Items.Length; ++i)
            {
                LootPackItem item = Items[i];

                if (rnd < item.Chance)
                {
                    Item loot = null;

                    if (item.ConstructCallback != null)
                    {
                        loot = item.ConstructCallback(from);
                    }
                    else
                    {
                        loot = item.Construct(IsInTokuno(from), IsMondain(from), IsStygian(from));
                    }

                    if (loot != null)
                    {
                        return(Mutate(from, luckChance, loot));
                    }
                }

                rnd -= item.Chance;
            }

            return(null);
        }