Esempio n. 1
0
        static public void InitWorldGenChests()
        {
            ChestLoots = new List <ChestLootData>();

            for (int i = 0; i < ItemLoader.ItemCount; i += 1)
            {
                ModItem modItem = ItemLoader.GetItem(i);
                if (modItem != null && modItem is IChestItem iChestItem)
                {
                    AddToGeneratedChests(modItem.item.type, iChestItem.ItemStack, iChestItem.GenerateCondition);
                    Instance.Logger.Warn("Chestloot: " + modItem.item.type + " found");
                }
            }
            Instance.Logger.Warn("Chestloot: Size of list is " + ChestLoots.Count);
        }
Esempio n. 2
0
        /// <summary>
        /// Gets a (human readable) unique key (as segments) from a given item type.
        /// </summary>
        /// <param name="itemType"></param>
        /// <returns></returns>
        public static Tuple <string, string> GetUniqueKeySegs(int itemType)
        {
            if (itemType < 0 || itemType >= ItemLoader.ItemCount)
            {
                throw new ArgumentOutOfRangeException("Invalid type: " + itemType);
            }
            if (itemType < ItemID.Count)
            {
                return(Tuple.Create("Terraria", ItemID.Search.GetName(itemType)));
            }

            var modItem = ItemLoader.GetItem(itemType);

            return(Tuple.Create(modItem.mod.Name, modItem.Name));
        }
Esempio n. 3
0
        public static List <TagCompound> SaveInventory(Item[] inv)
        {
            var list = new List <TagCompound>();

            for (int k = 0; k < inv.Length; k++)
            {
                if (ItemLoader.NeedsModSaving(inv[k]))
                {
                    var tag = ItemIO.Save(inv[k]);
                    tag.Set("slot", (short)k);
                    list.Add(tag);
                }
            }
            return(list.Count > 0 ? list : null);
        }
Esempio n. 4
0
        internal static TagCompound SaveAnglerQuest()
        {
            if (Main.anglerQuest < ItemLoader.vanillaQuestFishCount)
            {
                return(null);
            }

            int type    = Main.anglerQuestItemNetIDs[Main.anglerQuest];
            var modItem = ItemLoader.GetItem(type);

            return(new TagCompound {
                ["mod"] = modItem.Mod.Name,
                ["itemName"] = modItem.Name
            });
        }
Esempio n. 5
0
        public static void Consume(this Item item, int amount = 1, bool checkConsumable = true)
        {
            if (checkConsumable && !item.consumable)
            {
                return;
            }

            for (int i = 0; i < amount; i++)
            {
                if (ItemLoader.ConsumeItem(item, Main.LocalPlayer) && (item.stack--) <= 0)
                {
                    item.TurnToAir();
                }
            }
        }
