Beispiel #1
0
        public bool AttemptCopyColorAt(Player player, ushort tileX, ushort tileY)
        {
            var        myworld = ModContent.GetInstance <BetterPaintWorld>();
            PaintLayer data;

            int copyType    = ModContent.ItemType <CopyCartridgeItem>();
            int copyItemIdx = ItemFinderHelpers.FindIndexOfFirstOfItemInCollection(player.inventory, new HashSet <int> {
                copyType
            });

            if (copyItemIdx == -1)
            {
                return(false);
            }

            switch (this.Layer)
            {
            case PaintLayerType.Foreground:
                data = myworld.Layers.Foreground;
                break;

            case PaintLayerType.Background:
                data = myworld.Layers.Background;
                break;

            case PaintLayerType.Anyground:
                if (myworld.Layers.Foreground.HasColorAt(tileX, tileY))
                {
                    data = myworld.Layers.Foreground;
                }
                else
                {
                    data = myworld.Layers.Background;
                }
                break;

            default:
                throw new ModHelpersException("Not implemented.");
            }

            if (!data.HasColorAt(tileX, tileY))
            {
                return(false);
            }

            Color colorAt = (Color)data.GetRawColorAt(tileX, tileY);

            CopyCartridgeItem.SetWithColor(player, player.inventory[copyItemIdx], colorAt);

            return(true);
        }
        public CopyCartridgeRecipe(BetterPaintMod mymod, ModItem basecart, CopyCartridgeItem copycart) : base(mymod)
        {
            int manaPotQt = mymod.Config.CopyPaintRecipeManaPotions;
            int naniteQt  = mymod.Config.CopyPaintRecipeNanites;

            this.AddTile(ModContent.TileType <PaintMixerTile>());

            this.AddIngredient(basecart, 1);

            if (manaPotQt > 0)
            {
                this.AddIngredient(ItemID.GreaterManaPotion, manaPotQt);
            }
            if (naniteQt > 0)
            {
                this.AddIngredient(ItemID.Nanites, naniteQt);
            }

            this.SetResult(copycart);
        }