public bool IsMadeInFurnace = false; //indicate if it is made inside a furnace public oCraft(oItem sRecipe, oItem[] sInputs, oItem[] sOutputs, bool sIsFurnace = false) { this.Recipe = sRecipe; this.Inputs = sInputs; this.Outputs = sOutputs; this.IsMadeInFurnace = sIsFurnace; }
private void CreateNewButtonBoth(oItem i) { Bitmap img = Crafts.GetAssociatedIcon(i); this.CreateNewButtonBelt(img, i); this.CreateNewButtonMachine(img, i); }
private void RefreshSize() { this.TextBelt.Top = 15; // 15 this.TextBelt.Left = 5; // 5 this.TextBelt.AutoSize = true; this.TextAssembler.Top = 55; // 55 this.TextAssembler.Left = 5; // 5 this.TextAssembler.AutoSize = true; int StartLeft = 70; // 70 Size buttonsize = new Size(40, 40); // 40 40 int actualleft = StartLeft; foreach (Button b in this.listButtonBelt) { MOType mt = (MOType)(((object[])(b.Tag))[0]); oItem i = (oItem)(((object[])(b.Tag))[1]); b.Left = actualleft; b.Top = 1; b.Size = buttonsize; //back color //// couleur d'arrière plan b.BackColor = Color.Gainsboro; bool isbelt = i.IsBelt; if (!isbelt) { b.BackColor = Color.Crimson; } //next iteration actualleft += b.Width + 1; } actualleft = StartLeft; foreach (Button b in this.listButtonMachine) { MOType mt = (MOType)(((object[])(b.Tag))[0]); oItem i = (oItem)(((object[])(b.Tag))[1]); b.Left = actualleft; b.Top = 1 + buttonsize.Height + 2; b.Size = buttonsize; //back color //// couleur d'arrière plan b.BackColor = Color.Gainsboro; bool ismachine = i.IsRecipe; if (!ismachine) { b.BackColor = Color.Crimson; } //next iteration actualleft += b.Width + 1; } }
public MapObject(MOType StartMapType, oItem StartOut) { this.MapType = StartMapType; //must be define before calling SetRecipe if (this.MapType == MOType.Belt) { this.BeltOutput = StartOut; } if (this.MapType == MOType.Machine) { this.SetRecipe(StartOut); } }
private void CreateNewButtonMachine(Bitmap img, oItem i) { Button newb = new Button(); newb.Parent = this.panele; newb.Image = img; newb.ImageAlign = ContentAlignment.MiddleCenter; this.listButtonMachine.Add(newb); //newb.Click += new EventHandler(this.AnyButton_Click); newb.MouseDown += new MouseEventHandler(this.AnyButton_MosueDown); newb.Tag = new object[] { MOType.Machine, i }; }
public bool IsAllInputPresent = false; //used by RefreshImage. indicate if all inputs are present. it's reseted and recalculated every RefreshImage //// utilisé par RefreshImage. indique si tout les input sont présent public MapObject GetCopy() { //prepare the content to send to the constructor //// obtient les contenue à envoyer au constructeur oItem copyrecipe = this.BeltOutput; if (this.MapType == MOType.Machine) { copyrecipe = this.TheRecipe; } MapObject copy = new MapObject(this.MapType, copyrecipe); copy.NeedCoal = this.NeedCoal; return(copy); }
public void SetRecipe(oItem Recipe) { if (this.MapType == MOType.Belt) { this.BeltOutput = Recipe; } if (this.MapType == MOType.Machine) { this.TheRecipe = Recipe; oCraft c = Crafts.GetCraftFromRecipe(Recipe); //gets the craft this.TheCraft = c; //if (c != null) //{ // this.Outputs = c.Outputs; // this.Inputs = c.Inputs; // this.IsFurnace = c.IsMadeInFurnace; //} } }
private void CreateModControls(string smodname) { this.ModName = smodname; //loads every items of that mod. int index = 0; while (index < Crafts.listItems.Count) { oItem i = Crafts.listItems[index]; //check if it's an item of the mod if (i.ModName == smodname && i.ItemName != "none") { this.CreateNewButtonBoth(i); } //next iteration index++; } }
//return the closest belt with a compatible output //the only purpose of giving mo to the function is to know the coordinate. don't be confused public MapObject GetCompatibleBeltCloseTo(MapObject mo, oItem OutType) { MapObject mo1 = null; List <MapObject> lco = this.listMO.FindAll(x => (x.MapType == MOType.Belt) && (x.BeltOutput.Name == OutType.Name)); //get belts of compatible output try { lco.Remove(mo); } catch { } if (lco.Count > 0) { //sort by distance lco = lco.OrderBy(x => x.DistTo(mo.vpos.X, mo.vpos.Y)).ToList(); //get the closest mo1 = lco[0]; } return(mo1); }
private void AnyButton_MosueDown(object sender, MouseEventArgs e) { Button btn = (Button)sender; btn.Focus(); MOType mt = (MOType)(((object[])(btn.Tag))[0]); oItem i = (oItem)(((object[])(btn.Tag))[1]); if (e.Button == MouseButtons.Left) { if (mt == MOType.Belt) { if (i.IsBelt) //we set addmode only if the item can be a belt { MapObject newmo = new MapObject(MOType.Belt, i); this.Editer.StartAddMode(newmo); } } if (mt == MOType.Machine) { if (i.IsRecipe) //we set addmode only if the item can be a machine { MapObject newmo = new MapObject(MOType.Machine, i); this.Editer.StartAddMode(newmo); } } } if (e.Button == MouseButtons.Right) { //if this button is as machine, we show the user the inputs and outputs of the recipe if (mt == MOType.Machine) { //if this button is as machine, i represents the recipe oCraft c = Crafts.GetCraftFromRecipe(i); oRightClick3 rc = new oRightClick3(); rc.AddChoice(i.Name); if (c != null) { rc.AddSeparator(); rc.AddSeparator(); //add every outputs and inputs for the user rc.AddChoice("Outputs :"); foreach (oItem subi in c.Outputs) { rc.AddChoice("-" + subi.Name); } rc.AddChoice(""); rc.AddChoice("Inputs :"); foreach (oItem subi in c.Inputs) { rc.AddChoice("-" + subi.Name); } } string rep = rc.ShowDialog(); //it simply show to the user what the inputs and outputs are } //if this button is a belt, we show the user every crafts that require this item as input if (mt == MOType.Belt) { oRightClick3 rc = new oRightClick3(); rc.AddChoice(i.Name); rc.AddSeparator(); rc.AddChoice("Used In Recipe :"); //run through every crafts and check their inputs to see if the actual item is used in that craft foreach (oCraft c in Crafts.listCrafts) { //check the inputs and see if the item i is there foreach (oItem i2 in c.Inputs) { //check if this is the item we are searching if (i2.Name == i.Name) { //now that we have found the item in this craft, we add the craft recipe to the list and continue to the next item rc.AddChoice("-" + c.Recipe.Name); //now that we have found the item, we don't have to continue search in this craft break; } } } string rep = rc.ShowDialog(); //if the user clicked on a recipe, we set the editer to add mode and with a machine of that recipe. //we get the item from name oItem therecipe = Crafts.GetItemFromName(rep.Replace("-", string.Empty)); //the .Replace can be a little problem if - is truly part of the item name. //if rep is not an item, GetItemFromName will not return null, it will return the none item. if (therecipe.Name.ToLower() != "none") { MapObject newmo = new MapObject(MOType.Machine, therecipe); this.Editer.StartAddMode(newmo); } } } }
public void KeyDown(Keys k) { if (k == Keys.Back || k == Keys.Space) { this.keyBackSpaceDown = true; //remove the element under the mouse //// supprimme l'élément sous la souris PointF mvpos = this.MouseVirtualPos; MapObject mo = this.Map.GetObjThatTouch(mvpos.X, mvpos.Y); //return null if there's nothing if (mo != null) { try { this.Map.listMO.Remove(mo); } catch { } this.RefreshImage(); } } if (k == Keys.Q) { //copy the element under the mouse //// copie l'élément sous la souris if (!this.IsAddMode) { PointF mvpos = this.MouseVirtualPos; MapObject mo = this.Map.GetObjThatTouch(mvpos.X, mvpos.Y); //return null if there's nothing if (mo != null) { try { MapObject copy = mo.GetCopy(); this.StartAddMode(copy); } catch { } this.RefreshImage(); } } else //if the user is already in addmode, we want q to cancel addmode //// si l'utilisateur est déjà en addmode, q va le faire quitter le addmode { this.CancelAddMode(); } } if (k == Keys.W) { //copy the element under the mouse but it makes a copy for the other MOType //// copie l'élément sous la souris, mais si c'est une machine, il va donner une belt avec le output de la machine et inversement if (!this.IsAddMode) { PointF mvpos = this.MouseVirtualPos; MapObject mo = this.Map.GetObjThatTouch(mvpos.X, mvpos.Y); //return null if there's nothing if (mo != null) { try { if (mo.MapType == MOType.Machine) { oItem ft = mo.TheRecipe; MapObject copy = new MapObject(MOType.Belt, ft); this.StartAddMode(copy); } if (mo.MapType == MOType.Belt) { oItem ft = mo.BeltOutput; MapObject copy = new MapObject(MOType.Machine, ft); this.StartAddMode(copy); } } catch { } this.RefreshImage(); } } } if (k == Keys.F) { //toggle NeedCoal PointF mvpos = this.MouseVirtualPos; MapObject mo = this.Map.GetObjThatTouch(mvpos.X, mvpos.Y); //return null if there's nothing if (mo != null) { try { mo.NeedCoal = !mo.NeedCoal; } catch { } this.RefreshImage(); } } //alternative zoom control if (k == Keys.D1 || k == Keys.NumPad1) { this.VirtualWidth *= 1.5f; this.RefreshImage(); } if (k == Keys.D2 || k == Keys.NumPad2) { this.VirtualWidth /= 1.5f; this.RefreshImage(); } }