public void GetDrawInfo(BetterPaintMod mymod, int x, int y, out Color color, out float percent, out int stack) { if (this.PaintItem.modItem is ColorCartridgeItem) { var colorCart = (ColorCartridgeItem)this.PaintItem.modItem; color = colorCart.MyColor; percent = colorCart.Quantity / (float)mymod.Config.PaintCartridgeCapacity; stack = this.Copies; } else if (this.PaintItem.modItem is GlowCartridgeItem) { var glowCart = (GlowCartridgeItem)this.PaintItem.modItem; color = glowCart.MyColor; percent = glowCart.Quantity / (float)mymod.Config.PaintCartridgeCapacity; stack = this.Copies; } else if (ItemGroupIdentityHelpers.Paints.Group.Contains(this.PaintItem.type)) { color = WorldGen.paintColor(this.PaintItem.paint); percent = (float)this.PaintItem.stack / 999f; stack = this.PaintItem.stack; } else { throw new ModHelpersException("Not implemented."); } }
internal float ApplyColorAtNoSync(BetterPaintMod mymod, PaintLayerType layer, PaintBrushType brushType, Color color, byte glow, PaintBrushSize brushSize, float pressurePrecent, int randSeed, int worldX, int worldY) { if (Main.netMode == 2) { throw new ModHelpersException("No server."); } PaintBrush brush = mymod.Modes[brushType]; float paintsUsed = 0f; switch (layer) { case PaintLayerType.Background: paintsUsed += brush.Apply(this.Background, color, glow, brushSize, pressurePrecent, randSeed, worldX, worldY); break; case PaintLayerType.Foreground: paintsUsed += brush.Apply(this.Foreground, color, glow, brushSize, pressurePrecent, randSeed, worldX, worldY); break; case PaintLayerType.Anyground: paintsUsed += brush.Apply(this.Background, color, glow, brushSize, pressurePrecent, randSeed, worldX, worldY); paintsUsed += brush.Apply(this.Foreground, color, glow, brushSize, pressurePrecent, randSeed, worldX, worldY); break; default: throw new ModHelpersException("Not implemented."); } return(paintsUsed); }
public IDictionary <int, float> DrawColorPalette(BetterPaintMod mymod, SpriteBatch sb) { IDictionary <string, PaintDisplayInfo> infoSet = PaintDisplayInfo.GetPaintSelection(Main.LocalPlayer); var angles = new Dictionary <int, float>(infoSet.Count); double angleStep = 360d / (double)infoSet.Count; double angle = 0d; double radpi = Math.PI / 180d; foreach (var info in infoSet.Values) { int x = (Main.screenWidth / 2) + (int)(128d * Math.Cos(angle * radpi)); int y = (Main.screenHeight / 2) + (int)(128d * Math.Sin(angle * radpi)); int stack; float percent; Color color; info.GetDrawInfo(mymod, x, y, out color, out percent, out stack); this.DrawColorIcon(sb, info.PaintItem.type, color, percent, stack, x, y, angle, angleStep, (info.FirstInventoryIndex == this.CurrentPaintItemInventoryIndex)); angles[info.FirstInventoryIndex] = (float)angle; angle += angleStep; } return(angles); }
//////////////// internal void Load(BetterPaintMod mymod, TagCompound tags, string prefix) { var myworld = ModContent.GetInstance <BetterPaintWorld>(); this.Colors.Clear(); this.Glows.Clear(); if (tags.ContainsKey(prefix + "_x")) { int[] fgX = tags.GetIntArray(prefix + "_x"); for (int i = 0; i < fgX.Length; i++) { ushort tileX = (ushort)fgX[i]; int[] fgY = tags.GetIntArray(prefix + "_" + tileX + "_y"); for (int j = 0; j < fgY.Length; j++) { ushort tileY = (ushort)fgY[j]; byte[] clrArr = tags.GetByteArray(prefix + "_" + tileX + "_" + tileY); Color color = new Color(clrArr[0], clrArr[1], clrArr[2], clrArr[3]); Tile tile = Main.tile[tileX, tileY]; if (this.CanPaintAt(tile)) { this.SetRawColorAt(color, tileX, tileY); } } } } if (tags.ContainsKey(prefix + "_g_x")) { int[] fgX = tags.GetIntArray(prefix + "_g_x"); for (int i = 0; i < fgX.Length; i++) { ushort tileX = (ushort)fgX[i]; int[] fgY = tags.GetIntArray(prefix + "_g_" + tileX + "_y"); for (int j = 0; j < fgY.Length; j++) { ushort tileY = (ushort)fgY[j]; byte glow = tags.GetByte(prefix + "_g_" + tileX + "_" + tileY); Tile tile = Main.tile[tileX, tileY]; if (this.CanPaintAt(tile)) { this.SetGlowAt(glow, tileX, tileY); } } } } }
public CopyCartridgeCopyRecipe(BetterPaintMod mymod) : base(mymod) { this.AddTile(ModContent.TileType <PaintMixerTile>()); this.AddIngredient(ModContent.ItemType <CopyCartridgeItem>(), 1); this.AddIngredient(ModContent.ItemType <ColorCartridgeItem>(), 1); this.SetResult(ModContent.GetInstance <ColorCartridgeItem>()); }
//////////////// public void DrawHUD(BetterPaintMod mymod, SpriteBatch sb, PaintBlasterItem myblaster) { int x = mymod.Config.HudPaintAmmoOffsetX >= 0 ? mymod.Config.HudPaintAmmoOffsetX : (Main.screenWidth + mymod.Config.HudPaintAmmoOffsetX); int y = mymod.Config.HudPaintAmmoOffsetY >= 0 ? mymod.Config.HudPaintAmmoOffsetY : (Main.screenHeight + mymod.Config.HudPaintAmmoOffsetY); sb.Draw(PaintBlasterHUD.AmmoCan, new Vector2(x, y), Color.White); Item paintItem = myblaster.GetCurrentPaintItem(); if (paintItem != null) { BlasterPaintType paintType = PaintBlasterHelpers.GetPaintType(paintItem); Color paintColor = PaintBlasterHelpers.GetPaintColor(paintItem); float quantity = PaintBlasterHelpers.GetPaintAmount(paintItem); float capacity = paintType == BlasterPaintType.Can ? (float)paintItem.maxStack : (float)mymod.Config.PaintCartridgeCapacity; float capacityPercent = quantity / capacity; int height = (int)(capacityPercent * 50f) * 2; int top = 100 - height; Color color = capacityPercent >= 0.01f ? paintColor : paintColor * 0.25f; sb.Draw(PaintBlasterHUD.AmmoTop, new Vector2(x, y + 16 + top), color); sb.Draw(PaintBlasterHUD.AmmoBot, new Vector2(x, y + 124), color); sb.Draw(Main.magicPixel, new Rectangle(x + 4, y + 24 + top, 16, height), color); if (Main.mouseX >= x && Main.mouseX < (x + PaintBlasterHUD.AmmoCan.Width)) { if (Main.mouseY >= y && Main.mouseY < (y + PaintBlasterHUD.AmmoCan.Height)) { string percentStr = capacityPercent.ToString("P", CultureInfo.InvariantCulture); Utils.DrawBorderStringFourWay(sb, Main.fontMouseText, percentStr, Main.mouseX - 40, Main.mouseY + 16, Color.White, Color.Black, default(Vector2), 1f); } } } else { if (Main.mouseX >= x && Main.mouseX < (x + PaintBlasterHUD.AmmoCan.Width)) { if (Main.mouseY >= y && Main.mouseY < (y + PaintBlasterHUD.AmmoCan.Height)) { string str = "Color Cartridge needed"; Utils.DrawBorderStringFourWay(sb, Main.fontMouseText, str, Main.mouseX - 160, Main.mouseY + 16, Color.White, Color.Black, default(Vector2), 1f); } } } }
public void DrawScreen(BetterPaintMod mymod, SpriteBatch sb) { if (this.IsCopying) { Texture2D copyTex = Main.itemTexture[ItemID.EmptyDropper]; var mousePos = new Vector2(Main.mouseX, Main.mouseY); sb.Draw(copyTex, mousePos, Color.White); } }
//////////////// public GlowCartridgeRecipe(BetterPaintMod mymod, GlowCartridgeItem myitem) : base(mymod) { this.AddTile(ModContent.TileType <PaintMixerTile>()); this.AddIngredient(ModContent.GetInstance <ColorCartridgeItem>(), 1); if (mymod.Config.GlowPaintRecipeSpores > 0) { this.AddIngredient(ItemID.JungleSpores, mymod.Config.GlowPaintRecipeSpores); } this.SetResult(myitem, 1); }
public PaintMixerRecipe(BetterPaintMod mymod, PaintMixerItem mymixer) : base(mymod) { this.AddTile(TileID.HeavyWorkBench); this.AddIngredient(ItemID.DyeVat, 1); this.AddIngredient(ItemID.Extractinator, 1); if (mymod.Config.PaintMixerRecipeBlendOMatic) { this.AddIngredient(ItemID.BlendOMatic, 1); } this.SetResult(mymixer); }
//////////////// public ColorCartridgePaintRecipe(BetterPaintMod mymod, ColorCartridgeItem myitem) : base(mymod) { this.AddTile(ModContent.TileType <PaintMixerTile>()); if (mymod.Config.PaintRecipeGels > 0) { this.AddIngredient(ItemID.Gel, mymod.Config.PaintRecipeGels); } if (mymod.Config.PaintRecipePaints > 0) { this.AddRecipeGroup("ModHelpers:Paints", mymod.Config.PaintRecipePaints); } this.SetResult(myitem, 1); }
public static void InitializeStatic(BetterPaintMod mymod) { if (!Main.dedServ && PaintBlasterHUD.AmmoCan == null) { PaintBlasterHUD.AmmoCan = mymod.GetTexture("UI/PaintBlasterHUD/PaintAmmoContainer"); PaintBlasterHUD.AmmoTop = mymod.GetTexture("UI/PaintBlasterHUD/PaintAmmoTop"); PaintBlasterHUD.AmmoBot = mymod.GetTexture("UI/PaintBlasterHUD/PaintAmmoBottom"); LoadHooks.AddModUnloadHook(() => { PaintBlasterHUD.AmmoCan = null; PaintBlasterHUD.AmmoTop = null; PaintBlasterHUD.AmmoBot = null; }); } }
public PaintBlasterRecipe(BetterPaintMod mymod, PaintBlasterItem myblaster) : base(mymod) { this.AddTile(TileID.TinkerersWorkbench); if (mymod.Config.PaintBlasterRecipeClentaminator) { this.AddIngredient(ItemID.Clentaminator); } else { this.AddIngredient(ItemID.IllegalGunParts); } //this.AddIngredient( ItemID.Flamethrower ); this.AddIngredient(ItemID.PaintSprayer); this.SetResult(myblaster); }
//////////////// public float ApplyColorAt(BetterPaintMod mymod, PaintLayerType layer, PaintBrushType brushType, Color color, byte glow, PaintBrushSize brushSize, float pressurePrecent, int worldX, int worldY) { if (Main.netMode == 2) { throw new ModHelpersException("No server."); } int randSeed = DateTime.Now.Millisecond; float paintsUsed = this.ApplyColorAtNoSync(mymod, layer, brushType, color, glow, brushSize, pressurePrecent, randSeed, worldX, worldY); if (Main.netMode == 1) { PaintStrokeProtocol.SyncToAll(layer, brushType, color, glow, brushSize, pressurePrecent, randSeed, worldX, worldY); } return(paintsUsed); }
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); }
//////////////// public void DrawUI(BetterPaintMod mymod, SpriteBatch sb) { Rectangle streamRect, sprayRect, bucketRect, scrapeRect; Rectangle bgRect, sizeRect, copyRect, pressRect; int x = Main.screenWidth / 2; int y = Main.screenHeight / 2; sb.Draw(Main.magicPixel, new Rectangle(x, y, 160, 160), null, Color.LightPink * 0.3f, (float)(45d * DotNetHelpers.RadDeg), new Vector2(0.5f, 512f), SpriteEffects.None, 1f); HUDHelpers.DrawBorderedRect(sb, Color.DarkOliveGreen * 0.5f, Color.OliveDrab * 0.5f, new Rectangle(x - 48, y - 48, 96, 96), 4); this.DrawBrushes(sb, out streamRect, out sprayRect, out bucketRect, out scrapeRect); this.DrawOptionLayer(sb, x, y, out bgRect); this.DrawOptionSize(sb, x, y, out sizeRect); this.DrawOptionCopy(sb, x, y, out copyRect); this.DrawOptionPressure(sb, x, y, out pressRect); IDictionary <int, float> paletteAngles = this.DrawColorPalette(mymod, sb); if (Main.mouseLeft) { if (!this.IsInteractingWithUI) { this.IsInteractingWithUI = true; bool hasInteracted = false; hasInteracted = this.CheckUISettingsInteractions(bgRect, sizeRect, copyRect, pressRect); hasInteracted |= this.CheckUIBrushInteractions(streamRect, sprayRect, bucketRect, scrapeRect); hasInteracted |= this.CheckUIColorInteractions(paletteAngles); if (hasInteracted) { Main.PlaySound(SoundID.MenuTick); } } } else { this.IsInteractingWithUI = false; } }
public static void InitializeStatic(BetterPaintMod mymod) { if (!Main.dedServ && PaintBlasterUI.BrushStream == null) { PaintBlasterUI.BrushStream = mymod.GetTexture("UI/PaintBlasterUI/BrushStream"); PaintBlasterUI.BrushSpray = mymod.GetTexture("UI/PaintBlasterUI/BrushSpray"); PaintBlasterUI.BrushSpatter = mymod.GetTexture("UI/PaintBlasterUI/BrushSpatter"); PaintBlasterUI.BrushEraser = mymod.GetTexture("UI/PaintBlasterUI/BrushEraser"); PaintBlasterUI.LayerFgTex = mymod.GetTexture("UI/PaintBlasterUI/LayerFg"); PaintBlasterUI.LayerBgTex = mymod.GetTexture("UI/PaintBlasterUI/LayerBg"); PaintBlasterUI.LayerBothTex = mymod.GetTexture("UI/PaintBlasterUI/LayerBoth"); PaintBlasterUI.SizeSmallTex = mymod.GetTexture("UI/PaintBlasterUI/SizeSmall"); PaintBlasterUI.SizeLargeTex = mymod.GetTexture("UI/PaintBlasterUI/SizeLarge"); PaintBlasterUI.PressureLowTex = mymod.GetTexture("UI/PaintBlasterUI/PressureLow"); PaintBlasterUI.PressureMidTex = mymod.GetTexture("UI/PaintBlasterUI/PressureMid"); PaintBlasterUI.PressureHiTex = mymod.GetTexture("UI/PaintBlasterUI/PressureHi"); LoadHooks.AddModUnloadHook(() => { PaintBlasterUI.BrushStream = null; PaintBlasterUI.BrushSpray = null; PaintBlasterUI.BrushSpatter = null; PaintBlasterUI.BrushEraser = null; PaintBlasterUI.LayerFgTex = null; PaintBlasterUI.LayerBgTex = null; PaintBlasterUI.LayerBothTex = null; PaintBlasterUI.SizeSmallTex = null; PaintBlasterUI.SizeLargeTex = null; PaintBlasterUI.PressureLowTex = null; PaintBlasterUI.PressureMidTex = null; PaintBlasterUI.PressureHiTex = null; }); } }
//////////////// public void Load(BetterPaintMod mymod, TagCompound tags) { this.Background.Load(mymod, tags, "bg"); this.Foreground.Load(mymod, tags, "fg"); }
public ColorCartridgeBlendRecipe(BetterPaintMod mymod, ColorCartridgeItem myitem) : base(mymod) { this.AddTile(ModContent.TileType <PaintMixerTile>()); this.AddIngredient(myitem, 2); this.SetResult(myitem, 1); }