示例#1
0
        public override bool OnBlockInteractStart(IWorldAccessor world, IPlayer byPlayer, BlockSelection blockSel)
        {
            if (variantlist == null)
            {
                LoadVariantList(api);
            }
            //must sneak click
            if (!byPlayer.Entity.Controls.Sneak)
            {
                return(base.OnBlockInteractStart(world, byPlayer, blockSel));
            }
            //must have a relevant item
            ItemStack stack           = byPlayer.InventoryManager.ActiveHotbarSlot?.Itemstack;
            string    itemorblockcode = "";

            if (stack == null)
            {
                BEEAssembler bee = (BEEAssembler)api.World.BlockAccessor.GetBlockEntity(blockSel.Position);
                if (bee != null)
                {
                    bee.OpenStatusGUI(); return(true);
                }
                return(base.OnBlockInteractStart(world, byPlayer, blockSel));
            }
            if (stack.Item != null)
            {
                itemorblockcode = stack.Item.Code.ToString();
            }
            else if (stack.Block != null)
            {
                itemorblockcode = stack.Block.Code.ToString();
            }
            if (itemorblockcode == "")
            {
                return(base.OnBlockInteractStart(world, byPlayer, blockSel));
            }
            if (!variantlist.ContainsKey(itemorblockcode))
            {
                return(base.OnBlockInteractStart(world, byPlayer, blockSel));
            }
            byPlayer.InventoryManager.ActiveHotbarSlot.TakeOut(1);
            string newblockname = variantlist[itemorblockcode];

            newblockname += "-" + this.LastCodePart();
            Block newclayformer = world.GetBlock(new AssetLocation(newblockname));

            if (newclayformer == null)
            {
                return(base.OnBlockInteractStart(world, byPlayer, blockSel));
            }
            world.BlockAccessor.SetBlock(newclayformer.BlockId, blockSel.Position);
            return(true);
        }
示例#2
0
        public void SetupDialog(BEEAssembler bea)
        {
            ElementBounds dialogBounds = ElementStdBounds.AutosizedMainDialog.WithAlignment(EnumDialogArea.CenterMiddle);

            // Just a simple 300x100 pixel box with 40 pixels top spacing for the title bar
            ElementBounds textBounds = ElementBounds.Fixed(0, 40, 600, 600);

            // Background boundaries. Again, just make it fit it's child elements, then add the text as a child element
            ElementBounds bgBounds = ElementBounds.Fill.WithFixedPadding(GuiStyle.ElementToDialogPadding);

            bgBounds.BothSizing = ElementSizing.FitToChildren;
            bgBounds.WithChildren(textBounds);
            string guicomponame = bea.Pos.ToString() + "Assembler";
            string statustext   = "";
            string alertred     = "<font color=\"#ffbbaa\">";//<font <color=\"#ffdddd\">>";

            if (!bea.IsPowered)
            {
                statustext += alertred;
            }
            else if (bea.DeviceState == BEEBaseDevice.enDeviceState.MATERIALHOLD)
            {
                statustext += alertred;
            }
            else if (bea.DeviceState == BEEBaseDevice.enDeviceState.RUNNING)
            {
                statustext += "<font color=\"#aaff55\">";
            }
            else
            {
                statustext += "<font>";
            }
            statustext += "<strong>STATUS: " + bea.Status + "</strong></font><br><br>";
            statustext += "Making <strong>" + bea.FG.ToUpper() + "</strong><br><br>";
            statustext += "Requires <strong>" + bea.RM + "</strong>";
            if (bea.Materials.Length > 0 && bea.DeviceState == BEEBaseDevice.enDeviceState.MATERIALHOLD)
            {
                statustext += " of material ";
                statustext += "<font><strong>";

                for (int c = 0; c < bea.Materials.Length; c++)
                {
                    if (c == bea.Materials.Length - 1)
                    {
                        statustext += ", or ";
                    }
                    else if (c != 0)
                    {
                        statustext += ", ";
                    }

                    statustext += bea.Materials[c];
                }
                statustext += ".</font></strong>";
            }
            SingleComposer = capi.Gui.CreateCompo(guicomponame, dialogBounds)
                             .AddShadedDialogBG(bgBounds)
                             .AddDialogTitleBar("Metal Press Status", OnTitleBarCloseClicked)
                             .AddRichtext(statustext, CairoFont.WhiteDetailText(), textBounds)

                             .Compose()
            ;
        }