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); }
private PaintStrokeProtocol(PaintLayerType layer, PaintBrushType brushType, Color color, byte glow, PaintBrushSize brushSize, float pressurePercent, int randSeed, int worldX, int worldY) { this.Layer = (int)layer; this.BrushType = (int)brushType; this.MyColor = color; this.Glow = glow; this.BrushSize = (int)brushSize; this.PressurePercent = pressurePercent; this.WorldX = worldX; this.WorldY = worldY; }
public static void SyncToAll(PaintLayerType layer, PaintBrushType brushType, Color color, byte glow, PaintBrushSize brushSize, float pressurePercent, int randSeed, int worldX, int worldY) { if (Main.netMode != 1) { throw new ModHelpersException("Not client"); } var protocol = new PaintStrokeProtocol(layer, brushType, color, glow, brushSize, pressurePercent, randSeed, worldX, worldY); protocol.SendToServer(true); }
//////////////// 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); }