Esempio n. 6
0
        protected override void Draw(SpriteBatch spriteBatch)
        {
            fade.Update(IsMouseHovering || Selected);

            spriteBatch.Draw(bg, Dimensions, Color.White * fade);

            Item item = Item.Item;

            Main.instance.LoadItem(item.type);
            Texture2D itemTexture = TextureAssets.Item[item.type].Value;

            Rectangle rect       = Main.itemAnimations[item.type] != null ? Main.itemAnimations[item.type].GetFrame(itemTexture) : itemTexture.Frame();
            Color     newColor   = Color.White;
            float     pulseScale = 1f;

            ItemSlot.GetItemLight(ref newColor, ref pulseScale, item);
            int   height    = rect.Height;
            int   width     = rect.Width;
            float drawScale = 1f;

            float availableWidth = InnerDimensions.Width;

            if (width > availableWidth || height > availableWidth)
            {
                if (width > height)
                {
                    drawScale = availableWidth / width;
                }
                else
                {
                    drawScale = availableWidth / height;
                }
            }

            Vector2 position = Dimensions.Center();
            Vector2 origin   = rect.Size() * 0.5f;

            if (ItemLoader.PreDrawInInventory(item, spriteBatch, position - rect.Size() * 0.5f * drawScale, rect, item.GetAlpha(newColor), item.GetColor(Color.White), origin, drawScale * pulseScale))
            {
                spriteBatch.Draw(itemTexture, position, rect, item.GetAlpha(newColor), 0f, origin, drawScale * pulseScale, SpriteEffects.None, 0f);
                if (item.color != Color.Transparent)
                {
                    spriteBatch.Draw(itemTexture, position, rect, item.GetColor(Color.White), 0f, origin, drawScale * pulseScale, SpriteEffects.None, 0f);
                }
            }

            ItemLoader.PostDrawInInventory(item, spriteBatch, position - rect.Size() * 0.5f * drawScale, rect, item.GetAlpha(newColor), item.GetColor(Color.White), origin, drawScale * pulseScale);
        }
        //Yoinked and edited from https://github.com/Eternal-Team/BaseLibrary/blob/1.3/Utility/RenderingUtility.cs
        public static void DrawItemInWorld(this SpriteBatch spriteBatch, Item item, Vector2 position, Vector2 size, float rotation = 0f)
        {
            if (!item.IsAir)
            {
                Texture2D itemTexture = Main.itemTexture[item.type];
                Rectangle rect        = Main.itemAnimations[item.type] != null ? Main.itemAnimations[item.type].GetFrame(itemTexture) : itemTexture.Frame();
                Color     newColor    = Color.White;
                float     pulseScale  = 1f;
                ItemSlot.GetItemLight(ref newColor, ref pulseScale, item);

                float availableWidth = size.X;
                int   width          = rect.Width;
                int   height         = rect.Height;
                float drawScale      = 1f;
                if (width > availableWidth || height > availableWidth)
                {
                    if (width > height)
                    {
                        drawScale = availableWidth / width;
                    }
                    else
                    {
                        drawScale = availableWidth / height;
                    }
                }

                Vector2 origin = rect.Size() * 0.5f;

                float totalScale = pulseScale * drawScale;

                if (ItemLoader.PreDrawInWorld(item, spriteBatch, item.GetColor(Color.White), item.GetAlpha(newColor), ref rotation, ref totalScale, item.whoAmI))
                {
                    spriteBatch.Draw(itemTexture, position, rect, item.GetAlpha(newColor), rotation, origin, totalScale, SpriteEffects.None, 0f);

                    if (item.color != Color.Transparent)
                    {
                        spriteBatch.Draw(itemTexture, position, rect, item.GetColor(Color.White), rotation, origin, totalScale, SpriteEffects.None, 0f);
                    }
                }

                ItemLoader.PostDrawInWorld(item, spriteBatch, item.GetColor(Color.White), item.GetAlpha(newColor), rotation, totalScale, item.whoAmI);

                if (ItemID.Sets.TrapSigned[item.type])
                {
                    spriteBatch.Draw(Main.wireTexture, position + new Vector2(40f, 40f) * drawScale, new Rectangle(4, 58, 8, 8), Color.White, 0f, new Vector2(4f), drawScale, SpriteEffects.None, 0f);
                }
            }
        }
