public static void Render() { ImGui.SetNextWindowSize(size, ImGuiCond.Once); if (!ImGui.Begin("Entity placer")) { ImGui.End(); open = false; return; } open = true; var down = !ImGui.GetIO().WantCaptureMouse&& Input.Mouse.CheckLeftButton; var clicked = !ImGui.GetIO().WantCaptureMouse&& MouseData.HadClick; if (Input.Keyboard.IsDown(Keys.LeftControl, true)) { if (entity != null) { if (Input.Keyboard.WasPressed(Keys.C, true)) { copy = entity.GetType(); } if (copy != null && Input.Keyboard.WasPressed(Keys.V, true)) { var od = currentType; currentType = copy; CreateEntity(false); currentType = od; } if (Input.Keyboard.WasPressed(Keys.D, true)) { entity.Done = true; entity = null; } } } ImGui.Checkbox("Move", ref move); /*) { * if (entityMode != 0) { * RemoveEntity(); * } * }*/ if (!move && entity != null) { var mouse = Input.Mouse.GamePosition; if (SnapToGrid) { mouse.X = (float)Math.Floor(mouse.X / 16) * 16; mouse.Y = (float)Math.Floor(mouse.Y / 16) * 16; } mouse += new Vector2(8 - entity.Width / 2f, 8 - entity.Height / 2f); if (Center) { entity.Center = mouse; } else { entity.Position = mouse; } if (clicked) { CreateEntity(false); } } else if (move) { var mouse = Input.Mouse.GamePosition; Entity selected = null; foreach (var e in Editor.Area.Entities.Entities) { if (e.OnScreen && AreaDebug.PassFilter(e) && !(e is Firefly || e is WindFx || e is Lock)) { if (e.Contains(mouse)) { selected = e; } } } HoveredEntity = selected; if (clicked) { entity = selected; if (selected != null) { AreaDebug.ToFocus = entity; offset = entity.Position - mouse; } } else if (entity != null && (down && entity.Contains(mouse) || Input.Keyboard.IsDown(Keys.LeftAlt, true))) { mouse += offset; if (SnapToGrid) { mouse.X = (float)Math.Round(mouse.X / 16) * 16; mouse.Y = (float)Math.Round(mouse.Y / 16) * 16; } mouse += new Vector2(8 - entity.Width / 2f, 8 - entity.Height / 2f); if (Center) { entity.Center = mouse; } else { entity.Position = mouse; } } } ImGui.Checkbox("Snap to grid", ref SnapToGrid); ImGui.SameLine(); ImGui.Checkbox("Center", ref Center); if (entity != null) { ImGui.Separator(); ImGui.Text(entity.GetType().Name); if (ImGui.Button("Open debug")) { AreaDebug.ToFocus = entity; } ImGui.Separator(); } filter.Draw(""); var i = 0; ImGui.Separator(); var h = ImGui.GetStyle().ItemSpacing.Y; ImGui.BeginChild("ScrollingRegionConsole", new System.Numerics.Vector2(0, -h), false, ImGuiWindowFlags.HorizontalScrollbar); foreach (var t in Types) { if (filter.PassFilter(t.Name)) { if (ImGui.Selectable(t.Name, selected == i)) { selected = i; currentType = t.Type; CreateEntity(); } } i++; } ImGui.EndChild(); ImGui.End(); }