internal Recepe Find(Slot[] Grid) { string key = Recepe.GetKeyFromGrid(Grid); if (recepies.ContainsKey(key)) return recepies[key]; return null; }
public CraftingTable() { for (int i = 0; i < Grid.Length; i++) { Grid[i] = new Slot(); } }
public Inventory() { // An inventory is made of 100% empty slots :) for (int i = 0; i < Slots.Length; i++) { Slots[i] = new Slot(); } }
protected override bool OnBeforeTransfer(Controls.GuiPanel guiSlot, Controls.GuiStackControl guiStack, Slot slot) { if (slot == craftingTable.Product) { PickUpProduct(); return true; } return false; }
protected override bool OnPickUp(Controls.GuiPanel guiSlot, Controls.GuiStackControl guiStack, Slot slot) { if (slot == craftingTable.Product) { PickUpProduct(); return true; } else { BindAll(); return false; } }
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; }
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; }
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() }); }
protected virtual void OnAfterPickUp(GuiPanel guiSlot, GuiStackControl guiStack, Slot slot) { }
protected virtual bool OnPickUp(GuiPanel guiSlot, GuiStackControl guiStack, Slot slot) { return false; }
protected virtual bool OnBeforeTransfer(GuiPanel guiSlot, GuiStackControl guiStack, Slot slot) { return false; }
protected virtual void OnAfterTransfer(GuiPanel guiSlot, GuiStackControl guiStack, Slot slot) { }
protected override void OnAfterTransfer(Controls.GuiPanel guiSlot, Controls.GuiStackControl guiStack, Slot slot) { BindAll(); }