Esempio n. 8
0
    private GameObject GetPlaneObject(int code)
    {
        GameObject obj = null;

        switch (type)
        {
        case GridType.NOTSPRAYABLE:
        {
            obj = Resources.Load <GameObject>(defaultModelPath + "00");
            if (obj == null)
            {
                Debug.LogError($"Load Default Failed:{defaultModelPath + "00"}");
            }
            break;
        }

        case GridType.NORMAL:
        {
            obj = ItemLoader.LoadObject(planeFilePath, code);
            if (obj == null)
            {
                Debug.LogError($"Load Normal Failed:{planeFilePath}{code.ToString("X")}");
            }
            break;
        }

        case GridType.START:
        {
            obj = ItemLoader.LoadObject(objectBaseFilePath, code);
            if (obj == null)
            {
                Debug.LogError($"Load Start Failed:{objectBaseFilePath}{code.ToString("X")}");
            }
            break;
        }

        case GridType.END:
        {
            obj = ItemLoader.LoadObject(objectBaseFilePath, code);
            if (obj == null)
            {
                Debug.LogError($"Load End Failed:{objectBaseFilePath}{code.ToString("X")}");
            }
            break;
        }
        }
        return(obj);
    }
        public override void AddRecipeGroups()
        {
            // Automatically register MinionModels
            var item       = new Item();
            var projectile = new Projectile();

            for (int i = ItemID.Count; i < ItemLoader.ItemCount; i++)
            {
                item = ItemLoader.GetItem(i).item;
                if (item.buffType > 0 && item.shoot >= ProjectileID.Count)
                {
                    projectile = ProjectileLoader.GetProjectile(item.shoot).projectile;
                    if (projectile.minionSlots > 0)
                    {
                        // Avoid automatic support for manually supported
                        if (!SupportedMinions.Any(x => x.ItemID == i || x.ProjectileIDs.Contains(projectile.type) || x.BuffID == item.buffType))
                        {
                            AddMinion(new MinionModel(item.type, item.buffType, projectile.type));
                        }
                    }
                }
            }
            SupportedMinionsFinalized = true;

            var itemList = new List <int>();

            foreach (MinionModel minion in SupportedMinions)
            {
                itemList.Add(minion.ItemID);
            }

            foreach (int type in ModdedSummonerWeaponsWithExistingBuff)
            {
                itemList.Add(type);
            }
            ModdedSummonerWeaponsWithExistingBuff = null;

            var group = new RecipeGroup(() => Language.GetTextValue("LegacyMisc.37") + " Minion Staff", itemList.ToArray());

            RecipeGroup.RegisterGroup("SummonersAssociation:MinionStaffs", group);

            group = new RecipeGroup(() => Language.GetTextValue("LegacyMisc.37") + " Magic Mirror", new int[]
            {
                ItemID.MagicMirror,
                ItemID.IceMirror
            });
            RecipeGroup.RegisterGroup("SummonersAssociation:MagicMirrors", group);
        }
Esempio n. 10
0
        static void Main(string[] args)
        {
            var rooms = Directory.GetFiles(@"Content\Rooms", "*.txt", SearchOption.AllDirectories)
                        .Select(path => RoomLoader.Load(path))
                        .ToList();
            var items = Directory.GetFiles(@"Content\Items", "*.txt", SearchOption.AllDirectories)
                        .SelectMany(path => ItemLoader.Load(path).Select(w => w.itemtemplate))
                        .ToList();

            const int mapw = 75, maph = 25;
            var       map = new Map(mapw, maph, rooms, new Random());

            for (var row = 0; row < maph; ++row)
            {
                Console.Write('/');
                for (var col = 0; col < mapw; ++col)
                {
                    var tile = map.Tiles[row, col];
                    if (tile == TileTemplate.DoorTile)
                    {
                        Console.Write('d');
                    }
                    else if (tile == TileTemplate.WallTile)
                    {
                        Console.Write('+');
                    }
                    else if (tile == TileTemplate.StartTile)
                    {
                        Console.Write('s');
                    }
                    else if (tile == TileTemplate.EmptyTile)
                    {
                        Console.Write('.');
                    }
                    else if (tile == TileTemplate.VoidTile)
                    {
                        Console.Write(' ');
                    }
                    else
                    {
                        throw new InvalidOperationException();
                    }
                }
                Console.WriteLine('/');
            }

            Console.ReadKey();
        }
Esempio n. 11
0
        public void Setup()
        {
            yleClientMock = new Mock <IYleApiClient>();

            yleClientMock.Setup(c => c.Success).Returns(true);
            yleClientMock.Setup(c => c.Search("muumi", 0, 1))
            .Returns(new object[] { null }.GetEnumerator());
            yleClientMock.Setup(c => c.Result).Returns(new[]
            {
                new ItemModel
                {
                    title   = "a title",
                    subject = "a subject",
                    series  = "a series",
                    audio   = "en"
                }
            });

            var detailsPanel = new GameObject("DetailsPanel");
            var itemPrefab   = new GameObject();

            itemPrefab.AddComponent <Button>();
            detailsPanel.transform.SetParent(itemPrefab.transform);

            AddText(itemPrefab, "TitleText");
            AddText(detailsPanel, "SeriesText");
            AddText(detailsPanel, "SubjectText");
            AddText(detailsPanel, "AudioText");
            AddText(detailsPanel, "FromText");
            AddText(detailsPanel, "ToText");

            var scrollView = new GameObject();
            var viewport   = new GameObject("Viewport");

            content = new GameObject("Content");
            viewport.transform.SetParent(scrollView.transform);
            content.transform.SetParent(viewport.transform);

            scrollView.AddComponent <ScrollRect>();
            loader = scrollView.AddComponent <ItemLoader>();

            loader.itemPrefab = itemPrefab.transform;
            loader.baseUrl    = "https://external.api.yle.fi";
            loader.loadCount  = 1;
            loader.appId      = "c6d65741";
            loader.appKey     = "6a8b448b276a88171bad6f22a059b6cd";
            loader.Start();
        }
        public override void ModifyHitNPC(Projectile projectile, NPC target, ref int damage, ref float knockback, ref bool crit, ref int hitDirection)
        {
            if (!(projectile.modProjectile is ClickerProjectile clickerProjectile && clickerProjectile.isClickerProj))
            {
                return;
            }

            Player player = Main.player[projectile.owner];

            // Vanilla crit chance calculations. Crit chance of the currently held weapon matters, regardless of the damage type of the weapon.
            int critChance = player.HeldItem.crit;

            ItemLoader.GetWeaponCrit(player.HeldItem, player, ref critChance);
            PlayerHooks.GetWeaponCrit(player, player.HeldItem, ref critChance);
            crit = critChance >= 100 || Main.rand.Next(1, 101) <= critChance;
        }
