Exemple #1
0
 internal Recepe Find(Slot[] Grid)
 {
     string key = Recepe.GetKeyFromGrid(Grid);
     if (recepies.ContainsKey(key))
         return recepies[key];
     return null;
 }
Exemple #2
0
 public CraftingTable()
 {
     for (int i = 0; i < Grid.Length; i++)
     {
         Grid[i] = new Slot();
     }
 }
Exemple #3
0
 public Inventory()
 {
     // An inventory is made of 100% empty slots :)
     for (int i = 0; i < Slots.Length; i++)
     {
         Slots[i] = new Slot();
     }
 }
Exemple #4
0
 protected override bool OnBeforeTransfer(Controls.GuiPanel guiSlot, Controls.GuiStackControl guiStack, Slot slot)
 {
     if (slot == craftingTable.Product)
     {
         PickUpProduct();
         return true;
     }
     return false;
 }
Exemple #5
0
 protected override bool OnPickUp(Controls.GuiPanel guiSlot, Controls.GuiStackControl guiStack, Slot slot)
 {
     if (slot == craftingTable.Product)
     {
         PickUpProduct();
         return true;
     }
     else
     {
         BindAll();
         return false;
     }
 }
Exemple #6
0
 protected override bool OnBeforeTransfer(Controls.GuiPanel guiSlot, Controls.GuiStackControl guiStack, Slot slot)
 {
     if (slot == furnace.Fuel)
     {
         // we can only use blocks as fuel if they have HOF greater than 0
         return stackInHand.AsEntity.HeatOfCombustion <= 0;
     }
     else if (slot == furnace.Product)
     {
         return true;
     }
     return false;
 }
Exemple #7
0
        internal static string GetKeyFromGrid(Slot[] Grid)
        {
            List<int> ids = new List<int>();
            int minX = 3;
            int maxX = 0;
            int minY = 3;
            int maxY = 0;
            int x, y;
            for (int i = 0; i < 9; i++)
            {
                x = i % 3;
                y = i / 3;
                if (Grid[i].IsNotEmpty)
                {
                    if (x < minX)
                        minX = x;
                    if (x > maxX)
                        maxX = x;
                    if (y < minY)
                        minY = y;
                    if (y > maxY)
                        maxY = y;
                }
            }
            string key = "";
            for (y = minY; y <= maxY; y++)
            {
                for (x = minX; x <= maxX; x++)
                {

                    int i = x + y * 3;
                    if (Grid[i].Content.IsEmpty)
                    {
                        key += "0";
                        continue;
                    }
                    int id = Grid[i].Content.Id;
                    if (!ids.Contains(id))
                    {
                        ids.Add(id);
                    }
                    key += ids.IndexOf(id) + 1;
                }
                key += ",";
            }
            key += string.Join(":", ids);
            return key;
        }
        protected GuiPanel CreateAndBindGuiSlot(Slot slot, int x, int y)
        {
            GuiPanel panel = new GuiPanel()
            {
                Location = new SlimDX.Vector2(x * slotSize, y * slotSize),
                Size = new SlimDX.Vector2(slotSize, slotSize),
                Text = "",
                Tag = slot

            };
            panel.OnClick += new EventHandler<EventArgs>(slot_OnClick);
            AddControl(panel);

            // add moveable control...
            GuiStackControl guiStack = new GuiStackControl();
            guiStack.Size = new SlimDX.Vector2(GuiScaling.ItemSize, GuiScaling.ItemSize);
            guiStack.Tag = slot.Content;
            panel.AddControl(guiStack);
            guiStack.CenterInParent();
            BindControl(guiStack);

            return panel;
        }
Exemple #9
0
 internal Recepe Find(Slot input)
 {
     return Find(new Slot[] { input, new Slot(), new Slot(), new Slot(), new Slot(), new Slot(), new Slot(), new Slot(), new Slot() });
 }
Exemple #10
0
 protected virtual void OnAfterPickUp(GuiPanel guiSlot, GuiStackControl guiStack, Slot slot)
 {
 }
Exemple #11
0
 protected virtual bool OnPickUp(GuiPanel guiSlot, GuiStackControl guiStack, Slot slot)
 {
     return false;
 }
Exemple #12
0
 protected virtual bool OnBeforeTransfer(GuiPanel guiSlot, GuiStackControl guiStack, Slot slot)
 {
     return false;
 }
Exemple #13
0
 protected virtual void OnAfterTransfer(GuiPanel guiSlot, GuiStackControl guiStack, Slot slot)
 {
 }
Exemple #14
0
 protected override void OnAfterTransfer(Controls.GuiPanel guiSlot, Controls.GuiStackControl guiStack, Slot slot)
 {
     BindAll();
 }