private void SetTestCells() { //setBrushAt(0, 1, BrushFactory.singleCell()); //setBrushAt(5, 1, BrushFactory.singleCell()); //setBrushAt(10, 1, BrushFactory.singleCell()); // setBrushAt(0, 0, BrushFactory.solidThreeBlock()); // setBrushAt(10, 11, BrushFactory.singleCell()); /* * setBrushAt(0, 0, BrushFactory.simpleGlider()); * setBrushAt(0, 5, BrushFactory.simpleGlider()); * setBrushAt(5, 0, BrushFactory.simpleGlider()); * setBrushAt(5, 5, BrushFactory.simpleGlider()); * setBrushAt(10, 0, BrushFactory.simpleGlider()); * setBrushAt(0, 10, BrushFactory.simpleGlider()); * setBrushAt(10, 5, BrushFactory.simpleGlider()); * setBrushAt(5, 10, BrushFactory.simpleGlider()); * setBrushAt(10, 0, BrushFactory.simpleGlider()); * setBrushAt(10, 10, BrushFactory.simpleGlider()); */ // setBrushAt(64, 3, BrushFactory.acorn()); // setBrushAt(30, 25, BrushFactory.RPentomino()); // setBrushAt(5, 3, BrushFactory.Blinker()); SetBrushAt(64, 64, BrushFactory.GliderGun()); }
public override void Use(Player p, string message, CommandData data) { BrushArgs args = new BrushArgs(p, message, Block.Air); Brush brush = BrushFactory.Find("Replace").Construct(args); if (brush == null) { return; } Vec3S32 max = new Vec3S32(p.level.Width - 1, p.level.Height - 1, p.level.Length - 1); Vec3S32[] marks = new Vec3S32[] { Vec3S32.Zero, max }; MeasureDrawOp measure = new MeasureDrawOp(); measure.Setup(p, p.level, marks); measure.Perform(marks, brush, null); if (measure.Total > p.group.DrawLimit) { p.Message("You tried to replace " + measure.Total + " blocks."); p.Message("You cannot draw more than " + p.group.DrawLimit + "."); return; } DrawOp op = new CuboidDrawOp(); op.AffectedByTransform = false; if (!DrawOpPerformer.Do(op, brush, p, marks, false)) { return; } p.Message("&4/replaceall finished!"); }
public override void Use(Player p, string message) { message = message.ToLower(); string[] parts = message.SplitSpaces(); DrawArgs dArgs = new DrawArgs(); dArgs.Message = message; dArgs.Player = p; dArgs.Mode = GetMode(parts); dArgs.Op = GetDrawOp(dArgs); if (dArgs.Op == null) { return; } // Validate the brush syntax is correct BrushFactory factory = MakeBrush(dArgs); BrushArgs bArgs = new BrushArgs(p, dArgs.BrushArgs, dArgs.Block); if (!factory.Validate(bArgs)) { return; } Player.Message(p, PlaceMessage); p.MakeSelection(MarksCount, "Selecting region for %S" + dArgs.Op.Name, dArgs, DoDraw); }
public static IStageVm ToStageVm ( this ISorterStage <ISwitchEval> sorterStage, int useMax, double switchWidth, double lineThickness, Brush lineBrush, Brush backgroundBrush, IReadOnlyList <Brush> switchBrushes ) { return(new StageVmImpl ( keyCount: sorterStage.KeyCount, keyPairVms: sorterStage.ToStageLayouts() .Select( sl => new KeyPairVm ( keyPair: sl.Item2, switchBrush: BrushFactory.LogBrushOfInt ( value: (int)sl.Item2.UseCount, max: useMax, brushList: switchBrushes ), position: sl.Item1 ) ).ToList(), switchWidth: switchWidth, lineThickness: lineThickness, lineBrush: lineBrush, backgroundBrush: backgroundBrush )); }
public override void Use(Player p, string message) { if (Player.IsSuper(p)) { MessageInGameOnly(p); return; } message = message.ToLower(); string[] parts = message.Split(' '); DrawArgs dArgs = default(DrawArgs); dArgs.Message = message; dArgs.Player = p; dArgs.Mode = GetMode(parts); dArgs.Op = GetDrawOp(dArgs); if (dArgs.Op == null) { return; } // Validate the brush syntax is correct int offset = 0; BrushFactory factory = BrushFactory.Find(GetBrush(p, dArgs, ref offset)); BrushArgs bArgs = GetBrushArgs(dArgs, offset); if (!factory.Validate(bArgs)) { return; } Player.Message(p, PlaceMessage); p.MakeSelection(MarksCount, dArgs, DoDraw); }
public override void Use(Player p, string message) { if (message.Length == 0) { Player.Message(p, "Your current brush is: " + p.BrushName); return; } string[] args = message.SplitSpaces(2); BrushFactory brush = BrushFactory.Find(args[0]); if (args[0].CaselessEq("list")) { Player.Message(p, "%HAvailable brushes: %S" + BrushFactory.Available); } else if (brush == null) { Player.Message(p, "No brush found with name \"{0}\".", args[0]); Player.Message(p, "Available brushes: " + BrushFactory.Available); } else { Player.Message(p, "Set your brush to: " + brush.Name); p.BrushName = brush.Name; p.DefaultBrushArgs = args.Length > 1 ? args[1] : ""; } }
/// <summary/> public TestObjects(Variation v) { this.variation = v; this.viewport = null; this.visual = null; this.content = null; string ctb = v["ClipToBounds"]; string o = v["Opacity"]; string om = v["OpacityMask"]; string c = v["Clip"]; string t = v["Transform"]; string e = v["Effect"]; string ei = v["EffectInput"]; string em = v["EdgeMode"]; clipToBounds = (ctb == null) ? false : StringConverter.ToBool(ctb); clip = (c == null) ? null : GeometryFactory.MakeGeometry(c); opacity = (o == null) ? 1.0 : StringConverter.ToDouble(o); opacityMask = (om == null) ? null : BrushFactory.MakeBrush(om); transform = (t == null) ? null : Transform2DFactory.MakeTransform2D(t); effect = (e == null) ? null : EffectFactory.MakeEffect(e); effectInput = (ei == null) ? null : EffectInputFactory.MakeEffectInput(ei); edgeMode = (em == null) ? EdgeMode.Unspecified : (EdgeMode)Enum.Parse(typeof(EdgeMode), em); // Don't do DPI scaling here. Avalon needs unscaled input. // We will do the scale in the verification code. MathEx.RelativeToAbsolute(opacityMask, new Rect(0, 0, v.WindowWidth, v.WindowHeight)); // Can't scale effectInput here because we don't know the rendered bounds yet. }
bool ValidateArgs(Player p, string[] args) { if (args.Length < 2) { Help(p); return(false); } byte extBlock = 0; int block = DrawCmd.GetBlockIfAllowed(p, args[0], out extBlock); if (block == -1) { return(false); } BrushFactory factory = BrushFactory.Find(args[1]); if (factory == null) { Player.Message(p, "No brush found with name \"{0}\".", args[1]); Player.Message(p, "Available brushes: " + BrushFactory.Available); return(false); } string brushMessage = args.Length > 2 ? args[2] : ""; byte held, extHeld; held = p.GetActualHeldBlock(out extHeld); BrushArgs bArgs = new BrushArgs(p, brushMessage, held, extHeld); return(factory.Validate(bArgs)); }
bool DoReplace(Player p, Vec3S32[] marks, object state, byte type, byte extType) { string[] args = ((string)state).SplitSpaces(3); byte extBlock = 0; int block = DrawCmd.GetBlockIfAllowed(p, args[0], out extBlock); if (block == -1) { return(false); } BrushFactory factory = BrushFactory.Find(args[1]); string brushMessage = args.Length > 2 ? args[2] : ""; BrushArgs bArgs = new BrushArgs(p, brushMessage, type, extType); Brush brush = factory.Construct(bArgs); if (brush == null) { return(false); } DrawOp op = null; if (ReplaceNot) { op = new ReplaceNotDrawOp((byte)block, extBlock); } else { op = new ReplaceDrawOp((byte)block, extBlock); } return(DrawOp.DoDrawOp(op, brush, p, marks)); }
void Start() { Debug.Log("test xxx"); parallelGrain = 64; ColumnCount = gridSize; RowCount = gridSize; RawCount = ColumnCount * RowCount; _pauseDropDownComponent = pausedDropdown.GetComponentInChildren <TMP_Dropdown>(); _tickerActive = false; _mirrorDisplay = true; //enable ticker logic Ticker.OnTick += delegate(object sender, Ticker.OnTickArgs args) { if (_tickerActive) { TickForwardConwayState(); UpdateDisplay(); } }; InitializeAll(); CenterBrush(BrushFactory.GliderGun()); UpdateDisplay(); }
public static ISorterVm ToStagedSorterVm( this ISorterEval sorterEval, Brush lineBrush, Brush backgroundBrush ) { return(new SorterVmImpl( keyCount: sorterEval.KeyCount, stageVms: sorterEval.ToStagedSorter().SorterStages.Select ( ss => ss.ToStageVm ( switchWidth: StandardSwitchWidth, useMax: sorterEval.SwitchableGroupCount, lineThickness: StandardineThickness, lineBrush: lineBrush, backgroundBrush: backgroundBrush, switchBrushes: sorterEval.Success ? BrushFactory.GrayThenBlueToBlackBrushes() : BrushFactory.GrayThenBlueToRedBrushes() ) ).ToList() )); }
public override void Use(Player p, string message, CommandData data) { if (message.Length == 0) { p.Message("Your current brush is: " + p.BrushName); return; } string[] args = message.SplitSpaces(2); BrushFactory brush = BrushFactory.Find(args[0]); if (IsListCommand(args[0])) { List(p); } else if (brush == null) { p.Message("No brush found with name \"{0}\".", args[0]); List(p); } else { p.Message("Set your brush to: " + brush.Name); p.BrushName = brush.Name; p.DefaultBrushArgs = args.Length > 1 ? args[1] : ""; } }
private void RenderBodies() { var bodies = _engine.World.AllBodies.Where(x => x.Visible).ToList(); var parts = bodies.SelectMany(x => x.EnumParts().Where(y => y.Visible)).ToList(); if (_engine.Debug) { foreach (var body in bodies) { var bounds = body.Bounds.ToPointF(); _graphics.DrawPolygon(PenFactory.Get(Color.DarkGray), bounds); } } foreach (var part in parts) { var vertices = part.Vertices.ToPointF(); _graphics.FillPolygon(BrushFactory.Get(part.Render.Fill), vertices); _graphics.DrawPolygon(PenFactory.Get(part.Render.Stroke), vertices); } /*foreach (var part in parts) * { * foreach (var axis in part.Axes.Points) * { * _graphics.DrawLine(PenFactory.Get(Color.LightCyan), * (float) part.Position.X, (float) part.Position.Y, * (float) part.Position.X + 5f*(float) axis.X, * (float) part.Position.Y + 5f*(float) axis.Y); * } * }*/ if (!_engine.Debug) { return; } foreach (var part in parts) { foreach (var axis in part.Axes.Points) { var first = part.Vertices.Vertexes.First(); var last = part.Vertices.Vertexes.Last(); _graphics.DrawLine(PenFactory.Get(Color.Salmon), (float)part.Position.X, (float)part.Position.Y, ((float)first.X + (float)last.X) / 2f, ((float)first.Y + (float)last.Y) / 2f); } } foreach (var part in parts) { _graphics.DrawArc(PenFactory.Get(Color.Indigo), (float)part.Position.X - 1.5f, (float)part.Position.Y - 1.5f, 3f, 3f, 0f, 360f); } foreach (var body in bodies) { _graphics.DrawLine(PenFactory.Get(Color.CornflowerBlue), (float)body.Position.X, (float)body.Position.Y, (float)body.Position.X + 2f * (float)(body.Position.X - body.PositionPrev.X), (float)body.Position.Y + 2f * (float)(body.Position.Y - body.PositionPrev.Y)); } }
public static void ImportAndAppend(this BrushFactory brushFactory, string brushName, string brushFile, string appendBrushName) { brushFactory.LoadBrushFile(brushFile); var brush = brushFactory.GetBrush(brushName); var appendBrush = brushFactory.GetBrush(appendBrushName); brush.AppendFrom(appendBrush); }
public FontSetting(System.Drawing.Color color, string familyName, float size, System.Drawing.FontStyle style) { Foreground = BrushFactory.Create(Color.FromArgb(color.A, color.R, color.G, color.B)); Family = new FontFamily(familyName); Size = size; Style = (style & System.Drawing.FontStyle.Italic) == System.Drawing.FontStyle.Italic ? System.Windows.FontStyles.Italic : System.Windows.FontStyles.Normal; Weight = (style & System.Drawing.FontStyle.Bold) == System.Drawing.FontStyle.Bold ? System.Windows.FontWeights.Bold : System.Windows.FontWeights.Normal; Font = new System.Drawing.Font(familyName, size, style); }
protected BrushFactory MakeBrush(DrawArgs args) { args.BrushName = args.Player.BrushName; args.BrushArgs = ""; GetBrush(args); if (args.BrushArgs.Length == 0) { args.BrushArgs = args.Player.DefaultBrushArgs; } return(BrushFactory.Find(args.BrushName)); }
public void HandleInputData(int choice) { switch (choice) { case 0: // Debug.Log("Glider Gun"); main.ClearMap(); main.CenterBrush(BrushFactory.GliderGun()); main.UpdateDisplay(); break; case 1: Debug.Log("Simple Glider"); main.ClearMap(); main.CenterBrush(BrushFactory.SimpleGlider()); main.UpdateDisplay(); break; case 2: Debug.Log("Tiled Glider"); main.ClearMap(); CellOffset[] tempBrush = BrushFactory.SimpleGlider(); main.SetBrushAt(0, 0, BrushFactory.TiledBrush(main.ColumnCount, main.RowCount, 3, BrushFactory.SimpleGlider())); main.UpdateDisplay(); break; case 3: Debug.Log("RPentimeno"); main.ClearMap(); main.CenterBrush(BrushFactory.RPentomino()); main.UpdateDisplay(); break; case 4: Debug.Log("Acorn"); main.ClearMap(); main.CenterBrush(BrushFactory.Acorn()); main.UpdateDisplay(); break; case 5: Debug.Log("Randomize"); main.RandomizeState(); main.UpdateDisplay(); break; case 6: Debug.Log("Clear Map"); main.ClearMap(); main.UpdateDisplay(); break; } }
public void CreateCoreBrushMeshFromControlMesh() { ControlMesh controlMesh; Shape shape; BrushFactory.CreateCubeControlMesh(out controlMesh, out shape, Vector3.one); BrushMesh brushMesh = RealtimeCSG.Legacy.BrushFactory.GenerateFromControlMesh(controlMesh, shape); BrushMeshInstance coreBrushMesh = BrushMeshInstance.Create(brushMesh); Assert.AreEqual(true, coreBrushMesh.Valid); }
public override void Help(Player p, string message) { BrushFactory brush = BrushFactory.Find(message); if (brush == null) { Player.Message(p, "No brush found with name \"{0}\".", message); Player.Message(p, "%HAvailable brushes: %S" + BrushFactory.Available); } else { Player.MessageLines(p, brush.Help); } }
static BrushMeshInstance CreateCube(Vector3 size, CSGOperationType operation = CSGOperationType.Additive, Material material = null) { if (material == null) { material = material2; } ControlMesh controlMesh; Shape shape; BrushFactory.CreateCubeControlMesh(out controlMesh, out shape, size, material); BrushMesh brushMesh = RealtimeCSG.Legacy.BrushFactory.GenerateFromControlMesh(controlMesh, shape); return(BrushMeshInstance.Create(brushMesh)); }
static void TestFactory() { Console.WriteLine("Factory Test......."); ToolFactory toolFactory = new BrushFactory(); Tool tool = toolFactory.GetTool(); tool.Draw(); toolFactory = new PencilFactory(); tool = toolFactory.GetTool(); tool.Draw(); }
public override void Help(Player p, string message) { BrushFactory brush = BrushFactory.Find(message); if (brush == null) { p.Message("No brush found with name \"{0}\".", message); List(p); } else { p.MessageLines(brush.Help); } }
bool DoReplace(Player p, Vec3S32[] marks, object state, byte type, byte extType) { BrushArgs args = new BrushArgs(p, (string)state, type, extType); string name = ReplaceNot ? "replacenot" : "replace"; Brush brush = BrushFactory.Find(name).Construct(args); if (brush == null) { return(false); } DrawOp drawOp = new CuboidDrawOp(); return(DrawOp.DoDrawOp(drawOp, brush, p, marks)); }
private static void LoadBrushesHarmony(BrushFactory __instance) { var brushes = (IDictionary)BrushesField.GetValue(__instance); foreach (var brush in BrushInjector._brushes.Keys) { if (brushes.Contains(brush.Name)) { brushes[brush.Name] = brush; } else { brushes.Add(brush.Name, brush); } } }
protected override DrawOp GetDrawOp(DrawArgs dArgs) { string[] args = dArgs.Message.SplitSpaces(3); Player p = dArgs.Player; if (args.Length < 2) { Help(p); return(null); } string replaceCmd = ReplaceNot ? "ReplaceNot" : "Replace"; if (!p.CanUse(replaceCmd) || !p.CanUse("Brush")) { p.Message("You cannot use /brush and/or /" + replaceCmd + ", so therefore cannot use this command."); return(null); } BlockID target; if (!CommandParser.GetBlockIfAllowed(p, args[0], out target)) { return(null); } BrushFactory factory = BrushFactory.Find(args[1]); if (factory == null) { p.Message("No brush found with name \"{0}\".", args[1]); CmdBrush.List(p); return(null); } DrawOp op = null; if (ReplaceNot) { op = new ReplaceNotDrawOp(target); } else { op = new ReplaceDrawOp(target); } return(op); }
public void CreateBrushMeshFromControlMesh() { ControlMesh controlMesh; Shape shape; BrushFactory.CreateCubeControlMesh(out controlMesh, out shape, Vector3.one); BrushMesh brushMesh = RealtimeCSG.Legacy.BrushFactory.GenerateFromControlMesh(controlMesh, shape); Assert.AreNotEqual(null, brushMesh); Assert.AreNotEqual(null, brushMesh.vertices); Assert.AreNotEqual(null, brushMesh.halfEdges); Assert.AreNotEqual(null, brushMesh.polygons); Assert.AreEqual(8, brushMesh.vertices.Length); Assert.AreEqual(24, brushMesh.halfEdges.Length); Assert.AreEqual(6, brushMesh.polygons.Length); }
public override void Use(Player p, string message, CommandData data) { if (p.CurrentCopy == null) { p.Message("You haven't copied anything yet"); return; } BrushArgs args = new BrushArgs(p, message, Block.Air); if (!BrushFactory.Find("Paste").Validate(args)) { return; } p.Message("Place a block in the corner of where you want to paste."); p.MakeSelection(1, "Selecting location for %SPaste", args, DoPaste); }
static Brush ParseBrush(string raw, Player p, ExtBlock block) { string[] parts = raw.SplitSpaces(2); BrushFactory brush = BrushFactory.Find(parts[0]); if (brush == null) { Player.Message(p, "No brush found with name \"{0}\".", parts[0]); Player.Message(p, "Available brushes: " + BrushFactory.Available); return(null); } string brushArgs = parts.Length >= 2 ? parts[1].ToLower() : ""; BrushArgs args = new BrushArgs(p, brushArgs, block); return(brush.Construct(args)); }
public override void Use(Player p, string message) { string brushMsg = message.ToLower(); byte block, extBlock; block = p.GetActualHeldBlock(out extBlock); BrushArgs args = new BrushArgs(p, brushMsg, block, extBlock); string name = ReplaceNot ? "replacenot" : "replace"; if (!BrushFactory.Find(name).Validate(args)) { return; } Player.Message(p, "Place two blocks to determine the edges."); p.MakeSelection(2, message.ToLower(), DoReplace); }
public override void Use(Player p, string message) { if (p.CurrentCopySlot >= p.CopySlots.Count || p.CopySlots[p.CurrentCopySlot] == null) { Player.Message(p, "You haven't copied anything yet"); return; } BrushArgs args = new BrushArgs(p, message, ExtBlock.Air); Brush brush = BrushFactory.Find("paste").Construct(args); if (brush == null) { return; } Player.Message(p, "Place a block in the corner of where you want to paste."); p.MakeSelection(1, "Selecting location for %SPaste", brush, DoPaste); }