Esempio n. 13
0
 public static void LoadResearch(Player player, IList <TagCompound> list)
 {
     foreach (var tag in list)
     {
         ContentSamples.ItemNetIdsByPersistentIds.TryGetValue(tag.GetString("persistentID"), out int netID);
         ContentSamples.ItemsByType.TryGetValue(netID, out Item realItem);
         if (ItemLoader.NeedsModSaving(realItem))
         {
             player.creativeTracker.ItemSacrifices._sacrificeCountByItemPersistentId[tag.GetString("persistentID")] = tag.GetInt("sacrificeCount");
             if (ContentSamples.ItemNetIdsByPersistentIds.TryGetValue(tag.GetString("persistentID"), out int value2))
             {
                 player.creativeTracker.ItemSacrifices.SacrificesCountByItemIdCache[value2] = tag.GetInt("sacrificeCount");
             }
         }
     }
 }
Esempio n. 14
0
        // https://www.zeldadungeon.net/zelda-runners-examining-random-and-forced-drops-and-chatting-with-zant/
        private ItemSpriteFactory()
        {
            textures = new Dictionary <String, Texture2D>();
            dropRate = new Dictionary <IEntity.EnemyType, SettingsValues.Variable>();
            dropList = new Dictionary <IEntity.EnemyType, List <InventoryManager.ItemType> >();

            dropRate.Add(IEntity.EnemyType.A, SettingsValues.Variable.ItemDropA);
            dropRate.Add(IEntity.EnemyType.B, SettingsValues.Variable.ItemDropB);
            dropRate.Add(IEntity.EnemyType.C, SettingsValues.Variable.ItemDropC);
            dropRate.Add(IEntity.EnemyType.D, SettingsValues.Variable.ItemDropD);
            dropRate.Add(IEntity.EnemyType.X, SettingsValues.Variable.ItemDropX);

            itemLoader = new ItemLoader();

            killCounter = 0;
        }
Esempio n. 15
0
        /// <summary>Getter for index</summary>
        /// <param name="key">key to find (or load if needed)</param>
        /// <returns>the object value associated with key, or null if not found & could not be loaded</returns>
        public async Task <T> GetItem(TKey key, ItemLoader <TKey, T> loadItem = null)
        {
            INode <T> node = FindExistingNodeByKey(key);

            node?.Touch();

            lifespanManager.CheckValidity();

            ItemLoader <TKey, T> loader = loadItem ?? this.loadItem;

            if ((node?.Value == null) && (loader != null))
            {
                node = owner.AddAsNode(await loader(key));
            }

            return(node?.Value);
        }
Esempio n. 16
0
        public override void ModifyTooltips(Item item, List <TooltipLine> tooltips)
        {
            try {
                if (IsExplosive(item))
                {
                    if (NeedsDamageLine(item) && Origins.ExplosiveBaseDamage.ContainsKey(item.type))
                    {
                        Main.HoverItem.damage = Origins.ExplosiveBaseDamage[item.type];
                        Player player = Main.player[item.owner];
                        tooltips.Insert(1, new TooltipLine(mod, "Damage", $"{player.GetWeaponDamage(Main.HoverItem)} {Language.GetText("explosive")}{Language.GetText("LegacyTooltip.55")}"));
                        int crit = player.GetWeaponCrit(item);
                        ItemLoader.GetWeaponCrit(item, player, ref crit);
                        PlayerHooks.GetWeaponCrit(player, item, ref crit);
                        tooltips.Insert(2, new TooltipLine(mod, "CritChance", $"{crit}{Language.GetText("LegacyTooltip.41")}"));
                        return;
                    }
                    else
                    {
                        for (int i = 1; i < tooltips.Count; i++)
                        {
                            TooltipLine tooltip = tooltips[i];
                            if (tooltip.Name.Equals("Damage"))
                            {
                                tooltip.text = tooltip.text.Insert(tooltip.text.IndexOf(' '), " " + Language.GetText("explosive"));
                                return;
                            }
                        }
                    }
                }
                else
                {
                    switch (item.type)
                    {
                    case ItemID.MiningHelmet:
                        tooltips.Insert(3, new TooltipLine(mod, "Tooltip0", "3% increased explosive critical strike chance"));
                        break;

                    case ItemID.MiningShirt:
                        tooltips.Insert(3, new TooltipLine(mod, "Tooltip0", "5% increased explosive damage"));
                        break;
                    }
                }
            } catch (Exception e) {
                mod.Logger.Error(e);
            }
        }
Esempio n. 17
0
    public void discardItem()
    {
        GameObject go = ItemLoader.LoadItemToScene(item_Name);

        if (go != null)
        {
            go.SendMessage("Set_Visiable", true, SendMessageOptions.DontRequireReceiver);
            go.transform.position = this.gameObject.transform.position + new Vector3(0, discardOffset_Y, 0);

            Vector2 v2 = new Vector2(discardItemSpeed_X * (this.transform.localScale.x / Mathf.Abs(this.transform.localScale.x)), discardItemSpeed_Y);
            go.GetComponent <Rigidbody2D>().velocity = v2;

            Destroy(item);
            item_Name = null;
            item      = null;
        }
    }
Esempio n. 18
0
        public static void SaveCustomData(Item item, BinaryWriter writer, bool alwaysGlobal = true)
        {
            if (ItemLoader.IsModItem(item))
            {
                byte[] data;
                using (MemoryStream memoryStream = new MemoryStream())
                {
                    using (BinaryWriter customWriter = new BinaryWriter(memoryStream))
                    {
                        item.modItem.SaveCustomData(customWriter);
                    }
                    data = memoryStream.ToArray();
                }
                writer.Write((ushort)data.Length);
                writer.Write(data);
            }
            int numGlobals = ItemLoader.NeedsGlobalCustomSaving(item);

            if (numGlobals > 0)
            {
                writer.Write((ushort)numGlobals);
                foreach (GlobalItem globalItem in ItemLoader.globalItems)
                {
                    if (globalItem.NeedsCustomSaving(item))
                    {
                        byte[] data;
                        using (MemoryStream memoryStream = new MemoryStream())
                        {
                            using (BinaryWriter customWriter = new BinaryWriter(memoryStream))
                            {
                                globalItem.SaveCustomData(item, customWriter);
                            }
                            data = memoryStream.ToArray();
                        }
                        writer.Write(globalItem.mod.Name);
                        writer.Write(globalItem.Name);
                        writer.Write((ushort)data.Length);
                        writer.Write(data);
                    }
                }
            }
            else if (alwaysGlobal)
            {
                writer.Write((ushort)0);
            }
        }
Esempio n. 19
0
    // Update is called once per frame
    private void Start()
    {
        WeaponName = new List <string> {
            "Select your weapon"
        };
        jsonPath = Application.persistentDataPath + "/ItemDictionary.json";
        File.ReadAllText(jsonPath);
        player = item.GetComponent <ItemLoader>();


        foreach (Item itemZ in player.playerItems)
        {
            string name = itemZ.ItemName;
            WeaponName.Add(name);
        }
        WeaponList();
    }
        private static void DrawHeadLayer(Player player, int skinVariant, ref Vector2 drawOrigin, ref Color color1, ref Color color2, ref Color color3, float scale, SpriteEffects spriteEffects)
        {
            if (player.head != 38 && player.head != 135 && ItemLoader.DrawHead(player))
            {
                Texture2D pTex1 = Main.playerTextures[skinVariant, 0];
                Texture2D pTex2 = Main.playerTextures[skinVariant, 1];
                Texture2D pTex3 = Main.playerTextures[skinVariant, 2];

                var pos = new Vector2(player.position.X - Main.screenPosition.X - (float)(player.bodyFrame.Width / 2) + (float)(player.width / 2),
                                      player.position.Y - Main.screenPosition.Y + (float)player.height - (float)player.bodyFrame.Height + 4f
                                      ) + player.headPosition + drawOrigin;
                var rect = new Rectangle?(player.bodyFrame);

                Main.spriteBatch.Draw(pTex1, pos, rect, color1, player.headRotation, drawOrigin, scale, spriteEffects, 0f);
                Main.spriteBatch.Draw(pTex2, pos, rect, color2, player.headRotation, drawOrigin, scale, spriteEffects, 0f);
                Main.spriteBatch.Draw(pTex3, pos, rect, color3, player.headRotation, drawOrigin, scale, spriteEffects, 0f);
            }
        }
Esempio n. 21
0
 public static Item MakeItemFromID(int type)
 {
     if (type <= 0)
     {
         return(null);
     }
     if (type >= ItemID.Count)
     {
         return(ItemLoader.GetItem(type).item);
     }
     else
     {
         Item item;
         item = new Item();
         item.SetDefaults(type, true);
         return(item);
     }
 }
Esempio n. 22
0
    public override void UpdateVisual(int num, int code)
    {
        Transform childTransform = transform.Find($"{num}");

        if (childTransform.childCount > 0)
        {
            DestroyImmediate(childTransform.GetChild(0).gameObject);
        }

        if (code != -1)
        {
            GameObject sob = ItemLoader.LoadObject(objectPath, code);
            if (sob != null)
            {
                Instantiate(sob, childTransform);
            }
        }
    }
Esempio n. 23
0
    public bool AddItem(int itemID, int amount = 1)
    {
        //Add to the equipment slot if it's empty or stackable

        ItemData data = ItemLoader.GetItemData(itemID);

        if (data.slot != ItemData.EquipSlot.None)
        {
            if (equipment.GetItemAt((int)data.slot) == null || equipment.GetItemAt((int)data.slot).itemID == itemID)
            {
                if (equipment.AddItemAtIndex(itemID, amount, (int)data.slot) == false)
                {
                    return(true);
                }
            }
        }
        return(inventory.AddItem(itemID, amount));
    }
Esempio n. 24
0
    //internal static void WriteToStream(BlockInstanceData blockData, BinaryWriter writer)
    //{
    //byte[] bytes;
    //using (var ms = new MemoryStream())
    //{
    //    using (var bw = new BinaryWriter(ms))
    //        try
    //        {
    //            blockData.Serialize(bw);
    //        }
    //        catch (Exception e)
    //        {
    //            Logger.Error("Error during serialization of " + blockData);
    //            Logger.Exception(e);
    //        }

    //    bytes = ms.ToArray();
    //}

    //writer.Write(GameRegistry.GetBlockDataRegistryKey(blockData));
    //writer.Write((ushort)bytes.Length);
    //writer.Write(bytes);
    //}

    //internal static BlockData ReadFromStream(BinaryReader reader)
    //{
    //var blockDataRegistryKey = reader.ReadString();
    //var bytesLength = reader.ReadUInt16();
    //var bytes = reader.ReadBytes(bytesLength);

    //var entry = GameRegistry.BlockDataRegistry[blockDataRegistryKey];
    //var blockData = (BlockData)Activator.CreateInstance(entry.Type);

    //using (var ms = new MemoryStream(bytes))
    //using (var br = new BinaryReader(ms))
    //    blockData.Deserialize(br);

    //return blockData;

    //    return null;
    //}

    //public bool IsSolid(Direction direction)
    //{
    //    return solid[(int)direction];
    //}

    public void Break(Vector3 pos)
    {
        for (int i = 0; i < drops.Count; i++)
        {
            float roll = Random.Range(0f, 100f);
            if (roll <= drops[i].percentChance) //Is this right?
            {
                for (int j = 0; j < drops[i].amount; j++)
                {
                    Vector2    xyDir     = Random.insideUnitCircle.normalized * 0.25f;
                    Vector3    direction = new Vector3(xyDir.x, 0f, xyDir.y);
                    GameObject obj       = ItemLoader.CreateModel(drops[i].itemID);
                    obj.transform.position = pos + direction;
                    obj.GetComponent <Rigidbody>().AddForce(direction * Random.Range(40f, 60f) + Vector3.up * Random.Range(80f, 110f));
                }
            }
        }
    }
Esempio n. 25
0
        protected override void DrawSelf(SpriteBatch spriteBatch)
        {
            base.DrawSelf(spriteBatch);

            Main.HidePlayerCraftingMenu = true;

            if (!_vanillaItemSlot.Item.IsAir)
            {
                if (ItemLoader.PreReforge(_vanillaItemSlot.Item))
                {
                    GetInstance <VampKnives>().VampireUserInterface2.SetState(new UI.SkinInventory2());
                }
            }
            else
            {
                GetInstance <VampKnives>().VampireUserInterface2.SetState(null);
            }
        }
Esempio n. 26
0
    private static void ItemSlotText(ILContext il)
    {
        ILCursor cursor = new ILCursor(il);

        if (cursor.TryGotoNext(i => i.MatchLdloc(1), i => i.MatchLdfld <Item>("fishingPole"), i => i.MatchLdcI4(0)))
        {
            cursor.Emit(OpCodes.Ldloc, 1);
            cursor.Emit(OpCodes.Ldloc, 35);

            cursor.EmitDelegate <Func <Item, int, int> >((weapon, ammoCount) =>
            {
                foreach (BaseAmmoBag bag in GetAmmoBags(Main.LocalPlayer))
                {
                    ItemStorage storage = bag.GetItemStorage();

                    ammoCount += storage.Where(item => !item.IsAir && ItemLoader.CanChooseAmmo(weapon, item, Main.LocalPlayer)).Sum(item => item.stack);
                }

                return(ammoCount);
            });

            cursor.Emit(OpCodes.Stloc, 35);
        }

        if (cursor.TryGotoNext(i => i.MatchLdloc(1), i => i.MatchLdfld <Item>("tileWand"), i => i.MatchLdcI4(0)))
        {
            cursor.Emit(OpCodes.Ldloc, 35);

            cursor.EmitDelegate <Func <int, int> >(bait =>
            {
                foreach (FishingBelt bag in GetFishingBelts(Main.LocalPlayer))
                {
                    ItemStorage storage = bag.GetItemStorage();

                    bait += storage.Where(item => !item.IsAir && item.bait > 0).Sum(item => item.stack);
                }

                return(bait);
            });

            cursor.Emit(OpCodes.Stloc, 35);
        }
    }
Esempio n. 27
0
        internal override TwoColumnLine Create(Item item, DrawableTooltipLine line)
        {
            Player player     = Main.LocalPlayer;
            int    critChance = 0;

            if (item.melee)
            {
                critChance = player.meleeCrit - player.HeldItem.crit + item.crit;
                ItemLoader.GetWeaponCrit(item, player, ref critChance);
                PlayerHooks.GetWeaponCrit(player, item, ref critChance);
            }
            else if (item.ranged)
            {
                critChance = player.rangedCrit - player.HeldItem.crit + item.crit;
                ItemLoader.GetWeaponCrit(item, player, ref critChance);
                PlayerHooks.GetWeaponCrit(player, item, ref critChance);
            }
            else if (item.magic)
            {
                critChance = player.magicCrit - player.HeldItem.crit + item.crit;
                ItemLoader.GetWeaponCrit(item, player, ref critChance);
                PlayerHooks.GetWeaponCrit(player, item, ref critChance);
            }
            else if (item.thrown)
            {
                critChance = player.thrownCrit - player.HeldItem.crit + item.crit;
                ItemLoader.GetWeaponCrit(item, player, ref critChance);
                PlayerHooks.GetWeaponCrit(player, item, ref critChance);
            }
            else if (!item.summon)
            {
                critChance = item.crit;
                ItemLoader.GetWeaponCrit(item, player, ref critChance);
                PlayerHooks.GetWeaponCrit(player, item, ref critChance);
            }

            return(new TwoColumnLine(line)
            {
                textLeft = "Critical strike chance",
                textRight = critChance + "%",
                colorRight = Utility.DoubleLerp(Color.Red, Color.Yellow, Color.LimeGreen, critChance / GetMaxCrit(item))
            });
        }
Esempio n. 28
0
    void Start()
    {
        database = GetComponent <ItemLoader>();

        maxItemSlots   = 10;
        inventoryPanel = GameObject.Find("UIInventoryPanel");
        slotPanel      = inventoryPanel.transform.Find("SlotPanel").gameObject;
        Debug.Log("Inventory.cs|Start()|inventoryPanel: " + (inventoryPanel != null) + " | slotPanel: " + (slotPanel != null) + " | database: " + (database != null) + " | maxItemSlots: " + maxItemSlots);
        for (int i = 0; i < maxItemSlots; i++)
        {
            items.Add(new Item());
            slots.Add(Instantiate(inventorySlot));
            slots[i].transform.SetParent(slotPanel.transform);
        }
        AddItem(1);
        AddItem(2);
        AddItem(2);
        AddItem(2);
    }
Esempio n. 29
0
        public static void TestAddItemTranslation()
        {
            try
            {
                var type = ModLoader.GetMod("Bluemagic").ItemType("PuriumBreastplate");
                if (type > 0)
                {
                    TranslateTool.AddItemNameTranslation(ItemLoader.GetItem(type), "测试item名字", GameCulture.Chinese);

                    TranslateTool.AddItemTooltipTranslation(ItemLoader.GetItem(type), "测试tooltip", GameCulture.Chinese);

                    TranslateTool.AddSetBonusTranslation(ItemLoader.GetItem(type), "测试setbonus", GameCulture.Chinese);
                }
            }
            catch (Exception ex)
            {
                ErrorLogger.Log(ex.ToString());
            }
        }
Esempio n. 30
0
        public static void DrawItemGlowMask(Texture2D texture, PlayerDrawInfo info)
        {
            Item item = info.drawPlayer.HeldItem;

            if (info.shadow == 0f && !info.drawPlayer.frozen && ((info.drawPlayer.itemAnimation > 0 && item.useStyle != 0) || (item.holdStyle > 0 && !info.drawPlayer.pulley)) && !info.drawPlayer.dead && !item.noUseGraphic && (!info.drawPlayer.wet || !item.noWet))
            {
                Vector2 offset    = default(Vector2);
                float   rotOffset = 0f;
                Vector2 origin    = default(Vector2);
                if (item.useStyle == 5)
                {
                    if (Item.staff[item.type])
                    {
                        rotOffset = 0.785f * (float)info.drawPlayer.direction;
                        if (info.drawPlayer.gravDir == -1f)
                        {
                            rotOffset -= 1.57f * (float)info.drawPlayer.direction;
                        }
                        origin = new Vector2((float)texture.Width * 0.5f * (float)(1 - info.drawPlayer.direction), (float)((info.drawPlayer.gravDir == -1f) ? 0 : texture.Height));
                        int x = -(int)origin.X;
                        ItemLoader.HoldoutOrigin(info.drawPlayer, ref origin);
                        offset = new Vector2(origin.X + (float)x, 0f);
                    }
                    else
                    {
                        offset = new Vector2(10f, (float)(texture.Height / 2));
                        ItemLoader.HoldoutOffset(info.drawPlayer.gravDir, item.type, ref offset);
                        origin = new Vector2(-offset.X, (float)(texture.Height / 2));
                        if (info.drawPlayer.direction == -1)
                        {
                            origin.X = (float)texture.Width + offset.X;
                        }
                        offset = new Vector2((float)(texture.Width / 2), offset.Y);
                    }
                }
                else
                {
                    origin = new Vector2((float)texture.Width * 0.5f * (float)(1 - info.drawPlayer.direction), (float)((info.drawPlayer.gravDir == -1f) ? 0 : texture.Height));
                }
                Main.playerDrawData.Add(new DrawData(texture, info.itemLocation - Main.screenPosition + offset, new Rectangle?(texture.Bounds), new Color(250, 250, 250, item.alpha), info.drawPlayer.itemRotation + rotOffset, origin, item.scale, info.spriteEffects, 0));
            }
        }